当前位置: 首页>>代码示例>>PHP>>正文


PHP CMSCategory::cleanPositions方法代码示例

本文整理汇总了PHP中CMSCategory::cleanPositions方法的典型用法代码示例。如果您正苦于以下问题:PHP CMSCategory::cleanPositions方法的具体用法?PHP CMSCategory::cleanPositions怎么用?PHP CMSCategory::cleanPositions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMSCategory的用法示例。


在下文中一共展示了CMSCategory::cleanPositions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 public function postProcess($token = NULL)
 {
     global $cookie, $currentIndex;
     $this->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
     if (Tools::isSubmit('submitAdd' . $this->table)) {
         if ($id_cms_category = (int) Tools::getValue('id_cms_category')) {
             if (!CMSCategory::checkBeforeMove($id_cms_category, (int) Tools::getValue('id_parent'))) {
                 $this->_errors[] = Tools::displayError('CMS Category cannot be moved here');
                 return false;
             }
         }
     } elseif (isset($_GET['statuscms_category']) and Tools::getValue($this->identifier)) {
         if ($this->tabAccess['edit'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject())) {
                 if ($object->toggleStatus()) {
                     Tools::redirectAdmin($currentIndex . '&conf=5' . ((int) $object->id_parent ? '&id_cms_category=' . (int) $object->id_parent : '') . '&token=' . Tools::getValue('token'));
                 } else {
                     $this->_errors[] = Tools::displayError('An error occurred while updating status.');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (isset($_GET['delete' . $this->table])) {
         if ($this->tabAccess['delete'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject()) and isset($this->fieldImageSettings)) {
                 // check if request at least one object with noZeroObject
                 if (isset($object->noZeroObject) and sizeof($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1) {
                     $this->_errors[] = Tools::displayError('You need at least one object.') . ' <b>' . $this->table . '</b><br />' . Tools::displayError('You cannot delete all of the items.');
                 } else {
                     $this->deleteImage($object->id);
                     if ($this->deleted) {
                         $object->deleted = 1;
                         if ($object->update()) {
                             Tools::redirectAdmin($currentIndex . '&conf=1&token=' . Tools::getValue('token'));
                         }
                     } elseif ($object->delete()) {
                         Tools::redirectAdmin($currentIndex . '&conf=1&token=' . Tools::getValue('token'));
                     }
                     $this->_errors[] = Tools::displayError('An error occurred during deletion.');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('An error occurred while deleting object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } elseif (isset($_GET['position'])) {
         if ($this->tabAccess['edit'] !== '1') {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         } elseif (!Validate::isLoadedObject($object = new CMSCategory((int) Tools::getValue($this->identifier, Tools::getValue('id_cms_category_to_move', 1))))) {
             $this->_errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
         } elseif (!$object->updatePosition((int) Tools::getValue('way'), (int) Tools::getValue('position'))) {
             $this->_errors[] = Tools::displayError('Failed to update the position.');
         } else {
             Tools::redirectAdmin($currentIndex . '&' . $this->table . 'Orderby=position&' . $this->table . 'Orderway=asc&conf=5' . (($id_category = (int) Tools::getValue($this->identifier, Tools::getValue('id_cms_category_parent', 1))) ? '&' . $this->identifier . '=' . $id_category : '') . '&token=' . Tools::getAdminTokenLite('AdminCMSContent'));
         }
     } elseif (Tools::getValue('submitDel' . $this->table)) {
         if ($this->tabAccess['delete'] === '1') {
             if (isset($_POST[$this->table . 'Box'])) {
                 $cms_category = new CMSCategory();
                 $result = true;
                 $result = $cms_category->deleteSelection(Tools::getValue($this->table . 'Box'));
                 if ($result) {
                     $cms_category->cleanPositions((int) Tools::getValue('id_cms_category'));
                     Tools::redirectAdmin($currentIndex . '&conf=2&token=' . Tools::getAdminTokenLite('AdminCMSContent') . '&id_category=' . (int) Tools::getValue('id_cms_category'));
                 }
                 $this->_errors[] = Tools::displayError('An error occurred while deleting selection.');
             } else {
                 $this->_errors[] = Tools::displayError('You must select at least one element to delete.');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     }
     parent::postProcess(true);
 }
开发者ID:greench,项目名称:prestashop,代码行数:79,代码来源:AdminCMSCategories.php

示例2: delete

    public function delete()
    {
        if ($this->id == 1) {
            return false;
        }
        $this->clearCache();
        // Get children categories
        $to_delete = array((int) $this->id);
        $this->recursiveDelete($to_delete, (int) $this->id);
        $to_delete = array_unique($to_delete);
        // Delete CMS Category and its child from database
        $list = count($to_delete) > 1 ? implode(',', $to_delete) : (int) $this->id;
        $id_shop_list = Shop::getContextListShopID();
        if (count($this->id_shop_list)) {
            $id_shop_list = $this->id_shop_list;
        }
        Db::getInstance()->delete($this->def['table'] . '_shop', '`' . $this->def['primary'] . '` IN (' . $list . ') AND id_shop IN (' . implode(', ', $id_shop_list) . ')');
        $has_multishop_entries = $this->hasMultishopEntries();
        if (!$has_multishop_entries) {
            Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'cms_category` WHERE `id_cms_category` IN (' . $list . ')');
            Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'cms_category_lang` WHERE `id_cms_category` IN (' . $list . ')');
        }
        CMSCategory::cleanPositions($this->id_parent);
        // Delete pages which are in categories to delete
        $result = Db::getInstance()->executeS('
		SELECT `id_cms`
		FROM `' . _DB_PREFIX_ . 'cms`
		WHERE `id_cms_category` IN (' . $list . ')');
        foreach ($result as $c) {
            $cms = new CMS((int) $c['id_cms']);
            if (Validate::isLoadedObject($cms)) {
                $cms->delete();
            }
        }
        return true;
    }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:36,代码来源:CMSCategory.php

示例3: delete

    public function delete()
    {
        if ($this->id == 1) {
            return false;
        }
        $this->clearCache();
        // Get children categories
        $to_delete = array((int) $this->id);
        $this->recursiveDelete($to_delete, (int) $this->id);
        $to_delete = array_unique($to_delete);
        // Delete CMS Category and its child from database
        $list = count($to_delete) > 1 ? implode(',', $to_delete) : (int) $this->id;
        Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'cms_category` WHERE `id_cms_category` IN (' . $list . ')');
        Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'cms_category_lang` WHERE `id_cms_category` IN (' . $list . ')');
        CMSCategory::cleanPositions($this->id_parent);
        // Delete pages which are in categories to delete
        $result = Db::getInstance()->executeS('
		SELECT `id_cms`
		FROM `' . _DB_PREFIX_ . 'cms`
		WHERE `id_cms_category` IN (' . $list . ')');
        foreach ($result as $p) {
            $product = new CMS($p['id_cms']);
            if (Validate::isLoadedObject($product)) {
                $product->delete();
            }
        }
        return true;
    }
开发者ID:NathanGiesbrecht,项目名称:PrestaShopAutomationFramework,代码行数:28,代码来源:CMSCategory.php

示例4: postProcess

 public function postProcess()
 {
     $this->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, $this->id);
     if (Tools::isSubmit('submitAdd' . $this->table)) {
         $this->action = 'save';
         if ($id_cms_category = (int) Tools::getValue('id_cms_category')) {
             $this->id_object = $id_cms_category;
             if (!CMSCategory::checkBeforeMove($id_cms_category, (int) Tools::getValue('id_parent'))) {
                 $this->errors[] = Tools::displayError('The CMS Category cannot be moved here.');
                 return false;
             }
         }
         $object = parent::postProcess();
         $this->updateAssoShop((int) Tools::getValue('id_cms_category'));
         if ($object !== false) {
             Tools::redirectAdmin(self::$currentIndex . '&conf=3&id_cms_category=' . (int) $object->id . '&token=' . Tools::getValue('token'));
         }
         return $object;
     } elseif (Tools::isSubmit('statuscms_category') && Tools::getValue($this->identifier)) {
         if ($this->tabAccess['edit'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject())) {
                 if ($object->toggleStatus()) {
                     $identifier = (int) $object->id_parent ? '&id_cms_category=' . (int) $object->id_parent : '';
                     Tools::redirectAdmin(self::$currentIndex . '&conf=5' . $identifier . '&token=' . Tools::getValue('token'));
                 } else {
                     $this->errors[] = Tools::displayError('An error occurred while updating the status.');
                 }
             } else {
                 $this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->errors[] = Tools::displayError('You do not have permission to edit this.');
         }
     } elseif (Tools::isSubmit('delete' . $this->table)) {
         if ($this->tabAccess['delete'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings)) {
                 // check if request at least one object with noZeroObject
                 if (isset($object->noZeroObject) && count($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1) {
                     $this->errors[] = Tools::displayError('You need at least one object.') . ' <b>' . $this->table . '</b><br />' . Tools::displayError('You cannot delete all of the items.');
                 } else {
                     $identifier = (int) $object->id_parent ? '&' . $this->identifier . '=' . (int) $object->id_parent : '';
                     if ($this->deleted) {
                         $object->deleted = 1;
                         if ($object->update()) {
                             Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . Tools::getValue('token') . $identifier);
                         }
                     } elseif ($object->delete()) {
                         Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . Tools::getValue('token') . $identifier);
                     }
                     $this->errors[] = Tools::displayError('An error occurred during deletion.');
                 }
             } else {
                 $this->errors[] = Tools::displayError('An error occurred while deleting the object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->errors[] = Tools::displayError('You do not have permission to delete this.');
         }
     } elseif (Tools::isSubmit('position')) {
         $object = new CMSCategory((int) Tools::getValue($this->identifier, Tools::getValue('id_cms_category_to_move', 1)));
         if ($this->tabAccess['edit'] !== '1') {
             $this->errors[] = Tools::displayError('You do not have permission to edit this.');
         } elseif (!Validate::isLoadedObject($object)) {
             $this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
         } elseif (!$object->updatePosition((int) Tools::getValue('way'), (int) Tools::getValue('position'))) {
             $this->errors[] = Tools::displayError('Failed to update the position.');
         } else {
             $identifier = (int) $object->id_parent ? '&' . $this->identifier . '=' . (int) $object->id_parent : '';
             $token = Tools::getAdminTokenLite('AdminCmsContent');
             Tools::redirectAdmin(self::$currentIndex . '&' . $this->table . 'Orderby=position&' . $this->table . 'Orderway=asc&conf=5' . $identifier . '&token=' . $token);
         }
     } elseif (Tools::getValue('submitDel' . $this->table) || Tools::getValue('submitBulkdelete' . $this->table)) {
         if ($this->tabAccess['delete'] === '1') {
             if (Tools::isSubmit($this->table . 'Box')) {
                 $cms_category = new CMSCategory();
                 $result = true;
                 $result = $cms_category->deleteSelection(Tools::getValue($this->table . 'Box'));
                 if ($result) {
                     $cms_category->cleanPositions((int) Tools::getValue('id_cms_category'));
                     $token = Tools::getAdminTokenLite('AdminCmsContent');
                     Tools::redirectAdmin(self::$currentIndex . '&conf=2&token=' . $token . '&id_cms_category=' . (int) Tools::getValue('id_cms_category'));
                 }
                 $this->errors[] = Tools::displayError('An error occurred while deleting this selection.');
             } else {
                 $this->errors[] = Tools::displayError('You must select at least one element to delete.');
             }
         } else {
             $this->errors[] = Tools::displayError('You do not have permission to delete this.');
         }
     }
     parent::postProcess();
 }
开发者ID:ortegon000,项目名称:tienda,代码行数:91,代码来源:AdminCmsCategoriesController.php


注:本文中的CMSCategory::cleanPositions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。