From 3e0bb0ba0c0b8268f72fe5985df293feb34e0209 Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Wed, 16 Nov 2011 14:18:36 +0000 Subject: [PATCH] [*] BO : #PSFV-94 - added AdminCMSContentController, AdminCMSController, AdminCMSCategoriesController --- admin-dev/tabs/AdminCMS.php | 348 ----------------- admin-dev/tabs/AdminCMSCategories.php | 283 -------------- admin-dev/themes/default/admin.css | 3 +- admin-dev/themes/template/cms/form.tpl | 77 ++++ .../themes/template/cms_categories/form.tpl | 37 ++ .../themes/template/cms_content/content.tpl | 32 ++ .../themes/template/helper/form/form.tpl | 3 +- classes/CMS.php | 2 +- classes/CMSCategory.php | 40 +- cms.php | 2 +- .../admin/AdminCMSCategoriesController.php | 278 ++++++++++++++ .../admin/AdminCMSContentController.php | 99 +++-- controllers/admin/AdminCMSController.php | 350 ++++++++++++++++++ controllers/front/CmsController.php | 4 +- install-dev/sql/db_settings_lite.sql | 30 +- install-dev/sql/upgrade/1.5.0.1.sql | 8 +- 16 files changed, 886 insertions(+), 710 deletions(-) delete mode 100644 admin-dev/tabs/AdminCMS.php delete mode 100644 admin-dev/tabs/AdminCMSCategories.php create mode 100644 admin-dev/themes/template/cms/form.tpl create mode 100644 admin-dev/themes/template/cms_categories/form.tpl create mode 100644 admin-dev/themes/template/cms_content/content.tpl create mode 100644 controllers/admin/AdminCMSCategoriesController.php rename admin-dev/tabs/AdminCMSContent.php => controllers/admin/AdminCMSContentController.php (53%) create mode 100644 controllers/admin/AdminCMSController.php diff --git a/admin-dev/tabs/AdminCMS.php b/admin-dev/tabs/AdminCMS.php deleted file mode 100644 index 622d6dc01..000000000 --- a/admin-dev/tabs/AdminCMS.php +++ /dev/null @@ -1,348 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 7300 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -include_once(_PS_ADMIN_DIR_.'/../classes/AdminTab.php'); - -class AdminCMS extends AdminTab -{ - private $_category; - - public function __construct() - { - $this->table = 'cms'; - $this->className = 'CMS'; - $this->lang = true; - $this->edit = true; - $this->view = true; - $this->delete = true; - - $this->fieldsDisplay = array( - 'id_cms' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), - 'link_rewrite' => array('title' => $this->l('URL'), 'width' => 200), - 'meta_title' => array('title' => $this->l('Title'), 'width' => 300, 'filter_key' => 'b!meta_title'), - 'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'position', 'align' => 'center', 'position' => 'position'), - 'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false) - ); - - $this->_category = AdminCMSContent::getCurrentCMSCategory(); - $this->_join = ' - LEFT JOIN `'._DB_PREFIX_.'cms_category` c ON (c.`id_cms_category` = a.`id_cms_category`)'; - $this->_select = 'a.position '; - $this->_filter = 'AND c.id_cms_category = '.(int)($this->_category->id); - - parent::__construct(); - } - - private function _displayDraftWarning($active) - { - return - '
-

- - - '.$this->l('Your CMS page will be saved as a draft').' - - - -
-

-
'; - } - - public function displayForm($isMainTab = true) - { - parent::displayForm(); - - $obj = $this->loadObject(true); - $divLangName = 'meta_title¤meta_description¤meta_keywords¤ccontent¤link_rewrite'; - - echo ' -
- '.($obj->id ? '' : '').' - '.$this->_displayDraftWarning($obj->active).' -
'.$this->l('CMS page').''; - - // META TITLE - echo ' -
- -
- -
'; - foreach ($this->_languages as $language) - echo '
- * -
'; - - $this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'meta_title'); - echo '
 
'; - - // META DESCRIPTION - echo ' -
'; - foreach ($this->_languages as $language) - echo '
- -
'; - $this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'meta_description'); - echo '
 
'; - - // META KEYWORDS - echo ' -
'; - foreach ($this->_languages as $language) - echo '
- -
'; - $this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'meta_keywords'); - echo '
 
'; - - // LINK REWRITE - echo ' -
'; - foreach ($this->_languages as $language) - echo ' '; - $this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'link_rewrite'); - echo '
 
'; - - // CONTENT - echo ' -
'; - foreach ($this->_languages as $language) - echo '
- -
'; - $this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'ccontent'); - echo '
 
- -
- getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/> - - getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/> - -
'; - if (Shop::isFeatureActive()) - { - echo '
'; - $this->displayAssoShop(); - echo '
'; - } - // SUBMIT - echo '
- -
-
* '.$this->l('Required field').'
-

- '.$this->_displayDraftWarning($obj->active).' -
'; - // TinyMCE - $isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$this->context->language->iso_code.'.js') ? $this->context->language->iso_code : 'en'); - $ad = dirname($_SERVER["PHP_SELF"]); - echo ' - - - '; - } - - public function display($token = NULL) - { - - if (($id_cms_category = (int)Tools::getValue('id_cms_category'))) - self::$currentIndex .= '&id_cms_category='.$id_cms_category; - $this->getList($this->context->language->id, !$this->context->cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$this->context->cookie->__get($this->table.'Orderway') ? 'ASC' : NULL); - - if (!$id_cms_category) - $id_cms_category = 1; - echo '

'.(!$this->_listTotal ? ($this->l('No pages found')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('pages') : $this->l('page')))).' '. - $this->l('in category').' "'.stripslashes(CMSCategory::hideCMSCategoryPosition($this->_category->getName())).'"

