2 namespace wcf\acp\form
;
3 use wcf\system\exception\UserInputException
;
4 use wcf\system\request\LinkHandler
;
6 use wcf\util\StringUtil
;
9 * Shows the article category add form.
12 * @copyright 2001-2019 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package WoltLabSuite\Core\Acp\Form
17 class ArticleCategoryAddForm
extends AbstractCategoryAddForm
{
21 public $activeMenuItem = 'wcf.acp.menu.link.article.category.add';
26 public $objectTypeName = 'com.woltlab.wcf.article.category';
31 public $neededModules = ['MODULE_ARTICLE'];
37 public $availableSortFields = [
46 public $sortField = 'publicationDate';
52 public $sortOrder = 'DESC';
57 public function readParameters() {
58 parent
::readParameters();
60 if (isset($_POST['sortField'])) $this->sortField
= StringUtil
::trim($_POST['sortField']);
61 if (isset($_POST['sortOrder'])) $this->sortOrder
= StringUtil
::trim($_POST['sortOrder']);
67 public function validate() {
70 if (!in_array($this->sortField
, $this->availableSortFields
)) {
71 throw new UserInputException('sortField');
74 if ($this->sortOrder
!== 'ASC' && $this->sortOrder
!== 'DESC') {
75 throw new UserInputException('sortOrder');
82 public function save() {
83 $this->additionalData
['sortField'] = $this->sortField
;
84 $this->additionalData
['sortOrder'] = $this->sortOrder
;
88 WCF
::getTPL()->assign([
89 'objectEditLink' => LinkHandler
::getInstance()->getControllerLink(ArticleCategoryEditForm
::class, ['id' => $this->objectAction
->getReturnValues()['returnValues']->categoryID
]),
92 $this->sortField
= 'publicationDate';
93 $this->sortOrder
= 'DESC';
99 public function assignVariables() {
100 parent
::assignVariables();
102 WCF
::getTPL()->assign([
103 'availableSortFields' => $this->availableSortFields
,
104 'sortField' => $this->sortField
,
105 'sortOrder' => $this->sortOrder