Skip to content

Commit cb96487

Browse files
committed
Remove special code for option category handling
1 parent 4046ca9 commit cb96487

File tree

3 files changed

+7
-131
lines changed

3 files changed

+7
-131
lines changed

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,15 @@
2828
{if $_subMenuItems|empty}
2929
<li{if $_menuItem->menuItem|in_array:$_activeMenuItems} class="active"{/if}><a href="{$_menuItem->getLink()}" class="acpPageSubMenuLink">{$_menuItem}</a></li>
3030
{else}
31-
{if $_menuItem->menuItem === 'wcf.acp.menu.link.option.category'}
32-
{* handle special option categories *}
31+
<li class="acpPageSubMenuLinkWrapper">
32+
<a href="{$_menuItem->getLink()}" class="acpPageSubMenuLink{if $_menuItem->menuItem|in_array:$_activeMenuItems && $_activeMenuItems[0] === $_menuItem->menuItem} active{/if}">{$_menuItem}</a>
33+
3334
{foreach from=$_subMenuItems item=_subMenuItem}
34-
<li{if $_subMenuItem->menuItem|in_array:$_activeMenuItems} class="active"{/if}><a href="{$_subMenuItem->getLink()}" class="acpPageSubMenuLink">{$_subMenuItem}</a></li>
35+
<a href="{$_subMenuItem->getLink()}" class="acpPageSubMenuIcon jsTooltip{if $_subMenuItem->menuItem|in_array:$_activeMenuItems} active{/if}" title="{$_subMenuItem}">
36+
{unsafe:$_subMenuItem->getIcon()->toHtml()}
37+
</a>
3538
{/foreach}
36-
{else}
37-
<li class="acpPageSubMenuLinkWrapper">
38-
<a href="{$_menuItem->getLink()}" class="acpPageSubMenuLink{if $_menuItem->menuItem|in_array:$_activeMenuItems && $_activeMenuItems[0] === $_menuItem->menuItem} active{/if}">{$_menuItem}</a>
39-
40-
{foreach from=$_subMenuItems item=_subMenuItem}
41-
<a href="{$_subMenuItem->getLink()}" class="acpPageSubMenuIcon jsTooltip{if $_subMenuItem->menuItem|in_array:$_activeMenuItems} active{/if}" title="{$_subMenuItem}">
42-
{unsafe:$_subMenuItem->getIcon()->toHtml()}
43-
</a>
44-
{/foreach}
45-
</li>
46-
{/if}
39+
</li>
4740
{/if}
4841
{/foreach}
4942
</ol>

wcfsetup/install/files/lib/data/acp/menu/item/ACPMenuItem.class.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ public function getLink(): string
6767
'application' => $this->application,
6868
];
6969

