/**
  * @see	wcf\system\category\ICategoryType::afterDeletion()
  */
 public function afterDeletion(CategoryEditor $categoryEditor)
 {
     // move child categories to parent category
     foreach (CategoryHandler::getInstance()->getChildCategories($categoryEditor->getDecoratedObject()) as $category) {
         $__categoryEditor = new CategoryEditor($category);
         $__categoryEditor->update(array('parentCategoryID' => $categoryEditor->parentCategoryID));
     }
 }
	/**
	 * @see	wcf\system\category\ICategoryType::afterDeletion()
	 */
	public function afterDeletion(CategoryEditor $categoryEditor) {
		$categoryIDs = array_keys(CategoryHandler::getInstance()->getChildCategories($categoryEditor->getDecoratedObject()));
		
		if (!empty($categoryIDs)) {
			// move child categories to parent category
			$conditionBuilder = new PreparedStatementConditionBuilder();
			$conditionBuilder->add("categoryID IN (?)", array($categoryIDs));
			$sql = "UPDATE	wcf".WCF_N."_category
				SET	parentCategoryID = ?
				".$conditionBuilder;
			$statement = WCF::getDB()->prepareStatement($sql);
			$statement->execute(array_merge(array($categoryEditor->parentCategoryID), $conditionBuilder->getParameters()));
		}
	}
 /**
  * @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']);
     }
     $category = CategoryEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
     ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $category->categoryID);
     return $category->categoryID;
 }
<?php

use wcf\data\category\CategoryEditor;
use wcf\data\object\type\ObjectTypeCache;
use wcf\system\WCF;
/**
 * @author	Jens Krumsieck
 * @copyright	2013 - 2015 codeQuake
 * @license	GNU Lesser General Public License <http://www.gnu.org/licenses/lgpl-3.0.txt>
 * @package	de.codequake.cms
 */
$sql = "UPDATE\twcf" . WCF_N . "_option\n\tSET\toptionValue = ?\n\tWHERE\toptionName = ?";
$optionUpdate = WCF::getDB()->prepareStatement($sql);
// install date
$optionUpdate->execute(array(TIME_NOW, 'cms_install_date'));
// set default page title
if (!defined('PAGE_TITLE') || !PAGE_TITLE) {
    $optionUpdate->execute(array('Fireball CMS 2.0', 'page_title'));
}
// create default file category
CategoryEditor::create(array('objectTypeID' => ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.category', 'de.codequake.cms.file'), 'title' => 'Default Category', 'time' => TIME_NOW));
<?php

use wcf\data\category\CategoryEditor;
use wcf\data\object\type\ObjectTypeCache;
use wcf\system\dashboard\DashboardHandler;
use wcf\system\WCF;
/**
 * @author Alexander Merz
 * @copyright 2014 Incendium Community
 * @license    GNU Lesser General Public License <http://www.gnu.org/licenses/lgpl-3.0.txt>
 */
// set default values for dashboard boxes
DashboardHandler::setDefaultValues('com.woltlab.filebase.NewsOverviewPage', array('de.incendium.cms.news.tagCloud' => 1, 'de.incendium.cms.news.latestNews' => 2, 'de.incendium.cms.news.mostLikedNews' => 3, 'de.incendium.cms.news.featuredNews' => 4));
// add default category
CategoryEditor::create(array('objectTypeID' => ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.category', 'de.incendium.cms.news.category'), 'title' => 'Default Category', 'description' => 'This is a Default Category', 'time' => TIME_NOW));
 /**
  * Updates the i18n data of the category with the given id.
  *
  * @param	integer		$categoryID
  * @param	array		$category
  */
 private function updateCategoryI18nData($categoryID, array $category)
 {
     // get title
     if (preg_match('~wcf.category.category.title.category\\d+~', $category['title'])) {
         $titleValues = $this->getLanguageItemValues($category['title']);
         $title = $this->importLanguageVariable('wcf.category', 'wcf.category.category.title.category' . $categoryID, $titleValues);
         if ($title === false) {
             $title = 'Imported Category ' . $categoryID;
         }
     }
     // get description
     if (preg_match('~wcf.category.category.title.category\\d+.description~', $category['description'])) {
         $descriptionValues = $this->getLanguageItemValues($category['description']);
         $description = $this->importLanguageVariable('wcf.category', 'wcf.category.category.description.category' . $categoryID, $descriptionValues);
         if ($description === false) {
             $description = '';
         }
     }
     // update category
     $updateData = array();
     if (!empty($title)) {
         $updateData['title'] = $title;
     }
     if (!empty($description)) {
         $updateData['description'] = $description;
     }
     if (count($updateData)) {
         $importedCategory = new Category(null, array('categoryID' => $categoryID));
         $editor = new CategoryEditor($importedCategory);
         $editor->update($updateData);
     }
 }
	/**
	 * @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 > 0 ? $this->showOrder : null,
				'title' => $this->title
			)
		));
		$this->objectAction->executeAction();
		$returnValues = $this->objectAction->getReturnValues();
		
		if (($this->objectType->getProcessor()->hasDescription() && !I18nHandler::getInstance()->isPlainValue('description')) || !I18nHandler::getInstance()->isPlainValue('title')) {
			$categoryID = $returnValues['returnValues']->categoryID;
			
			$updateData = array();
			if ($this->objectType->getProcessor()->hasDescription() && !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);
			ACLHandler::getInstance()->disableAssignVariables();
			CategoryPermissionHandler::getInstance()->resetCache();
		}
		
		// reload cache
		CategoryHandler::getInstance()->reloadCache();
		$this->readCategories();
		
		// 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);
	}