'; - echo ' '.$this->l('Add a new page').' -
'; - $this->displayList($token); - echo '
'; - } - - public function displayList($token = NULL) - { - /* Display list header (filtering, pagination and column names) */ - $this->displayListHeader($token); - if (!sizeof($this->_list)) - echo ''.$this->l('No items found').''; - - /* Show the content of the table */ - $this->displayListContent($token); - - /* Close list table and submit button */ - $this->displayListFooter($token); - } - - function postProcess() - { - if (Tools::isSubmit('viewcms') AND ($id_cms = (int)(Tools::getValue('id_cms'))) AND $cms = new CMS($id_cms, $this->context->language->id) AND Validate::isLoadedObject($cms)) - { - $redir = $this->context->link->getCMSLink($cms); - if (!$cms->active) - { - $admin_dir = dirname($_SERVER['PHP_SELF']); - $admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1); - $redir .= '?adtoken='.Tools::encrypt('PreviewCMS'.$cms->id).'&ad='.$admin_dir; - } - Tools::redirectAdmin($redir); - } - elseif (Tools::isSubmit('deletecms')) - { - if (Tools::getValue('id_cms') == Configuration::get('PS_CONDITIONS_CMS_ID')) - { - Configuration::updateValue('PS_CONDITIONS', 0); - Configuration::updateValue('PS_CONDITIONS_CMS_ID', 0); - } - $cms = new CMS((int)(Tools::getValue('id_cms'))); - $cms->cleanPositions($cms->id_cms_category); - if (!$cms->delete()) - $this->_errors[] = Tools::displayError('An error occurred while deleting object.').' '.$this->table.' ('.Db::getInstance()->getMsgError().')'; - else - Tools::redirectAdmin(self::$currentIndex.'&id_cms_category='.$cms->id_cms_category.'&conf=1&token='.Tools::getAdminTokenLite('AdminCMSContent')); - }/* Delete multiple objects */ - elseif (Tools::getValue('submitDel'.$this->table)) - { - if ($this->tabAccess['delete'] === '1') - { - if (isset($_POST[$this->table.'Box'])) - { - $cms = new CMS(); - $result = true; - $result = $cms->deleteSelection(Tools::getValue($this->table.'Box')); - if ($result) - { - $cms->cleanPositions((int)(Tools::getValue('id_cms_category'))); - Tools::redirectAdmin(self::$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.'); - } - elseif (Tools::isSubmit('submitAddcms') OR Tools::isSubmit('submitAddcmsAndPreview')) - { - parent::validateRules(); - - if (!sizeof($this->_errors)) - { - if (!$id_cms = (int)(Tools::getValue('id_cms'))) - { - $cms = new CMS(); - $this->copyFromPost($cms, 'cms'); - if (!$cms->add()) - $this->_errors[] = Tools::displayError('An error occurred while creating object.').' '.$this->table.' ('.Db::getInstance()->getMsgError().')'; - elseif (Tools::isSubmit('submitAddcmsAndPreview')) - { - $preview_url = $this->context->link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), $this->context->language->id); - if (!$cms->active) - { - $admin_dir = dirname($_SERVER['PHP_SELF']); - $admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1); - $token = Tools::encrypt('PreviewCMS'.$cms->id); - - $preview_url .= $object->active ? '' : '&adtoken='.$token.'&ad='.$admin_dir; - } - Tools::redirectAdmin($preview_url); - } - else - Tools::redirectAdmin(self::$currentIndex.'&id_cms_category='.$cms->id_cms_category.'&conf=3&token='.Tools::getAdminTokenLite('AdminCMSContent')); - } - else - { - $cms = new CMS($id_cms); - $this->copyFromPost($cms, 'cms'); - if (!$cms->update()) - $this->_errors[] = Tools::displayError('An error occurred while updating object.').' '.$this->table.' ('.Db::getInstance()->getMsgError().')'; - elseif (Tools::isSubmit('submitAddcmsAndPreview')) - { - $preview_url = $this->context->link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), $this->context->language->id); - if (!$cms->active) - { - $admin_dir = dirname($_SERVER['PHP_SELF']); - $admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1); - $token = Tools::encrypt('PreviewCMS'.$cms->id); - - $preview_url .= $object->active ? '' : '&adtoken='.$token.'&ad='.$admin_dir; - } - Tools::redirectAdmin($preview_url); - } - else - Tools::redirectAdmin(self::$currentIndex.'&id_cms_category='.$cms->id_cms_category.'&conf=4&token='.Tools::getAdminTokenLite('AdminCMSContent')); - } - } - } - elseif (Tools::getValue('position')) - { - if ($this->tabAccess['edit'] !== '1') - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - elseif (!Validate::isLoadedObject($object = $this->loadObject())) - $this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' '.$this->table.' '.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(self::$currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=4'.(($id_category = (int)(Tools::getValue('id_cms_category'))) ? ('&id_cms_category='.$id_category) : '').'&token='.Tools::getAdminTokenLite('AdminCMSContent')); - } - /* Change object statuts (active, inactive) */ - elseif (Tools::isSubmit('status') AND Tools::isSubmit($this->identifier)) - { - if ($this->tabAccess['edit'] === '1') - { - if (Validate::isLoadedObject($object = $this->loadObject())) - { - if ($object->toggleStatus()) - Tools::redirectAdmin(self::$currentIndex.'&conf=5'.((int)Tools::getValue('id_cms_category') ? '&id_cms_category='.(int)Tools::getValue('id_cms_category') : '').'&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.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - else - parent::postProcess(true); - } -} - - diff --git a/admin-dev/tabs/AdminCMSCategories.php b/admin-dev/tabs/AdminCMSCategories.php deleted file mode 100644 index 7a5b0538e..000000000 --- a/admin-dev/tabs/AdminCMSCategories.php +++ /dev/null @@ -1,283 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 6844 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -include_once(_PS_ADMIN_DIR_.'/../classes/AdminTab.php'); - -class AdminCMSCategories extends AdminTab -{ - /** @var object CMSCategory() instance for navigation*/ - private $_CMSCategory; - - public function __construct() - { - $this->table = 'cms_category'; - $this->className = 'CMSCategory'; - $this->lang = true; - $this->edit = true; - $this->view = true; - $this->delete = true; - - - $this->fieldsDisplay = array( - 'id_cms_category' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 30), - 'name' => array('title' => $this->l('Name'), 'width' => 100, 'callback' => 'hideCMSCategoryPosition'), - 'description' => array('title' => $this->l('Description'), 'width' => 500, 'maxlength' => 90, 'orderby' => false), - 'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'position', 'align' => 'center', 'position' => 'position'), - 'active' => array('title' => $this->l('Displayed'), 'active' => 'status', 'align' => 'center', 'type' => 'bool', 'orderby' => false)); - - $this->_CMSCategory = AdminCMSContent::getCurrentCMSCategory(); - $this->_filter = 'AND `id_parent` = '.(int)($this->_CMSCategory->id); - $this->_select = 'position '; - - parent::__construct(); - } - - public function displayList($token = NULL) - { - /* Display list header (filtering, pagination and column names) */ - $this->displayListHeader($token); - if (!sizeof($this->_list)) - echo ''.$this->l('No items found').''; - - /* Show the content of the table */ - $this->displayListContent($token); - - /* Close list table and submit button */ - $this->displayListFooter($token); - } - - public function display($token = NULL) - { - $id_cms_category = (int)(Tools::getValue('id_cms_category', 1)); - - $this->getList((int)($this->context->cookie->id_lang), !$this->context->cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$this->context->cookie->__get($this->table.'Orderway') ? 'ASC' : NULL); - - echo '

'.(!$this->_listTotal ? ($this->l('There are no subcategories')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('subcategories') : $this->l('subCMS Category')))).' '.$this->l('in CMS Category').' "'.stripslashes(CMSCategory::hideCMSCategoryPosition($this->_CMSCategory->getName())).'"

'; - echo ' '.$this->l('Add a new sub CMS Category').' -
'; - $this->displayList($token); - echo '
'; - } - - public function postProcess($token = NULL) - { - $this->tabAccess = Profile::getProfileAccess($this->context->employee->id_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; - } - } - } - /* Change object statuts (active, inactive) */ - 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(self::$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.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - /* Delete object */ - 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.').' '.$this->table.'
'.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(self::$currentIndex.'&conf=1&token='.Tools::getValue('token')); - } - elseif ($object->delete()) - Tools::redirectAdmin(self::$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.').' '.$this->table.' '.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.').' '.$this->table.' '.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(self::$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')); - } - /* Delete multiple objects */ - 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(self::$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); - } - - public function displayForm($token=NULL) - { - parent::displayForm(); - - if (!($obj = $this->loadObject(true))) - return; - $active = $this->getFieldValue($obj, 'active'); - - echo ' -
- '.($obj->id ? '' : '').' -
'.$this->l('CMS Category').' - -
'; - foreach ($this->_languages as $language) - echo ' -
- id) ? ' onkeyup="copy2friendlyURL();"' : '').' /> * - '.$this->l('Invalid characters:').' <>;=#{}  -
'; - echo '

