[*] BO : #PSFV-94 - added AdminCMSContentController, AdminCMSController, AdminCMSCategoriesController

This commit is contained in:
tDidierjean
2011-11-16 14:18:36 +00:00
parent 73c2a7d75b
commit 3e0bb0ba0c
16 changed files with 886 additions and 710 deletions

View File

@@ -1,348 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
* @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
'<div class="warn draft" style="'.($active ? 'display:none' : '').'">
<p>
<span style="float: left">
<img src="../img/admin/warn2.png" />
'.$this->l('Your CMS page will be saved as a draft').'
</span>
<input type="button" class="button" style="float: right;" value="'.$this->l('Save and preview').'" onclick="submitAddcmsAndPreview();">
<input type="hidden" name="previewSubmitAddcmsAndPreview" id="previewSubmitAddcmsAndPreview" />
<br class="clear" />
</p>
</div>';
}
public function displayForm($isMainTab = true)
{
parent::displayForm();
$obj = $this->loadObject(true);
$divLangName = 'meta_title¤meta_description¤meta_keywords¤ccontent¤link_rewrite';
echo '
<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.Tools::getAdminTokenLite('AdminCMSContent').'" method="post" name="cms" id="cms">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
'.$this->_displayDraftWarning($obj->active).'
<fieldset><legend><img src="../img/admin/cms.gif" />'.$this->l('CMS page').'</legend>';
// META TITLE
echo '<label>'.$this->l('CMS Category:').' </label>
<div class="margin-form">
<select name="id_cms_category">';
$categories = CMSCategory::getCategories($this->context->language->id, false);
CMSCategory::recurseCMSCategory($categories, $categories[0][1], 1, $this->getFieldValue($obj, 'id_cms_category'));
echo '
</select>
</div>
<label>'.$this->l('Meta title').' </label>
<div class="margin-form">';
foreach ($this->_languages as $language)
echo ' <div id="meta_title_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input size="40" type="text" onkeyup="copyMeta2friendlyURL();" id="name_'.$language['id_lang'].'" name="meta_title_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_title', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'meta_title');
echo ' </div><div class="clear space">&nbsp;</div>';
// META DESCRIPTION
echo ' <label>'.$this->l('Meta description').' </label>
<div class="margin-form">';
foreach ($this->_languages as $language)
echo ' <div id="meta_description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input size="50" type="text" name="meta_description_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_description', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'meta_description');
echo ' </div><div class="clear space">&nbsp;</div>';
// META KEYWORDS
echo ' <label>'.$this->l('Meta keywords').' </label>
<div class="margin-form">';
foreach ($this->_languages as $language)
echo ' <div id="meta_keywords_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input size="50" type="text" name="meta_keywords_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_keywords', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'meta_keywords');
echo ' </div><div class="clear space">&nbsp;</div>';
// LINK REWRITE
echo ' <label>'.$this->l('Friendly URL').' </label>
<div class="margin-form">';
foreach ($this->_languages as $language)
echo ' <div id="link_rewrite_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input size="30" type="text" id="input_link_rewrite_'.$language['id_lang'].'" name="link_rewrite_'.$language['id_lang'].'" onkeyup="this.value = str2url(this.value); updateFriendlyURL();" value="'.htmlentities($this->getFieldValue($obj, 'link_rewrite', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'link_rewrite');
echo ' </div><div class="clear space">&nbsp;</div>';
// CONTENT
echo ' <label>'.$this->l('Page content').' </label>
<div class="margin-form">';
foreach ($this->_languages as $language)
echo ' <div id="ccontent_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').';float: left;">
<textarea class="rte" cols="80" rows="30" id="content_'.$language['id_lang'].'" name="content_'.$language['id_lang'].'">'.htmlentities(stripslashes($this->getFieldValue($obj, 'content', $language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'ccontent');
echo ' </div><div class="clear space">&nbsp;</div>
<label>'.$this->l('Enable:').' </label>
<div class="margin-form">
<input type="radio" name="active" id="active_on" onclick="toggleDraftWarning(false);" value="1" '.($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
<input type="radio" name="active" id="active_off" onclick="toggleDraftWarning(true);" value="0" '.(!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
</div>';
if (Shop::isFeatureActive())
{
echo '<label>'.$this->l('Shop association:').'</label><div class="margin-form">';
$this->displayAssoShop();
echo '</div>';
}
// SUBMIT
echo ' <div class="margin-form space">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
</div>
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
</fieldset><br />
'.$this->_displayDraftWarning($obj->active).'
</form>';
// 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 '
<script type="text/javascript">
var iso = \''.$isoTinyMCE.'\' ;
var pathCSS = \''._THEME_CSS_DIR_.'\' ;
var ad = \''.$ad.'\' ;
</script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce.inc.js"></script>';
}
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 '<h3>'.(!$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())).'"</h3>';
echo '<a href="'.self::$currentIndex.'&id_cms_category='.$id_cms_category.'&add'.$this->table.'&token='.Tools::getAdminTokenLite('AdminCMSContent').'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add a new page').'</a>
<div style="margin:10px;">';
$this->displayList($token);
echo '</div>';
}
public function displayList($token = NULL)
{
/* Display list header (filtering, pagination and column names) */
$this->displayListHeader($token);
if (!sizeof($this->_list))
echo '<tr><td class="center" colspan="'.(sizeof($this->fieldsDisplay) + 2).'">'.$this->l('No items found').'</td></tr>';
/* 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.').' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>';
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.').' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>';
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.').' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>';
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.').' <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(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.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
else
parent::postProcess(true);
}
}

View File

@@ -1,283 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
* @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 '<tr><td class="center" colspan="'.(sizeof($this->fieldsDisplay) + 2).'">'.$this->l('No items found').'</td></tr>';
/* 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 '<h3>'.(!$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())).'"</h3>';
echo '<a href="'.__PS_BASE_URI__.substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)).'?tab=AdminCMSContent&add'.$this->table.'&id_parent='.Tools::getValue('id_cms_category').'&token='.($token!=NULL ? $token : $this->token).'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add a new sub CMS Category').'</a>
<div style="margin:10px;">';
$this->displayList($token);
echo '</div>';
}
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.').' <b>'.$this->table.'</b> '.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.').' <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(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.').' <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(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 '
<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.($token!=NULL ? $token : $this->token).'" method="post" enctype="multipart/form-data">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset style="width:520px"><legend><img src="../img/admin/tab-categories.gif" />'.$this->l('CMS Category').'</legend>
<label>'.$this->l('Name:').' </label>
<div class="margin-form translatable">';
foreach ($this->_languages as $language)
echo '
<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input type="text" style="width: 260px" name="name_'.$language['id_lang'].'" id="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" '.((!$obj->id) ? ' onkeyup="copy2friendlyURL();"' : '').' /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</div>';
echo ' <p class="clear"></p>
</div>
<label>'.$this->l('Displayed:').' </label>
<div class="margin-form">
<input type="radio" name="active" id="active_on" value="1" '.($active ? 'checked="checked" ' : '').'/>
<label class="t" for="active_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
<input type="radio" name="active" id="active_off" value="0" '.(!$active ? 'checked="checked" ' : '').'/>
<label class="t" for="active_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
</div>
<label>'.$this->l('Parent CMS Category:').' </label>
<div class="margin-form">
<select name="id_parent">';
$categories = CMSCategory::getCategories($this->context->language->id, false);
CMSCategory::recurseCMSCategory($categories, $categories[0][1], 1, $this->getFieldValue($obj, 'id_parent'));
echo '
</select>
</div>
<label>'.$this->l('Description:').' </label>
<div class="margin-form translatable">';
foreach ($this->_languages as $language)
echo '
<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<textarea name="description_'.$language['id_lang'].'" rows="5" cols="40">'.htmlentities($this->getFieldValue($obj, 'description', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
</div>';
echo ' <p class="clear"></p>
</div>
<div class="clear"><br /></div>
<label>'.$this->l('Meta title:').' </label>
<div class="margin-form translatable">';
foreach ($this->_languages as $language)
echo '
<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input type="text" name="meta_title_'.$language['id_lang'].'" id="meta_title_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_title', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</div>';
echo ' <p class="clear"></p>
</div>
<label>'.$this->l('Meta description:').' </label>
<div class="margin-form translatable">';
foreach ($this->_languages as $language)
echo '<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input type="text" name="meta_description_'.$language['id_lang'].'" id="meta_description_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_description', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</div>';
echo ' <p class="clear"></p>
</div>
<label>'.$this->l('Meta keywords:').' </label>
<div class="margin-form translatable">';
foreach ($this->_languages as $language)
echo '
<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input type="text" name="meta_keywords_'.$language['id_lang'].'" id="meta_keywords_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_keywords', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</div>';
echo ' <p class="clear"></p>
</div>
<label>'.$this->l('Friendly URL:').' </label>
<div class="margin-form translatable">';
foreach ($this->_languages as $language)
echo '<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input type="text" name="link_rewrite_'.$language['id_lang'].'" id="link_rewrite_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'link_rewrite', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" onkeyup="this.value = str2url(this.value);" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Only letters and the minus (-) character are allowed').'<span class="hint-pointer">&nbsp;</span></span>
</div>';
echo ' <p class="clear"></p>
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l('Save and back to parent CMS Category').'" name="submitAdd'.$this->table.'AndBackToParent" class="button" />
&nbsp;<input type="submit" class="button" name="submitAdd'.$this->table.'" value="'.$this->l('Save').'"/>
</div>
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
</fieldset>
</form>
<p class="clear"></p>';
}
}

View File

@@ -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;}

View File

@@ -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 <contact@prestashop.com>
* @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('<input type="hidden" name="'+btn_submit.attr("name")+'AndPreview" value="1" />');
$('#{$table}_form').submit();
});
}
}
$('#active_on').bind('click', function(){
toggleDraftWarning(true);
});
$('#active_off').bind('click', function(){
toggleDraftWarning(false);
});
});
{/block}
{block name="leadin"}
<div class="warn draft" style="{if $active}display:none{/if}">
<p>
<span style="float: left">
{l s='Your CMS page will be saved as a draft'}
</span>
<br class="clear" />
</p>
</div>
{/block}
{block name="start_field_block"}
<div class="margin-form">
{if $input.type == 'select_category'}
<select name="{$input.name}">
{$input.options.html}
</select>
{/if}
{/block}

View File

@@ -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 <contact@prestashop.com>
* @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"}
<div class="margin-form">
{if $input.type == 'select_category'}
<select name="id_parent">
{$input.options.html}
</select>
{/if}
{/block}

View File

@@ -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 <contact@prestashop.com>
* @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)}
<div class="cat_bar">
<span style="color: #3C8534;">{l s='Current category'} :</span>&nbsp;&nbsp;&nbsp;{$cms_breadcrumb}
</div>
{/if}
{$content}

View File

@@ -78,9 +78,10 @@
{if isset($input.lang)}
<div class="translatable">
{foreach $languages as $language}
<div class="lang_{$language.id_lang}" id="{$input.name}_{$language.id_lang}" style="display:{if $language.id_lang == $defaultFormLanguage}block{else}none{/if}; float: left;">
<div class="lang_{$language.id_lang}" style="display:{if $language.id_lang == $defaultFormLanguage}block{else}none{/if}; float: left;">
<input type="text"
name="{$input.name}_{$language.id_lang}"
id="{if isset($input.id)}{$input.id}_{$language.id_lang}{else}{$input.name}_{$language.id_lang}{/if}"
value="{$fields_value[$input.name][$language.id_lang]}"
{if isset($input.size)}size="{$input.size}"{/if}
{if isset($input.maxlength)}maxlength="{$input.maxlength}"{/if}

View File

@@ -165,7 +165,7 @@ class CMSCore extends ObjectModel
FROM `'._DB_PREFIX_.'cms`
WHERE `id_cms_category` = '.(int)($id_category).'
ORDER BY `position`');
for ($i = 0, $total = count($result); $i < $sizeof; ++$i)
for ($i = 0, $total = count($result); $i < $total; ++$i)
{
$sql = 'UPDATE `'._DB_PREFIX_.'cms`
SET `position` = '.(int)$i.'

View File

@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -43,7 +43,7 @@ class CMSCategoryCore extends ObjectModel
/** @var integer Parent CMSCategory ID */
public $id_parent;
/** @var integer category position */
public $position;
@@ -152,7 +152,7 @@ class CMSCategoryCore extends ObjectModel
if (is_null($id_lang))
$id_lang = Context::getContext()->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)));

