--- /dev/null
+{foreach from=$categoryNodeList item=category}
+ {if !$maximumNestingLevel|isset || $maximumNestingLevel == -2 || $categoryNodeList->getDepth() <= $maximumNestingLevel}
+ <option value="{$category->objectTypeCategoryID}"{if $categoryID|isset && $categoryID == $category->objectTypeCategoryID} selected="selected"{/if}>{section name=i loop=$categoryNodeList->getDepth()} {/section}{$category->getTitle()}</option>
+ {/if}
+{/foreach}
\ No newline at end of file
+++ /dev/null
-{foreach from=$categoryNodeList item=category}
- <option value="{$category->objectTypeCategoryID}"{if $categoryID|isset && $categoryID == $category->objectTypeCategoryID} selected="selected"{/if}>{section name=i loop=$categoryNodeList->getDepth()} {/section}{$category->getTitle()}</option>
-{/foreach}
\ No newline at end of file
+++ /dev/null
-{include file='header'}
-
-{if $aclObjectTypeID}
- {include file='aclPermissions'}
-{/if}
-<script type="text/javascript">
- //<![CDATA[
- $(function() {
- {if $aclObjectTypeID}
- new WCF.ACL.List($('#groupPermissions'), {@$aclObjectTypeID}{if $category|isset}, '', {@$category->categoryID}{/if});
- {/if}
- });
- //]]>
-</script>
-
-{include file='multipleLanguageInputJavascript' elementIdentifier='title'}
-{if $objectType->getProcessor()->supportsDescriptions()}
- {include file='multipleLanguageInputJavascript' elementIdentifier='description'}
-{/if}
-
-<header class="boxHeadline">
- <hgroup>
- <h1>{@$objectType->getProcessor()->getLanguageVariable($action)}</h1>
- </hgroup>
-</header>
-
-{if $errorField}
- <p class="error">{lang}wcf.global.form.error{/lang}</p>
-{/if}
-
-{if $success|isset}
- <p class="success">{lang}wcf.global.form.{@$action}.success{/lang}</p>
-{/if}
-
-{hascontent}
- <div class="contentNavigation">
- <nav>
- <ul>
- {content}
- {if $objectType->getProcessor()->canDeleteCategory() || $objectType->getProcessor()->canEditCategory()}
- <li><a href="{link controller=$listController}{/link}" title="{$objectType->getProcessor()->getLanguageVariable('button.list')}" class="button"><img src="{@$__wcf->getPath()}icon/list.svg" alt="" class="icon24" /> <span>{@$objectType->getProcessor()->getLanguageVariable('button.list')}</span></a></li>
- {/if}
-
- {event name='contentNavigationButtons'}
- {/content}
- </ul>
- </nav>
- </div>
-{/hascontent}
-
-<form method="post" action="{if $action == 'add'}{link controller=$addController}{/link}{else}{link controller=$editController id=$category->categoryID title=$category->getTitle()}{/link}{/if}">
- <div class="container containerPadding marginTop shadow">
- <fieldset>
- <legend>{lang}wcf.global.form.data{/lang}</legend>
-
- {if $categoryNodeList|count}
- <dl{if $errorField == 'parentCategoryID'} class="formError"{/if}>
- <dt><label for="parentCategoryID">{@$objectType->getProcessor()->getLanguageVariable('parentCategoryID')}</label></dt>
- <dd>
- <select id="parentCategoryID" name="parentCategoryID">
- <option value="0"></option>
- {include file='categorySelectList' categoryID=$parentCategoryID}
- </select>
- {if $errorField == 'parentCategoryID'}
- <small class="innerError">
- {assign var=__languageVariable value='parentCategoryID.error.'|concat:$errorType}
- {@$objectType->getProcessor()->getLanguageVariable($__languageVariable)}
- </small>
- {/if}
- {hascontent}<small>{content}{@$objectType->getProcessor()->getLanguageVariable('parentCategoryID.description', true)}{/content}</small>{/hascontent}
- </dd>
- </dl>
- {/if}
-
- <dl{if $errorField == 'title'} class="formError"{/if}>
- <dt><label for="title">{@$objectType->getProcessor()->getLanguageVariable('title')}</label></dt>
- <dd>
- <input type="text" id="title" name="title" value="{$i18nPlainValues['title']}" class="long" />
- {if $errorField == 'title'}
- <small class="innerError">
- {if $errorType == 'empty'}
- {lang}wcf.global.form.error.empty{/lang}
- {else}
- {assign var=__languageVariable value='title.error.'|concat:$errorType}
- {@$objectType->getProcessor()->getLanguageVariable($__languageVariable)}
- {/if}
- </small>
- {/if}
- {hascontent}<small>{content}{@$objectType->getProcessor()->getLanguageVariable('title.description', true)}{/content}</small>{/hascontent}
- </dd>
- </dl>
-
- {if $objectType->getProcessor()->supportsDescriptions()}
- <dl{if $errorField == 'description'} class="formError"{/if}>
- <dt><label for="description">{@$objectType->getProcessor()->getLanguageVariable('description')}</label></dt>
- <dd>
- <textarea cols="40" rows="10" id="description" name="description">{$i18nPlainValues['description']}</textarea>
- {if $errorField == 'description'}
- <small class="innerError">
- {if $errorType == 'empty'}
- {lang}wcf.global.form.error.empty{/lang}
- {else}
- {assign var=__languageVariable value='description.error.'|concat:$errorType}
- {@$objectType->getProcessor()->getLanguageVariable($__languageVariable)}
- {/if}
- </small>
- {/if}
- {hascontent}<small>{content}{@$objectType->getProcessor()->getLanguageVariable('description.description', true)}{/content}</small>{/hascontent}
- </dd>
- </dl>
- {/if}
-
- <dl{if $errorField == 'isDisabled'} class="formError"{/if}>
- <dt class="reversed"><label for="isDisabled">{@$objectType->getProcessor()->getLanguageVariable('isDisabled')}</label></dt>
- <dd>
- <input type="checkbox" id="isDisabled" name="isDisabled"{if $isDisabled} checked="checked"{/if} />
- {hascontent}<small>{content}{@$objectType->getProcessor()->getLanguageVariable('isDisabled.description', true)}{/content}</small>{/hascontent}
- </dd>
- </dl>
-
- <dl{if $errorField == 'showOrder'} class="formError"{/if}>
- <dt><label for="showOrder">{@$objectType->getProcessor()->getLanguageVariable('showOrder')}</label></dt>
- <dd>
- <input type="text" id="showOrder" name="showOrder" value="{$showOrder}" class="short" />
- {if $errorField == 'showOrder'}
- <small class="innerError">
- {assign var=__languageVariable value='showOrder.error.'|concat:$errorType}
- {@$objectType->getProcessor()->getLanguageVariable($__languageVariable)}
- </small>
- {/if}
- {hascontent}<small>{content}{@$objectType->getProcessor()->getLanguageVariable('showOrder.description', true)}{/content}</small>{/hascontent}
- </dd>
- </dl>
-
- {event name='dataFields'}
- </fieldset>
-
- {if $aclObjectTypeID}
- <fieldset>
- <legend>{lang}wcf.acp.acl.permissions{/lang}</legend>
-
- <dl id="groupPermissions" class="wide">
- <dt>{lang}wcf.acp.acl.permissions{/lang}</dt>
- <dd></dd>
- </dl>
-
- {event name='permissionFields'}
- </fieldset>
- {/if}
-
- {event name='fieldsets'}
- </div>
-
- <div class="formSubmit">
- <input type="reset" value="{lang}wcf.global.button.reset{/lang}" accesskey="r" />
- <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
- </div>
-</form>
-
-{include file='footer'}
\ No newline at end of file
+++ /dev/null
-{include file='header'}
-
-{if $categoryNodeList|count}
- <script type="text/javascript">
- //<![CDATA[
- $(function() {
- {if $collapsibleObjectTypeID && $categoryNodeList|count > 1}
- new WCF.ACP.Category.Collapsible('wcf\\data\\category\\CategoryAction', {@$collapsibleObjectTypeID});
- {/if}
-
- {if $objectType->getProcessor()->canDeleteCategory()}
- new WCF.ACP.Category.Delete('wcf\\data\\category\\CategoryAction', $('.jsCategory'));
- {/if}
- {if $objectType->getProcessor()->canEditCategory()}
- new WCF.Action.Toggle('wcf\\data\\category\\CategoryAction', $('.jsCategory'), '> .buttons > .jsToggleButton');
-
- {if $categoryNodeList|count > 1}
- new WCF.Sortable.List('categoryList', 'wcf\\data\\category\\CategoryAction');
- {/if}
- {/if}
- });
- //]]>
- </script>
-{/if}
-
-<header class="box48 boxHeadline">
- <hgroup>
- <h1>{@$objectType->getProcessor()->getLanguageVariable('list')}</h1>
- </hgroup>
-</header>
-
-{hascontent}
- <div class="contentNavigation">
- <nav>
- <ul>
- {content}
- {if $objectType->getProcessor()->canAddCategory()}
- <li><a href="{link controller=$addController}{/link}" title="{$objectType->getProcessor()->getLanguageVariable('add')}" class="button"><img src="{@$__wcf->getPath()}icon/add.svg" alt="" class="icon24" /> <span>{@$objectType->getProcessor()->getLanguageVariable('add')}</span></a></li>
- {/if}
-
- {event name='contentNavigationButtons'}
- {/content}
- </ul>
- </nav>
- </div>
-{/hascontent}
-
-{if $categoryNodeList|count}
- <section id="categoryList" class="container containerPadding marginTop shadow{if $objectType->getProcessor()->canEditCategory() && $categoryNodeList|count > 1} sortableListContainer{/if}">
- <ol class="categoryList sortableList" data-object-id="0">
- {assign var=oldDepth value=0}
- {foreach from=$categoryNodeList item=category}
- {section name=i loop=$oldDepth-$categoryNodeList->getDepth()}</ol></li>{/section}
-
- <li class="{if $objectType->getProcessor()->canEditCategory() && $categoryNodeList|count > 1}sortableNode {/if}jsCategory" data-object-id="{@$category->categoryID}"{if $collapsedCategoryIDs|is_array} data-is-open="{if $collapsedCategoryIDs[$category->categoryID]|isset}0{else}1{/if}"{/if}>
- <span class="sortableNodeLabel">
- <span class="buttons">
- {if $objectType->getProcessor()->canEditCategory()}
- <a href="{link controller=$editController id=$category->categoryID title=$category->getTitle()}{/link}"><img src="{@$__wcf->getPath()}icon/edit.svg" alt="" title="{lang}wcf.global.button.edit{/lang}" class="icon16 jsTooltip" /></a>
- {else}
- <img src="{@$__wcf->getPath()}icon/edit.svg" alt="" title="{lang}wcf.global.button.edit{/lang}" class="icon16 disabled" />
- {/if}
-
- {if $objectType->getProcessor()->canDeleteCategory()}
- <img src="{@$__wcf->getPath()}icon/delete.svg" alt="" title="{lang}wcf.global.button.delete{/lang}" class="icon16 jsDeleteButton jsTooltip" data-object-id="{@$category->categoryID}" data-confirm-message="{@$objectType->getProcessor()->getLanguageVariable('delete.sure')}" />
- {else}
- <img src="{@$__wcf->getPath()}icon/delete.svg" alt="" title="{lang}wcf.global.button.delete{/lang}" class="icon16 disabled" />
- {/if}
-
- {if $objectType->getProcessor()->canEditCategory()}
- <img src="{@$__wcf->getPath()}icon/{if !$category->isDisabled}enabled{else}disabled{/if}.svg" alt="" title="{lang}wcf.global.button.{if !$category->isDisabled}disable{else}enable{/if}{/lang}" class="icon16 jsToggleButton jsTooltip" data-object-id="{@$category->categoryID}" />
- {else}
- <img src="{@$__wcf->getPath()}icon/{if !$category->isDisabled}enabled{else}disabled{/if}.svg" alt="" title="{lang}wcf.global.button.{if !$category->isDisabled}enable{else}disable{/if}{/lang}" class="icon16 disabled" />
- {/if}
-
- {event name='buttons'}
- </span>
-
- <span class="title">
- {$category->getTitle()}
- </span>
- </span>
-
- <ol class="categoryList sortableList" data-object-id="{@$category->categoryID}">
- {if !$categoryNodeList->current()->hasChildren()}
- </ol></li>
- {/if}
- {assign var=oldDepth value=$categoryNodeList->getDepth()}
- {/foreach}
- {section name=i loop=$oldDepth}</ol></li>{/section}
- </ol>
-
- {if $objectType->getProcessor()->canEditCategory() && $categoryNodeList|count > 1}
- <div class="formSubmit">
- <button class="button default" data-type="submit">{lang}wcf.global.button.save{/lang}</button>
- </div>
- {/if}
- </section>
-
- {hascontent}
- <div class="contentNavigation">
- <nav>
- <ul>
- {content}
- {if $objectType->getProcessor()->canAddCategory()}
- <li><a href="{link controller=$addController}{/link}" title="{$objectType->getProcessor()->getLanguageVariable('add')}" class="button"><img src="{@$__wcf->getPath()}icon/add.svg" alt="" class="icon24" /> <span>{@$objectType->getProcessor()->getLanguageVariable('add')}</span></a></li>
- {/if}
-
- {event name='contentNavigationButtons'}
- {/content}
- </ul>
- </nav>
- </div>
- {/hascontent}
-{else}
- <p class="info">{@$objectType->getProcessor()->getLanguageVariable('noneAvailable')}</p>
-{/if}
-
-{include file='footer'}
\ No newline at end of file
--- /dev/null
+{foreach from=$categoryNodeList item=category}
+ {if !$maximumNestingLevel|isset || $maximumNestingLevel == -2 || $categoryNodeList->getDepth() <= $maximumNestingLevel}
+ <option value="{$category->categoryID}"{if $categoryID|isset && $categoryID == $category->categoryID} selected="selected"{/if}>{section name=i loop=$categoryNodeList->getDepth()} {/section}{$category->getTitle()}</option>
+ {/if}
+{/foreach}
\ No newline at end of file
+++ /dev/null
-{foreach from=$categoryNodeList item=category}
- <option value="{$category->objectTypeCategoryID}"{if $categoryID|isset && $categoryID == $category->objectTypeCategoryID} selected="selected"{/if}>{section name=i loop=$categoryNodeList->getDepth()} {/section}{$category->getTitle()}</option>
-{/foreach}
\ No newline at end of file
+++ /dev/null
-<?php
-namespace wcf\acp\form;
-use wcf\data\category\CategoryAction;
-use wcf\data\category\CategoryEditor;
-use wcf\data\category\CategoryNodeList;
-use wcf\system\acl\ACLHandler;
-use wcf\system\category\CategoryHandler;
-use wcf\system\exception\PermissionDeniedException;
-use wcf\system\exception\SystemException;
-use wcf\system\exception\UserInputException;
-use wcf\system\language\I18nHandler;
-use wcf\system\WCF;
-use wcf\util\ArrayUtil;
-use wcf\util\StringUtil;
-
-/**
- * Abstract implementation of a form to create categories.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2012 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage acp.form
- * @category Community Framework
- */
-abstract class AbstractCategoryAddForm extends ACPForm {
- /**
- * id of the category acl object type
- * @var integer
- */
- public $aclObjectTypeID = 0;
-
- /**
- * name of the controller used to add new categories
- * @var string
- */
- public $addController = '';
-
- /**
- * additional category data
- * @var array
- */
- public $additionalData = array();
-
- /**
- * list with the category nodes
- * @var wcf\data\category\CategoryNodeList
- */
- public $categoryNodeList = null;
-
- /**
- * description of the category
- * @var string
- */
- public $description = '';
-
- /**
- * indicates if the category is disabled
- * @var integer
- */
- public $isDisabled = 0;
-
- /**
- * name of the controller used to edit categories
- * @var string
- */
- public $editController = '';
-
- /**
- * name of the controller used to list the categories
- * @var string
- */
- public $listController = '';
-
- /**
- * category object type object
- * @var wcf\data\object\type\ObjectType
- */
- public $objectType = null;
-
- /**
- * name of the category object type
- * @var string
- */
- public $objectTypeName = '';
-
- /**
- * id of the package the created package belongs to
- * @var integer
- */
- public $packageID = 0;
-
- /**
- * id of the parent category id
- * @var integer
- */
- public $parentCategoryID = 0;
-
- /**
- * category show order
- * @var integer
- */
- public $showOrder = 0;
-
- /**
- * @see wcf\page\AbstractPage::$templateName
- */
- public $templateName = 'categoryAdd';
-
- /**
- * title of the category
- * @var string
- */
- public $title = '';
-
- /**
- * @see wcf\page\AbstractPage::__run()
- */
- public function __run() {
- $classNameParts = explode('\\', get_called_class());
- $className = array_pop($classNameParts);
-
- // autoset controllers
- if (empty($this->addController)) {
- $this->addController = StringUtil::replace(array('AddForm', 'EditForm'), 'Add', $className);
- }
- if (empty($this->editController)) {
- $this->editController = StringUtil::replace(array('AddForm', 'EditForm'), 'Edit', $className);
- }
- if (empty($this->listController)) {
- $this->listController = StringUtil::replace(array('AddForm', 'EditForm'), 'List', $className);
- }
-
- parent::__run();
- }
-
- /**
- * @see wcf\page\IPage::assignVariables()
- */
- public function assignVariables() {
- parent::assignVariables();
-
- I18nHandler::getInstance()->assignVariables();
-
- WCF::getTPL()->assign(array(
- 'aclObjectTypeID' => $this->aclObjectTypeID,
- 'action' => 'add',
- 'addController' => $this->addController,
- 'categoryNodeList' => $this->categoryNodeList,
- 'description' => $this->description,
- 'editController' => $this->editController,
- 'isDisabled' => $this->isDisabled,
- 'listController' => $this->listController,
- 'objectType' => $this->objectType,
- 'parentCategoryID' => $this->parentCategoryID,
- 'showOrder' => $this->showOrder,
- 'title' => $this->title
- ));
- }
-
- /**
- * Reads the categories.
- */
- protected function readCategories() {
- $this->categoryNodeList = new CategoryNodeList($this->objectType->objectTypeID, 0, true);
- }
-
- /**
- * Checks if the active user has the needed permissions to add a new category.
- */
- protected function checkCategoryPermissions() {
- if (!$this->objectType->getProcessor()->canAddCategory()) {
- throw new PermissionDeniedException();
- }
- }
-
- /**
- * @see wcf\page\IPage::readData()
- */
- public function readData() {
- $this->objectType = CategoryHandler::getInstance()->getObjectTypeByName($this->objectTypeName);
- if ($this->objectType === null) {
- throw new SystemException("Unknown category object type with name '".$this->objectTypeName."'");
- }
-
- // check permissions
- $this->checkCategoryPermissions();
-
- // get acl object type id
- if ($this->objectType->getProcessor()->getACLObjectTypeName()) {
- $this->aclObjectTypeID = ACLHandler::getInstance()->getObjectTypeID($this->objectType->getProcessor()->getACLObjectTypeName());
- }
-
- // autoset package id
- if (!$this->packageID) {
- $this->packageID = $this->objectType->packageID;
- }
-
- if ($this->objectType->getProcessor()->supportsDescriptions()) {
- I18nHandler::getInstance()->register('description');
- }
- I18nHandler::getInstance()->register('title');
-
- parent::readData();
-
- $this->readCategories();
- }
-
- /**
- * @see wcf\page\IForm::readFormParameters()
- */
- public function readFormParameters() {
- parent::readFormParameters();
-
- I18nHandler::getInstance()->readValues();
-
- if (isset($_POST['additionalData'])) {
- $this->additionalData = ArrayUtil::trim($_POST['additionalData']);
- }
- if ($this->objectType->getProcessor()->supportsDescriptions() && isset($_POST['description'])) {
- $this->description = StringUtil::trim($_POST['description']);
- }
- if (isset($_POST['isDisabled'])) {
- $this->isDisabled = 1;
- }
- if (isset($_POST['parentCategoryID'])) {
- $this->parentCategoryID = intval($_POST['parentCategoryID']);
- }
- if (isset($_POST['showOrder'])) {
- $this->showOrder = intval($_POST['showOrder']);
- }
- if (isset($_POST['title'])) {
- $this->title = StringUtil::trim($_POST['title']);
- }
- }
-
- /**
- * @see wcf\page\IForm::save()
- */
- public function save() {
- parent::save();
-
- $this->objectAction = new CategoryAction(array(), 'create', array(
- 'data' => array(
- 'additionalData' => serialize($this->additionalData),
- 'description' => $this->description,
- 'isDisabled' => $this->isDisabled,
- 'objectTypeID' => $this->objectType->objectTypeID,
- 'parentCategoryID' => $this->parentCategoryID,
- 'showOrder' => $this->showOrder,
- 'title' => $this->title
- )
- ));
- $this->objectAction->executeAction();
- $returnValues = $this->objectAction->getReturnValues();
-
- if (($this->objectType->getProcessor()->supportsDescriptions() && !I18nHandler::getInstance()->isPlainValue('description')) || !I18nHandler::getInstance()->isPlainValue('title')) {
- $categoryID = $returnValues['returnValues']->categoryID;
-
- $updateData = array();
- if ($this->objectType->getProcessor()->supportsDescriptions() && !I18nHandler::getInstance()->isPlainValue('description')) {
- $updateData['description'] = $this->objectType->getProcessor()->getI18nLangVarPrefix().'.description.category'.$categoryID;
- I18nHandler::getInstance()->save('description', $updateData['description'], $this->objectType->getProcessor()->getDescriptionLangVarCategory(), $this->packageID);
- }
- if (!I18nHandler::getInstance()->isPlainValue('title')) {
- $updateData['title'] = $this->objectType->getProcessor()->getI18nLangVarPrefix().'.title.category'.$categoryID;
- I18nHandler::getInstance()->save('title', $updateData['title'], $this->objectType->getProcessor()->getTitleLangVarCategory(), $this->packageID);
- }
-
- // update description/title
- $editor = new CategoryEditor($returnValues['returnValues']);
- $editor->update($updateData);
- }
-
- // save acl
- if ($this->aclObjectTypeID) {
- ACLHandler::getInstance()->save($returnValues['returnValues']->categoryID, $this->aclObjectTypeID);
- }
-
- // reload cache
- CategoryHandler::getInstance()->reloadCache();
-
- // reset values
- $this->parentCategoryID = 0;
- $this->showOrder = 0;
-
- $this->saved();
-
- // disable assignment of i18n values
- I18nHandler::getInstance()->disableAssignValueVariables();
-
- // show success message
- WCF::getTPL()->assign('success', true);
- }
-
- /**
- * @see wcf\page\IForm::validate()
- */
- public function validate() {
- parent::validate();
-
- $this->validateParentCategory();
-
- if (!I18nHandler::getInstance()->validateValue('title')) {
- throw new UserInputException('title');
- }
-
- if ($this->objectType->getProcessor()->supportsDescriptions() && !I18nHandler::getInstance()->validateValue('description')) {
- throw new UserInputException('description');
- }
- }
-
- /**
- * Validates the parent category.
- */
- protected function validateParentCategory() {
- if ($this->parentCategoryID) {
- if (CategoryHandler::getInstance()->getCategory($this->objectType->objectTypeID, $this->parentCategoryID) === null) {
- throw new UserInputException('parentCategoryID', 'invalid');
- }
- }
- }
-}
+++ /dev/null
-<?php
-namespace wcf\acp\form;
-use wcf\data\category\Category;
-use wcf\data\category\CategoryAction;
-use wcf\data\category\CategoryNodeList;
-use wcf\system\acl\ACLHandler;
-use wcf\system\category\CategoryHandler;
-use wcf\system\exception\IllegalLinkException;
-use wcf\system\exception\PermissionDeniedException;
-use wcf\system\exception\UserInputException;
-use wcf\system\language\I18nHandler;
-use wcf\system\WCF;
-
-/**
- * Abstract implementation of a form to edit a category.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2012 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage acp.form
- * @category Community Framework
- */
-class AbstractCategoryEditForm extends AbstractCategoryAddForm {
- /**
- * edited category
- * @var wcf\data\category\Category
- */
- public $category = null;
-
- /**
- * id of the edited category
- * @var integer
- */
- public $categoryID = 0;
-
- /**
- * @see wcf\page\IPage::assignVariables()
- */
- public function assignVariables() {
- parent::assignVariables();
-
- I18nHandler::getInstance()->assignVariables(!empty($_POST));
-
- WCF::getTPL()->assign(array(
- 'action' => 'edit',
- 'category' => $this->category
- ));
- }
-
- /**
- * @see wcf\acp\form\AbstractCategoryAddForm::checkCategoryPermissions()
- */
- protected function checkCategoryPermissions() {
- if (!$this->objectType->getProcessor()->canEditCategory()) {
- throw new PermissionDeniedException();
- }
- }
-
- /**
- * @see wcf\acp\form\AbstractCategoryAddForm::readCategories()
- */
- protected function readCategories() {
- $this->categoryNodeList = new CategoryNodeList($this->objectType->objectTypeID, 0, true, array($this->category->objectTypeCategoryID));
- }
-
- /**
- * @see wcf\page\IPage::readParameters()
- */
- public function readParameters() {
- parent::readParameters();
-
- if (isset($_REQUEST['id'])) {
- $this->categoryID = intval($_REQUEST['id']);
- }
- $this->category = new Category($this->categoryID);
- if (!$this->category->categoryID) {
- throw new IllegalLinkException();
- }
- }
-
- /**
- * @see wcf\page\IPage::readData()
- */
- public function readData() {
- parent::readData();
-
- if (empty($_POST)) {
- if ($this->objectType->getProcessor()->supportsDescriptions()) {
- I18nHandler::getInstance()->setOptions('description', $this->packageID, $this->category->description, $this->objectType->getProcessor()->getI18nLangVarPrefix().'.description.category\d+');
- }
- I18nHandler::getInstance()->setOptions('title', $this->packageID, $this->category->title, $this->objectType->getProcessor()->getI18nLangVarPrefix().'.title.category\d+');
-
- $this->additionalData = $this->category->additionalData;
- $this->isDisabled = $this->category->isDisabled;
- $this->parentCategoryID = $this->category->parentCategoryID;
- $this->showOrder = $this->category->showOrder;
- }
- }
-
- /**
- * @see wcf\form\IForm::save()
- */
- public function save() {
- ACPForm::save();
-
- // handle description
- if ($this->objectType->getProcessor()->supportsDescriptions()) {
- $this->description = $this->objectType->getProcessor()->getI18nLangVarPrefix().'.description.category'.$this->category->categoryID;
- if (I18nHandler::getInstance()->isPlainValue('description')) {
- I18nHandler::getInstance()->remove($this->description, $this->packageID);
- $this->description = I18nHandler::getInstance()->getValue('description');
- }
- else {
- I18nHandler::getInstance()->save('description', $this->description, $this->objectType->getProcessor()->getDescriptionLangVarCategory(), $this->packageID);
- }
- }
-
- // handle title
- $this->title = $this->objectType->getProcessor()->getI18nLangVarPrefix().'.title.category'.$this->category->categoryID;
- if (I18nHandler::getInstance()->isPlainValue('title')) {
- I18nHandler::getInstance()->remove($this->title, $this->packageID);
- $this->title = I18nHandler::getInstance()->getValue('title');
- }
- else {
- I18nHandler::getInstance()->save('title', $this->title, $this->objectType->getProcessor()->getTitleLangVarCategory(), $this->packageID);
- }
-
- // update category
- $this->objectAction = new CategoryAction(array($this->category), 'update', array(
- 'data' => array(
- 'additionalData' => serialize($this->additionalData),
- 'description' => $this->description,
- 'isDisabled' => $this->isDisabled,
- 'parentCategoryID' => $this->parentCategoryID,
- 'showOrder' => $this->showOrder,
- 'title' => $this->title
- )
- ));
- $this->objectAction->executeAction();
-
- // update acl
- if ($this->aclObjectTypeID) {
- ACLHandler::getInstance()->save($this->category->categoryID, $this->aclObjectTypeID);
- }
-
- // reload cache
- CategoryHandler::getInstance()->reloadCache();
-
- $this->saved();
-
- // show success message
- WCF::getTPL()->assign('success', true);
- }
-
- /**
- * @see wcf\acp\form\AbstractCategoryAddForm::validateParentCategory()
- */
- protected function validateParentCategory() {
- parent::validateParentCategory();
-
- // check if new parent category is no child category of the category
- $childCategories = CategoryHandler::getInstance()->getChildCategories($this->category);
- if (isset($childCategories[$this->parentCategoryID])) {
- throw new UserInputException('parentCategoryID', 'invalid');
- }
- }
-}
+++ /dev/null
-<?php
-namespace wcf\acp\page;
-use wcf\data\category\CategoryNodeList;
-use wcf\page\AbstractPage;
-use wcf\system\category\CategoryHandler;
-use wcf\system\exception\PermissionDeniedException;
-use wcf\system\exception\SystemException;
-use wcf\system\menu\acp\ACPMenu;
-use wcf\system\user\collapsible\content\UserCollapsibleContentHandler;
-use wcf\system\WCF;
-use wcf\util\StringUtil;
-
-/**
- * Abstract implementation of a page with lists all categories of a certain object
- * type.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2012 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage acp.page
- * @category Community Framework
- */
-abstract class AbstractCategoryListPage extends AbstractPage {
- /**
- * active acp menu item
- * @var string
- */
- public $activeMenuItem = '';
-
- /**
- * name of the controller used to add new categories
- * @var string
- */
- public $addController = '';
-
- /**
- * category node list
- * @var wcf\data\category\CategoryNodeList
- */
- public $categoryNodeList = null;
-
- /**
- * ids of collapsed categories
- * @var array<integer>
- */
- public $collapsedCategoryIDs = null;
-
- /**
- * id of the collapsible category object type
- * @var integer
- */
- public $collapsibleObjectTypeID = 0;
-
- /**
- * name of the controller used to edit categories
- * @var string
- */
- public $editController = '';
-
- /**
- * category object type object
- * @var wcf\data\object\type\ObjectType
- */
- public $objectType = null;
-
- /**
- * name of the category object type
- * @var string
- */
- public $objectTypeName = '';
-
- /**
- * @see wcf\page\AbstractPage::$templateName
- */
- public $templateName = 'categoryList';
-
- /**
- * @see wcf\page\AbstractPage::__run()
- */
- public function __run() {
- $classNameParts = explode('\\', get_called_class());
- $className = array_pop($classNameParts);
-
- // autoset controllers
- if (empty($this->addController)) {
- $this->addController = StringUtil::replace('ListPage', 'Add', $className);
- }
- if (empty($this->editController)) {
- $this->editController = StringUtil::replace('ListPage', 'Edit', $className);
- }
-
- parent::__run();
- }
-
- /**
- * @see wcf\page\IPage::assignVariables()
- */
- public function assignVariables() {
- parent::assignVariables();
-
- WCF::getTPL()->assign(array(
- 'addController' => $this->addController,
- 'categoryNodeList' => $this->categoryNodeList,
- 'collapsedCategoryIDs' => $this->collapsedCategoryIDs,
- 'collapsibleObjectTypeID' => $this->collapsibleObjectTypeID,
- 'editController' => $this->editController,
- 'objectType' => $this->objectType
- ));
- }
-
- /**
- * Checks if the active user has the needed permissions to view this list.
- */
- protected function checkCategoryPermissions() {
- if (!$this->objectType->getProcessor()->canDeleteCategory() && !$this->objectType->getProcessor()->canEditCategory()) {
- throw new PermissionDeniedException();
- }
- }
-
- /**
- * Reads the categories.
- */
- protected function readCategories() {
- $this->categoryNodeList = new CategoryNodeList($this->objectType->objectTypeID, 0, true);
- }
-
- /**
- * @see wcf\page\IPage::readData()
- */
- public function readData() {
- $this->objectType = CategoryHandler::getInstance()->getObjectTypeByName($this->objectTypeName);
- if ($this->objectType === null) {
- throw new SystemException("Unknown category object type with name '".$this->objectTypeName."'");
- }
-
- // check permissions
- $this->checkCategoryPermissions();
-
- $this->readCategories();
-
- // get ids of collapsed category
- $this->collapsibleObjectTypeID = UserCollapsibleContentHandler::getInstance()->getObjectTypeID($this->objectType->getProcessor()->getCollapsibleObjectTypeName());
- if ($this->collapsibleObjectTypeID !== null) {
- $this->collapsedCategoryIDs = UserCollapsibleContentHandler::getInstance()->getCollapsedContent($this->collapsibleObjectTypeID);
- $this->collapsedCategoryIDs = array_flip($this->collapsedCategoryIDs);
- }
-
- parent::readData();
- }
-
- /**
- * @see wcf\page\IPage::show()
- */
- public function show() {
- if ($this->activeMenuItem) {
- ACPMenu::getInstance()->setActiveMenuItem($this->activeMenuItem);
- }
-
- parent::show();
- }
-}
* @see wcf\system\request\IRouteController::getID()
*/
public function getID() {
- return $this->objectTypeCategoryID;
+ return $this->categoryID;
}
/**
*/
public function getParentCategory() {
if ($this->parentCategoryID && $this->parentCategory === null) {
- $this->parentCategory = CategoryHandler::getInstance()->getCategory($this->objectTypeID, $this->parentCategoryID);
+ $this->parentCategory = CategoryHandler::getInstance()->getCategory($this->parentCategoryID);
}
return $this->parentCategory;
}
/**
- * @see wcf\system\request\IRouteController::getTitle()
+ * @see wcf\data\ITitledDatabaseObject::getTitle()
*/
public function getTitle() {
return WCF::getLanguage()->get($this->title);
foreach ($categoryIDs as $categoryID) {
$this->objects[$categoryID]->update(array(
- 'parentCategoryID' => $parentCategoryID ? $this->objects[$parentCategoryID]->objectTypeCategoryID : 0,
+ 'parentCategoryID' => $parentCategoryID ? $this->objects[$parentCategoryID]->categoryID : 0,
'showOrder' => $showOrders[$parentCategoryID]++
));
}
}
foreach ($this->objects as $categoryEditor) {
- if (!$categoryEditor->getCategoryType()->canAddCategory()) {
+ if (!$categoryEditor->getCategoryType()->canDeleteCategory()) {
throw new ValidateActionException('Insufficient permissions');
}
}
foreach ($this->parameters['data']['structure'] as $parentCategoryID => $categoryIDs) {
if ($parentCategoryID) {
// validate category
- $category = CategoryHandler::getInstance()->getCategoryByID($parentCategoryID);
+ $category = CategoryHandler::getInstance()->getCategory($parentCategoryID);
if ($category === null) {
throw new ValidateActionException("Unknown category with id '".$parentCategoryID."'");
}
foreach ($categoryIDs as $categoryID) {
// validate category
- $category = CategoryHandler::getInstance()->getCategoryByID($categoryID);
+ $category = CategoryHandler::getInstance()->getCategory($categoryID);
if ($category === null) {
throw new ValidateActionException("Unknown category with id '".$categoryID."'");
}
<?php
namespace wcf\data\category;
-use wcf\data\object\type\ObjectTypeEditor;
use wcf\data\DatabaseObjectEditor;
use wcf\data\IEditableCachedObject;
use wcf\system\cache\CacheHandler;
use wcf\system\category\CategoryHandler;
-use wcf\system\exception\SystemException;
use wcf\system\WCF;
/**
*/
protected function updateShowOrder($parentCategoryID, $showOrder) {
// correct invalid values
- if ($showOrder <= 0) {
- $showOrder = 1;
+ if ($showOrder === null) {
+ $showOrder = PHP_INT_MAX;
}
if ($parentCategoryID != $this->parentCategoryID) {
// handle show order
$parameters['showOrder'] = static::getShowOrder($parameters['objectTypeID'], $parameters['parentCategoryID'], $parameters['showOrder']);
- $parameters['objectTypeCategoryID'] = static::getNextCategoryID($parameters['objectTypeID']);
// handle additionalData
if (!isset($parameters['additionalData'])) {
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($objectIDs as $categoryID) {
- $category = CategoryHandler::getInstance()->getCategoryByID($categoryID);
+ $category = CategoryHandler::getInstance()->getCategory($categoryID);
$statement->execute(array($category->parentCategoryID, $category->showOrder));
}
return parent::deleteAll($objectIDs);
}
- /**
- * Returns the next category id for the given object type id.
- *
- * @param integer $objectTypeID
- * @return integer
- */
- protected static function getNextCategoryID($objectTypeID) {
- $objectType = CategoryHandler::getInstance()->getObjectType($objectTypeID);
- if ($objectType === null) {
- throw new SystemException("Invalid category object type id '".$objectTypeID."'");
- }
-
- $nextCategoryID = 1;
- if ($objectType->nextCategoryID !== null) {
- $nextCategoryID = $objectType->nextCategoryID;
- }
-
- // update next category additional data
- $objectTypeEditor = new ObjectTypeEditor($objectType);
- $objectTypeEditor->update(array(
- 'additionalData' => serialize(array_merge($objectType->additionalData, array(
- 'nextCategoryID' => $nextCategoryID + 1
- )))
- ));
-
- // reset object type cache
- CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.objectType-*.php');
-
- return $nextCategoryID;
- }
-
/**
* Returns the show order for a new category.
*
*/
protected static function getShowOrder($objectTypeID, $parentCategoryID, $showOrder) {
// correct invalid values
- if ($showOrder <= 0) {
- $showOrder = 1;
+ if ($showOrder === null) {
+ $showOrder = PHP_INT_MAX;
}
$sql = "SELECT MAX(showOrder) AS showOrder
* list of object type category ids of excluded categories
* @var array<integer>
*/
- protected $excludedObjectTypeCategoryIDs = false;
+ protected $excludedCategoryIDs = false;
/**
* @see wcf\data\DatabaseObjectDecorator::$baseClass
/**
* @see wcf\data\DatabaseObjectDecorator::__construct()
*/
- public function __construct(DatabaseObject $object, $inludeDisabledCategories = false, array $excludedObjectTypeCategoryIDs = array()) {
+ public function __construct(DatabaseObject $object, $inludeDisabledCategories = false, array $excludedCategoryIDs = array()) {
parent::__construct($object);
$this->inludeDisabledCategories = $inludeDisabledCategories;
- $this->excludedObjectTypeCategoryIDs = $excludedObjectTypeCategoryIDs;
+ $this->excludedCategoryIDs = $excludedCategoryIDs;
$className = get_called_class();
foreach (CategoryHandler::getInstance()->getChildCategories($this->getDecoratedObject()) as $category) {
if ($this->fulfillsConditions($category)) {
- $this->childCategories[] = new $className($category, $inludeDisabledCategories, $excludedObjectTypeCategoryIDs);
+ $this->childCategories[] = new $className($category, $inludeDisabledCategories, $excludedCategoryIDs);
}
}
}
* @return boolean
*/
public function fulfillsConditions(Category $category) {
- return !in_array($category->objectTypeCategoryID, $this->excludedObjectTypeCategoryIDs) && ($this->includeDisabledCategories || !$category->isDisabled);
+ return !in_array($category->categoryID, $this->excludedCategoryIDs) && ($this->includeDisabledCategories || !$category->isDisabled);
}
/**
/**
* Creates a new CategoryNodeList instance.
*
- * @param integer $objectTypeID
+ * @param string $objectType
* @param integer $parentCategoryID
* @param boolean $inludeDisabledCategories
* @param array<integer> $excludedCategoryIDs
*/
- public function __construct($objectTypeID, $parentCategoryID = 0, $inludeDisabledCategories = false, array $excludedObjectTypeCategoryIDs = array()) {
+ public function __construct($objectType, $parentCategoryID = 0, $inludeDisabledCategories = false, array $excludedCategoryIDs = array()) {
$this->parentCategoryID = $parentCategoryID;
// get parent category
if (!$this->parentCategoryID) {
// empty node
$parentCategory = new Category(null, array(
- 'categoryID' => $this->parentCategoryID,
- 'objectTypeID' => $objectTypeID,
- 'objectTypeCategoryID' => $this->parentCategoryID
+ 'categoryID' => 0,
+ 'objectTypeID' => CategoryHandler::getInstance()->getObjectTypeByName($objectType)->objectTypeID
));
}
else {
- $parentCategory = CategoryHandler::getInstance()->getCategory($objectTypeID, $this->parentCategoryID);
+ $parentCategory = CategoryHandler::getInstance()->getCategory($this->parentCategoryID);
if ($parentCategory === null) {
- throw new SystemException("There is no category with id '".$this->parentCategoryID."' and object type id '".$objectTypeID."'");
+ throw new SystemException("There is no category with id '".$this->parentCategoryID."'");
}
}
- parent::__construct(new $this->nodeClassName($parentCategory, $inludeDisabledCategories, $excludedObjectTypeCategoryIDs), \RecursiveIteratorIterator::SELF_FIRST);
+ parent::__construct(new $this->nodeClassName($parentCategory, $inludeDisabledCategories, $excludedCategoryIDs), \RecursiveIteratorIterator::SELF_FIRST);
}
/**
<?php
namespace wcf\system\cache\builder;
use wcf\data\category\CategoryList;
+use wcf\system\package\PackageDependencyHandler;
/**
* Caches the categories for a certain package.
* @see wcf\system\cache\ICacheBuilder::getData()
*/
public function getData(array $cacheResource) {
- list(, $packageID) = explode('-', $cacheResource['cache']);
-
$list = new CategoryList();
$list->sqlLimit = 0;
+ $list->sqlSelects = "object_type.objectType";
$list->sqlJoins = " LEFT JOIN wcf".WCF_N."_object_type object_type
- ON (object_type.objectTypeID = category.objectTypeID)
- LEFT JOIN wcf".WCF_N."_package_dependency package_dependency
- ON (package_dependency.dependency = object_type.packageID)";
- $list->getConditionBuilder()->add("package_dependency.packageID = ?", array($packageID));
- $list->sqlOrderBy = "package_dependency.priority ASC, category.showOrder ASC";
+ ON (object_type.objectTypeID = category.objectTypeID)";
+ $list->getConditionBuilder()->add("object_type.packageID IN (?)", array(PackageDependencyHandler::getInstance()->getDependencies()));
+ $list->sqlOrderBy = "category.showOrder ASC";
$list->readObjects();
$data = array(
- 'categories' => array(),
- 'categoryIDs' => array()
+ 'categories' => $list->getObjects(),
+ 'objectTypeCategoryIDs' => array()
);
foreach ($list as $category) {
- if (!isset($data['categories'][$category->objectTypeID])) {
- $data['categories'][$category->objectTypeID] = array();
+ if (!isset($data['objectTypeCategoryIDs'][$category->objectType])) {
+ $data['objectTypeCategoryIDs'][$category->objectType] = array();
}
- $data['categories'][$category->objectTypeID][$category->objectTypeCategoryID] = $category;
- $data['categoryIDs'][$category->categoryID] = array(
- 'objectTypeID' => $category->objectTypeID,
- 'objectTypeCategoryID' => $category->objectTypeCategoryID
- );
+ $data['objectTypeCategoryIDs'][$category->objectType][] = $category->categoryID;
}
return $data;
*/
abstract class AbstractCategoryType extends SingletonFactory implements ICategoryType {
/**
- * name of the acl object type
- * @var string
+ * indicates if categories of this type may have no empty description
+ * @var boolean
*/
- protected $aclObjectTypeName = '';
+ protected $forceDescription = true;
/**
- * name of the collapsible object type
- * @var string
+ * indicates if categories of this type have descriptions
+ * @var boolean
*/
- protected $collapsibleObjectTypeName = '';
+ protected $hasDescription = true;
/**
* language category which contains the language variables of i18n values
protected $permissionPrefix = '';
/**
- * indicates if the category type supports descriptions
- * @var boolean
+ * maximum category nesting lebel
+ * @var integer
+ */
+ protected $maximumNestingLevel = -1;
+
+ /**
+ * name of the object types associated with categories of this type (the
+ * key is the definition name and value the object type name)
+ * @var array<string>
*/
- protected $supportsDescriptions = true;
+ protected $objectTypes = array();
/**
* @see wcf\system\category\ICategoryType::afterDeletion()
}
/**
- * @see wcf\system\category\ICategoryType::getACLObjectTypeName()
+ * @see wcf\system\category\ICategoryType::forceDescription()
*/
- public function getACLObjectTypeName() {
- return $this->aclObjectTypeName ?: null;
+ public function forceDescription() {
+ return $this->hasDescription() && $this->forceDescription;
}
/**
- * @see wcf\system\category\ICategoryType::getCollapsibleObjectTypeName()
+ * @see wcf\system\category\ICategoryType::getObjectTypeName()
*/
- public function getCollapsibleObjectTypeName() {
- return $this->aclObjectTypeName ?: null;
+ public function getObjectTypeName($definitionName) {
+ if (isset($this->objectTypes[$definitionName])) {
+ return $this->objectTypes[$definitionName];
+ }
+
+ return null;
}
/**
return WCF::getLanguage()->get('wcf.category.'.$name, $optional);
}
+ /**
+ * @see wcf\system\category\ICategoryType::getMaximumNestingLevel()
+ */
+ public function getMaximumNestingLevel() {
+ return $this->maximumNestingLevel;
+ }
+
/**
* @see wcf\system\category\ICategoryType::getTitleLangVarCategory()
*/
}
/**
- * @see wcf\system\category\ICategoryType::supportsDescriptions()
+ * @see wcf\system\category\ICategoryType::hasDescription()
*/
- public function supportsDescriptions() {
- return $this->supportsDescriptions;
+ public function hasDescription() {
+ return $this->hasDescription;
}
}
protected $categories = array();
/**
- * maps each category id to its object type id and object type category id
+ * category ids grouped by the object type they belong to
* @var array<array>
*/
- protected $categoryIDs = array();
+ protected $objectTypeCategoryIDs = array();
/**
* mapes the names of the category object types to the object type ids
protected $objectTypes = array();
/**
- * Returns all category objects with the given object type id.
+ * Returns all category objects with the given object type. If no object
+ * type is given, all categories grouped by object type are returned.
*
- * @param integer $objectTypeID
- * @return array<wcf\data\category\Category>
+ * @param string $objectType
+ * @return array<mixed>
*/
- public function getCategories($objectTypeID) {
- if (isset($this->categories[$objectTypeID])) {
- return $this->categories[$objectTypeID];
+ public function getCategories($objectType = null) {
+ $categories = array();
+ if ($objectType === null) {
+ foreach ($this->objectTypes as $objectType) {
+ $categories[$objectType->objectType] = $this->getCategories($objectType->objectType);
+ }
}
-
- return array();
- }
-
- /**
- * Returns the category object with the given object type id and object
- * type category id.
- *
- * @param integer $objectTypeID
- * @param integer $objectTypeCategoryID
- * @return wcf\data\category\Category
- */
- public function getCategory($objectTypeID, $objectTypeCategoryID) {
- if (isset($this->categories[$objectTypeID][$objectTypeCategoryID])) {
- return $this->categories[$objectTypeID][$objectTypeCategoryID];
+ else if (isset($this->objectTypeCategoryIDs[$objectType])) {
+ foreach ($this->objectTypeCategoryIDs[$objectType] as $categoryID) {
+ $categories[$categoryID] = $this->getCategory($categoryID);
+ }
}
- return null;
+ return $categories;
}
/**
* @param integer $categoryID
* @return wcf\data\category\Category
*/
- public function getCategoryByID($categoryID) {
- if (isset($this->categoryIDs[$categoryID])) {
- return $this->getCategory($this->categoryIDs[$categoryID]['objectTypeID'], $this->categoryIDs[$categoryID]['objectTypeCategoryID']);
+ public function getCategory($categoryID) {
+ if (isset($this->categories[$categoryID])) {
+ return $this->categories[$categoryID];
}
return null;
public function getChildCategories(Category $category) {
$categories = array();
- if (isset($this->categories[$category->objectTypeID])) {
- foreach ($this->categories[$category->objectTypeID] as $__category) {
- if ($__category->parentCategoryID == $category->objectTypeCategoryID) {
- $categories[$__category->objectTypeCategoryID] = $__category;
- }
+ foreach ($this->categories as $__category) {
+ if ($__category->parentCategoryID == $category->categoryID && ($category->categoryID || $category->objectTypeID == $__category->objectTypeID)) {
+ $categories[$__category->categoryID] = $__category;
}
}
/**
* Gets the object type with the given name.
*
- * @param string $objectTypeName
+ * @param string $objectType
* @return wcf\data\object\type\ObjectType
*/
- public function getObjectTypeByName($objectTypeName) {
- if (isset($this->objectTypes[$objectTypeName])) {
- return $this->objectTypes[$objectTypeName];
+ public function getObjectTypeByName($objectType) {
+ if (isset($this->objectTypes[$objectType])) {
+ return $this->objectTypes[$objectType];
}
return null;
}
+ /**
+ * Returns all category object types.
+ *
+ * @return array<wcf\data\object\type\ObjectType>
+ */
+ public function getObjectTypes() {
+ return $this->objectTypes;
+ }
+
/**
* @see wcf\system\SingletonFactory::init()
*/
'wcf\system\cache\builder\CategoryCacheBuilder'
);
$this->categories = CacheHandler::getInstance()->get($cacheName, 'categories');
- $this->categoryIDs = CacheHandler::getInstance()->get($cacheName, 'categoryIDs');
+ $this->objectTypeCategoryIDs = CacheHandler::getInstance()->get($cacheName, 'objectTypeCategoryIDs');
}
/**
public function canEditCategory();
/**
- * Returns the name of the acl object type for categories of this type.
- * Returns null if categories of this type don't support acl.
+ * Returns true if a category of this type may have no empty description.
*
- * @return string
+ * @return boolean
*/
- public function getACLObjectTypeName();
+ public function forceDescription();
/**
- * Returns the name of the collapsible object type for categories of this
- * type. Returns null if categories of this type don't support collapsing.
+ * Returns the name of the object type of the definition with the given
+ * name for categories of this type. If categories of this type are no
+ * object of the relevant type, null is returned.
*
+ * @param string $definitionName
* @return string
*/
- public function getCollapsibleObjectTypeName();
+ public function getObjectTypeName($definitionName);
/**
* Returns the language variable category for the description language
*/
public function getLanguageVariable($name, $optional = false);
+ /**
+ * Returns the maximum category nesting level for this type. "-1" means
+ * that there is no maximum.
+ *
+ * @return integer
+ */
+ public function getMaximumNestingLevel();
+
/**
* Returns the language variable category for the title language variables
* of categories of this type.
public function getTitleLangVarCategory();
/**
- * Returns true if categories of this type support descriptions.
+ * Returns true if categories of this type have descriptions.
*
* @return boolean
*/
- public function supportsDescriptions();
+ public function hasDescription();
}
CREATE TABLE wcf1_category (
categoryID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
objectTypeID INT(10) NOT NULL,
- objectTypeCategoryID INT(10) NOT NULL,
parentCategoryID INT(10) NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
showOrder INT(10) NOT NULL,
time INT(10) NOT NULL,
isDisabled TINYINT(1) NOT NULL DEFAULT 0,
- additionalData TEXT,
- UNIQUE KEY (objectTypeID, objectTypeCategoryID)
+ additionalData TEXT
);
DROP TABLE IF EXISTS wcf1_cleanup_listener;