Skip to content

Commit 3cf640a

Browse files
committed
Remove support for collapsible categories
The basic implementation was not used anywhere. Closes #6099
1 parent d71a2c8 commit 3cf640a

File tree

4 files changed

+9
-152
lines changed

4 files changed

+9
-152
lines changed

wcfsetup/install/files/acp/js/WCF.ACP.js

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -807,76 +807,6 @@ WCF.ACP.Worker = Class.extend({
807807
}
808808
});
809809

810-
/**
811-
* Namespace for category-related functions.
812-
*/
813-
WCF.ACP.Category = { };
814-
815-
/**
816-
* Handles collapsing categories.
817-
*
818-
* @param string className
819-
* @param integer objectTypeID
820-
*/
821-
WCF.ACP.Category.Collapsible = WCF.Collapsible.SimpleRemote.extend({
822-
/**
823-
* @see WCF.Collapsible.Remote.init()
824-
*/
825-
init: function(className) {
826-
var sortButton = $('.formSubmit > button[data-type="submit"]');
827-
if (sortButton) {
828-
sortButton.click($.proxy(this._sort, this));
829-
}
830-
831-
this._super(className);
832-
},
833-
834-
/**
835-
* @see WCF.Collapsible.Remote._getButtonContainer()
836-
*/
837-
_getButtonContainer: function(containerID) {
838-
return $('#' + containerID + ' > .buttons');
839-
},
840-
841-
/**
842-
* @see WCF.Collapsible.Remote._getContainers()
843-
*/
844-
_getContainers: function() {
845-
return $('.jsCategory').has('ol').has('li');
846-
},
847-
848-
/**
849-
* @see WCF.Collapsible.Remote._getTarget()
850-
*/
851-
_getTarget: function(containerID) {
852-
return $('#' + containerID + ' > ol');
853-
},
854-
855-
/**
856-
* Handles a click on the sort button.
857-
*/
858-
_sort: function() {
859-
// remove existing collapsible buttons
860-
$('.collapsibleButton').remove();
861-
862-
// reinit containers
863-
this._containers = { };
864-
this._containerData = { };
865-
866-
var $containers = this._getContainers();
867-
if ($containers.length == 0) {
868-
console.debug('[WCF.ACP.Category.Collapsible] Empty container set given, aborting.');
869-
}
870-
$containers.each($.proxy(function(index, container) {
871-
var $container = $(container);
872-
var $containerID = $container.wcfIdentify();
873-
this._containers[$containerID] = $container;
874-
875-
this._initContainer($containerID);
876-
}, this));
877-
}
878-
});
879-
880810
/**
881811
* Provides the search dropdown for ACP
882812
*

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
{include file='header'}
22

3-
{if $categoryNodeList->hasChildren()}
3+
{if $categoryNodeList->hasChildren() && $objectType->getProcessor()->canEditCategory()}
44
<script data-relocate="true">
5-
$(function() {
6-
{if $collapsibleObjectTypeID}
7-
new WCF.ACP.Category.Collapsible('wcf\\data\\category\\CategoryAction', {@$collapsibleObjectTypeID});
8-
{/if}
9-
10-
{if $objectType->getProcessor()->canEditCategory()}
11-
require(['WoltLabSuite/Core/Ui/Sortable/List'], function (UiSortableList) {
12-
new UiSortableList({
13-
containerId: 'categoryList',
14-
className: 'wcf\\data\\category\\CategoryAction',
15-
maxNestingLevel: {if $objectType->getProcessor()->getMaximumNestingLevel() == -1}undefined{else}{$objectType->getProcessor()->getMaximumNestingLevel()}{/if},
16-
});
17-
});
18-
{/if}
5+
require(['WoltLabSuite/Core/Ui/Sortable/List'], function (UiSortableList) {
6+
new UiSortableList({
7+
containerId: 'categoryList',
8+
className: 'wcf\\data\\category\\CategoryAction',
9+
maxNestingLevel: {if $objectType->getProcessor()->getMaximumNestingLevel() == -1}undefined{else}{$objectType->getProcessor()->getMaximumNestingLevel()}{/if},
10+
});
1911
});
2012
</script>
2113
{/if}
@@ -48,7 +40,7 @@
4840
{foreach from=$categoryNodeList item='category'}
4941
{section name=i loop=$oldDepth-$categoryNodeList->getDepth()}</ol></li>{/section}
5042

51-
<li class="{if $objectType->getProcessor()->canEditCategory()}sortableNode {if $categoryNodeList->getDepth() == $objectType->getProcessor()->getMaximumNestingLevel()}sortableNoNesting {/if}{/if}jsCategory jsObjectActionObject" data-object-id="{@$category->getObjectID()}"{if $collapsedCategoryIDs|is_array} data-is-open="{if $collapsedCategoryIDs[$category->categoryID]|isset}0{else}1{/if}"{/if}>
43+
<li class="{if $objectType->getProcessor()->canEditCategory()}sortableNode {if $categoryNodeList->getDepth() == $objectType->getProcessor()->getMaximumNestingLevel()}sortableNoNesting {/if}{/if}jsCategory jsObjectActionObject" data-object-id="{@$category->getObjectID()}">
5244
<span class="sortableNodeLabel">
5345
<span class="title">
5446
{event name='beforeTitle'}

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use wcf\system\category\CategoryHandler;
99
use wcf\system\exception\InvalidObjectTypeException;
1010
use wcf\system\exception\PermissionDeniedException;
11-
use wcf\system\user\collapsible\content\UserCollapsibleContentHandler;
1211
use wcf\system\WCF;
1312

1413
/**
@@ -33,18 +32,6 @@ abstract class AbstractCategoryListPage extends AbstractPage
3332
*/
3433
public $categoryNodeTree;
3534

