Skip to content

Commit 45f7cd6

Browse files
committed
Merge branch '6.2-TemplateGroupListPage-to-grid-view' into 6.2-TemplateListPage-to-grid-view
# Conflicts: # wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php
2 parents 3bc9721 + 5d89515 commit 45f7cd6

File tree

9 files changed

+309
-131
lines changed

9 files changed

+309
-131
lines changed

wcfsetup/install/files/acp/templates/templateGroupList.tpl

Lines changed: 4 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<header class="contentHeader">
44
<div class="contentHeaderTitle">
5-
<h1 class="contentTitle">{lang}wcf.acp.template.group.list{/lang} <span class="badge badgeInverse">{#$items}</span></h1>
5+
<h1 class="contentTitle">{lang}wcf.acp.template.group.list{/lang} <span class="badge badgeInverse">{#$gridView->countRows()}</span></h1>
66
</div>
77

88
<nav class="contentHeaderNavigation">
@@ -14,90 +14,8 @@
1414
</nav>
1515
</header>
1616

17-
{hascontent}
18-
<div class="paginationTop">
19-
{content}{pages print=true assign=pagesLinks controller="TemplateGroupList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}{/content}
20-
</div>
21-
{/hascontent}
22-
23-
{if $objects|count}
24-
<div id="templateGroupTableContainer" class="section tabularBox">
25-
<table class="table jsObjectActionContainer" data-object-action-class-name="wcf\data\template\group\TemplateGroupAction">
26-
<thead>
27-
<tr>
28-
<th class="columnID columnTemplateGroupID{if $sortField == 'templateGroupID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='TemplateGroupList'}pageNo={@$pageNo}&sortField=templateGroupID&sortOrder={if $sortField == 'templateGroupID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
29-
<th class="columnTitle columnTemplateGroupName{if $sortField == 'templateGroupName'} active {@$sortOrder}{/if}"><a href="{link controller='TemplateGroupList'}pageNo={@$pageNo}&sortField=templateGroupName&sortOrder={if $sortField == 'templateGroupName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.name{/lang}</a></th>
30-
<th class="columnText columnTemplateGroupFolderName{if $sortField == 'templateGroupFolderName'} active {@$sortOrder}{/if}"><a href="{link controller='TemplateGroupList'}pageNo={@$pageNo}&sortField=templateGroupFolderName&sortOrder={if $sortField == 'templateGroupFolderName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.template.group.folderName{/lang}</a></th>
31-
<th class="columnDigits columnTemplates{if $sortField == 'templates'} active {@$sortOrder}{/if}"><a href="{link controller='TemplateGroupList'}pageNo={@$pageNo}&sortField=templates&sortOrder={if $sortField == 'templates' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.template.group.templates{/lang}</a></th>
32-
<th class="columnDigits columnStyles{if $sortField == 'styles'} active {@$sortOrder}{/if}"><a href="{link controller='TemplateGroupList'}pageNo={@$pageNo}&sortField=styles&sortOrder={if $sortField == 'styles' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.template.group.styles{/lang}</a></th>
33-
34-
{event name='columnHeads'}
35-
</tr>
36-
</thead>
37-
38-
<tbody class="jsReloadPageWhenEmpty">
39-
{foreach from=$objects item=templateGroup}
40-
<tr class="jsTemplateGroupRow jsObjectActionObject" data-object-id="{@$templateGroup->getObjectID()}">
41-
<td class="columnIcon">
42-
{if $templateGroup->isImmutable()}
43-
<span class="disabled" title="{lang}wcf.global.button.edit{/lang}">
44-
{icon name='pencil'}
45-
</span>
46-
{else}
47-
<a href="{link controller='TemplateGroupEdit' id=$templateGroup->templateGroupID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip">{icon name='pencil'}</a>
48-
{/if}
49-
50-
<a href="{link controller='TemplateList' templateGroupID=$templateGroup->templateGroupID}{/link}" title="{lang}wcf.acp.template.list{/lang}" class="jsTooltip">{icon name='list'}</a>
51-
52-
{if $templateGroup->isImmutable()}
53-
<span class="disabled" title="{lang}wcf.global.button.delete{/lang}">
54-
{icon name='xmark'}
55-
</span>
56-
{else}
57-
{objectAction action="delete" objectTitle=$templateGroup->getName()}
58-
{/if}
59-
60-
{event name='rowButtons'}
61-
</td>
62-
<td class="columnID">{@$templateGroup->templateGroupID}</td>
63-
<td class="columnTitle columnTemplateGroupName">
64-
{if !$templateGroup->isImmutable()}
65-
<a href="{link controller='TemplateGroupEdit' id=$templateGroup->templateGroupID}{/link}">
66-
{$templateGroup->getName()}
67-
</a>
68-
{else}
69-
{$templateGroup->getName()}
70-
{/if}
71-
</td>
72-
<td class="columnText columnTemplateGroupFolderName">{$templateGroup->templateGroupFolderName}</td>
73-
<td class="columnDigits columnTemplates">{#$templateGroup->templates}</td>
74-
<td class="columnDigits columnStyles">{#$templateGroup->styles}</td>
75-
76-
{event name='columns'}
77-
</tr>
78-
{/foreach}
79-
</tbody>
80-
</table>
81-
82-
</div>
83-
84-
<footer class="contentFooter">
85-
{hascontent}
86-
<div class="paginationBottom">
87-
{content}{@$pagesLinks}{/content}
88-
</div>
89-
{/hascontent}
90-
91-
<nav class="contentFooterNavigation">
92-
<ul>
93-
<li><a href="{link controller='TemplateGroupAdd'}{/link}" class="button">{icon name='plus'} <span>{lang}wcf.acp.template.group.add{/lang}</span></a></li>
94-
95-
{event name='contentFooterNavigation'}
96-
</ul>
97-
</nav>
98-
</footer>
99-
{else}
100-
<woltlab-core-notice type="info">{lang}wcf.global.noItems{/lang}</woltlab-core-notice>
101-
{/if}
17+
<div class="section">
18+
{unsafe:$gridView->render()}
19+
</div>
10220

10321
{include file='footer'}

wcfsetup/install/files/lib/acp/page/TemplateGroupListPage.class.php

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22

33
namespace wcf\acp\page;
44

5-
use wcf\data\template\group\TemplateGroupList;
6-
use wcf\page\SortablePage;
5+
use wcf\page\AbstractGridViewPage;
6+
use wcf\system\gridView\AbstractGridView;
7+
use wcf\system\gridView\admin\TemplateGroupGridView;
78

89
/**
910
* Shows a list of installed template groups.
1011
*
11-
* @author Marcel Werk
12-
* @copyright 2001-2019 WoltLab GmbH
13-
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
12+
* @author Olaf Braun, Marcel Werk
13+
* @copyright 2001-2025 WoltLab GmbH
14+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
1415
*
15-
* @property TemplateGroupList $objectList
16+
* @property TemplateGroupGridView $gridView
1617
*/
17-
class TemplateGroupListPage extends SortablePage
18+
class TemplateGroupListPage extends AbstractGridViewPage
1819
{
1920
/**
2021
* @inheritDoc
@@ -26,44 +27,9 @@ class TemplateGroupListPage extends SortablePage
2627
*/
2728
public $neededPermissions = ['admin.template.canManageTemplate'];
2829

29-
/**
30-
* @inheritDoc
31-
*/
32-
public $defaultSortField = 'templateGroupName';
33-
34-
/**
35-
* @inheritDoc
36-
*/
37-
public $objectListClassName = TemplateGroupList::class;
38-
39-
/**
40-
* @inheritDoc
41-
*/
42-
public $validSortFields = [
43-
'templateGroupID',
44-
'templateGroupName',
45-
'templateGroupFolderName',
46-
'templates',
47-
'styles',
48-
];
49-
50-
/**
51-
* @inheritDoc
52-
*/
53-
protected function initObjectList()
30+
#[\Override]
31+
protected function createGridViewController(): AbstractGridView
5432
{
55-
parent::initObjectList();
56-
57-
$this->objectList->sqlSelects = "
58-
(
59-
SELECT COUNT(*)
60-
FROM wcf1_template
61-
WHERE templateGroupID = template_group.templateGroupID
62-
) AS templates,
63-
(
64-
SELECT COUNT(*)
65-
FROM wcf1_style
66-
WHERE templateGroupID = template_group.templateGroupID
67-
) AS styles";
33+
return new TemplateGroupGridView();
6834
}
6935
}

wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ static function (\wcf\event\endpoint\ControllerCollecting $event) {
186186
$event->register(new \wcf\system\endpoint\controller\core\languages\SetAsDefaultLanguage());
187187
$event->register(new \wcf\system\endpoint\controller\core\languages\items\DeleteItem());
188188
$event->register(new \wcf\system\endpoint\controller\core\labels\groups\DeleteGroup());
189+
$event->register(new \wcf\system\endpoint\controller\core\templates\groups\DeleteTemplateGroup());
189190
$event->register(new \wcf\system\endpoint\controller\core\templates\DeleteTemplate());
190191
}
191192
);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace wcf\data\template\group;
4+
5+
use wcf\data\I18nDatabaseObjectList;
6+
7+
/**
8+
* I18n implementation of template group list.
9+
*
10+
* @author Olaf Braun
11+
* @copyright 2001-2025 WoltLab GmbH
12+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13+
* @since 6.2
14+
*
15+
* @method TemplateGroup current()
16+
* @method TemplateGroup[] getObjects()
17+
* @method TemplateGroup|null getSingleObject()
18+
* @method TemplateGroup|null search($objectID)
19+
* @property TemplateGroup[] $objects
20+
*/
21+
class I18nTemplateGroupList extends I18nDatabaseObjectList
22+
{
23+
/**
24+
* @inheritDoc
25+
*/
26+
public $i18nFields = ['templateGroupName' => 'templateGroupNameI18n'];
27+
28+
/**
29+
* @inheritDoc
30+
*/
31+
public $className = TemplateGroup::class;
32+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace wcf\event\gridView\admin;
4+
5+
use wcf\event\IPsr14Event;
6+
use wcf\system\gridView\admin\TemplateGroupGridView;
7+
8+
/**
9+
* Indicates that the template group grid view has been initialized.
10+
*
11+
* @author Olaf Braun
12+
* @copyright 2001-2025 WoltLab GmbH
13+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14+
* @since 6.2
15+
*/
16+
final class TemplateGroupGridViewInitialized implements IPsr14Event
17+
{
18+
public function __construct(public readonly TemplateGroupGridView $gridView)
19+
{
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace wcf\event\interaction\admin;
4+
5+
use wcf\event\IPsr14Event;
6+
use wcf\system\interaction\admin\TemplateGroupInteractions;
7+
8+
/**
9+
* Indicates that the provider for template group interactions is collecting interactions.
10+
*
11+
* @author Olaf Braun
12+
* @copyright 2001-2025 WoltLab GmbH
13+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14+
* @since 6.2
15+
*/
16+
final class TemplateGroupInteractionCollecting implements IPsr14Event
17+
{
18+
public function __construct(public readonly TemplateGroupInteractions $provider)
19+
{
20+
}
21+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace wcf\system\endpoint\controller\core\templates\groups;
4+
5+
use Laminas\Diactoros\Response\JsonResponse;
6+
use Psr\Http\Message\ResponseInterface;
7+
use Psr\Http\Message\ServerRequestInterface;
8+
use wcf\data\template\group\TemplateGroup;
9+
use wcf\data\template\group\TemplateGroupAction;
10+
use wcf\http\Helper;
11+
use wcf\system\endpoint\DeleteRequest;
12+
use wcf\system\endpoint\IController;
13+
use wcf\system\exception\PermissionDeniedException;
14+
use wcf\system\WCF;
15+
16+
/**
17+
* API endpoint for the deletion of template groups.
18+
*
19+
* @author Olaf Braun
20+
* @copyright 2001-2025 WoltLab GmbH
21+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
22+
* @since 6.2
23+
*/
24+
#[DeleteRequest('/core/templates/groups/{id:\d+}')]
25+
final class DeleteTemplateGroup implements IController
26+
{
27+
#[\Override]
28+
public function __invoke(ServerRequestInterface $request, array $variables): ResponseInterface
29+
{
30+
$group = Helper::fetchObjectFromRequestParameter($variables['id'], TemplateGroup::class);
31+
32+
$this->assertTemplateGroupCanBeDeleted($group);
33+
34+
(new TemplateGroupAction([$group], 'delete'))->executeAction();
35+
36+
return new JsonResponse([]);
37+
}
38+
39+
private function assertTemplateGroupCanBeDeleted(TemplateGroup $group): void
40+
{
41+
WCF::getSession()->checkPermissions(["admin.template.canManageTemplate"]);
42+
43+
if ($group->isImmutable()) {
44+
throw new PermissionDeniedException();
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)