• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AJenbo / agcms / 21419177689

28 Jan 2026 12:03AM UTC coverage: 52.306% (-1.4%) from 53.72%
21419177689

Pull #77

github

web-flow
Merge 25510f18e into 655757ab5
Pull Request #77: Bump phpunit/phpunit from 9.6.11 to 9.6.33 in /application

3039 of 5810 relevant lines covered (52.31%)

12.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.92
/application/inc/Http/Controllers/Base.php
1
<?php
2

3
namespace App\Http\Controllers;
4

5
use App\Exceptions\Exception;
6
use App\Http\Request;
7
use App\Models\Category;
8
use App\Models\CustomPage;
9
use App\Services\ConfigService;
10
use App\Services\DbService;
11
use App\Services\OrmService;
12
use Symfony\Component\HttpFoundation\RedirectResponse;
13

14
class Base extends AbstractController
15
{
16
    public const DEFAULT_ICON = '/theme/default/images/intet-foto.jpg';
17

18
    /**
19
     * Generate a redirect to the search page based on the current request url.
20
     *
21
     * @throws Exception
22
     */
23
    public function redirectToSearch(Request $request): RedirectResponse
24
    {
25
        $redirectUrl = '/search/';
8✔
26

27
        $query = preg_replace(
8✔
28
            [
8✔
29
                '/\/|-|_|\.html|\.htm|\.php|\.gif|\.jpeg|\.jpg|\.png|mærke[0-9]+-|kat[0-9]+-|side[0-9]+-|\.php/u',
8✔
30
                '/[^\w0-9]/u',
8✔
31
                '/([0-9]+)/u',
8✔
32
                '/([[:upper:]]?[[:lower:]]+)/u',
8✔
33
                '/\s+/u',
8✔
34
            ],
8✔
35
            [
8✔
36
                ' ',
8✔
37
                ' ',
8✔
38
                ' \1 ',
8✔
39
                ' \1',
8✔
40
                ' ',
8✔
41
            ],
8✔
42
            rawurldecode($request->getPathInfo())
8✔
43
        );
8✔
44
        if (null === $query) {
8✔
45
            throw new Exception('preg_replace failed');
×
46
        }
47
        $query = mb_trim($query);
8✔
48
        if ($query) {
8✔
49
            $redirectUrl = '/search/results/?q=' . rawurlencode($query) . '&sogikke=&minpris=&maxpris=&maerke=0';
8✔
50
        }
51

52
        return redirect($redirectUrl, RedirectResponse::HTTP_SEE_OTHER);
8✔
53
    }
54

55
    /**
56
     * Get the basice render data.
57
     *
58
     * @throws Exception
59
     *
60
     * @return array<string, mixed>
61
     */
62
    protected function basicPageData(): array
63
    {
64
        $orm = app(OrmService::class);
28✔
65

66
        $category = $orm->getOne(Category::class, 0);
28✔
67
        if (!$category) {
28✔
68
            throw new Exception(_('Root category is missing.'));
×
69
        }
70

71
        return [
28✔
72
            'menu'           => $category->getVisibleChildren(),
28✔
73
            'infoPage'       => $orm->getOne(CustomPage::class, 2),
28✔
74
            'crumbs'         => [$category],
28✔
75
            'category'       => $category,
28✔
76
            'companyName'    => ConfigService::getString('site_name'),
28✔
77
            'companyAddress' => ConfigService::getString('address'),
28✔
78
            'companyZipCode' => ConfigService::getString('postcode'),
28✔
79
            'companyCity'    => ConfigService::getString('city'),
28✔
80
            'companyPhone'   => ConfigService::getString('phone'),
28✔
81
            'companyEmail'   => ConfigService::getDefaultEmail(),
28✔
82
            'blankImage'     => ConfigService::getString('blank_image', self::DEFAULT_ICON),
28✔
83
            'pageCount'      => ConfigService::getBool('has_count') ? $this->getActivePageCount() : null,
28✔
84
        ];
28✔
85
    }
86

87
    /**
88
     * Get number active page.
89
     */
90
    private function getActivePageCount(): int
91
    {
92
        $activeCategoryIds = [];
×
93
        $categories = app(OrmService::class)->getByQuery(Category::class, 'SELECT * FROM kat');
×
94
        foreach ($categories as $category) {
×
95
            if ($category->isInactive()) {
×
96
                continue;
×
97
            }
98
            $activeCategoryIds[] = $category->getId();
×
99
        }
100

101
        $pages = app(DbService::class)->fetchOne(
×
102
            'SELECT COUNT(DISTINCT side) as count FROM bind WHERE kat IN(' . implode(',', $activeCategoryIds) . ')'
×
103
        );
×
104

105
        return (int)$pages['count'];
×
106
    }
107
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc