[-] BO : #PSFV-492 : BugFix CMS pages & categories
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13540 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+14
-6
@@ -160,11 +160,13 @@ class CMSCore extends ObjectModel
|
||||
|
||||
public static function cleanPositions($id_category)
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT `id_cms`
|
||||
FROM `'._DB_PREFIX_.'cms`
|
||||
WHERE `id_cms_category` = '.(int)$id_category.'
|
||||
ORDER BY `position`');
|
||||
$sql = 'SELECT `id_cms`
|
||||
FROM `'._DB_PREFIX_.'cms`
|
||||
WHERE `id_cms_category` = '.(int)$id_category.'
|
||||
ORDER BY `position`';
|
||||
|
||||
$result = Db::getInstance()->executeS($sql);
|
||||
|
||||
for ($i = 0, $total = count($result); $i < $total; ++$i)
|
||||
{
|
||||
$sql = 'UPDATE `'._DB_PREFIX_.'cms`
|
||||
@@ -173,12 +175,17 @@ class CMSCore extends ObjectModel
|
||||
AND `id_cms` = '.(int)$result[$i]['id_cms'];
|
||||
Db::getInstance()->execute($sql);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getLastPosition($id_category)
|
||||
{
|
||||
return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'cms` WHERE `id_cms_category` = '.(int)$id_category));
|
||||
$sql = 'SELECT MAX(position) + 1
|
||||
FROM `'._DB_PREFIX_.'cms`
|
||||
WHERE `id_cms_category` = '.(int)$id_category;
|
||||
|
||||
return (Db::getInstance()->getValue($sql));
|
||||
}
|
||||
|
||||
public static function getCMSPages($id_lang = null, $id_cms_category = null, $active = true)
|
||||
@@ -207,6 +214,7 @@ class CMSCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'lang` AS l ON c.`id_lang` = l.`id_lang`
|
||||
WHERE c.`id_cms` = '.(int)$id_cms.'
|
||||
AND l.`active` = 1';
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,7 +792,7 @@ class ShopCore extends ObjectModel
|
||||
if (!isset($asso_tables[$table]) || $asso_tables[$table]['type'] != 'shop')
|
||||
return;
|
||||
|
||||
$sql = (($inner_join) ? ' INNER' : ' LEFT').' JOIN '._DB_PREFIX_.$table.'_shop '.$table_alias.'
|
||||
$sql = (($inner_join) ? ' INNER' : ' RIGHT').' JOIN '._DB_PREFIX_.$table.'_shop '.$table_alias.'
|
||||
ON '.$table_alias.'.id_'.$table.' = '.$alias.'.id_'.$table.'
|
||||
AND '.$table_alias.'.id_shop IN('.implode(', ', $this->getListOfID()).') ';
|
||||
return $sql;
|
||||
|
||||
@@ -112,7 +112,7 @@ class AdminCmsContentControllerCore extends AdminController
|
||||
|| isset($_GET['updatecms_category'])
|
||||
|| isset($_GET['addcms_category']))
|
||||
$this->display = 'edit_category';
|
||||
elseif (((Tools::isSubmit('submitAddcms') || Tools::isSubmit('submitAddcmsAndStay')) && count($this->adminCMS->errors))
|
||||
else if (((Tools::isSubmit('submitAddcms') || Tools::isSubmit('submitAddcmsAndStay')) && count($this->adminCMS->errors))
|
||||
|| isset($_GET['updatecms'])
|
||||
|| isset($_GET['addcms']))
|
||||
$this->display = 'edit_page';
|
||||
@@ -127,9 +127,12 @@ class AdminCmsContentControllerCore extends AdminController
|
||||
|| 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('statuscms') && Tools::isSubmit('id_cms'))
|
||||
|| (Tools::isSubmit('way') && Tools::isSubmit('id_cms')) && (Tools::isSubmit('position')))
|
||||
{
|
||||
$this->adminCMS->postProcess();
|
||||
}
|
||||
else if (Tools::isSubmit('submitDelcms_category')
|
||||
|| Tools::isSubmit('submitAddcms_categoryAndBackToParent')
|
||||
|| Tools::isSubmit('submitAddcms_category')
|
||||
|| isset($_GET['deletecms_category'])
|
||||
|
||||
@@ -53,7 +53,7 @@ class AdminCmsControllerCore extends AdminController
|
||||
$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);
|
||||
$this->_filter = 'AND c.id_cms_category = '.(int)$this->_category->id;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -232,7 +232,7 @@ class AdminCmsControllerCore extends AdminController
|
||||
Configuration::updateValue('PS_CONDITIONS', 0);
|
||||
Configuration::updateValue('PS_CONDITIONS_CMS_ID', 0);
|
||||
}
|
||||
$cms = new CMS((int)(Tools::getValue('id_cms')));
|
||||
$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>';
|
||||
@@ -330,7 +330,7 @@ class AdminCmsControllerCore extends AdminController
|
||||
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') && Tools::isSubmit($this->identifier))
|
||||
elseif (Tools::isSubmit('statuscms') && Tools::isSubmit($this->identifier))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
|
||||
@@ -131,7 +131,10 @@ class BlockCMSModel extends ObjectModel
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'cms_block` (`id_cms_category`, `location`, `position`, `display_store`)
|
||||
VALUES('.(int)$id_category.', '.(int)$location.', '.(int)$position.', '.(int)$display_store.')';
|
||||
|
||||
return Db::getInstance()->execute($sql);
|
||||
if (Db::getInstance()->execute($sql))
|
||||
return Db::getInstance()->Insert_ID();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function insertCMSBlockLang($id_cms_block, $id_lang)
|
||||
@@ -154,10 +157,10 @@ class BlockCMSModel extends ObjectModel
|
||||
return Db::getInstance()->Insert_ID();
|
||||
}
|
||||
|
||||
public static function insertCMSBlockShop($id_cms_block, $id_shop)
|
||||
public static function insertCMSBlockShop($id_cms_block, $id_group_shop, $id_shop)
|
||||
{
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'cms_block_shop` (`id_cms_block`, `id_shop`)
|
||||
VALUES('.(int)$id_cms_block.', '.(int)$id_shop.')';
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'cms_block_shop` (`id_cms_block`, `id_group_shop`, `id_shop`)
|
||||
VALUES('.(int)$id_cms_block.', '.(int)$id_group_shop.', '.(int)$id_shop.')';
|
||||
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
@@ -254,12 +257,11 @@ class BlockCMSModel extends ObjectModel
|
||||
|
||||
public static function getCMSTitlesFooter()
|
||||
{
|
||||
$content = array();
|
||||
$context = Context::getContext();
|
||||
$footerCms = Configuration::get('FOOTER_CMS', null, $context->shop->getGroupID(), $context->shop->getID());
|
||||
|
||||
if (empty($footerCms))
|
||||
return $content;
|
||||
if (empty($footerCms))
|
||||
return array();
|
||||
|
||||
$cmsCategories = explode('|', $footerCms);
|
||||
foreach ($cmsCategories as $cmsCategory)
|
||||
@@ -287,7 +289,8 @@ class BlockCMSModel extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT cl.`name`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms_category_lang` cl
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category` c ON (cl.`id_cms_category` = c.`id_cms_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category` c
|
||||
ON (cl.`id_cms_category` = c.`id_cms_category`)
|
||||
WHERE cl.`id_cms_category` = '.(int)$id.'
|
||||
AND (c.`active` = 1 OR c.`id_cms_category` = 1)
|
||||
AND cl.`id_lang` = '.(int)Context::getContext()->language->id;
|
||||
@@ -299,7 +302,8 @@ class BlockCMSModel extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT cl.`name`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms_category_lang` cl
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category` c ON (cl.`id_cms_category` = c.`id_cms_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category` c
|
||||
ON (cl.`id_cms_category` = c.`id_cms_category`)
|
||||
WHERE cl.`id_cms_category` = '.(int)$id.'
|
||||
AND (c.`active` = 1 OR c.`id_cms_category` = 1)
|
||||
AND cl.`id_lang` = '.(int)Context::getContext()->language->id;
|
||||
@@ -311,7 +315,8 @@ class BlockCMSModel extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT cl.`meta_title`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms_lang` cl
|
||||
INNER JOIN `'._DB_PREFIX_.'cms` c ON (cl.`id_cms` = c.`id_cms`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms` c
|
||||
ON (cl.`id_cms` = c.`id_cms`)
|
||||
WHERE cl.`id_cms` = '.(int)$id.'
|
||||
AND (c.`active` = 1 OR c.`id_cms` = 1)
|
||||
AND cl.`id_lang` = '.(int)Context::getContext()->language->id;
|
||||
@@ -319,34 +324,45 @@ class BlockCMSModel extends ObjectModel
|
||||
return Db::getInstance()->getRow($sql);
|
||||
}
|
||||
|
||||
public static function getCMSCategoriesByLocation($location)
|
||||
public static function getCMSCategoriesByLocation($location, $id_shop = false)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = 'SELECT bc.`id_cms_block`, bc.`id_cms_category`, bc.`display_store`, ccl.`link_rewrite`, ccl.`name` category_name, bcl.`name` block_name
|
||||
FROM `'._DB_PREFIX_.'cms_block` bc
|
||||
LEFT JOIN `'._DB_PREFIX_.'cms_block_shop` bcs ON (bcs.id_cms_block = bc.id_cms_block)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` ccl ON (bc.`id_cms_category` = ccl.`id_cms_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_block_lang` bcl ON (bc.`id_cms_block` = bcl.`id_cms_block`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'cms_block_shop` bcs
|
||||
ON (bcs.id_cms_block = bc.id_cms_block)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` ccl
|
||||
ON (bc.`id_cms_category` = ccl.`id_cms_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_block_lang` bcl
|
||||
ON (bc.`id_cms_block` = bcl.`id_cms_block`)
|
||||
WHERE bc.`location` = '.(int)($location).'
|
||||
AND ccl.`id_lang` = '.(int)$context->language->id.'
|
||||
AND bcl.`id_lang` = '.(int)$context->language->id.'
|
||||
AND bcs.id_shop = '.(int)$context->shop->getID(true).'
|
||||
AND bcs.id_shop = '.($id_shop ? (int)$id_shop : (int)$context->shop->getID()).'
|
||||
ORDER BY `position`';
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
|
||||
public static function getCMSPages($id_cms_category)
|
||||
public static function getCMSPages($id_cms_category, $id_shop = false)
|
||||
{
|
||||
$id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->getID();
|
||||
|
||||
$sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms` c
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_lang` cl ON (c.`id_cms` = cl.`id_cms`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_shop` cs
|
||||
ON (c.`id_cms` = cs.`id_cms`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_lang` cl
|
||||
ON (c.`id_cms` = cl.`id_cms`)
|
||||
WHERE c.`id_cms_category` = '.(int)$id_cms_category.'
|
||||
AND cs.`id_shop` = '.(int)$id_shop.'
|
||||
AND cl.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND c.`active` = 1
|
||||
ORDER BY `position`';
|
||||
|
||||
// d($sql);
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
|
||||
@@ -354,8 +370,10 @@ class BlockCMSModel extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT cl.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms_block_page` bcp
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_lang` cl ON (bcp.`id_cms` = cl.`id_cms`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms` c ON (bcp.`id_cms` = c.`id_cms`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_lang` cl
|
||||
ON (bcp.`id_cms` = cl.`id_cms`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms` c
|
||||
ON (bcp.`id_cms` = c.`id_cms`)
|
||||
WHERE bcp.`id_cms_block` = '.(int)$id_block.'
|
||||
AND cl.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND bcp.`is_category` = 0
|
||||
@@ -369,7 +387,8 @@ class BlockCMSModel extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT bcp.`id_cms`, cl.`name`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms_block_page` bcp
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (bcp.`id_cms` = cl.`id_cms_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl
|
||||
ON (bcp.`id_cms` = cl.`id_cms_category`)
|
||||
WHERE bcp.`id_cms_block` = '.(int)$id_cms_block.'
|
||||
AND cl.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND bcp.`is_category` = 1';
|
||||
@@ -383,7 +402,8 @@ class BlockCMSModel extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT bcp.`id_cms_category`, bcp.`id_parent`, bcp.`level_depth`, bcp.`active`, bcp.`position`, cl.`name`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms_category` bcp
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (bcp.`id_cms_category` = cl.`id_cms_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl
|
||||
ON (bcp.`id_cms_category` = cl.`id_cms_category`)
|
||||
WHERE cl.`id_lang` = '.(int)Context::getContext()->language->id;
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
@@ -392,7 +412,8 @@ class BlockCMSModel extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT bcp.`id_cms_category`, bcp.`id_parent`, bcp.`level_depth`, bcp.`active`, bcp.`position`, cl.`name`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms_category` bcp
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (bcp.`id_cms_category` = cl.`id_cms_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl
|
||||
ON (bcp.`id_cms_category` = cl.`id_cms_category`)
|
||||
WHERE cl.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND bcp.`id_parent` = '.(int)$from;
|
||||
|
||||
@@ -415,36 +436,38 @@ class BlockCMSModel extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT cb.`id_cms_category`, cb.`location`, cb.`position`, cb.`display_store`, cbl.id_lang, cbl.name
|
||||
FROM `'._DB_PREFIX_.'cms_block` cb
|
||||
LEFT JOIN `'._DB_PREFIX_.'cms_block_lang` cbl ON (cbl.`id_cms_block` = cb.`id_cms_block`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'cms_block_lang` cbl
|
||||
ON (cbl.`id_cms_block` = cb.`id_cms_block`)
|
||||
WHERE cb.`id_cms_block` = '.(int)$id_cms_block;
|
||||
|
||||
$cmsBlocks = Db::getInstance()->executeS($sql);
|
||||
// $store_display_update = array(0, $size = count($cmsBlocks), $display = Configuration::get('PS_STORES_DISPLAY_FOOTER'));
|
||||
|
||||
foreach ($cmsBlocks as $cmsBlock)
|
||||
{
|
||||
$results[(int)$cmsBlock['id_lang']] = $cmsBlock;
|
||||
$restuls[(int)$cmsBlock['id_lang']]['name'] = $cmsBlock['name'];
|
||||
|
||||
/* Don't know if needed */
|
||||
// $cmsBlocks['name'][(int)$cmsBlock['id_lang']] = $cmsBlock['name'];
|
||||
// if ($store_display_update['0'] < $store_display_update['1'])
|
||||
// $cmsBlocks[$store_display_update['0']]['display_store'] = $store_display_update['2'];
|
||||
// $store_display_update['0']++;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/* Get all CMS blocks by location */
|
||||
public static function getCMSBlocksByLocation($location)
|
||||
public static function getCMSBlocksByLocation($location, $id_shop = false)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = 'SELECT bc.`id_cms_block`, bcl.`name` block_name, ccl.`name` category_name, bc.`position`, bc.`id_cms_category`, bc.`display_store`
|
||||
FROM `'._DB_PREFIX_.'cms_block` bc
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` ccl ON (bc.`id_cms_category` = ccl.`id_cms_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_block_lang` bcl ON (bc.`id_cms_block` = bcl.`id_cms_block`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'cms_block_shop` bcs
|
||||
ON (bcs.id_cms_block = bc.id_cms_block)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` ccl
|
||||
ON (bc.`id_cms_category` = ccl.`id_cms_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_block_lang` bcl
|
||||
ON (bc.`id_cms_block` = bcl.`id_cms_block`)
|
||||
WHERE ccl.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND bcl.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND bc.`location` = '.(int)$location.'
|
||||
AND bcs.id_shop = '.($id_shop ? (int)$id_shop : (int)$context->shop->getID()).'
|
||||
ORDER BY bc.`position`';
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
@@ -455,8 +478,10 @@ class BlockCMSModel extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT bc.`id_cms_block`, bcl.`name` block_name, ccl.`name` category_name, bc.`position`, bc.`id_cms_category`, bc.`display_store`
|
||||
FROM `'._DB_PREFIX_.'cms_block` bc
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` ccl ON (bc.`id_cms_category` = ccl.`id_cms_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_block_lang` bcl ON (bc.`id_cms_block` = bcl.`id_cms_block`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` ccl
|
||||
ON (bc.`id_cms_category` = ccl.`id_cms_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_block_lang` bcl
|
||||
ON (bc.`id_cms_block` = bcl.`id_cms_block`)
|
||||
WHERE ccl.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND bcl.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
ORDER BY bc.`position`';
|
||||
@@ -465,12 +490,13 @@ class BlockCMSModel extends ObjectModel
|
||||
}
|
||||
|
||||
/* Get all CMS blocks */
|
||||
public static function getAllCMSStructure()
|
||||
public static function getAllCMSStructure($id_shop = false)
|
||||
{
|
||||
$categories = BlockCMSModel::getCMSCategories();
|
||||
$id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->getID();
|
||||
|
||||
foreach ($categories as $key => $value)
|
||||
$categories[$key]['cms_pages'] = BlockCMSModel::getCMSPages($value['id_cms_category']);
|
||||
$categories[$key]['cms_pages'] = BlockCMSModel::getCMSPages($value['id_cms_category'], $id_shop);
|
||||
|
||||
return $categories;
|
||||
}
|
||||
@@ -495,11 +521,11 @@ class BlockCMSModel extends ObjectModel
|
||||
return $titles;
|
||||
}
|
||||
|
||||
public static function getCMSTitles($location)
|
||||
public static function getCMSTitles($location, $id_group_shop = false, $id_shop = false)
|
||||
{
|
||||
$content = array();
|
||||
$context = Context::getContext();
|
||||
$cmsCategories = BlockCMSModel::getCMSCategoriesByLocation($location);
|
||||
$cmsCategories = BlockCMSModel::getCMSCategoriesByLocation($location, $id_group_shop, $id_shop);
|
||||
|
||||
if (is_array($cmsCategories) && count($cmsCategories))
|
||||
{
|
||||
|
||||
@@ -227,7 +227,7 @@ class BlockCms extends Module
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'on',
|
||||
'name' => $this->l('Display the Footer\'s various links'),
|
||||
'name' => $this->l('Display the Footer\'s informations'),
|
||||
'val' => '1'
|
||||
),
|
||||
),
|
||||
@@ -457,7 +457,7 @@ class BlockCms extends Module
|
||||
|
||||
protected function _postValidation()
|
||||
{
|
||||
$this->errors = array();
|
||||
$this->_errors = array();
|
||||
|
||||
if (Tools::isSubmit('submitBlockCMS'))
|
||||
{
|
||||
@@ -465,24 +465,24 @@ class BlockCms extends Module
|
||||
$cmsBoxes = Tools::getValue('cmsBox');
|
||||
|
||||
if (!Validate::isInt(Tools::getValue('display_stores')) || (Tools::getValue('display_stores') != 0 && Tools::getValue('display_stores') != 1))
|
||||
$this->errors[] = Tools::displayError('Invalid store display value');
|
||||
$this->_errors[] = Tools::displayError('Invalid store display value');
|
||||
if (!Validate::isInt(Tools::getValue('block_location')) || (Tools::getValue('block_location') != BlockCMSModel::LEFT_COLUMN && Tools::getValue('block_location') != BlockCMSModel::RIGHT_COLUMN))
|
||||
$this->errors[] = Tools::displayError('Invalid block location');
|
||||
$this->_errors[] = Tools::displayError('Invalid block location');
|
||||
if (!is_array($cmsBoxes))
|
||||
$this->errors[] = Tools::displayError('You must choose at least one page or subcategory to create a CMS block.');
|
||||
$this->_errors[] = Tools::displayError('You must choose at least one page or subcategory to create a CMS block.');
|
||||
else
|
||||
{
|
||||
foreach ($cmsBoxes as $cmsBox)
|
||||
if (!preg_match('#^[01]_[0-9]+$#', $cmsBox))
|
||||
$this->errors[] = Tools::displayError('Invalid CMS page or category');
|
||||
$this->_errors[] = Tools::displayError('Invalid CMS page or category');
|
||||
foreach ($this->context->controller->_languages as $language)
|
||||
if (strlen(Tools::getValue('block_name_'.$language['id_lang'])) > 40)
|
||||
$this->errors[] = Tools::displayError('Block name is too long');
|
||||
$this->_errors[] = Tools::displayError('Block name is too long');
|
||||
}
|
||||
}
|
||||
else if (Tools::isSubmit('deleteBlockCMS') && !Validate::isInt(Tools::getValue('id_cms_block')))
|
||||
{
|
||||
$this->errors[] = Tools::displayError('Invalid id_cms_block');
|
||||
$this->_errors[] = Tools::displayError('Invalid id_cms_block');
|
||||
}
|
||||
else if (Tools::isSubmit('submitFooterCMS'))
|
||||
{
|
||||
@@ -490,7 +490,7 @@ class BlockCms extends Module
|
||||
{
|
||||
foreach (Tools::getValue('footerBox') as $cmsBox)
|
||||
if (!preg_match('#^[01]_[0-9]+$#', $cmsBox))
|
||||
$this->errors[] = Tools::displayError('Invalid CMS page or category');
|
||||
$this->_errors[] = Tools::displayError('Invalid CMS page or category');
|
||||
}
|
||||
|
||||
$empty_footer_text = true;
|
||||
@@ -513,7 +513,7 @@ class BlockCms extends Module
|
||||
}
|
||||
|
||||
if (!$empty_footer_text && empty($footer_text[(int)Configuration::get('PS_LANG_DEFAULT')]))
|
||||
$this->errors[] = Tools::displayError('Please provide a footer text for the default language');
|
||||
$this->_errors[] = Tools::displayError('Please provide a footer text for the default language');
|
||||
else
|
||||
{
|
||||
foreach ($this->context->controller->_languages as $language)
|
||||
@@ -521,11 +521,11 @@ class BlockCms extends Module
|
||||
}
|
||||
|
||||
if ((Tools::getValue('cms_footer_on') != 0) && (Tools::getValue('cms_footer_on') != 1))
|
||||
$this->errors[] = Tools::displayError('Invalid activation footer');
|
||||
$this->_errors[] = Tools::displayError('Invalid activation footer');
|
||||
}
|
||||
if (count($this->errors))
|
||||
if (count($this->_errors))
|
||||
{
|
||||
foreach ($this->errors as $err)
|
||||
foreach ($this->_errors as $err)
|
||||
$this->_html .= '<div class="alert error">'.$err.'</div>';
|
||||
|
||||
return false;
|
||||
@@ -538,6 +538,7 @@ class BlockCms extends Module
|
||||
if ($this->_postValidation() == false)
|
||||
return false;
|
||||
|
||||
$this->_errors = array();
|
||||
if (Tools::isSubmit('submitBlockCMS'))
|
||||
{
|
||||
$this->context->controller->getLanguages();
|
||||
@@ -550,10 +551,15 @@ class BlockCms extends Module
|
||||
{
|
||||
$id_cms_block = BlockCMSModel::insertCMSBlock($id_cms_category, $location, $position, $display_store);
|
||||
|
||||
foreach ($this->context->controller->_languages as $language)
|
||||
BlockCMSModel::insertCMSBlockLang($id_cms_block, $language['id_lang']);
|
||||
if ($id_cms_block !== false)
|
||||
{
|
||||
foreach ($this->context->controller->_languages as $language)
|
||||
BlockCMSModel::insertCMSBlockLang($id_cms_block, $language['id_lang']);
|
||||
|
||||
BlockCMSModel::insertCMSBlockShop($id_cms_block, Context::getContext()->shop->id);
|
||||
BlockCMSModel::insertCMSBlockShop($id_cms_block, $this->context->shop->getGroupID(), $this->context->shop->getID());
|
||||
}
|
||||
|
||||
$this->_errors[] = $this->l('New block cannot be created !');
|
||||
}
|
||||
else if (Tools::isSubmit('editBlockCMS'))
|
||||
{
|
||||
@@ -614,12 +620,13 @@ class BlockCms extends Module
|
||||
{
|
||||
$powered_by = Tools::getValue('cms_footer_powered_by_on') ? 1 : 0;
|
||||
$footer_boxes = Tools::getValue('footerBox') ? implode('|', Tools::getValue('footerBox')) : '';
|
||||
$block_activation = (Tools::getValue('cms_footer_on') == 1) ? 1 : 0;
|
||||
|
||||
Configuration::updateValue('FOOTER_CMS', rtrim($footer_boxes, '|'), false, $this->context->shop->getGroupID(), $this->context->shop->getID());
|
||||
Configuration::updateValue('FOOTER_POWEREDBY', $powered_by, false, $this->context->shop->getGroupID(), $this->context->shop->getID());
|
||||
Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', Tools::getValue('cms_footer_on'), false, $this->context->shop->getGroupID(), $this->context->shop->getID());
|
||||
Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', $block_activation, false, $this->context->shop->getGroupID(), $this->context->shop->getID());
|
||||
|
||||
$this->_html .= $this->displayConfirmation($this->l('Footer\'s CMS updated'));
|
||||
$this->_html .= $this->displayConfirmation($this->l('Footer\'s informations updated'));
|
||||
}
|
||||
else if (Tools::isSubmit('addBlockCMSConfirmation'))
|
||||
$this->_html .= $this->displayConfirmation($this->l('Block CMS added'));
|
||||
@@ -628,7 +635,13 @@ class BlockCms extends Module
|
||||
else if (Tools::isSubmit('deleteBlockCMSConfirmation'))
|
||||
$this->_html .= $this->displayConfirmation($this->l('Deletion successful'));
|
||||
else if (Tools::isSubmit('id_cms_block') && Tools::isSubmit('way') && Tools::isSubmit('position') && Tools::isSubmit('location'))
|
||||
$this->changePosition();
|
||||
$this->changePosition()
|
||||
;
|
||||
if (count($this->_errors))
|
||||
{
|
||||
foreach ($this->_errors as $err)
|
||||
$this->_html .= '<div class="alert error">'.$err.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
|
||||
Reference in New Issue
Block a user