// Improve multishop API

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13566 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2012-02-23 15:39:44 +00:00
parent ec8f05c3ca
commit b24dcffc9c
71 changed files with 377 additions and 425 deletions
+5 -5
View File
@@ -258,7 +258,7 @@ class BlockCMSModel extends ObjectModel
public static function getCMSTitlesFooter()
{
$context = Context::getContext();
$footerCms = Configuration::get('FOOTER_CMS', null, $context->shop->getGroupID(), $context->shop->getID());
$footerCms = Configuration::get('FOOTER_CMS');
if (empty($footerCms))
return array();
@@ -339,7 +339,7 @@ class BlockCMSModel extends ObjectModel
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 = '.($id_shop ? (int)$id_shop : (int)$context->shop->getID()).'
AND bcs.id_shop = '.($id_shop ? (int)$id_shop : (int)$context->shop->id).'
ORDER BY `position`';
return Db::getInstance()->executeS($sql);
@@ -347,7 +347,7 @@ class BlockCMSModel extends ObjectModel
public static function getCMSPages($id_cms_category, $id_shop = false)
{
$id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->getID();
$id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->id;
$sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
FROM `'._DB_PREFIX_.'cms` c
@@ -467,7 +467,7 @@ class BlockCMSModel extends ObjectModel
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()).'
AND bcs.id_shop = '.($id_shop ? (int)$id_shop : (int)$context->shop->id).'
ORDER BY bc.`position`';
return Db::getInstance()->executeS($sql);
@@ -493,7 +493,7 @@ class BlockCMSModel extends ObjectModel
public static function getAllCMSStructure($id_shop = false)
{
$categories = BlockCMSModel::getCMSCategories();
$id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->getID();
$id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->id;
foreach ($categories as $key => $value)
$categories[$key]['cms_pages'] = BlockCMSModel::getCMSPages($value['id_cms_category'], $id_shop);
+15 -18
View File
@@ -55,9 +55,9 @@ class BlockCms extends Module
if (!parent::install() ||
!$this->registerHooks() ||
!BlockCMSModel::createTables() ||
!Configuration::updateValue('FOOTER_CMS', '', false, $this->context->shop->getGroupID(), $this->context->shop->getID()) ||
!Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1, false, $this->context->shop->getGroupID(), $this->context->shop->getID()) ||
!Configuration::updateValue('FOOTER_POWEREDBY', 1, false, $this->context->shop->getGroupID(), $this->context->shop->getID()))
!Configuration::updateValue('FOOTER_CMS', '') ||
!Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) ||
!Configuration::updateValue('FOOTER_POWEREDBY', 1))
return false;
// Install fixtures for blockcms
@@ -244,19 +244,19 @@ class BlockCms extends Module
);
$this->context->controller->getLanguages();
$tmp = Configuration::get('FOOTER_CMS', null, $this->context->shop->getGroupID(), $this->context->shop->getID());
$tmp = Configuration::get('FOOTER_CMS');
$footer_boxes = explode('|', $tmp);
if ($footer_boxes && is_array($footer_boxes))
foreach ($footer_boxes as $key => $value)
$this->fields_value[$value] = true;
$this->fields_value['cms_footer_on'] = Configuration::get('FOOTER_BLOCK_ACTIVATION', null, $this->context->shop->getGroupID(), $this->context->shop->getID());
$this->fields_value['cms_footer_powered_by_on'] = Configuration::get('FOOTER_POWEREDBY', null, $this->context->shop->getGroupID(), $this->context->shop->getID());
$this->fields_value['cms_footer_on'] = Configuration::get('FOOTER_BLOCK_ACTIVATION');
$this->fields_value['cms_footer_powered_by_on'] = Configuration::get('FOOTER_POWEREDBY');
foreach ($this->context->controller->_languages as $language)
{
$footer_text = Configuration::get('FOOTER_CMS_TEXT_'.$language['id_lang'], null, $this->context->shop->getGroupID(), $this->context->shop->getID());
$footer_text = Configuration::get('FOOTER_CMS_TEXT_'.$language['id_lang']);
$this->fields_value['footer_text'][$language['id_lang']] = $footer_text;
}
@@ -556,7 +556,7 @@ class BlockCms extends Module
foreach ($this->context->controller->_languages as $language)
BlockCMSModel::insertCMSBlockLang($id_cms_block, $language['id_lang']);
BlockCMSModel::insertCMSBlockShop($id_cms_block, $this->context->shop->getGroupID(), $this->context->shop->getID());
BlockCMSModel::insertCMSBlockShop($id_cms_block, Shop::getContextGroupShopID(), Shop::getContextShopID());
}
$this->_errors[] = $this->l('New block cannot be created !');
@@ -622,9 +622,9 @@ class BlockCms extends Module
$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', $block_activation, false, $this->context->shop->getGroupID(), $this->context->shop->getID());
Configuration::updateValue('FOOTER_CMS', rtrim($footer_boxes, '|'));
Configuration::updateValue('FOOTER_POWEREDBY', $powered_by);
Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', $block_activation);
$this->_html .= $this->displayConfirmation($this->l('Footer\'s informations updated'));
}
@@ -688,17 +688,14 @@ class BlockCms extends Module
public function hookFooter()
{
$context = Context::getContext();
$shop_id = $context->shop->getID();
$shop_group_id = $context->shop->getGroupID();
$block_activation = Configuration::get('FOOTER_BLOCK_ACTIVATION', null, $shop_group_id, $shop_id);
$block_activation = Configuration::get('FOOTER_BLOCK_ACTIVATION');
if ($block_activation)
{
$cms_titles = BlockCMSModel::getCMSTitlesFooter();
$display_footer = Configuration::get('PS_STORES_DISPLAY_FOOTER', null, $shop_group_id, $shop_id);
$display_poweredby = Configuration::get('FOOTER_POWEREDBY', null, $shop_group_id, $shop_id);
$footer_text = Configuration::get('FOOTER_CMS_TEXT_'.(int)$context->language->id);
$display_footer = Configuration::get('PS_STORES_DISPLAY_FOOTER');
$display_poweredby = Configuration::get('FOOTER_POWEREDBY');
$footer_text = Configuration::get('FOOTER_CMS_TEXT_'.(int)$this->context->language->id);
$this->smarty->assign(
array(