[-] MO : editorial : bugfix on install/uninstall, norm
This commit is contained in:
@@ -50,55 +50,61 @@ class Editorial extends Module
|
|||||||
|
|
||||||
public function install()
|
public function install()
|
||||||
{
|
{
|
||||||
if (!parent::install() OR !$this->registerHook('displayHome') OR !$this->registerHook('displayHeader'));
|
if (!parent::install() || !$this->registerHook('displayHome') || !$this->registerHook('displayHeader'))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!Db::getInstance()->execute('
|
$res = Db::getInstance()->execute('
|
||||||
CREATE TABLE `'._DB_PREFIX_.'editorial` (
|
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'editorial` (
|
||||||
`id_editorial` int(10) unsigned NOT NULL auto_increment,
|
`id_editorial` int(10) unsigned NOT NULL auto_increment,
|
||||||
`body_home_logo_link` varchar(255) NOT NULL,
|
`body_home_logo_link` varchar(255) NOT NULL,
|
||||||
PRIMARY KEY (`id_editorial`))
|
PRIMARY KEY (`id_editorial`))
|
||||||
ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'))
|
ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!Db::getInstance()->execute('
|
if ($res)
|
||||||
CREATE TABLE `'._DB_PREFIX_.'editorial_lang` (
|
$res &= Db::getInstance()->execute('
|
||||||
`id_editorial` int(10) unsigned NOT NULL,
|
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'editorial_lang` (
|
||||||
`id_lang` int(10) unsigned NOT NULL,
|
`id_editorial` int(10) unsigned NOT NULL,
|
||||||
`body_title` varchar(255) NOT NULL,
|
`id_lang` int(10) unsigned NOT NULL,
|
||||||
`body_subheading` varchar(255) NOT NULL,
|
`body_title` varchar(255) NOT NULL,
|
||||||
`body_paragraph` text NOT NULL,
|
`body_subheading` varchar(255) NOT NULL,
|
||||||
`body_logo_subheading` varchar(255) NOT NULL,
|
`body_paragraph` text NOT NULL,
|
||||||
PRIMARY KEY (`id_editorial`, `id_lang`))
|
`body_logo_subheading` varchar(255) NOT NULL,
|
||||||
ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'))
|
PRIMARY KEY (`id_editorial`, `id_lang`))
|
||||||
return false;
|
ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
|
||||||
|
|
||||||
if (!Db::getInstance()->execute('
|
if ($res)
|
||||||
INSERT INTO `'._DB_PREFIX_.'editorial`(`body_home_logo_link`)
|
$res &= Db::getInstance()->execute('
|
||||||
VALUES("http://www.prestashop.com")'))
|
INSERT INTO `'._DB_PREFIX_.'editorial`(`body_home_logo_link`)
|
||||||
return false;
|
VALUES("http://www.prestashop.com")');
|
||||||
|
if ($res)
|
||||||
|
{
|
||||||
|
$id_editorial = Db::getInstance()->Insert_ID();
|
||||||
|
foreach (Language::getLanguages(false) as $lang)
|
||||||
|
$res &= Db::getInstance()->autoExecute(_DB_PREFIX_.'editorial_lang', array(
|
||||||
|
'id_editorial' => $id_editorial,
|
||||||
|
'id_lang' => $lang['id_lang'],
|
||||||
|
'body_title' => 'Lorem ipsum dolor sit amet',
|
||||||
|
'body_subheading' => 'Excepteur sint occaecat cupidatat non proident',
|
||||||
|
'body_paragraph' => '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>',
|
||||||
|
'body_logo_subheading' => 'Lorem ipsum presta shop amet',
|
||||||
|
), 'INSERT');
|
||||||
|
}
|
||||||
|
|
||||||
$id_editorial = Db::getInstance()->Insert_ID();
|
if (!$res)
|
||||||
$result = true;
|
$res &= $this->uninstall();
|
||||||
foreach (Language::getLanguages(false) as $lang)
|
|
||||||
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'editorial_lang', array(
|
return $res;
|
||||||
'id_editorial' => $id_editorial,
|
|
||||||
'id_lang' => $lang['id_lang'],
|
|
||||||
'body_title' => 'Lorem ipsum dolor sit amet',
|
|
||||||
'body_subheading' => 'Excepteur sint occaecat cupidatat non proident',
|
|
||||||
'body_paragraph' => '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>',
|
|
||||||
'body_logo_subheading' => 'Lorem ipsum presta shop amet',
|
|
||||||
), 'INSERT');
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uninstall()
|
public function uninstall()
|
||||||
{
|
{
|
||||||
if (!parent::uninstall())
|
$res = Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'editorial`');
|
||||||
|
$res &= Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'editorial_lang`');
|
||||||
|
|
||||||
|
if (!$res || !parent::uninstall())
|
||||||
return false;
|
return false;
|
||||||
return (Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'editorial`') AND
|
|
||||||
Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'editorial_lang`'));
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function putContent($xml_data, $key, $field, $forbidden, $section)
|
public function putContent($xml_data, $key, $field, $forbidden, $section)
|
||||||
|
|||||||
Reference in New Issue
Block a user