/** * @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)); } }
/** * 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); }