View File

@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*

View File

@@ -0,0 +1,278 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
* @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.').' <b>'.$this->table.'</b> '.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.').' <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(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.').' <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(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();
}
}

View File

@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -20,16 +20,12 @@
*
* @author PrestaShop SA <contact@prestashop.com>
* @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 '<br /><br /><a href="'.self::$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
}
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 '<br /><br /><a href="'.self::$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
}
$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 '<div class="cat_bar"><span style="color: #3C8534;">'.$this->l('Current category').' :</span>&nbsp;&nbsp;&nbsp;'.getPath($catBarIndex, $id_cms_category,'','','cms').'</div>';
echo '<h2>'.$this->l('Categories').'</h2>';
$this->adminCMSCategories->display($this->token);
echo '<div style="margin:10px">&nbsp;</div>';
echo '<h2>'.$this->l('Pages in this category').'</h2>';
$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();
}
}

View File

@@ -0,0 +1,350 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
* @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.'&amp;add'.$this->table.'&amp;id_cms_category='.(int)$this->id_cms_category.'&amp;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 '<tr><td class="center" colspan="'.(sizeof($this->fieldsDisplay) + 2).'">'.$this->l('No items found').'</td></tr>';
/* 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.').' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>';
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.').' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>';
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.').' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>';
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.').' <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(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.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
else
parent::postProcess(true);
}
}

View File

@@ -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;

View File

@@ -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'),

View File

@@ -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;