-
- -
- - - - -
- -
- -
- -
'; - foreach ($this->_languages as $language) - echo ' -
- -
'; - echo '

-
-

- -
'; - foreach ($this->_languages as $language) - echo ' -
- - '.$this->l('Forbidden characters:').' <>;=#{}  -
'; - echo '

-
- -
'; - foreach ($this->_languages as $language) - echo '
- - '.$this->l('Forbidden characters:').' <>;=#{}  -
'; - echo '

-
- -
'; - foreach ($this->_languages as $language) - echo ' -
- - '.$this->l('Forbidden characters:').' <>;=#{}  -
'; - echo '

-
- -
'; - foreach ($this->_languages as $language) - echo '
- * - '.$this->l('Only letters and the minus (-) character are allowed').'  -
'; - echo '

-
- -
- -   -
-
* '.$this->l('Required field').'
-
-
-

'; - } -} diff --git a/admin-dev/themes/default/admin.css b/admin-dev/themes/default/admin.css index b434063a8..f9bf18b9a 100644 --- a/admin-dev/themes/default/admin.css +++ b/admin-dev/themes/default/admin.css @@ -144,7 +144,7 @@ a.module_toggle_all{color: #268CCD;} .processing {overflow: auto;} /*TABLE STATUS COMMANDE*/ -.table td span.color_field { font-size:11px; padding:2px 5px; border-radius:3px; text-transform:uppercase; text-shadow:0 1px 0 #fff; color:#fff; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px;} +.table td span.color_field { font-size:11px; padding:2px 5px; border-radius:3px; text-transform:uppercase; color:#fff; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px;} /*toolbarBox*/ .toolbarBox { background-color: #F8F8F8; border: 1px solid #CCCCCC; margin-bottom:10px; padding: 10px 0; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px;} @@ -170,6 +170,7 @@ a.module_toggle_all{color: #268CCD;} .toolbarBox .process-icon-save-calendar { background-image: url(process-icon-save-calendar.png);} .toolbarBox .process-icon-new-module { background-image: url(process-icon-new-module.png);} .toolbarBox .process-icon-new-module-addon { background-image: url(process-icon-new-module-addon.png);} +.toolbarBox .process-icon-save-and-preview { background-image: url(process-icon-preview.png);} div.fix-toolbar {border-bottom: 1px solid #E0E0E0;position:fixed;top:0;opacity:0.9;z-index:1;} diff --git a/admin-dev/themes/template/cms/form.tpl b/admin-dev/themes/template/cms/form.tpl new file mode 100644 index 000000000..e2f0a5d60 --- /dev/null +++ b/admin-dev/themes/template/cms/form.tpl @@ -0,0 +1,77 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + +{extends file="../helper/form/form.tpl"} + +{block name="script"} + $(document).ready(function() { + if (btn_submit.length > 0) + { + //get reference on save and stay link + btn_save_and_preview = $('span[class~="process-icon-save-and-preview"]').parent(); + + //get reference on current save link label + lbl_save = $('#desc-{$table}-save div'); + + //submit the form + if (btn_save_and_preview) + { + btn_save_and_preview.click(function() { + //add hidden input to emulate submit button click when posting the form -> field name posted + btn_submit.before(''); + $('#{$table}_form').submit(); + }); + } + } + $('#active_on').bind('click', function(){ + toggleDraftWarning(true); + }); + $('#active_off').bind('click', function(){ + toggleDraftWarning(false); + }); + }); +{/block} + +{block name="leadin"} +
+

+ + {l s='Your CMS page will be saved as a draft'} + +
+

