// Fix id_shop on meta

This commit is contained in:
rMalie
2011-11-30 08:47:37 +00:00
parent 604ae4f3e3
commit 5b3b1db482
+20 -19
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2011 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -33,11 +33,11 @@ class MetaCore extends ObjectModel
public $description; public $description;
public $keywords; public $keywords;
public $url_rewrite; public $url_rewrite;
protected $fieldsRequired = array('page'); protected $fieldsRequired = array('page');
protected $fieldsSize = array('page' => 64); protected $fieldsSize = array('page' => 64);
protected $fieldsValidate = array('page' => 'isFileName'); protected $fieldsValidate = array('page' => 'isFileName');
protected $fieldsRequiredLang = array(); protected $fieldsRequiredLang = array();
protected $fieldsSizeLang = array('title' => 128, 'description' => 255, 'keywords' => 255, 'url_rewrite' => 255); protected $fieldsSizeLang = array('title' => 128, 'description' => 255, 'keywords' => 255, 'url_rewrite' => 255);
protected $fieldsValidateLang = array('title' => 'isGenericName', 'description' => 'isGenericName', 'keywords' => 'isGenericName', 'url_rewrite' => 'isLinkRewrite'); protected $fieldsValidateLang = array('title' => 'isGenericName', 'description' => 'isGenericName', 'keywords' => 'isGenericName', 'url_rewrite' => 'isLinkRewrite');
@@ -45,25 +45,25 @@ class MetaCore extends ObjectModel
protected $langMultiShop = true; protected $langMultiShop = true;
protected $table = 'meta'; protected $table = 'meta';
protected $identifier = 'id_meta'; protected $identifier = 'id_meta';
public function getFields() public function getFields()
{ {
$this->validateFields(); $this->validateFields();
return array('page' => pSQL($this->page)); return array('page' => pSQL($this->page));
} }
public function getTranslationsFieldsChild() public function getTranslationsFieldsChild()
{ {
$this->validateFieldsLang(); $this->validateFieldsLang();
return $this->getTranslationsFields(array('title', 'description', 'keywords', 'url_rewrite')); return $this->getTranslationsFields(array('title', 'description', 'keywords', 'url_rewrite'));
} }
public static function getPages($excludeFilled = false, $addPage = false) public static function getPages($excludeFilled = false, $addPage = false)
{ {
$selectedPages = array(); $selectedPages = array();
if (!$files = scandir(_PS_ROOT_DIR_.'/controllers')) if (!$files = scandir(_PS_ROOT_DIR_.'/controllers'))
die(Tools::displayError('Cannot scan root directory')); die(Tools::displayError('Cannot scan root directory'));
// Exclude pages forbidden // Exclude pages forbidden
$exludePages = array('category', 'changecurrency', 'cms', 'footer', 'header', $exludePages = array('category', 'changecurrency', 'cms', 'footer', 'header',
'pagination', 'product', 'product-sort', 'statistics'); 'pagination', 'product', 'product-sort', 'statistics');
@@ -86,7 +86,7 @@ class MetaCore extends ObjectModel
} }
return $selectedPages; return $selectedPages;
} }
public static function getMetas() public static function getMetas()
{ {
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
@@ -107,7 +107,7 @@ class MetaCore extends ObjectModel
.$shop->addSqlRestrictionOnLang('ml'). .$shop->addSqlRestrictionOnLang('ml').
'ORDER BY page ASC'; 'ORDER BY page ASC';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
} }
static public function getMetaByPage($page, $id_lang, Context $context = null) static public function getMetaByPage($page, $id_lang, Context $context = null)
@@ -127,8 +127,8 @@ class MetaCore extends ObjectModel
public function update($nullValues = false) public function update($nullValues = false)
{ {
if (!parent::update($nullValues)) if (!parent::update($nullValues))
return false; return false;
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess', return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
(int)Configuration::get('PS_REWRITING_SETTINGS'), (int)Configuration::get('PS_REWRITING_SETTINGS'),
(int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'), (int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'),
@@ -140,7 +140,7 @@ class MetaCore extends ObjectModel
public function add($autodate = true, $nullValues = false) public function add($autodate = true, $nullValues = false)
{ {
if (!parent::add($autodate, $nullValues)); if (!parent::add($autodate, $nullValues));
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess', return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
(int)Configuration::get('PS_REWRITING_SETTINGS'), (int)Configuration::get('PS_REWRITING_SETTINGS'),
(int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'), (int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'),
@@ -148,12 +148,12 @@ class MetaCore extends ObjectModel
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS') (int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
); );
} }
public function delete() public function delete()
{ {
if (!parent::delete()) if (!parent::delete())
return false; return false;
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess', return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
(int)Configuration::get('PS_REWRITING_SETTINGS'), (int)Configuration::get('PS_REWRITING_SETTINGS'),
(int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'), (int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'),
@@ -161,7 +161,7 @@ class MetaCore extends ObjectModel
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS') (int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
); );
} }
public function deleteSelection($selection) public function deleteSelection($selection)
{ {
if (!is_array($selection) OR !Validate::isTableOrIdentifier($this->identifier) OR !Validate::isTableOrIdentifier($this->table)) if (!is_array($selection) OR !Validate::isTableOrIdentifier($this->identifier) OR !Validate::isTableOrIdentifier($this->table))
@@ -172,10 +172,10 @@ class MetaCore extends ObjectModel
$this->id = (int)($id); $this->id = (int)($id);
$result = $result AND $this->delete(); $result = $result AND $this->delete();
} }
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess', return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
(int)Configuration::get('PS_REWRITING_SETTINGS'), (int)Configuration::get('PS_REWRITING_SETTINGS'),
(int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'), (int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'),
'', '',
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS') (int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
); );
@@ -191,7 +191,8 @@ class MetaCore extends ObjectModel
FROM `'._DB_PREFIX_.'meta_lang` FROM `'._DB_PREFIX_.'meta_lang`
WHERE url_rewrite = \''.pSQL($url_rewrite).'\' AND id_lang = '.(int)($id_lang).' WHERE url_rewrite = \''.pSQL($url_rewrite).'\' AND id_lang = '.(int)($id_lang).'
) )
AND id_lang = '.(int)($new_id_lang)); AND id_lang = '.(int)($new_id_lang).'
AND id_shop = '.Context::getContext()->shop->getID(true));
} }
} }