70-
// links of top option category menu items need the id of the option
71-
// category
72-
if ($this->parentMenuItem == 'wcf.acp.menu.link.option.category') {
73-
$linkParameters['id'] = $this->optionCategoryID;
74-
}
75-
7670
return LinkHandler::getInstance()->getLink(
7771
$this->controller,
7872
$linkParameters,
@@ -119,14 +113,6 @@ protected function parseController()
119113
*/
120114
public function __toString(): string
121115
{
122-
// This is a placeholder category that represents the dynamic menu items
123-
// generated by categories in the `options.xml`. It has no title and
124-
// trying to access its name causes a false-positive for missing phrases
125-
// with every ACP request.
126-
if ($this->menuItem === 'wcf.acp.menu.link.option.category') {
127-
return 'wcf.acp.menu.link.option.category';
128-
}
129-
130116
return WCF::getLanguage()->get($this->menuItem);
131117
}
132118

wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
namespace wcf\system\cache\builder;
44

5-
use wcf\acp\form\OptionForm;
6-
use wcf\data\acp\menu\item\ACPMenuItem;
75
use wcf\data\acp\menu\item\ACPMenuItemList;
8-
use wcf\data\option\category\OptionCategory;
9-
use wcf\data\option\category\OptionCategoryList;
10-
use wcf\data\option\OptionList;
116

127
/**
138
* Caches the ACP menu items.
@@ -18,118 +13,20 @@
1813
*/
1914
class ACPMenuCacheBuilder extends AbstractCacheBuilder
2015
{
21-
/**
22-
* list of option categories which directly contain options
23-
* @var string[]
24-
*/
25-
protected $categoriesWithOptions = [];
26-
27-
/**
28-
* list of option categories grouped by the name of their parent category
29-
* @var array<string, OptionCategory[]>
30-
*/
31-
protected $categoryStructure = [];
32-
3316
/**
3417
* @inheritDoc
3518
*/
3619
public function rebuild(array $parameters)
3720
{
3821
$data = [];
3922

40-
// get "real" menu items
4123
$menuItemList = new ACPMenuItemList();
4224
$menuItemList->sqlOrderBy = "acp_menu_item.showOrder";
4325
$menuItemList->readObjects();
4426
foreach ($menuItemList as $menuItem) {
4527
$data[$menuItem->parentMenuItem][] = $menuItem;
4628
}
4729

48-
// get menu items for top option categories
49-
/*$data['wcf.acp.menu.link.option.category'] = [];
50-
foreach ($this->getTopOptionCategories() as $optionCategory) {
51-
$data['wcf.acp.menu.link.option.category'][] = new ACPMenuItem(null, [
52-
'menuItem' => 'wcf.acp.option.category.' . $optionCategory->categoryName,
53-
'parentMenuItem' => 'wcf.acp.menu.link.option.category',
54-
'menuItemController' => OptionForm::class,
55-
'permissions' => $optionCategory->permissions,
56-
'optionCategoryID' => $optionCategory->categoryID,
57-
'options' => $optionCategory->options,
58-
]);
59-
}*/
60-
6130
return $data;
6231
}
63-
64-
/**
65-
* Returns the list with top option categories which contain options.
66-
*
67-
* @return OptionCategory[]
68-
*/
69-
protected function getTopOptionCategories()
70-
{
71-
$optionCategoryList = new OptionCategoryList();
72-
$optionCategoryList->readObjects();
73-
$optionCategories = $optionCategoryList->getObjects();
74-
75-
// build category structure
76-
$this->categoryStructure = [];
77-
foreach ($optionCategories as $optionCategory) {
78-
if (!isset($this->categoryStructure[$optionCategory->parentCategoryName])) {
79-
$this->categoryStructure[$optionCategory->parentCategoryName] = [];
80-
}
81-
82-
$this->categoryStructure[$optionCategory->parentCategoryName][] = $optionCategory;
83-
}
84-
85-
$optionList = new OptionList();
86-
$optionList->readObjects();
87-
88-
// collect names of categories which contain options
89-
foreach ($optionList as $option) {
90-
if (!isset($this->categoriesWithOptions[$option->categoryName])) {
91-
$this->categoriesWithOptions[$option->categoryName] = $option->categoryName;
92-
}
93-
}
94-
95-
// collect top categories which contain options
96-
$topCategories = [];
97-
foreach ($this->categoryStructure[""] as $topCategory) {
98-
if ($this->containsOptions($topCategory)) {
99-
$topCategories[$topCategory->categoryID] = $topCategory;
100-
}
101-
}
102-
103-
return $topCategories;
104-
}
105-
106-
/**
107-
* Returns true if the given category or one of its child categories contains
108-
* options.
109-
*
110-
* @param OptionCategory $topCategory
111-
* @return bool
112-
*/
113-
protected function containsOptions(OptionCategory $topCategory)
114-
{
115-
// check if category directly contains options
116-
if (isset($this->categoriesWithOptions[$topCategory->categoryName])) {
117-
return true;
118-
}
119-
120-
if (!isset($this->categoryStructure[$topCategory->categoryName])) {
121-
// if category directly contains no options and has no child
122-
// categories, it contains no options at all
123-
return false;
124-
}
125-
126-
// check child categories
127-
foreach ($this->categoryStructure[$topCategory->categoryName] as $category) {
128-
if ($this->containsOptions($category)) {
129-
return true;
130-
}
131-
}
132-
133-
return false;
134-
}
13532
}

0 commit comments

Comments
 (0)