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

AJenbo / agcms / 20972446633

13 Jan 2026 09:01PM UTC coverage: 53.72% (+0.2%) from 53.541%
20972446633

Pull #74

github

web-flow
Merge 8dba43e0f into 498ff829e
Pull Request #74: Add PHP versions 8.4 to 8.5 to CI matrix

248 of 341 new or added lines in 40 files covered. (72.73%)

6 existing lines in 5 files now uncovered.

2780 of 5175 relevant lines covered (53.72%)

13.07 hits per line

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

0.0
/application/inc/Http/Controllers/Admin/SiteTreeController.php
1
<?php
2

3
namespace App\Http\Controllers\Admin;
4

5
use App\Exceptions\InvalidInput;
6
use App\Http\Request;
7
use App\Models\Category;
8
use App\Services\DbService;
9
use App\Services\OrmService;
10
use App\Services\RenderService;
11
use App\Services\SiteTreeService;
12
use Symfony\Component\HttpFoundation\JsonResponse;
13
use Symfony\Component\HttpFoundation\Response;
14

15
class SiteTreeController extends AbstractAdminController
16
{
17
    /**
18
     * Page showing the site structure.
19
     */
20
    public function index(Request $request): Response
21
    {
NEW
22
        $openCategories = explode('<', valstring($request->cookies->get('openkat', '')));
×
23
        $openCategories = array_map('intval', $openCategories);
×
24

25
        $siteTreeService = new SiteTreeService();
×
26

27
        $data = $this->basicPageData($request);
×
28
        $data['siteTree'] = $siteTreeService->getSiteTreeData($openCategories);
×
29

30
        return $this->render('admin/getSiteTree', $data);
×
31
    }
32

33
    /**
34
     * Fetch the content for a category.
35
     */
36
    public function categoryContent(Request $request, int $categoryId): JsonResponse
37
    {
38
        $inputType = $request->query->get('type');
×
39
        if (!is_string($inputType)) {
×
40
            $inputType = '';
×
41
        }
NEW
42
        $openCategories = explode('<', valstring($request->cookies->get('openkat', '')));
×
43
        $openCategories = array_map('intval', $openCategories);
×
44

45
        $data = [
×
46
            'openCategories' => $openCategories,
47
            'includePages'   => (!$inputType || 'pages' === $inputType),
48
            'inputType'      => $inputType,
49
            'node'           => app(OrmService::class)->getOne(Category::class, $categoryId),
×
50
        ];
51
        $html = app(RenderService::class)->render('admin/partial-kat_expand', $data);
×
52

53
        return new JsonResponse(['id' => $categoryId, 'html' => $html]);
×
54
    }
55

56
    /**
57
     * Get the label for a folded tree widget.
58
     */
59
    public function lable(Request $request, int $id): JsonResponse
60
    {
61
        $category = app(OrmService::class)->getOne(Category::class, $id);
×
62
        if (!$category) {
×
63
            throw new InvalidInput(_('Category not found.'), Response::HTTP_NOT_FOUND);
×
64
        }
65

66
        $data = [
×
67
            'id'   => 'katsheader',
68
            'text' => _('Select location:') . ' ' . $category->getPath(),
×
69
        ];
70

71
        return new JsonResponse($data);
×
72
    }
73

74
    /**
75
     * Page picker widget.
76
     */
77
    public function pageWidget(Request $request): Response
78
    {
NEW
79
        $openCategories = explode('<', valstring($request->cookies->get('openkat', '')));
×
80
        $openCategories = array_map('intval', $openCategories);
×
81

82
        $siteTreeService = new SiteTreeService();
×
83
        $data = [
×
84
            'siteTree' => $siteTreeService->getSiteTreeData(
×
85
                $openCategories,
86
                'pages',
NEW
87
                valint($request->cookies->get('activekat', -1))
×
88
            ),
89
        ];
90

91
        return $this->render('admin/pagelist', $data);
×
92
    }
93

94
    /**
95
     * List all site products.
96
     */
97
    public function inventory(Request $request): Response
98
    {
99
        app(DbService::class)->addLoadedTable('bind', 'kat', 'krav', 'maerke', 'sider');
×
100
        $response = $this->cachedResponse();
×
101
        if ($response->isNotModified($request)) {
×
102
            return $response;
×
103
        }
104

105
        $categoryId = $request->query->getInt('kat');
×
106
        $sort = $request->query->get('sort');
×
107
        if (!is_string($sort)) {
×
108
            $sort = 'navn';
×
109
        }
110

111
        $sortOptions = [
×
112
            'id'     => _('ID'),
×
113
            'navn'   => _('Title'),
×
114
            'varenr' => _('SKU'),
×
115
            'for'    => _('Previous price'),
×
116
            'pris'   => _('Price'),
×
117
            'dato'   => _('Updated'),
×
118
            'maerke' => _('Brand'),
×
119
            'krav'   => _('Requirement'),
×
120
        ];
121

122
        $reverseOrder = false;
×
123
        if ('-' === mb_substr($sort, 0, 1)) {
×
124
            $sort = mb_substr($sort, 1);
×
125
            $reverseOrder = true;
×
126
        }
127

128
        $sort = isset($sortOptions[$sort]) ? $sort : 'navn';
×
129

130
        $orm = app(OrmService::class);
×
131

132
        $categories = $orm->getByQuery(Category::class, 'SELECT * FROM kat WHERE bind IS NULL');
×
133
        if ($categoryId) {
×
134
            $categories = [$orm->getOne(Category::class, $categoryId)];
×
135
        }
136

137
        $data = [
×
138
            'sortOptions'  => $sortOptions,
139
            'sort'         => $sort,
140
            'reverseOrder' => $reverseOrder,
141
            'categories'   => $categories,
142
            'pathPrefix'   => '',
143
            'categoryId'   => $categoryId,
144
        ];
145

146
        return $this->render('admin/listview', $data, $response);
×
147
    }
148
}
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