Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 0 additions & 70 deletions wcfsetup/install/files/acp/js/WCF.ACP.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,76 +807,6 @@ WCF.ACP.Worker = Class.extend({
}
});

/**
* Namespace for category-related functions.
*/
WCF.ACP.Category = { };

/**
* Handles collapsing categories.
*
* @param string className
* @param integer objectTypeID
*/
WCF.ACP.Category.Collapsible = WCF.Collapsible.SimpleRemote.extend({
/**
* @see WCF.Collapsible.Remote.init()
*/
init: function(className) {
var sortButton = $('.formSubmit > button[data-type="submit"]');
if (sortButton) {
sortButton.click($.proxy(this._sort, this));
}

this._super(className);
},

/**
* @see WCF.Collapsible.Remote._getButtonContainer()
*/
_getButtonContainer: function(containerID) {
return $('#' + containerID + ' > .buttons');
},

/**
* @see WCF.Collapsible.Remote._getContainers()
*/
_getContainers: function() {
return $('.jsCategory').has('ol').has('li');
},

/**
* @see WCF.Collapsible.Remote._getTarget()
*/
_getTarget: function(containerID) {
return $('#' + containerID + ' > ol');
},

/**
* Handles a click on the sort button.
*/
_sort: function() {
// remove existing collapsible buttons
$('.collapsibleButton').remove();

// reinit containers
this._containers = { };
this._containerData = { };

var $containers = this._getContainers();
if ($containers.length == 0) {
console.debug('[WCF.ACP.Category.Collapsible] Empty container set given, aborting.');
}
$containers.each($.proxy(function(index, container) {
var $container = $(container);
var $containerID = $container.wcfIdentify();
this._containers[$containerID] = $container;

this._initContainer($containerID);
}, this));
}
});

/**
* Provides the search dropdown for ACP
*
Expand Down
24 changes: 8 additions & 16 deletions wcfsetup/install/files/acp/templates/categoryList.tpl
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
{include file='header'}

{if $categoryNodeList->hasChildren()}
{if $categoryNodeList->hasChildren() && $objectType->getProcessor()->canEditCategory()}
<script data-relocate="true">
$(function() {
{if $collapsibleObjectTypeID}
new WCF.ACP.Category.Collapsible('wcf\\data\\category\\CategoryAction', {@$collapsibleObjectTypeID});
{/if}

{if $objectType->getProcessor()->canEditCategory()}
require(['WoltLabSuite/Core/Ui/Sortable/List'], function (UiSortableList) {
new UiSortableList({
containerId: 'categoryList',
className: 'wcf\\data\\category\\CategoryAction',
maxNestingLevel: {if $objectType->getProcessor()->getMaximumNestingLevel() == -1}undefined{else}{$objectType->getProcessor()->getMaximumNestingLevel()}{/if},
});
});
{/if}
require(['WoltLabSuite/Core/Ui/Sortable/List'], function (UiSortableList) {
new UiSortableList({
containerId: 'categoryList',
className: 'wcf\\data\\category\\CategoryAction',
maxNestingLevel: {if $objectType->getProcessor()->getMaximumNestingLevel() == -1}undefined{else}{$objectType->getProcessor()->getMaximumNestingLevel()}{/if},
});
});
</script>
{/if}
Expand Down Expand Up @@ -48,7 +40,7 @@
{foreach from=$categoryNodeList item='category'}
{section name=i loop=$oldDepth-$categoryNodeList->getDepth()}</ol></li>{/section}

<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}>
<li class="{if $objectType->getProcessor()->canEditCategory()}sortableNode {if $categoryNodeList->getDepth() == $objectType->getProcessor()->getMaximumNestingLevel()}sortableNoNesting {/if}{/if}jsCategory jsObjectActionObject" data-object-id="{@$category->getObjectID()}">
<span class="sortableNodeLabel">
<span class="title">
{event name='beforeTitle'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use wcf\system\category\CategoryHandler;
use wcf\system\exception\InvalidObjectTypeException;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\user\collapsible\content\UserCollapsibleContentHandler;
use wcf\system\WCF;

/**
Expand All @@ -33,18 +32,6 @@ abstract class AbstractCategoryListPage extends AbstractPage
*/
public $categoryNodeTree;

