$item->setAttribute('moduleCodename', $codename); $item->setProtected($protected); if (!$parentId) { $parentCategory = $item->getParent(); } else { // Parent category $parentCategory = CMS_moduleCategories_catalog::getById($parentId); } $parentCategory->setAttribute('language', $cms_language); //check mandatory fields if (!$defaultLabel) { $cms_message .= $cms_language->getMessage(MESSAGE_FORM_ERROR_MANDATORY_FIELDS); break; } else { // If insertion, must be saved once added to its parent $newParentCategory = CMS_moduleCategories_catalog::getById($parentId); if (!$newParentCategory->hasError()) { // Detach from current category $oldParentCategory = $item->getParent(); if ($item->getID()) { if ($oldParentCategory->getID() != $newParentCategory->getID()) { if (!CMS_moduleCategories_catalog::detachCategory($item)) { $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_ACTION_SAVE_ERROR); } // Attach to new category if (!CMS_moduleCategories_catalog::attachCategory($item, $newParentCategory)) { $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_ACTION_SAVE_ERROR); } } } else { // Attach to new category
/** * Get root category to this one * * @access public * @return CMS_moduleCategory */ function getRoot() { if ($this->isRoot()) { return null; } else { return CMS_moduleCategories_catalog::getById($this->_rootID); } }
unset($all_languages[$cms_language->getCode()]); array_unshift($all_languages, $userlanguage); } // Current category object to manipulate if ($catId) { $item = new CMS_moduleCategory($catId); $item->setAttribute('language', $cms_language); $item->setAttribute('moduleCodename', $codename); $parentCategory = $item->getParent(); } else { // Parent category $item = new CMS_moduleCategory(); $item->setAttribute('language', $cms_language); $item->setAttribute('moduleCodename', $codename); if ($fatherId) { $parentCategory = CMS_moduleCategories_catalog::getById($fatherId); $parentCategory->setAttribute('language', $cms_language); } } if (!function_exists("build_category_tree_options")) { /** * Recursive function to build the categories tree. * * @param CMS_moduleCategory $category * @param integer $count, to determine category in-tree depth * @return string HTML formated */ function build_category_tree_options($category, $count) { global $codename, $cms_language, $parentCategory, $cms_module, $cms_user, $catId; //if category is not itself (to avoid infinite loop in lineage)