コード例 #1
0
             if (!$item->writeToPersistence()) {
                 $cms_message = $cms_language->getMessage(MESSAGE_PAGE_ACTION_SAVE_ERROR);
             } else {
                 $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
                 $content = array('success' => true, 'id' => $item->getID());
             }
         }
     } else {
         $cms_message = $cms_language->getMessage(MESSAGE_PAGE_ACTION_ERROR_PROTECTED);
         $item->raiseError('Error during modification of category ' . $item->getID() . '. Category is protected.');
     }
     break;
 case 'delete':
     $category = new CMS_moduleCategory($categoryId);
     if (!$category->isProtected()) {
         $father = new CMS_moduleCategory($category->getAttribute('parentID'));
         if (CMS_moduleCategories_catalog::detachCategory($category)) {
             $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
             $content = array('success' => true);
         } else {
             $cms_message = $cms_language->getMessage(MESSAGE_PAGE_ACTION_DELETE_ERROR);
         }
     } else {
         $cms_message = $cms_language->getMessage(MESSAGE_PAGE_ACTION_ERROR_PROTECTED);
         $category->raiseError('Error during modification of category ' . $category->getID() . '. Category is protected.');
     }
     break;
 case 'move':
     $category = new CMS_moduleCategory($categoryId);
     if (!$category->isProtected()) {
         $newParent = new CMS_moduleCategory($newParentId);
コード例 #2
0
 /**
  * Moves position of a category in list at given index
  * 
  * @access public
  * @param CMS_moduleCategory $category 
  * @param integer $index values (start to 1)
  * @return boolean true on succes, false on failure
  */
 static function moveCategoryIndex($category, $index)
 {
     // Checks : pages must be CMS_moduleCategory and offset in (1, -1)
     if (!$category instanceof CMS_moduleCategory) {
         CMS_grandFather::raiseError("Category to move not valid.");
         return false;
     }
     if (!SensitiveIO::isPositiveInteger($index)) {
         CMS_grandFather::raiseError("Index must be a positive integer : " . $index);
         return false;
     }
     //if index is the same than current coregory index, do nothing
     if ($category->getAttribute('order') == $index) {
         return true;
     }
     // Find the siblings to switch order
     $parent = $category->getParent();
     // Use this function to compact of siblings order
     if (!$parent instanceof CMS_moduleCategory || !CMS_moduleCategories_catalog::compactSiblingsOrder($parent)) {
         CMS_grandFather::raiseError("Reordering siblings failed for category " . $parent->getID());
         return false;
     }
     if ($category->getAttribute('order') < $index) {
         //move sibling order
         $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tmodulesCategories\n\t\t\t\tset\n\t\t\t\t\torder_mca = order_mca - 1\n\t\t\t\twhere\n\t\t\t\t\torder_mca > '" . $category->getAttribute('order') . "'\n\t\t\t\t\tand order_mca <= '" . $index . "'\n\t\t\t\t\tand parent_mca = '" . $parent->getID() . "'\n\t\t\t";
         $q = new CMS_query($sql);
     } else {
         //move sibling order
         $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tmodulesCategories\n\t\t\t\tset\n\t\t\t\t\torder_mca = order_mca + 1\n\t\t\t\twhere\n\t\t\t\t\torder_mca < '" . $category->getAttribute('order') . "'\n\t\t\t\t\tand order_mca >= '" . $index . "'\n\t\t\t\t\tand parent_mca = '" . $parent->getID() . "'\n\t\t\t";
         $q = new CMS_query($sql);
     }
     //move category index
     $sql = "\n\t\t\tupdate\n\t\t\t\tmodulesCategories\n\t\t\tset\n\t\t\t\torder_mca = " . $index . "\n\t\t\twhere\n\t\t\t\tid_mca='" . $category->getID() . "'\n\t\t";
     $q = new CMS_query($sql);
     //Clear polymod cache
     //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $category->getAttribute('moduleCodename')));
     CMS_cache::clearTypeCache('polymod');
     return true;
 }
コード例 #3
0
                foreach ($siblings as $aSibling) {
                    $aSibling->setAttribute('language', $cms_language);
                    $a = array_merge($a, build_category_tree_options($aSibling, $count));
                }
            }
        }
        return $a;
    }
}
$items = array();
if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
    // Select parent category
    $attrs = array("module" => $codename, "language" => $cms_language, "level" => 0, "root" => -1, "cms_user" => $cms_user, "clearanceLevel" => CLEARANCE_MODULE_MANAGE, "strict" => true);
    $root_categories = CMS_module::getModuleCategories($attrs);
} else {
    $parentID = $item->getAttribute('parentID');
    if (sensitiveIO::isPositiveInteger($parentID) && $cms_user->hasModuleCategoryClearance($parentID, CLEARANCE_MODULE_MANAGE, $codename) || !$catId) {
        $root_categories = $cms_user->getRootModuleCategoriesManagable($codename, true);
    }
}
$selectContent = array();
if (is_array($root_categories) && sizeof($root_categories) > 0) {
    foreach ($root_categories as $aRoot) {
        // Show all sub categories
        $selectContent = array_merge($selectContent, build_category_tree_options($aRoot, 0));
    }
}
if ($selectContent) {
    $items[] = array('xtype' => 'atmCombo', 'fieldLabel' => $cms_language->getMessage(MESSAGE_PAGE_FIELD_PARENT_CATEGORY), 'name' => 'parentId', 'hiddenName' => 'parentId', 'forceSelection' => true, 'mode' => 'local', 'valueField' => 'id', 'displayField' => 'name', 'triggerAction' => 'all', 'allowBlank' => true, 'selectOnFocus' => true, 'editable' => false, 'value' => isset($parentCategory) ? $parentCategory->getId() : '', 'store' => array('xtype' => 'arraystore', 'fields' => array('id', 'name'), 'data' => $selectContent));
}
// Build label list of all languages avalaibles