+
+{/block} + +{block name="start_field_block"} +
+ {if $input.type == 'select_category'} + + {/if} +{/block} + diff --git a/admin-dev/themes/template/cms_categories/form.tpl b/admin-dev/themes/template/cms_categories/form.tpl new file mode 100644 index 000000000..e162197cb --- /dev/null +++ b/admin-dev/themes/template/cms_categories/form.tpl @@ -0,0 +1,37 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + +{extends file="../helper/form/form.tpl"} + +{block name="start_field_block"} +
+ {if $input.type == 'select_category'} + + {/if} +{/block} + diff --git a/admin-dev/themes/template/cms_content/content.tpl b/admin-dev/themes/template/cms_content/content.tpl new file mode 100644 index 000000000..acc115010 --- /dev/null +++ b/admin-dev/themes/template/cms_content/content.tpl @@ -0,0 +1,32 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} +{if isset($cms_breadcrumb)} +
+ {l s='Current category'} :   {$cms_breadcrumb} +
+{/if} + +{$content} diff --git a/admin-dev/themes/template/helper/form/form.tpl b/admin-dev/themes/template/helper/form/form.tpl index 7f36532b9..dc4df32d3 100644 --- a/admin-dev/themes/template/helper/form/form.tpl +++ b/admin-dev/themes/template/helper/form/form.tpl @@ -78,9 +78,10 @@ {if isset($input.lang)}
{foreach $languages as $language} -
+
language->id; - + //recursivity for subcategories $children = array(); if (($maxDepth == 0 OR $currentDepth < $maxDepth) AND $subcats = $this->getSubCategories($id_lang, true) AND sizeof($subcats)) @@ -229,8 +229,8 @@ class CMSCategoryCore extends ObjectModel $html .= self::recurseCMSCategory($categories, $categories[$id_cms_category][$key], $key, $id_selected, $is_html); return $html; } - - + + /** * Recursively add specified CMSCategory childs to $toDelete array @@ -257,7 +257,7 @@ class CMSCategoryCore extends ObjectModel public function delete() { if ($this->id == 1) return false; - + $this->clearCache(); /* Get childs categories */ @@ -271,7 +271,7 @@ class CMSCategoryCore extends ObjectModel Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'cms_category_lang` WHERE `id_cms_category` IN ('.$list.')'); self::cleanPositions($this->id_parent); - + /* Delete pages which are in categories to delete */ $result = Db::getInstance()->executeS(' SELECT `id_cms` @@ -285,7 +285,7 @@ class CMSCategoryCore extends ObjectModel } return true; } - + /** * Delete several categories from database * @@ -530,9 +530,9 @@ class CMSCategoryCore extends ObjectModel return Db::getInstance()->getRow(' SELECT c.*, cl.* FROM `'._DB_PREFIX_.'cms_category` c - LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category` AND `id_lang` = '.(int)($id_lang).') - WHERE `name` LIKE \''.pSQL($CMSCategory_name).'\' - AND c.`id_cms_category` != 1 + LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category` AND `id_lang` = '.(int)($id_lang).') + WHERE `name` LIKE \''.pSQL($CMSCategory_name).'\' + AND c.`id_cms_category` != 1 AND c.`id_parent` = '.(int)($id_parent_CMSCategory)); } @@ -565,20 +565,20 @@ class CMSCategoryCore extends ObjectModel $idCurrent = $result[0]['id_parent']; } } - + public function updatePosition($way, $position) - { + { if (!$res = Db::getInstance()->executeS(' - SELECT cp.`id_cms_category`, cp.`position`, cp.`id_parent` + SELECT cp.`id_cms_category`, cp.`position`, cp.`id_parent` FROM `'._DB_PREFIX_.'cms_category` cp - WHERE cp.`id_parent` = '.(int)$this->id_parent.' + WHERE cp.`id_parent` = '.(int)$this->id_parent.' ORDER BY cp.`position` ASC' )) return false; foreach ($res AS $category) if ((int)($category['id_cms_category']) == (int)($this->id)) $movedCategory = $category; - + if (!isset($movedCategory) || !isset($position)) return false; // < and > statements rather than BETWEEN operator @@ -586,8 +586,8 @@ class CMSCategoryCore extends ObjectModel return (Db::getInstance()->execute(' UPDATE `'._DB_PREFIX_.'cms_category` SET `position`= `position` '.($way ? '- 1' : '+ 1').' - WHERE `position` - '.($way + WHERE `position` + '.($way ? '> '.(int)($movedCategory['position']).' AND `position` <= '.(int)($position) : '< '.(int)($movedCategory['position']).' AND `position` >= '.(int)($position)).' AND `id_parent`='.(int)($movedCategory['id_parent'])) @@ -597,7 +597,7 @@ class CMSCategoryCore extends ObjectModel WHERE `id_parent` = '.(int)($movedCategory['id_parent']).' AND `id_cms_category`='.(int)($movedCategory['id_cms_category']))); } - + public static function cleanPositions($id_category_parent) { $result = Db::getInstance()->executeS(' @@ -616,7 +616,7 @@ class CMSCategoryCore extends ObjectModel } return true; } - + public static function getLastPosition($id_category_parent) { return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'cms_category` WHERE `id_parent` = '.(int)($id_category_parent))); diff --git a/cms.php b/cms.php index 1d469e923..889987af6 100644 --- a/cms.php +++ b/cms.php @@ -1,6 +1,6 @@ +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 6844 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +class AdminCMSCategoriesControllerCore extends AdminController +{ + /** @var object CMSCategory() instance for navigation*/ + private $_CMSCategory; + + public function __construct() + { + $this->table = 'cms_category'; + $this->className = 'CMSCategory'; + $this->lang = true; + $this->addRowAction('view'); + $this->addRowAction('edit'); + $this->addRowAction('delete'); + $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + + $this->fieldsDisplay = array( + 'id_cms_category' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 30), + 'name' => array('title' => $this->l('Name'), 'width' => 'auto', 'callback' => 'hideCMSCategoryPosition', 'callback_object' => 'CMSCategory'), + 'description' => array('title' => $this->l('Description'), 'width' => 500, 'maxlength' => 90, 'orderby' => false), + 'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'position', 'align' => 'center', 'position' => 'position'), + 'active' => array('title' => $this->l('Displayed'), 'width' => 25, 'active' => 'status', 'align' => 'center', 'type' => 'bool', 'orderby' => false)); + + $this->_CMSCategory = AdminCMSContentController::getCurrentCMSCategory(); + $this->_filter = 'AND `id_parent` = '.(int)($this->_CMSCategory->id); + $this->_select = 'position '; + + parent::__construct(); + } + + public function initList() + { + $this->initToolbar(); + return parent::initList(); + } + + /** + * Modifying initial getList method to display position feature (drag and drop) + */ + public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) + { + if ($order_by && $this->context->cookie->__get($this->table.'Orderby')) + $order_by = $this->context->cookie->__get($this->table.'Orderby'); + else + $order_by = 'position'; + + parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); + } + + public function postProcess($token = NULL) + { + $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'))) + { + if (!CMSCategory::checkBeforeMove($id_cms_category, (int)(Tools::getValue('id_parent')))) + { + $this->_errors[] = Tools::displayError('CMS Category cannot be moved here'); + return false; + } + } + } + /* Change object statuts (active, inactive) */ + 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(self::$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.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); + } + else + $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); + } + /* Delete object */ + 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.').' '.$this->table.'
'.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(self::$currentIndex.'&conf=1&token='.Tools::getValue('token')); + } + elseif ($object->delete()) + Tools::redirectAdmin(self::$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.').' '.$this->table.' '.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.').' '.$this->table.' '.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(self::$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')); + } + /* Delete multiple objects */ + 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(self::$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); + } + + public function initForm() + { + $this->display = 'edit'; + $this->initToolbar(); + if (!$this->loadObject(true)) + return; + + $categories = CMSCategory::getCategories($this->context->language->id, false); + $html_categories = CMSCategory::recurseCMSCategory($categories, $categories[0][1], 1, $this->getFieldValue($this->object, 'id_parent'), 1); + + $this->fields_form = array( + 'legend' => array( + 'title' => $this->l('CMS Category'), + 'image' => '../img/admin/tab-categories.gif' + ), + 'input' => array( + array( + 'type' => 'text', + 'label' => $this->l('Name:'), + 'name' => 'name', + 'required' => true, + 'lang' => true, + 'class' => 'copy2friendlyUrl', + 'hint' => $this->l('Invalid characters:').' <>;=#{}' + ), + array( + 'type' => 'radio', + 'label' => $this->l('Displayed:'), + 'name' => 'active', + 'required' => false, + 'class' => 't', + 'is_bool' => true, + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + 'label' => $this->l('Enabled') + ), + array( + 'id' => 'active_off', + 'value' => 0, + 'label' => $this->l('Disabled') + ) + ), + ), + // custom template + array( + 'type' => 'select_category', + 'label' => $this->l('Parent CMS Category:'), + 'name' => 'id_parent', + 'options' => array( + 'html' => $html_categories, + ), + ), + array( + 'type' => 'textarea', + 'label' => $this->l('Name:'), + 'name' => 'description', + 'lang' => true, + 'rows' => 5, + 'cols' => 40, + 'hint' => $this->l('Invalid characters:').' <>;=#{}' + ), + array( + 'type' => 'text', + 'label' => $this->l('Meta title:'), + 'name' => 'meta_title', + 'lang' => true, + 'hint' => $this->l('Invalid characters:').' <>;=#{}' + ), + array( + 'type' => 'text', + 'label' => $this->l('Meta description:'), + 'name' => 'meta_description', + 'lang' => true, + 'hint' => $this->l('Invalid characters:').' <>;=#{}' + ), + array( + 'type' => 'text', + 'label' => $this->l('Meta keywords:'), + 'name' => 'meta_keywords', + 'lang' => true, + 'hint' => $this->l('Invalid characters:').' <>;=#{}' + ), + array( + 'type' => 'text', + 'label' => $this->l('Friendly URL:'), + 'name' => 'link_rewrite', + 'required' => true, + 'lang' => true, + 'hint' => $this->l('Only letters and the minus (-) character are allowed') + ), + ), + 'submit' => array( + 'title' => $this->l(' Save '), + 'class' => 'button' + ) + ); + + return parent::initForm(); + } +} diff --git a/admin-dev/tabs/AdminCMSContent.php b/controllers/admin/AdminCMSContentController.php similarity index 53% rename from admin-dev/tabs/AdminCMSContent.php rename to controllers/admin/AdminCMSContentController.php index 4d65a6b2b..215137c7d 100644 --- a/admin-dev/tabs/AdminCMSContent.php +++ b/controllers/admin/AdminCMSContentController.php @@ -1,6 +1,6 @@ * @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 6844 $ +* @version Release: $Revision$ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ -include_once(_PS_ADMIN_DIR_.'/../classes/AdminTab.php'); -include(_PS_ADMIN_DIR_.'/tabs/AdminCMSCategories.php'); -include(_PS_ADMIN_DIR_.'/tabs/AdminCMS.php'); - -class AdminCMSContent extends AdminTab +class AdminCMSContentControllerCore extends AdminController { /** @var object adminCMSCategories() instance */ private $adminCMSCategories; @@ -49,8 +45,8 @@ class AdminCMSContent extends AdminTab die('Category cannot be loaded'); $this->table = array('cms_category', 'cms'); - $this->adminCMSCategories = new adminCMSCategories(); - $this->adminCMS = new adminCMS(); + $this->adminCMSCategories = new AdminCMSCategoriesController(); + $this->adminCMS = new AdminCMSController(); parent::__construct(); } @@ -73,14 +69,6 @@ class AdminCMSContent extends AdminTab return $result; } - public function postProcess() - { - if (Tools::isSubmit('submitDelcms') OR Tools::isSubmit('previewSubmitAddcmsAndPreview') OR Tools::isSubmit('submitAddcms') OR isset($_GET['deletecms']) OR Tools::isSubmit('viewcms') OR (Tools::isSubmit('statuscms') AND Tools::isSubmit('id_cms')) OR (Tools::isSubmit('position') AND !Tools::isSubmit('id_cms_category_to_move'))) - $this->adminCMS->postProcess(); - if(Tools::isSubmit('submitDelcms_category') OR Tools::isSubmit('submitAddcms_categoryAndBackToParent') OR Tools::isSubmit('submitAddcms_category') OR isset($_GET['deletecms_category']) OR (Tools::isSubmit('statuscms_category') AND Tools::isSubmit('id_cms_category')) OR (Tools::isSubmit('position') AND Tools::isSubmit('id_cms_category_to_move'))) - $this->adminCMSCategories->postProcess(); - - } public function displayErrors() { @@ -89,39 +77,72 @@ class AdminCMSContent extends AdminTab $this->adminCMSCategories->displayErrors(); } - public function display() + public function initContent() { - if (((Tools::isSubmit('submitAddcms_category') OR Tools::isSubmit('submitAddcms_categoryAndStay')) AND sizeof($this->adminCMSCategories->_errors)) OR isset($_GET['updatecms_category']) OR isset($_GET['addcms_category'])) - { - $this->adminCMSCategories->displayForm($this->token); - echo '

'.$this->l('Back to list').'
'; - - } - elseif (((Tools::isSubmit('submitAddcms') OR Tools::isSubmit('submitAddcmsAndStay')) AND sizeof($this->adminCMS->_errors)) OR isset($_GET['updatecms']) OR isset($_GET['addcms'])) - { - $this->adminCMS->displayForm($this->token); - echo '

'.$this->l('Back to list').'
'; - - } + $this->adminCMSCategories->token = $this->token; + $this->adminCMS->token = $this->token; + + if ($this->display == 'edit_category') + $this->content .= $this->adminCMSCategories->initForm(); + elseif ($this->display == 'edit_page') + $this->content .= $this->adminCMS->initForm(); + elseif ($this->display == 'view_page'){} else { $id_cms_category = (int)(Tools::getValue('id_cms_category')); if (!$id_cms_category) $id_cms_category = 1; + + // CMS categories breadcrumb $cms_tabs = array('cms_category', 'cms'); // Cleaning links $catBarIndex = self::$currentIndex; foreach ($cms_tabs AS $tab) - if (Tools::getValue($tab.'Orderby') && Tools::getValue($tab.'Orderway')) + if (Tools::getValue($tab.'Orderby') && Tools::getValue($tab.'Orderway')) $catBarIndex = preg_replace('/&'.$tab.'Orderby=([a-z _]*)&'.$tab.'Orderway=([a-z]*)/i', '', self::$currentIndex); - echo '
'.$this->l('Current category').' :   '.getPath($catBarIndex, $id_cms_category,'','','cms').'
'; - echo '

'.$this->l('Categories').'

'; - $this->adminCMSCategories->display($this->token); - echo '
 
'; - echo '

'.$this->l('Pages in this category').'

'; - $this->adminCMS->display($this->token); + + $this->content .= $this->adminCMSCategories->initList(); + $this->adminCMS->id_cms_category = $id_cms_category; + $this->content .= $this->adminCMS->initList(); + $this->context->smarty->assign(array( + 'cms_breadcrumb' => getPath($catBarIndex, $id_cms_category,'','','cms'), + )); } - + + $this->context->smarty->assign(array( + 'content' => $this->content + )); + } + + public function postProcess() + { + if (((Tools::isSubmit('submitAddcms_category') || Tools::isSubmit('submitAddcms_categoryAndStay')) && sizeof($this->adminCMSCategories->_errors)) + || isset($_GET['updatecms_category']) + || isset($_GET['addcms_category'])) + $this->display = 'edit_category'; + elseif (((Tools::isSubmit('submitAddcms') || Tools::isSubmit('submitAddcmsAndStay')) && sizeof($this->adminCMS->_errors)) + || isset($_GET['updatecms']) + || isset($_GET['addcms'])) + $this->display = 'edit_page'; + else + { + $this->display = 'list'; + $this->id_cms_category = (int)(Tools::getValue('id_cms_category')); + } + + if (Tools::isSubmit('submitDelcms') + || Tools::isSubmit('previewSubmitAddcmsAndPreview') + || Tools::isSubmit('submitAddcms') + || isset($_GET['deletecms']) + || Tools::isSubmit('viewcms') + || (Tools::isSubmit('statuscms') && Tools::isSubmit('id_cms')) && (Tools::isSubmit('position') && !Tools::isSubmit('id_cms_category_to_move'))) + $this->adminCMS->postProcess(); + elseif(Tools::isSubmit('submitDelcms_category') + || Tools::isSubmit('submitAddcms_categoryAndBackToParent') + || Tools::isSubmit('submitAddcms_category') + || isset($_GET['deletecms_category']) + || (Tools::isSubmit('statuscms_category') && Tools::isSubmit('id_cms_category')) + || (Tools::isSubmit('position') && Tools::isSubmit('id_cms_category_to_move'))) + $this->adminCMSCategories->postProcess(); } } - diff --git a/controllers/admin/AdminCMSController.php b/controllers/admin/AdminCMSController.php new file mode 100644 index 000000000..3d6e1c54c --- /dev/null +++ b/controllers/admin/AdminCMSController.php @@ -0,0 +1,350 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 7300 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +class AdminCMSControllerCore extends AdminController +{ + private $_category; + + public $id_cms_category; + + public function __construct() + { + $this->table = 'cms'; + $this->className = 'CMS'; + $this->lang = true; + $this->addRowAction('view'); + $this->addRowAction('edit'); + $this->addRowAction('delete'); + $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + + $this->fieldsDisplay = array( + 'id_cms' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), + 'link_rewrite' => array('title' => $this->l('URL'), 'width' => 'auto'), + 'meta_title' => array('title' => $this->l('Title'), 'width' => '300', 'filter_key' => 'b!meta_title'), + 'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'position', 'align' => 'center', 'position' => 'position'), + 'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false) + ); + + $this->_category = AdminCMSContentController::getCurrentCMSCategory(); + $this->_join = ' + LEFT JOIN `'._DB_PREFIX_.'cms_category` c ON (c.`id_cms_category` = a.`id_cms_category`)'; + $this->_select = 'a.position '; + $this->_filter = 'AND c.id_cms_category = '.(int)($this->_category->id); + + parent::__construct(); + } + + public function initForm() + { + $this->display = 'edit'; + $this->toolbar_btn['save-and-preview'] = array( + 'href' => '#', + 'desc' => $this->l('Save and preview') + ); + $this->initToolbar(); + if (!$this->loadObject(true)) + return; + + $categories = CMSCategory::getCategories($this->context->language->id, false); + $html_categories = CMSCategory::recurseCMSCategory($categories, $categories[0][1], 1, $this->getFieldValue($this->object, 'id_cms_category'), 1); + + $this->fields_form = array( + 'tinymce' => true, + 'legend' => array( + 'title' => $this->l('CMS Category'), + 'image' => '../img/admin/tab-categories.gif' + ), + 'input' => array( + // custom template + array( + 'type' => 'select_category', + 'label' => $this->l('Parent CMS Category'), + 'name' => 'id_cms_category', + 'options' => array( + 'html' => $html_categories, + ), + ), + array( + 'type' => 'text', + 'label' => $this->l('Meta title:'), + 'name' => 'meta_title', + 'id' => 'name', // for copy2friendlyUrl compatibility + 'lang' => true, + 'required' => true, + 'class' => 'copy2friendlyUrl', + 'hint' => $this->l('Invalid characters:').' <>;=#{}' + ), + array( + 'type' => 'text', + 'label' => $this->l('Meta description'), + 'name' => 'meta_description', + 'lang' => true, + 'hint' => $this->l('Invalid characters:').' <>;=#{}' + ), + array( + 'type' => 'text', + 'label' => $this->l('Meta keywords'), + 'name' => 'meta_keywords', + 'lang' => true, + 'hint' => $this->l('Invalid characters:').' <>;=#{}' + ), + array( + 'type' => 'text', + 'label' => $this->l('Friendly URL'), + 'name' => 'link_rewrite', + 'required' => true, + 'lang' => true, + 'hint' => $this->l('Only letters and the minus (-) character are allowed') + ), + array( + 'type' => 'textarea', + 'label' => $this->l('Page content'), + 'name' => 'content', + 'lang' => true, + 'rows' => 5, + 'cols' => 40, + 'hint' => $this->l('Invalid characters:').' <>;=#{}' + ), + array( + 'type' => 'radio', + 'label' => $this->l('Enable:'), + 'name' => 'active', + 'required' => false, + 'class' => 't', + 'is_bool' => true, + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + 'label' => $this->l('Enabled') + ), + array( + 'id' => 'active_off', + 'value' => 0, + 'label' => $this->l('Disabled') + ) + ), + ), + ), + 'submit' => array( + 'title' => $this->l(' Save '), + 'class' => 'button' + ) + ); + + if (Shop::isFeatureActive()) + { + $this->fields_form['input'][] = array( + 'type' => 'shop', + 'label' => $this->l('Shop association:'), + 'name' => 'checkBoxShopAsso', + 'values' => Shop::getTree() + ); + } + + $this->tpl_form_vars = array( + 'active' => $this->object->active + ); + + return parent::initForm(); + } + + public function initList() + { + $this->toolbar_title = $this->l('Pages in this category'); + $this->toolbar_btn['new'] = array( + 'href' => self::$currentIndex.'&add'.$this->table.'&id_cms_category='.(int)$this->id_cms_category.'&token='.$this->token, + 'desc' => $this->l('Add new') + ); + + return parent::initList(); + } + + public function displayList($token = NULL) + { + /* Display list header (filtering, pagination and column names) */ + $this->displayListHeader($token); + if (!sizeof($this->_list)) + echo ''.$this->l('No items found').''; + + /* Show the content of the table */ + $this->displayListContent($token); + + /* Close list table and submit button */ + $this->displayListFooter($token); + } + + /** + * Modifying initial getList method to display position feature (drag and drop) + */ + public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) + { + if ($order_by && $this->context->cookie->__get($this->table.'Orderby')) + $order_by = $this->context->cookie->__get($this->table.'Orderby'); + else + $order_by = 'position'; + + parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); + } + + function postProcess() + { + if (Tools::isSubmit('viewcms') AND ($id_cms = (int)(Tools::getValue('id_cms'))) AND $cms = new CMS($id_cms, $this->context->language->id) AND Validate::isLoadedObject($cms)) + { + $redir = $this->context->link->getCMSLink($cms); + if (!$cms->active) + { + $admin_dir = dirname($_SERVER['PHP_SELF']); + $admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1); + $redir .= '?adtoken='.Tools::encrypt('PreviewCMS'.$cms->id).'&ad='.$admin_dir; + } + Tools::redirectAdmin($redir); + } + elseif (Tools::isSubmit('deletecms')) + { + if (Tools::getValue('id_cms') == Configuration::get('PS_CONDITIONS_CMS_ID')) + { + Configuration::updateValue('PS_CONDITIONS', 0); + Configuration::updateValue('PS_CONDITIONS_CMS_ID', 0); + } + $cms = new CMS((int)(Tools::getValue('id_cms'))); + $cms->cleanPositions($cms->id_cms_category); + if (!$cms->delete()) + $this->_errors[] = Tools::displayError('An error occurred while deleting object.').' '.$this->table.' ('.Db::getInstance()->getMsgError().')'; + else + Tools::redirectAdmin(self::$currentIndex.'&id_cms_category='.$cms->id_cms_category.'&conf=1&token='.Tools::getAdminTokenLite('AdminCMSContent')); + }/* Delete multiple objects */ + elseif (Tools::getValue('submitDel'.$this->table)) + { + if ($this->tabAccess['delete'] === '1') + { + if (isset($_POST[$this->table.'Box'])) + { + $cms = new CMS(); + $result = true; + $result = $cms->deleteSelection(Tools::getValue($this->table.'Box')); + if ($result) + { + $cms->cleanPositions((int)(Tools::getValue('id_cms_category'))); + Tools::redirectAdmin(self::$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.'); + } + elseif (Tools::isSubmit('submitAddcms') OR Tools::isSubmit('submitAddcmsAndPreview')) + { + parent::validateRules(); + if (!sizeof($this->_errors)) + { + if (!$id_cms = (int)(Tools::getValue('id_cms'))) + { + $cms = new CMS(); + $this->copyFromPost($cms, 'cms'); + if (!$cms->add()) + $this->_errors[] = Tools::displayError('An error occurred while creating object.').' '.$this->table.' ('.Db::getInstance()->getMsgError().')'; + elseif (Tools::isSubmit('submitAddcmsAndPreview')) + { + $preview_url = $this->context->link->getCMSLink($cms, $this->getFieldValue($cms, 'link_rewrite', $this->context->language->id), $this->context->language->id); + + if (!$cms->active) + { + $admin_dir = dirname($_SERVER['PHP_SELF']); + $admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1); + $token = Tools::encrypt('PreviewCMS'.$cms->id); + + $preview_url .= $cms->active ? '' : '&adtoken='.$token.'&ad='.$admin_dir; + } + Tools::redirectAdmin($preview_url); + } + else + Tools::redirectAdmin(self::$currentIndex.'&id_cms_category='.$cms->id_cms_category.'&conf=3&token='.Tools::getAdminTokenLite('AdminCMSContent')); + } + else + { + $cms = new CMS($id_cms); + $this->copyFromPost($cms, 'cms'); + if (!$cms->update()) + $this->_errors[] = Tools::displayError('An error occurred while updating object.').' '.$this->table.' ('.Db::getInstance()->getMsgError().')'; + elseif (Tools::isSubmit('submitAddcmsAndPreview')) + { + $preview_url = $this->context->link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->context->language->id), $this->context->language->id); + if (!$cms->active) + { + $admin_dir = dirname($_SERVER['PHP_SELF']); + $admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1); + $token = Tools::encrypt('PreviewCMS'.$cms->id); + + $preview_url .= $object->active ? '' : '&adtoken='.$token.'&ad='.$admin_dir; + } + Tools::redirectAdmin($preview_url); + } + else + Tools::redirectAdmin(self::$currentIndex.'&id_cms_category='.$cms->id_cms_category.'&conf=4&token='.Tools::getAdminTokenLite('AdminCMSContent')); + } + } + } + elseif (Tools::getValue('position')) + { + if ($this->tabAccess['edit'] !== '1') + $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); + elseif (!Validate::isLoadedObject($object = $this->loadObject())) + $this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' '.$this->table.' '.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(self::$currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=4'.(($id_category = (int)(Tools::getValue('id_cms_category'))) ? ('&id_cms_category='.$id_category) : '').'&token='.Tools::getAdminTokenLite('AdminCMSContent')); + } + /* Change object statuts (active, inactive) */ + elseif (Tools::isSubmit('status') AND Tools::isSubmit($this->identifier)) + { + if ($this->tabAccess['edit'] === '1') + { + if (Validate::isLoadedObject($object = $this->loadObject())) + { + if ($object->toggleStatus()) + Tools::redirectAdmin(self::$currentIndex.'&conf=5'.((int)Tools::getValue('id_cms_category') ? '&id_cms_category='.(int)Tools::getValue('id_cms_category') : '').'&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.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); + } + else + $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); + } + else + parent::postProcess(true); + } +} + + diff --git a/controllers/front/CmsController.php b/controllers/front/CmsController.php index b35d77b48..6da1f3c26 100644 --- a/controllers/front/CmsController.php +++ b/controllers/front/CmsController.php @@ -55,8 +55,8 @@ class CmsControllerCore extends FrontController $this->canonicalRedirection(); /* assignCase (1 = CMS page, 2 = CMS category) */ - if (Validate::isLoadedObject($this->cms) && ($this->cms->isAssociatedToShop() && $this->cms->active || (Tools::getValue('adtoken') == Tools::encrypt('PreviewCMS'.$this->cms->id) - && file_exists(dirname(__FILE__).'/../'.Tools::getValue('ad').'/ajax.php')))) + if (Validate::isLoadedObject($this->cms) + && ($this->cms->isAssociatedToShop() && $this->cms->active || (Tools::getValue('adtoken') == Tools::encrypt('PreviewCMS'.$this->cms->id)))) $this->assignCase = 1; else if (Validate::isLoadedObject($this->cms_category)) $this->assignCase = 2; diff --git a/install-dev/sql/db_settings_lite.sql b/install-dev/sql/db_settings_lite.sql index ac874017b..84a9f01d9 100644 --- a/install-dev/sql/db_settings_lite.sql +++ b/install-dev/sql/db_settings_lite.sql @@ -361,8 +361,8 @@ INSERT INTO `PREFIX_category_lang` (`id_category`, `id_lang`, `name`, `descripti (1, 1, 'Home', '', 'home', NULL, NULL, NULL),(1, 2, 'Accueil', '', 'home', NULL, NULL, NULL),(1, 3, 'Inicio', '', 'home', NULL, NULL, NULL),(1, 4, 'Start', '', 'home', NULL, NULL, NULL),(1, 5, 'Home page', '', 'home', NULL, NULL, NULL); INSERT INTO `PREFIX_order_state` (`id_order_state`, `invoice`, `send_email`, `color`, `unremovable`, `logable`, `delivery`, `shipped`) VALUES -(1, 0, 1, 'RoyalBlue', 1, 0, 0, 0),(2, 1, 1, 'LimeGreen', 1, 1, 0, 0),(3, 1, 1, 'DarkOrange', 1, 1, 1, 0),(4, 1, 1, 'BlueViolet', 1, 1, 1, 1),(5, 1, 0, 'Crimson', 1, 1, 1, 1), -(6, 0, 1, '#999999', 1, 0, 0, 0),(7, 1, 1, 'Orange', 1, 0, 0, 0),(8, 0, 1, 'DarkOrange', 1, 0, 0, 0),(9, 1, 1, 'HotPink', 1, 0, 0, 0),(10, 0, 1, 'RoyalBlue', 1, 0, 0, 0),(11, 0, 0, 'RoyalBlue', 1, 0, 0, 0),(12, 1, 0, 'LimeGreen', 1, 1, 0, 0); +(1, 0, 1, 'RoyalBlue', 1, 0, 0, 0),(2, 1, 1, 'LimeGreen', 1, 1, 0, 0),(3, 1, 1, 'DarkOrange', 1, 1, 1, 0),(4, 1, 1, 'BlueViolet', 1, 1, 1, 1),(5, 1, 0, '#108510', 1, 1, 1, 1), +(6, 0, 1, 'Crimson', 1, 0, 0, 0),(7, 1, 1, '#ec2e15', 1, 0, 0, 0),(8, 0, 1, '#8f0621', 1, 0, 0, 0),(9, 1, 1, 'HotPink', 1, 0, 0, 0),(10, 0, 1, 'RoyalBlue', 1, 0, 0, 0),(11, 0, 0, 'RoyalBlue', 1, 0, 0, 0),(12, 1, 0, 'LimeGreen', 1, 1, 0, 0); INSERT INTO `PREFIX_order_state_lang` (`id_order_state`, `id_lang`, `name`, `template`) VALUES (1, 1, 'Awaiting cheque payment', 'cheque'), @@ -954,7 +954,9 @@ INSERT INTO `PREFIX_tab` (`id_tab`, `class_name`, `id_parent`, `position`) VALUE (101, 'AdminAttributeGenerator', -1, 0), (102, 'AdminAccounting', 0, 16), (103, 'AdminAccountingManagement', 102, 1), -(104, 'AdminAccountingExport', 102, 2); +(104, 'AdminAccountingExport', 102, 2), +(105, 'AdminCMSCategories', -1, 0), +(106, 'AdminCMS', -1, 0); INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) (SELECT 1, id_tab, 1, 1, 1, 1 FROM `PREFIX_tab`); @@ -983,7 +985,9 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (1, 101, 'Combinations generator'), (1, 102, 'Accounting'), (1, 103, 'Account Number Management'), -(1, 104, 'Export'); +(1, 104, 'Export'), +(1, 105, 'CMS categories'), +(1, 106, 'CMS pages'); INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (2, 1, 'Catalogue'),(2, 2, 'Clients'),(2, 3, 'Commandes'),(2, 4, 'Paiement'),(2, 5, 'Transport'), @@ -1010,7 +1014,9 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (2, 101, 'Générateur de combinaisons'), (2, 102, 'Comptabilité'), (2, 103, 'Gestion des numéros de comptes'), -(2, 104, 'Export'); +(2, 104, 'Export'), +(2, 105, 'Catégories CMS'), +(2, 106, 'Pages CMS'); INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (3, 1, 'Catálogo'),(3, 2, 'Clientes'),(3, 3, 'Pedidos'),(3, 4, 'Pago'),(3, 5, 'Transporte'), @@ -1036,7 +1042,9 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (3, 101, 'Combinations generator'), (3, 102, 'Accounting'), (3, 103, 'Account Number Management'), -(3, 104, 'Export'); +(3, 104, 'Export'), +(3, 105, 'CMS categories'), +(3, 106, 'CMS pages'); INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (4, 1, 'Katalog'),(4, 2, 'Kunden'),(4, 3, 'Bestellungen'),(4, 4, 'Zahlung'), @@ -1063,7 +1071,9 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (4, 101, 'Combinations generator'), (4, 102, 'Accounting'), (4, 103, 'Account Number Management'), -(4, 104, 'Export'); +(4, 104, 'Export'), +(4, 105, 'CMS categories'), +(4, 106, 'CMS pages'); INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (5, 1, 'Catalogo'),(5, 2, 'Clienti'),(5, 3, 'Ordini'),(5, 4, 'Pagamento'), @@ -1090,7 +1100,9 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES (5, 101, 'Combinations generator'), (5, 102, 'Accounting'), (5, 103, 'Account Number Management'), -(5, 104, 'Export'); +(5, 104, 'Export'), +(5, 105, 'CMS categories'), +(5, 106, 'CMS pages'); INSERT IGNORE INTO `PREFIX_tab_lang` (`id_tab`, `id_lang`, `name`) (SELECT `id_tab`, id_lang, (SELECT tl.`name` @@ -1111,7 +1123,7 @@ INSERT INTO `PREFIX_quick_access_lang` (`id_quick_access`, `id_lang`, `name`) VA (4, 1, 'New product'),(4, 2, 'Nouveau produit'),(4, 3, 'Nuevo producto'),(4, 4, 'Neues Produkt'),(4, 5, 'Nuovo prodotto'), (5, 1, 'New voucher'),(5, 2, 'Nouveau bon de réduction'),(5, 3, 'Nuevo cupón'),(5, 4, 'Neuer Ermäßigungsgutschein'),(5, 5, 'Nuovo buono sconto'); -INSERT INTO `PREFIX_order_return_state` (`id_order_return_state`, `color`) VALUES (1, '#ADD8E6'),(2, 'BlueViolet'),(3, 'Crimson'),(4, 'HotPink'),(5, 'Orange'); +INSERT INTO `PREFIX_order_return_state` (`id_order_return_state`, `color`) VALUES (1, 'RoyalBlue'),(2, 'BlueViolet'),(3, 'LimeGreen'),(4, 'Crimson'),(5, '#108510'); INSERT INTO `PREFIX_order_return_state_lang` (`id_order_return_state`, `id_lang`, `name`) VALUES (1, 1, 'Waiting for confirmation'),(2, 1, 'Waiting for package'),(3, 1, 'Package received'),(4, 1, 'Return denied'),(5, 1, 'Return completed'), diff --git a/install-dev/sql/upgrade/1.5.0.1.sql b/install-dev/sql/upgrade/1.5.0.1.sql index 978b8079f..4c4086960 100644 --- a/install-dev/sql/upgrade/1.5.0.1.sql +++ b/install-dev/sql/upgrade/1.5.0.1.sql @@ -399,10 +399,6 @@ INSERT INTO `PREFIX_configuration` (`name`, `value`, `date_add`, `date_upd`) ( UPDATE `PREFIX_tab` SET class_name = 'AdminCartRules' WHERE class_name = 'AdminDiscounts'; - - - - UPDATE `PREFIX_hook` SET `name` = 'displayPayment' WHERE `name` = 'payment'; UPDATE `PREFIX_hook` SET `name` = 'actionValidateOrder' WHERE `name` = 'newOrder'; UPDATE `PREFIX_hook` SET `name` = 'actionPaymentConfirmation' WHERE `name` = 'paymentConfirm'; @@ -497,7 +493,9 @@ ALTER TABLE `PREFIX_hook` ADD `is_native` TINYINT( 1 ) NOT NULL DEFAULT '0'; ALTER TABLE `PREFIX_tax` ADD COLUMN `account_number` VARCHAR(64) NOT NULL; -/* PHP:add_new_tab(AdminAttributeGenerator, fr:Générateur de combinaisons|es:Combinations generator|en:Combinations generator|de:Combinations generator|it:Combinations generator, 1); */; +/* PHP:add_new_tab(AdminAttributeGenerator, fr:Générateur de combinaisons|es:Combinations generator|en:Combinations generator|de:Combinations generator|it:Combinations generator, -1); */; +/* PHP:add_new_tab(AdminCMSCategories, fr:Catégories CMS|es:CMS categories|en:CMS categories|de:CMS categories|it:CMS categories, -1); */; +/* PHP:add_new_tab(AdminCMS, fr:Pages CMS|es:CMS pages|en:CMS pages|de:CMS pages|it:CMS pages, -1); */; UPDATE `PREFIX_quick_access` SET `link` = 'index.php?controller=AdminCategories&addcategory' WHERE `id_quick_access` = 3; UPDATE `PREFIX_quick_access` SET `link` = 'index.php?controller=AdminProducts&addproduct' WHERE `id_quick_access` = 4;