36-
/**
37-
* ids of collapsed categories
38-
* @var int[]
39-
*/
40-
public $collapsedCategoryIDs;
41-
42-
/**
43-
* id of the collapsible category object type
44-
* @var int
45-
*/
46-
public $collapsibleObjectTypeID = 0;
47-
4835
/**
4936
* name of the controller used to edit categories
5037
* @var string
@@ -103,8 +90,6 @@ public function assignVariables()
10390
WCF::getTPL()->assign([
10491
'addController' => $this->addController,
10592
'categoryNodeList' => $this->categoryNodeTree->getIterator(),
106-
'collapsedCategoryIDs' => $this->collapsedCategoryIDs,
107-
'collapsibleObjectTypeID' => $this->collapsibleObjectTypeID,
10893
'editController' => $this->editController,
10994
'objectType' => $this->objectType,
11095
]);
@@ -151,23 +136,6 @@ public function readData()
151136

152137
$this->readCategories();
153138

154-
// note that the implementation of wcf\system\category\ICategoryType
155-
// needs to support a object type of the pseudo definition
156-
// 'com.woltlab.wcf.collapsibleContent.acp' which has to be registered
157-
// during package installation as a 'com.woltlab.wcf.collapsibleContent'
158-
// object type if you want to support collapsible categories in the
159-
// acp; the pseudo object type is used to distinguish between
160-
// collapsible categories in the frontend and the acp
161-
$collapsibleObjectTypeName = $this->objectType->getProcessor()->getObjectTypeName('com.woltlab.wcf.collapsibleContent.acp');
162-
if ($collapsibleObjectTypeName) {
163-
$this->collapsibleObjectTypeID = UserCollapsibleContentHandler::getInstance()->getObjectTypeID($collapsibleObjectTypeName);
164-
// get ids of collapsed category
165-
if ($this->collapsibleObjectTypeID !== null) {
166-
$this->collapsedCategoryIDs = UserCollapsibleContentHandler::getInstance()->getCollapsedContent($this->collapsibleObjectTypeID);
167-
$this->collapsedCategoryIDs = \array_flip($this->collapsedCategoryIDs);
168-
}
169-
}
170-
171139
parent::readData();
172140
}
173141
}

wcfsetup/install/files/lib/data/category/CategoryAction.class.php

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@
55
use wcf\data\AbstractDatabaseObjectAction;
66
use wcf\data\ISortableAction;
77
use wcf\data\IToggleAction;
8-
use wcf\data\IToggleContainerAction;
98
use wcf\data\language\item\LanguageItemAction;
109
use wcf\data\TDatabaseObjectToggle;
1110
use wcf\system\acl\ACLHandler;
1211
use wcf\system\category\CategoryHandler;
1312
use wcf\system\database\util\PreparedStatementConditionBuilder;
1413
use wcf\system\exception\PermissionDeniedException;
15-
use wcf\system\exception\SystemException;
1614
use wcf\system\exception\UserInputException;
17-
use wcf\system\user\collapsible\content\UserCollapsibleContentHandler;
1815
use wcf\system\WCF;
1916

2017
/**
@@ -28,8 +25,7 @@
2825
*/
2926
class CategoryAction extends AbstractDatabaseObjectAction implements
3027
ISortableAction,
31-
IToggleAction,
32-
IToggleContainerAction
28+
IToggleAction
3329
{
3430
use TDatabaseObjectToggle;
3531

@@ -105,27 +101,6 @@ public function delete()
105101
return $returnValue;
106102
}
107103

108-
/**
109-
* @inheritDoc
110-
*/
111-
public function toggleContainer()
112-
{
113-
$collapsibleObjectTypeName = $this->getObjects()[0]->getProcessor()->getObjectTypeName('com.woltlab.wcf.collapsibleContent');
114-
if ($collapsibleObjectTypeName === null) {
115-
throw new SystemException("Categories of this type don't support collapsing");
116-
}
117-
118-
$objectTypeID = UserCollapsibleContentHandler::getInstance()->getObjectTypeID($collapsibleObjectTypeName);
119-
$collapsedCategories = UserCollapsibleContentHandler::getInstance()->getCollapsedContent($objectTypeID);
120-
121-
$categoryID = $this->objects[0]->categoryID;
122-
if (\array_search($categoryID, $collapsedCategories) !== false) {
123-
UserCollapsibleContentHandler::getInstance()->markAsOpened($objectTypeID, (string)$categoryID);
124-
} else {
125-
UserCollapsibleContentHandler::getInstance()->markAsCollapsed($objectTypeID, (string)$categoryID);
126-
}
127-
}
128-
129104
/**
130105
* @inheritDoc
131106
*/
@@ -241,14 +216,6 @@ public function validateDelete()
241216
}
242217
}
243218

244-
/**
245-
* @inheritDoc
246-
*/
247-
public function validateToggleContainer()
248-
{
249-
$this->validateUpdate();
250-
}
251-
252219
/**
253220
* @inheritDoc
254221
*/

0 commit comments

Comments
 (0)