Added category importer
authorMarcel Werk <burntime@woltlab.com>
Thu, 1 Aug 2013 22:58:37 +0000 (00:58 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 1 Aug 2013 22:58:37 +0000 (00:58 +0200)
wcfsetup/install/files/lib/system/importer/AbstractCategoryImporter.class.php [new file with mode: 0644]

diff --git a/wcfsetup/install/files/lib/system/importer/AbstractCategoryImporter.class.php b/wcfsetup/install/files/lib/system/importer/AbstractCategoryImporter.class.php
new file mode 100644 (file)
index 0000000..ed26c4f
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+namespace wcf\system\importer;
+use wcf\data\category\CategoryAction;
+
+/**
+ * Imports categories.
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2013 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.importer
+ * @category   Community Framework
+ */
+class AbstractCategoryImporter implements IImporter {
+       /**
+        * object type id for categories
+        * @var integer
+        */
+       protected $objectTypeID = 0;
+       
+       /**
+        * object type name
+        * @var integer
+        */
+       protected $objectTypeName = '';
+       
+       /**
+        * @see wcf\system\importer\IImporter::import()
+        */
+       public function import($oldID, array $data, array $additionalData = array()) {
+               if (!empty($data['parentCategoryID'])) $data['parentCategoryID'] = ImportHandler::getInstance()->getNewID($this->objectTypeName, $data['parentCategoryID']);
+               
+               $action = new CategoryAction(array(), 'create', array(
+                       'data' => array_merge($data, array('objectTypeID' => $this->objectTypeID))              
+               ));
+               $returnValues = $action->executeAction();
+               $newID = $returnValues['returnValues']->categoryID;
+               
+               ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $newID);
+               
+               return $newID;
+       }
+}