Adds better support for additional category data
authorMatthias Schmidt <gravatronics@live.com>
Mon, 21 May 2012 11:13:55 +0000 (13:13 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 21 May 2012 11:13:55 +0000 (13:13 +0200)
wcfsetup/install/files/lib/acp/form/AbstractCategoryAddForm.class.php
wcfsetup/install/files/lib/acp/form/AbstractCategoryEditForm.class.php
wcfsetup/install/files/lib/data/category/CategoryEditor.class.php

index d35768ea51f60e9f20590ef7d2a0b06e164d2039..b68bdf51774d6a037220cf203b31a10f8514d4b1 100644 (file)
@@ -10,6 +10,7 @@ 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;
 
 /**
@@ -35,6 +36,12 @@ abstract class AbstractCategoryAddForm extends ACPForm {
         */
        public $addController = '';
        
+       /**
+        * additional category data
+        * @var array
+        */
+       public $additionalData = array();
+       
        /**
         * list with the category nodes
         * @var wcf\data\category\CategoryNodeList
@@ -202,6 +209,9 @@ abstract class AbstractCategoryAddForm extends ACPForm {
                
                I18nHandler::getInstance()->readValues();
                
+               if (isset($_POST['additionalData'])) {
+                       $this->additionalData = ArrayUtil::trim($_POST['additionalData']);
+               }
                if (isset($_POST['description'])) {
                        $this->description = StringUtil::trim($_POST['description']);
                }
@@ -237,6 +247,7 @@ abstract class AbstractCategoryAddForm extends ACPForm {
                
                $this->objectAction = new CategoryAction(array(), 'create', array(
                        'data' => array(
+                               'additionalData' => serialize($this->additionalData),
                                'description' => $this->description,
                                'isDisabled' => $this->isDisabled,
                                'objectTypeID' => $this->objectType->objectTypeID,
index 6dcad76e2bd38040b01342381647a4329898da16..740114b182342918aae4c06f1b70616eb048fe35 100644 (file)
@@ -89,6 +89,7 @@ class AbstractCategoryEditForm extends AbstractCategoryAddForm {
                        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;
@@ -124,6 +125,7 @@ class AbstractCategoryEditForm extends AbstractCategoryAddForm {
                // 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,
index 47de399d6d3d68a71a7fc7f97b67f3cec5915d86..3a05137cf276cf55427d2ac119745f9a0cbcfabc 100644 (file)
@@ -139,9 +139,8 @@ class CategoryEditor extends DatabaseObjectEditor implements IEditableCachedObje
                
                // handle additionalData
                if (!isset($parameters['additionalData'])) {
-                       $parameters['additionalData'] = array();
+                       $parameters['additionalData'] = serialize(array());
                }
-               $parameters['additionalData'] = serialize($parameters['additionalData']);
                
                return parent::create($parameters);
        }