/**
* ids of collapsed categories
* @var int[]
*/
public $collapsedCategoryIDs;

/**
* id of the collapsible category object type
* @var int
*/
public $collapsibleObjectTypeID = 0;

/**
* name of the controller used to edit categories
* @var string
Expand Down Expand Up @@ -103,8 +90,6 @@ public function assignVariables()
WCF::getTPL()->assign([
'addController' => $this->addController,
'categoryNodeList' => $this->categoryNodeTree->getIterator(),
'collapsedCategoryIDs' => $this->collapsedCategoryIDs,
'collapsibleObjectTypeID' => $this->collapsibleObjectTypeID,
'editController' => $this->editController,
'objectType' => $this->objectType,
]);
Expand Down Expand Up @@ -151,23 +136,6 @@ public function readData()

$this->readCategories();

// note that the implementation of wcf\system\category\ICategoryType
// needs to support a object type of the pseudo definition
// 'com.woltlab.wcf.collapsibleContent.acp' which has to be registered
// during package installation as a 'com.woltlab.wcf.collapsibleContent'
// object type if you want to support collapsible categories in the
// acp; the pseudo object type is used to distinguish between
// collapsible categories in the frontend and the acp
$collapsibleObjectTypeName = $this->objectType->getProcessor()->getObjectTypeName('com.woltlab.wcf.collapsibleContent.acp');
if ($collapsibleObjectTypeName) {
$this->collapsibleObjectTypeID = UserCollapsibleContentHandler::getInstance()->getObjectTypeID($collapsibleObjectTypeName);
// get ids of collapsed category
if ($this->collapsibleObjectTypeID !== null) {
$this->collapsedCategoryIDs = UserCollapsibleContentHandler::getInstance()->getCollapsedContent($this->collapsibleObjectTypeID);
$this->collapsedCategoryIDs = \array_flip($this->collapsedCategoryIDs);
}
}

parent::readData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\ISortableAction;
use wcf\data\IToggleAction;
use wcf\data\IToggleContainerAction;
use wcf\data\language\item\LanguageItemAction;
use wcf\data\TDatabaseObjectToggle;
use wcf\system\acl\ACLHandler;
use wcf\system\category\CategoryHandler;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\SystemException;
use wcf\system\exception\UserInputException;
use wcf\system\user\collapsible\content\UserCollapsibleContentHandler;
use wcf\system\WCF;

/**
Expand All @@ -28,8 +25,7 @@
*/
class CategoryAction extends AbstractDatabaseObjectAction implements
ISortableAction,
IToggleAction,
IToggleContainerAction
IToggleAction
{
use TDatabaseObjectToggle;

Expand Down Expand Up @@ -105,27 +101,6 @@ public function delete()
return $returnValue;
}

/**
* @inheritDoc
*/
public function toggleContainer()
{
$collapsibleObjectTypeName = $this->getObjects()[0]->getProcessor()->getObjectTypeName('com.woltlab.wcf.collapsibleContent');
if ($collapsibleObjectTypeName === null) {
throw new SystemException("Categories of this type don't support collapsing");
}

$objectTypeID = UserCollapsibleContentHandler::getInstance()->getObjectTypeID($collapsibleObjectTypeName);
$collapsedCategories = UserCollapsibleContentHandler::getInstance()->getCollapsedContent($objectTypeID);

$categoryID = $this->objects[0]->categoryID;
if (\array_search($categoryID, $collapsedCategories) !== false) {
UserCollapsibleContentHandler::getInstance()->markAsOpened($objectTypeID, (string)$categoryID);
} else {
UserCollapsibleContentHandler::getInstance()->markAsCollapsed($objectTypeID, (string)$categoryID);
}
}

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -241,14 +216,6 @@ public function validateDelete()
}
}

/**
* @inheritDoc
*/
public function validateToggleContainer()
{
$this->validateUpdate();
}

/**
* @inheritDoc
*/
Expand Down