// Normalize

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12746 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2012-01-27 10:28:56 +00:00
parent b50321d328
commit d514b6dc9b
15 changed files with 223 additions and 231 deletions
+78 -79
View File
@@ -52,7 +52,7 @@ class BlockCms extends Module
public function install() public function install()
{ {
if (!parent::install() OR !$this->registerHook('leftColumn') OR !$this->registerHook('rightColumn') OR !$this->registerHook('footer') OR !$this->registerHook('header') OR if (!parent::install() || !$this->registerHook('leftColumn') || !$this->registerHook('rightColumn') || !$this->registerHook('footer') || !$this->registerHook('header') ||
!Db::getInstance()->execute(' !Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`( CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`(
`id_cms_block` int(10) unsigned NOT NULL auto_increment, `id_cms_block` int(10) unsigned NOT NULL auto_increment,
@@ -61,14 +61,14 @@ class BlockCms extends Module
`position` int(10) unsigned NOT NULL default \'0\', `position` int(10) unsigned NOT NULL default \'0\',
`display_store` tinyint(1) unsigned NOT NULL default \'1\', `display_store` tinyint(1) unsigned NOT NULL default \'1\',
PRIMARY KEY (`id_cms_block`) PRIMARY KEY (`id_cms_block`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') ||
!Db::getInstance()->execute(' !Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_lang`( CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_lang`(
`id_cms_block` int(10) unsigned NOT NULL, `id_cms_block` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL,
`name` varchar(40) NOT NULL default \'\', `name` varchar(40) NOT NULL default \'\',
PRIMARY KEY (`id_cms_block`, `id_lang`) PRIMARY KEY (`id_cms_block`, `id_lang`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') ||
!Db::getInstance()->execute(' !Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_page`( CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_page`(
`id_cms_block_page` int(10) unsigned NOT NULL auto_increment, `id_cms_block_page` int(10) unsigned NOT NULL auto_increment,
@@ -76,15 +76,15 @@ class BlockCms extends Module
`id_cms` int(10) unsigned NOT NULL, `id_cms` int(10) unsigned NOT NULL,
`is_category` tinyint(1) unsigned NOT NULL, `is_category` tinyint(1) unsigned NOT NULL,
PRIMARY KEY (`id_cms_block_page`) PRIMARY KEY (`id_cms_block_page`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') ||
!Db::getInstance()->execute(' !Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_shop` ( CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_shop` (
`id_cms_block` int(10) unsigned NOT NULL auto_increment, `id_cms_block` int(10) unsigned NOT NULL auto_increment,
`id_shop` int(10) unsigned NOT NULL, `id_shop` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_cms_block`, `id_shop`) PRIMARY KEY (`id_cms_block`, `id_shop`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') ||
!Configuration::updateValue('FOOTER_CMS', '') OR !Configuration::updateValue('FOOTER_CMS', '') ||
!Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) OR !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) ||
!Configuration::updateValue('FOOTER_POWEREDBY', 1)) !Configuration::updateValue('FOOTER_POWEREDBY', 1))
return false; return false;
@@ -97,7 +97,7 @@ class BlockCms extends Module
return false; return false;
$id_cms_block = Db::getInstance()->Insert_ID(); $id_cms_block = Db::getInstance()->Insert_ID();
$result = true; $result = true;
$shops = Shop::getShops(true, null, true); $shops = Shop::getShops(true, null, true);
foreach ($shops as $shop) foreach ($shops as $shop)
$result &= Db::getInstance()->insert('cms_block_shop', array( $result &= Db::getInstance()->insert('cms_block_shop', array(
'id_cms_block' => $id_cms_block, 'id_cms_block' => $id_cms_block,
@@ -124,10 +124,10 @@ class BlockCms extends Module
public function uninstall() public function uninstall()
{ {
if (!parent::uninstall() OR if (!parent::uninstall() ||
!Configuration::deleteByName('FOOTER_CMS') OR !Configuration::deleteByName('FOOTER_CMS') ||
!Configuration::deleteByName('FOOTER_BLOCK_ACTIVATION') OR !Configuration::deleteByName('FOOTER_BLOCK_ACTIVATION') ||
!Configuration::deleteByName('FOOTER_POWEREDBY') OR !Configuration::deleteByName('FOOTER_POWEREDBY') ||
!Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'cms_block` , `'._DB_PREFIX_.'cms_block_page`, `'._DB_PREFIX_.'cms_block_lang`, `'._DB_PREFIX_.'cms_block_shop`')) !Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'cms_block` , `'._DB_PREFIX_.'cms_block_page`, `'._DB_PREFIX_.'cms_block_lang`, `'._DB_PREFIX_.'cms_block_shop`'))
return false; return false;
return true; return true;
@@ -142,7 +142,7 @@ class BlockCms extends Module
WHERE cb.`id_cms_block` = '.(int)$id_cms_block); WHERE cb.`id_cms_block` = '.(int)$id_cms_block);
$store_display_update = array(0, $size = count($cmsBlocks), $display = Configuration::get('PS_STORES_DISPLAY_FOOTER')); $store_display_update = array(0, $size = count($cmsBlocks), $display = Configuration::get('PS_STORES_DISPLAY_FOOTER'));
foreach ($cmsBlocks AS $cmsBlock) foreach ($cmsBlocks as $cmsBlock)
{ {
$cmsBlocks['name'][(int)$cmsBlock['id_lang']] = $cmsBlock['name']; $cmsBlocks['name'][(int)$cmsBlock['id_lang']] = $cmsBlock['name'];
if ($store_display_update['0'] < $store_display_update['1']) if ($store_display_update['0'] < $store_display_update['1'])
@@ -154,7 +154,6 @@ class BlockCms extends Module
private function getBlocksCMS($location) private function getBlocksCMS($location)
{ {
return Db::getInstance()->executeS(' return Db::getInstance()->executeS('
SELECT bc.`id_cms_block`, bcl.`name` block_name, ccl.`name` category_name, bc.`position`, bc.`id_cms_category`, bc.`display_store` 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 FROM `'._DB_PREFIX_.'cms_block` bc
@@ -169,7 +168,7 @@ class BlockCms extends Module
return array_merge($this->getBlocksCMS(self::LEFT_COLUMN), $this->getBlocksCMS(self::RIGHT_COLUMN)); return array_merge($this->getBlocksCMS(self::LEFT_COLUMN), $this->getBlocksCMS(self::RIGHT_COLUMN));
} }
static public function getCMStitlesFooter() public static function getCMStitlesFooter()
{ {
$context = Context::getContext(); $context = Context::getContext();
@@ -179,7 +178,7 @@ class BlockCms extends Module
$cmsCategories = explode('|', $footerCms); $cmsCategories = explode('|', $footerCms);
$content = array(); $content = array();
foreach ($cmsCategories AS $cmsCategory) foreach ($cmsCategories as $cmsCategory)
{ {
$ids = explode('_', $cmsCategory); $ids = explode('_', $cmsCategory);
if ($ids[0] == 1) if ($ids[0] == 1)
@@ -211,7 +210,7 @@ class BlockCms extends Module
return $content; return $content;
} }
static public function getCMStitles($location) public static function getCMStitles($location)
{ {
$context = Context::getContext(); $context = Context::getContext();
@@ -226,8 +225,8 @@ class BlockCms extends Module
$content = array(); $content = array();
if (is_array($cmsCategories) AND sizeof($cmsCategories)) if (is_array($cmsCategories) && count($cmsCategories))
foreach ($cmsCategories AS $cmsCategory) foreach ($cmsCategories as $cmsCategory)
{ {
$key = (int)$cmsCategory['id_cms_block']; $key = (int)$cmsCategory['id_cms_block'];
$content[$key]['display_store'] = $cmsCategory['display_store']; $content[$key]['display_store'] = $cmsCategory['display_store'];
@@ -238,15 +237,16 @@ class BlockCms extends Module
INNER JOIN `'._DB_PREFIX_.'cms_lang` cl ON (bcp.`id_cms` = cl.`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`) INNER JOIN `'._DB_PREFIX_.'cms` c ON (bcp.`id_cms` = c.`id_cms`)
WHERE bcp.`id_cms_block` = '.(int)$cmsCategory['id_cms_block'].' AND cl.`id_lang` = '.(int)$context->language->id.' AND bcp.`is_category` = 0 AND c.`active` = 1 WHERE bcp.`id_cms_block` = '.(int)$cmsCategory['id_cms_block'].' AND cl.`id_lang` = '.(int)$context->language->id.' AND bcp.`is_category` = 0 AND c.`active` = 1
ORDER BY `position`'); ORDER BY `position`
');
$links = array(); $links = array();
if (sizeof($content[$key]['cms'])) if (count($content[$key]['cms']))
foreach ($content[$key]['cms'] AS $row) foreach ($content[$key]['cms'] as $row)
{ {
$row['link'] = $context->link->getCMSLink((int)($row['id_cms']), $row['link_rewrite']); $row['link'] = $context->link->getCMSLink((int)($row['id_cms']), $row['link_rewrite']);
$links[] = $row; $links[] = $row;
} }
$content[$key]['cms'] = $links; $content[$key]['cms'] = $links;
@@ -259,12 +259,12 @@ class BlockCms extends Module
AND bcp.`is_category` = 1'); AND bcp.`is_category` = 1');
$links = array(); $links = array();
if (sizeof($content[$key]['categories'])) if (count($content[$key]['categories']))
foreach ($content[$key]['categories'] as $row) foreach ($content[$key]['categories'] as $row)
{ {
$row['link'] = $context->link->getCMSCategoryLink((int)$row['id_cms'], $row['link_rewrite']); $row['link'] = $context->link->getCMSCategoryLink((int)$row['id_cms'], $row['link_rewrite']);
$links[] = $row; $links[] = $row;
} }
$content[$key]['categories'] = $links; $content[$key]['categories'] = $links;
$content[$key]['name'] = $cmsCategory['block_name']; $content[$key]['name'] = $cmsCategory['block_name'];
@@ -278,12 +278,12 @@ class BlockCms extends Module
public function getAllCMSTitles() public function getAllCMSTitles()
{ {
$titles = array(); $titles = array();
foreach(self::getCMStitles(self::LEFT_COLUMN) AS $key => $title) foreach (self::getCMStitles(self::LEFT_COLUMN) as $key => $title)
{ {
unset($title['categories'], $title['name'], $title['category_link'], $title['category_name']); unset($title['categories'], $title['name'], $title['category_link'], $title['category_name']);
$titles[$key] = $title; $titles[$key] = $title;
} }
foreach(self::getCMStitles(self::RIGHT_COLUMN) AS $key => $title) foreach (self::getCMStitles(self::RIGHT_COLUMN) as $key => $title)
{ {
unset($title['categories'], $title['name'], $title['category_link'], $title['category_name']); unset($title['categories'], $title['name'], $title['category_link'], $title['category_name']);
$titles[$key] = $title; $titles[$key] = $title;
@@ -295,7 +295,7 @@ class BlockCms extends Module
{ {
static $irow = 0; static $irow = 0;
$img = $categories['level_depth'] == 0 ? 'lv1.gif' : 'lv'.($categories['level_depth'] + 1).'_'.((sizeof($categories['cms']) OR isset($categories['children'])) ? 'b' : 'f').'.gif'; $img = $categories['level_depth'] == 0 ? 'lv1.gif' : 'lv'.($categories['level_depth'] + 1).'_'.((count($categories['cms']) || isset($categories['children'])) ? 'b' : 'f').'.gif';
$this->_html .= ' $this->_html .= '
<tr '.($irow++ % 2 ? 'class="alt_row"' : '').'> <tr '.($irow++ % 2 ? 'class="alt_row"' : '').'>
@@ -312,7 +312,7 @@ class BlockCms extends Module
foreach ($categories['children'] as $key => $category) foreach ($categories['children'] as $key => $category)
{ {
$has_suite[$categories['level_depth']] = 1; $has_suite[$categories['level_depth']] = 1;
if (sizeof($categories['children']) == $key + 1 AND !sizeof($categories['cms'])) if (count($categories['children']) == $key + 1 && !count($categories['cms']))
$has_suite[$categories['level_depth']] = 0; $has_suite[$categories['level_depth']] = 0;
$this->displayRecurseCheckboxes($category, $selected, $has_suite, 0); $this->displayRecurseCheckboxes($category, $selected, $has_suite, 0);
} }
@@ -328,7 +328,7 @@ class BlockCms extends Module
<td width="94%">'; <td width="94%">';
for ($i = 0; $i < $categories['level_depth']; $i++) for ($i = 0; $i < $categories['level_depth']; $i++)
$this->_html .= '<img style="vertical-align:middle;" src="../img/admin/lvl_'.$has_suite[$i].'.gif" alt="" />'; $this->_html .= '<img style="vertical-align:middle;" src="../img/admin/lvl_'.$has_suite[$i].'.gif" alt="" />';
$this->_html .= '<img style="vertical-align:middle;" src="../img/admin/lv2_'.(++$cpt == sizeof($categories['cms']) ? 'f' : 'b').'.gif" alt="" /> &nbsp; $this->_html .= '<img style="vertical-align:middle;" src="../img/admin/lv2_'.(++$cpt == count($categories['cms']) ? 'f' : 'b').'.gif" alt="" /> &nbsp;
<label for="0_'.$cms['id_cms'].'" class="t" style="margin-top:6px;">'.$cms['meta_title'].'</label></td> <label for="0_'.$cms['id_cms'].'" class="t" style="margin-top:6px;">'.$cms['meta_title'].'</label></td>
</tr>'; </tr>';
} }
@@ -341,7 +341,7 @@ class BlockCms extends Module
$cms_blocks_right = $this->getBlocksCMS(1); $cms_blocks_right = $this->getBlocksCMS(1);
$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$this->context->language->iso_code.'.js') ? $this->context->language->iso_code : 'en'); $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"]); $ad = dirname($_SERVER['PHP_SELF']);
$this->_html .= ' $this->_html .= '
<script type="text/javascript"> <script type="text/javascript">
@@ -360,7 +360,7 @@ class BlockCms extends Module
<p><a href="'.AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&addBlockCMS"><img src="'._PS_ADMIN_IMG_.'add.gif" alt="" /> '.$this->l('Add a new CMS block').'</a></p>'; <p><a href="'.AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&addBlockCMS"><img src="'._PS_ADMIN_IMG_.'add.gif" alt="" /> '.$this->l('Add a new CMS block').'</a></p>';
$this->_html .= '<div style="width:440px; float:left; margin-right:10px;" ><h3>'.$this->l('List of Left CMS blocks').'</h3>'; $this->_html .= '<div style="width:440px; float:left; margin-right:10px;" ><h3>'.$this->l('List of Left CMS blocks').'</h3>';
if (sizeof($cms_blocks_left)) if (count($cms_blocks_left))
{ {
$this->_html .= '<table width="100%" class="table" cellspacing="0" cellpadding="0" id="table_left" class="tableDnD"> $this->_html .= '<table width="100%" class="table" cellspacing="0" cellpadding="0" id="table_left" class="tableDnD">
<thead> <thead>
@@ -383,7 +383,7 @@ class BlockCms extends Module
<td width="30%" class="center">'.(empty($cms_block['block_name']) ? $cms_block['category_name'] : $cms_block['block_name']).'</td> <td width="30%" class="center">'.(empty($cms_block['block_name']) ? $cms_block['category_name'] : $cms_block['block_name']).'</td>
<td width="30%" class="center">'.$cms_block['category_name'].'</td> <td width="30%" class="center">'.$cms_block['category_name'].'</td>
<td class="center pointer dragHandle"> <td class="center pointer dragHandle">
<a'.(($cms_block['position'] == (sizeof($cms_blocks_left) - 1) OR sizeof($cms_blocks_left) == 1) ? ' style="display: none;"' : '').' href="'.AdminController::$currentIndex.'&configure=blockcms&id_cms_block='.$cms_block['id_cms_block'].'&way=1&position='.(int)($cms_block['position'] + 1).'&location=0&token='.Tools::getAdminTokenLite('AdminModules').'"> <a'.(($cms_block['position'] == (count($cms_blocks_left) - 1) || count($cms_blocks_left) == 1) ? ' style="display: none;"' : '').' href="'.AdminController::$currentIndex.'&configure=blockcms&id_cms_block='.$cms_block['id_cms_block'].'&way=1&position='.(int)($cms_block['position'] + 1).'&location=0&token='.Tools::getAdminTokenLite('AdminModules').'">
<img src="../img/admin/down.gif" alt="'.$this->l('Down').'" title="'.$this->l('Down').'" /></a> <img src="../img/admin/down.gif" alt="'.$this->l('Down').'" title="'.$this->l('Down').'" /></a>
<a'.($cms_block['position'] == 0 ? ' style="display: none;"' : '').' href="'.AdminController::$currentIndex.'&configure=blockcms&id_cms_block='.$cms_block['id_cms_block'].'&way=0&position='.(int)($cms_block['position'] - 1).'&location=0&token='.Tools::getAdminTokenLite('AdminModules').'"> <a'.($cms_block['position'] == 0 ? ' style="display: none;"' : '').' href="'.AdminController::$currentIndex.'&configure=blockcms&id_cms_block='.$cms_block['id_cms_block'].'&way=0&position='.(int)($cms_block['position'] - 1).'&location=0&token='.Tools::getAdminTokenLite('AdminModules').'">
<img src="../img/admin/up.gif" alt="'.$this->l('Up').'" title="'.$this->l('Up').'" /></a> <img src="../img/admin/up.gif" alt="'.$this->l('Up').'" title="'.$this->l('Up').'" /></a>
@@ -403,7 +403,7 @@ class BlockCms extends Module
$this->_html .= '</div>'; $this->_html .= '</div>';
$this->_html .= '<div style="width:440px; float:left;" ><h3>'.$this->l('List of Right CMS blocks').'</h3>'; $this->_html .= '<div style="width:440px; float:left;" ><h3>'.$this->l('List of Right CMS blocks').'</h3>';
if (sizeof($cms_blocks_right)) if (count($cms_blocks_right))
{ {
$this->_html .= '<table width="100%" class="table" cellspacing="0" cellpadding="0" id="table_right" class="tableDnD"> $this->_html .= '<table width="100%" class="table" cellspacing="0" cellpadding="0" id="table_right" class="tableDnD">
<thead> <thead>
@@ -426,7 +426,7 @@ class BlockCms extends Module
<td width="30%" class="center">'.(empty($cms_block['block_name']) ? $cms_block['category_name'] : $cms_block['block_name']).'</td> <td width="30%" class="center">'.(empty($cms_block['block_name']) ? $cms_block['category_name'] : $cms_block['block_name']).'</td>
<td width="30%" class="center">'.$cms_block['category_name'].'</td> <td width="30%" class="center">'.$cms_block['category_name'].'</td>
<td class="center pointer dragHandle"> <td class="center pointer dragHandle">
<a'.(($cms_block['position'] == (sizeof($cms_blocks_right) - 1) OR sizeof($cms_blocks_right) == 1) ? ' style="display: none;"' : '').' href="'.AdminController::$currentIndex.'&configure=blockcms&id_cms_block='.$cms_block['id_cms_block'].'&way=1&position='.(int)($cms_block['position'] + 1).'&location=1&token='.Tools::getAdminTokenLite('AdminModules').'"> <a'.(($cms_block['position'] == (count($cms_blocks_right) - 1) || count($cms_blocks_right) == 1) ? ' style="display: none;"' : '').' href="'.AdminController::$currentIndex.'&configure=blockcms&id_cms_block='.$cms_block['id_cms_block'].'&way=1&position='.(int)($cms_block['position'] + 1).'&location=1&token='.Tools::getAdminTokenLite('AdminModules').'">
<img src="../img/admin/down.gif" alt="'.$this->l('Down').'" title="'.$this->l('Down').'" /></a> <img src="../img/admin/down.gif" alt="'.$this->l('Down').'" title="'.$this->l('Down').'" /></a>
<a'.($cms_block['position'] == 0 ? ' style="display: none;"' : '').' href="'.AdminController::$currentIndex.'&configure=blockcms&id_cms_block='.$cms_block['id_cms_block'].'&way=0&position='.(int)($cms_block['position'] - 1).'&location=1&token='.Tools::getAdminTokenLite('AdminModules').'"> <a'.($cms_block['position'] == 0 ? ' style="display: none;"' : '').' href="'.AdminController::$currentIndex.'&configure=blockcms&id_cms_block='.$cms_block['id_cms_block'].'&way=0&position='.(int)($cms_block['position'] - 1).'&location=1&token='.Tools::getAdminTokenLite('AdminModules').'">
<img src="../img/admin/up.gif" alt="'.$this->l('Up').'" title="'.$this->l('Up').'" /></a> <img src="../img/admin/up.gif" alt="'.$this->l('Up').'" title="'.$this->l('Up').'" /></a>
@@ -487,8 +487,8 @@ class BlockCms extends Module
$languages = Language::getLanguages(false); $languages = Language::getLanguages(false);
$divLangName = 'name'; $divLangName = 'name';
$cmsBlock = NULL; $cmsBlock = null;
if (Tools::isSubmit('editBlockCMS') AND Tools::getValue('id_cms_block')) if (Tools::isSubmit('editBlockCMS') && Tools::getValue('id_cms_block'))
$cmsBlock = $this->getBlockCMS((int)Tools::getValue('id_cms_block')); $cmsBlock = $this->getBlockCMS((int)Tools::getValue('id_cms_block'));
$this->_html .= ' $this->_html .= '
@@ -522,7 +522,7 @@ class BlockCms extends Module
<div class="margin-form"> <div class="margin-form">
<select name="id_category" id="id_category" onchange="CMSCategory_js($(this).val(), \''.$this->secure_key.'\')">'; <select name="id_category" id="id_category" onchange="CMSCategory_js($(this).val(), \''.$this->secure_key.'\')">';
$categories = CMSCategory::getCategories($this->context->language->id, false); $categories = CMSCategory::getCategories($this->context->language->id, false);
$this->_html .= CMSCategory::recurseCMSCategory($categories, $categories[0][1], 1, ($cmsBlock != NULL ? $cmsBlock[0]['id_cms_category'] : 1), 1); $this->_html .= CMSCategory::recurseCMSCategory($categories, $categories[0][1], 1, ($cmsBlock != null ? $cmsBlock[0]['id_cms_category'] : 1), 1);
$this->_html .= ' $this->_html .= '
</select> </select>
</div><br /> </div><br />
@@ -530,18 +530,18 @@ class BlockCms extends Module
<label>'.$this->l('Location:').'</label> <label>'.$this->l('Location:').'</label>
<div class="margin-form"> <div class="margin-form">
<select name="block_location" id="block_location"> <select name="block_location" id="block_location">
<option value="'.self::LEFT_COLUMN.'" '.(($cmsBlock AND $cmsBlock[0]['location'] == self::LEFT_COLUMN) ? 'selected="selected"' : '').'>'.$this->l('Left').'</option> <option value="'.self::LEFT_COLUMN.'" '.(($cmsBlock && $cmsBlock[0]['location'] == self::LEFT_COLUMN) ? 'selected="selected"' : '').'>'.$this->l('Left').'</option>
<option value="'.self::RIGHT_COLUMN.'" '.(($cmsBlock AND $cmsBlock[0]['location'] == self::RIGHT_COLUMN) ? 'selected="selected"' : '').'>'.$this->l('Right').'</option> <option value="'.self::RIGHT_COLUMN.'" '.(($cmsBlock && $cmsBlock[0]['location'] == self::RIGHT_COLUMN) ? 'selected="selected"' : '').'>'.$this->l('Right').'</option>
</select> </select>
</div>'; </div>';
$this->_html .= ' $this->_html .= '
<label for="PS_STORES_DISPLAY_CMS_on">'.$this->l('Display Stores:').'</label> <label for="PS_STORES_DISPLAY_CMS_on">'.$this->l('Display Stores:').'</label>
<div class="margin-form"> <div class="margin-form">
<img src="../img/admin/enabled.gif" alt="Yes" title="Yes" /> <img src="../img/admin/enabled.gif" alt="Yes" title="Yes" />
<input type="radio" name="PS_STORES_DISPLAY_CMS" id="PS_STORES_DISPLAY_CMS_on" '.(($cmsBlock AND ( isset($cmsBlock[0]['display_store']) && $cmsBlock[0]['display_store'] == 0)) ? '' : 'checked="checked" ').'value="1" /> <input type="radio" name="PS_STORES_DISPLAY_CMS" id="PS_STORES_DISPLAY_CMS_on" '.(($cmsBlock && (isset($cmsBlock[0]['display_store']) && $cmsBlock[0]['display_store'] == 0)) ? '' : 'checked="checked" ').'value="1" />
<label class="t" for="PS_STORES_DISPLAY_CMS_on">'.$this->l('Yes').'</label> <label class="t" for="PS_STORES_DISPLAY_CMS_on">'.$this->l('Yes').'</label>
<img src="../img/admin/disabled.gif" alt="No" title="No" style="margin-left: 10px;" /> <img src="../img/admin/disabled.gif" alt="No" title="No" style="margin-left: 10px;" />
<input type="radio" name="PS_STORES_DISPLAY_CMS" id="PS_STORES_DISPLAY_CMS_off" '.(($cmsBlock AND ( isset($cmsBlock[0]['display_store']) && $cmsBlock[0]['display_store'] == 0)) ? 'checked="checked" ' : '').'value="0" /> <input type="radio" name="PS_STORES_DISPLAY_CMS" id="PS_STORES_DISPLAY_CMS_off" '.(($cmsBlock && (isset($cmsBlock[0]['display_store']) && $cmsBlock[0]['display_store'] == 0)) ? 'checked="checked" ' : '').'value="0" />
<label class="t" for="PS_STORES_DISPLAY_CMS_off">'.$this->l('No').'</label><br />' <label class="t" for="PS_STORES_DISPLAY_CMS_off">'.$this->l('No').'</label><br />'
.$this->l('Display "our stores" at the end of the block') .$this->l('Display "our stores" at the end of the block')
.'</div>'; .'</div>';
@@ -571,27 +571,27 @@ class BlockCms extends Module
{ {
$languages = Language::getLanguages(false); $languages = Language::getLanguages(false);
$cmsBoxes = Tools::getValue('cmsBox'); $cmsBoxes = Tools::getValue('cmsBox');
if (!Validate::isInt(Tools::getValue('PS_STORES_DISPLAY_CMS')) OR (Tools::getValue('PS_STORES_DISPLAY_CMS') != 0 AND Tools::getValue('PS_STORES_DISPLAY_CMS') != 1)) if (!Validate::isInt(Tools::getValue('PS_STORES_DISPLAY_CMS')) || (Tools::getValue('PS_STORES_DISPLAY_CMS') != 0 && Tools::getValue('PS_STORES_DISPLAY_CMS') != 1))
$errors[] = $this->l('Invalid store display'); $errors[] = $this->l('Invalid store display');
if (!Validate::isInt(Tools::getValue('block_location')) OR (Tools::getValue('block_location') != self::LEFT_COLUMN AND Tools::getValue('block_location') != self::RIGHT_COLUMN)) if (!Validate::isInt(Tools::getValue('block_location')) || (Tools::getValue('block_location') != self::LEFT_COLUMN && Tools::getValue('block_location') != self::RIGHT_COLUMN))
$errors[] = $this->l('Invalid block location'); $errors[] = $this->l('Invalid block location');
if (!is_array($cmsBoxes)) if (!is_array($cmsBoxes))
$errors[] = $this->l('You must choose at least one page or subcategory to create a CMS block.'); $errors[] = $this->l('You must choose at least one page or subcategory to create a CMS block.');
else else
foreach ($cmsBoxes as $cmsBox) foreach ($cmsBoxes as $cmsBox)
if (!preg_match("#^[01]_[0-9]+$#", $cmsBox)) if (!preg_match('#^[01]_[0-9]+$#', $cmsBox))
$errors[] = $this->l('Invalid CMS page or category'); $errors[] = $this->l('Invalid CMS page or category');
foreach ($languages as $language) foreach ($languages as $language)
if (strlen(Tools::getValue('block_name_'.$language['id_lang'])) > 40) if (strlen(Tools::getValue('block_name_'.$language['id_lang'])) > 40)
$errors[] = $this->l('Block name is too long'); $errors[] = $this->l('Block name is too long');
} }
elseif (Tools::isSubmit('deleteBlockCMS') AND !Validate::isInt(Tools::getValue('id_cms_block'))) elseif (Tools::isSubmit('deleteBlockCMS') && !Validate::isInt(Tools::getValue('id_cms_block')))
$errors[] = $this->l('Invalid id_cms_block'); $errors[] = $this->l('Invalid id_cms_block');
elseif (Tools::isSubmit('submitFooterCMS')) elseif (Tools::isSubmit('submitFooterCMS'))
{ {
if (Tools::getValue('footerBox')) if (Tools::getValue('footerBox'))
foreach (Tools::getValue('footerBox') as $cmsBox) foreach (Tools::getValue('footerBox') as $cmsBox)
if (!preg_match("#^[01]_[0-9]+$#", $cmsBox)) if (!preg_match('#^[01]_[0-9]+$#', $cmsBox))
$errors[] = $this->l('Invalid CMS page or category'); $errors[] = $this->l('Invalid CMS page or category');
$empty_footer_text = true; $empty_footer_text = true;
@@ -623,10 +623,10 @@ class BlockCms extends Module
Configuration::updateValue('FOOTER_CMS_TEXT_'.(int)$lang['id_lang'], $footer_text[(int)$lang['id_lang']], true); Configuration::updateValue('FOOTER_CMS_TEXT_'.(int)$lang['id_lang'], $footer_text[(int)$lang['id_lang']], true);
} }
if (Tools::getValue('footer_active') != 0 AND Tools::getValue('footer_active') != 1) if (Tools::getValue('footer_active') != 0 && Tools::getValue('footer_active') != 1)
$errors[] = $this->l('Invalid activation footer'); $errors[] = $this->l('Invalid activation footer');
} }
if (sizeof($errors)) if (count($errors))
{ {
$this->_html .= $this->displayError(implode('<br />', $errors)); $this->_html .= $this->displayError(implode('<br />', $errors));
return false; return false;
@@ -636,9 +636,9 @@ class BlockCms extends Module
private function changePosition() private function changePosition()
{ {
if (!Validate::isInt(Tools::getValue('position')) OR if (!Validate::isInt(Tools::getValue('position')) ||
(Tools::getValue('location') != self::LEFT_COLUMN AND Tools::getValue('location') != self::RIGHT_COLUMN) OR (Tools::getValue('location') != self::LEFT_COLUMN && Tools::getValue('location') != self::RIGHT_COLUMN) ||
(Tools::getValue('way') != 0 AND Tools::getValue('way') != 1)) (Tools::getValue('way') != 0 && Tools::getValue('way') != 1))
Tools::displayError(); Tools::displayError();
$this->_html .= 'pos change!'; $this->_html .= 'pos change!';
@@ -656,7 +656,7 @@ class BlockCms extends Module
} }
elseif (Tools::getValue('way') == 1) elseif (Tools::getValue('way') == 1)
{ {
if(Db::getInstance()->execute(' if (Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'cms_block` UPDATE `'._DB_PREFIX_.'cms_block`
SET `position` = '.((int)Tools::getValue('position') - 1).' SET `position` = '.((int)Tools::getValue('position') - 1).'
WHERE `position` = '.((int)Tools::getValue('position')).' WHERE `position` = '.((int)Tools::getValue('position')).'
@@ -747,7 +747,7 @@ class BlockCms extends Module
} }
$cmsBoxes = Tools::getValue('cmsBox'); $cmsBoxes = Tools::getValue('cmsBox');
if (sizeof($cmsBoxes)) if (count($cmsBoxes))
foreach ($cmsBoxes as $cmsBox) foreach ($cmsBoxes as $cmsBox)
{ {
$cms_properties = explode('_', $cmsBox); $cms_properties = explode('_', $cmsBox);
@@ -761,10 +761,10 @@ class BlockCms extends Module
elseif (Tools::isSubmit('editBlockCMS')) elseif (Tools::isSubmit('editBlockCMS'))
Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editBlockCMSConfirmation'); Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editBlockCMSConfirmation');
} }
elseif (Tools::isSubmit('deleteBlockCMS') AND Tools::getValue('id_cms_block')) elseif (Tools::isSubmit('deleteBlockCMS') && Tools::getValue('id_cms_block'))
{ {
$old_block = Db::getInstance()->executeS('SELECT `location`, `position` FROM `'._DB_PREFIX_.'cms_block` WHERE `id_cms_block` = '.Tools::getvalue('id_cms_block')); $old_block = Db::getInstance()->executeS('SELECT `location`, `position` FROM `'._DB_PREFIX_.'cms_block` WHERE `id_cms_block` = '.Tools::getvalue('id_cms_block'));
if (sizeof($old_block)) if (count($old_block))
{ {
Db::getInstance()->execute(' Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'cms_block` UPDATE `'._DB_PREFIX_.'cms_block`
@@ -800,13 +800,13 @@ class BlockCms extends Module
$this->_html = $this->displayConfirmation($this->l('Footer\'s CMS updated')); $this->_html = $this->displayConfirmation($this->l('Footer\'s CMS updated'));
} }
elseif (Tools::isSubmit('addBlockCMSConfirmation')) elseif (Tools::isSubmit('addBlockCMSConfirmation'))
$this->_html = $this->displayConfirmation($this->l('Block CMS added')); $this->_html = $this->displayConfirmation($this->l('Block CMS added'));
elseif (Tools::isSubmit('editBlockCMSConfirmation')) elseif (Tools::isSubmit('editBlockCMSConfirmation'))
$this->_html = $this->displayConfirmation($this->l('Block CMS edited')); $this->_html = $this->displayConfirmation($this->l('Block CMS edited'));
elseif (Tools::isSubmit('deleteBlockCMSConfirmation')) elseif (Tools::isSubmit('deleteBlockCMSConfirmation'))
$this->_html .= $this->displayConfirmation($this->l('Deletion successful')); $this->_html .= $this->displayConfirmation($this->l('Deletion successful'));
elseif (Tools::isSubmit('id_cms_block') AND Tools::isSubmit('way') AND Tools::isSubmit('position') AND Tools::isSubmit('location')) elseif (Tools::isSubmit('id_cms_block') && Tools::isSubmit('way') && Tools::isSubmit('position') && Tools::isSubmit('location'))
$this->changePosition(); $this->changePosition();
} }
public function getContent() public function getContent()
@@ -815,7 +815,7 @@ class BlockCms extends Module
if ($this->_postValidation()) if ($this->_postValidation())
$this->_postProcess(); $this->_postProcess();
$this->_html .= '<h2>'.$this->l('CMS Block configuration').'</h2>'; $this->_html .= '<h2>'.$this->l('CMS Block configuration').'</h2>';
if (Tools::isSubmit('addBlockCMS') OR Tools::isSubmit('editBlockCMS')) if (Tools::isSubmit('addBlockCMS') || Tools::isSubmit('editBlockCMS'))
$this->_displayAddForm(); $this->_displayAddForm();
else else
$this->_displayForm(); $this->_displayForm();
@@ -845,7 +845,6 @@ class BlockCms extends Module
public function hookFooter() public function hookFooter()
{ {
if (Configuration::get('FOOTER_BLOCK_ACTIVATION')) if (Configuration::get('FOOTER_BLOCK_ACTIVATION'))
{ {
$cms_titles = self::getCMStitlesFooter(); $cms_titles = self::getCMStitlesFooter();
+10 -6
View File
@@ -28,7 +28,7 @@
if (!defined('_CAN_LOAD_FILES_')) if (!defined('_CAN_LOAD_FILES_'))
exit; exit;
class blockcontact extends Module class Blockcontact extends Module
{ {
public function __construct() public function __construct()
{ {
@@ -44,13 +44,17 @@ class blockcontact extends Module
public function install() public function install()
{ {
return (parent::install() AND Configuration::updateValue('blockcontact_telnumber', '') AND Configuration::updateValue('blockcontact_email', '') AND $this->registerHook('displayRightColumn') && $this->registerHook('displayHeader')); return parent::install()
&& Configuration::updateValue('blockcontact_telnumber', '')
&& Configuration::updateValue('blockcontact_email', '')
&& $this->registerHook('displayRightColumn')
&& $this->registerHook('displayHeader');
} }
public function uninstall() public function uninstall()
{ {
//Delete configuration // Delete configuration
return (Configuration::deleteByName('blockcontact_telnumber') AND Configuration::deleteByName('blockcontact_email') AND parent::uninstall()); return Configuration::deleteByName('blockcontact_telnumber') && Configuration::deleteByName('blockcontact_email') && parent::uninstall();
} }
public function getContent() public function getContent()
@@ -69,10 +73,10 @@ class blockcontact extends Module
<form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post"> <form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post">
<fieldset> <fieldset>
<label for="telnumber">'.$this->l('Telephone number : ').'</label> <label for="telnumber">'.$this->l('Telephone number : ').'</label>
<input type="text" id="telnumber" name="telnumber" value="'.((Configuration::get('blockcontact_telnumber') != "") ? Configuration::get('blockcontact_telnumber') : "").'" /> <input type="text" id="telnumber" name="telnumber" value="'.((Configuration::get('blockcontact_telnumber') != '') ? Configuration::get('blockcontact_telnumber') : '').'" />
<div class="clear">&nbsp;</div> <div class="clear">&nbsp;</div>
<label for="email">'.$this->l('Email : ').'</label> <label for="email">'.$this->l('Email : ').'</label>
<input type="text" id="email" name="email" value="'.((Configuration::get('blockcontact_email') != "") ? Configuration::get('blockcontact_email') : "").'" /> <input type="text" id="email" name="email" value="'.((Configuration::get('blockcontact_email') != '') ? Configuration::get('blockcontact_email') : '').'" />
<div class="clear">&nbsp;</div> <div class="clear">&nbsp;</div>
<div class="margin-form"> <div class="margin-form">
<input type="submit" name="submitModule" value="'.$this->l('Update settings').'" class="button" /></center> <input type="submit" name="submitModule" value="'.$this->l('Update settings').'" class="button" /></center>
+12 -12
View File
@@ -28,12 +28,12 @@
if (!defined('_CAN_LOAD_FILES_')) if (!defined('_CAN_LOAD_FILES_'))
exit; exit;
class blockcontactinfos extends Module class Blockcontactinfos extends Module
{ {
public function __construct() public function __construct()
{ {
$this->name = 'blockcontactinfos'; $this->name = 'blockcontactinfos';
if(version_compare(_PS_VERSION_, '1.4.0.0') >= 0) if (version_compare(_PS_VERSION_, '1.4.0.0') >= 0)
$this->tab = 'front_office_features'; $this->tab = 'front_office_features';
else else
$this->tab = 'Blocks'; $this->tab = 'Blocks';
@@ -48,18 +48,18 @@ class blockcontactinfos extends Module
public function install() public function install()
{ {
return (parent::install() return (parent::install()
AND Configuration::updateValue('blockcontactinfos_company', Configuration::get('PS_SHOP_NAME')) && Configuration::updateValue('blockcontactinfos_company', Configuration::get('PS_SHOP_NAME'))
AND Configuration::updateValue('blockcontactinfos_address', '') AND Configuration::updateValue('blockcontactinfos_phone', '') && Configuration::updateValue('blockcontactinfos_address', '') && Configuration::updateValue('blockcontactinfos_phone', '')
AND Configuration::updateValue('blockcontactinfos_email', Configuration::get('PS_SHOP_EMAIL')) && Configuration::updateValue('blockcontactinfos_email', Configuration::get('PS_SHOP_EMAIL'))
AND $this->registerHook('header') AND $this->registerHook('footer')); && $this->registerHook('header') && $this->registerHook('footer'));
} }
public function uninstall() public function uninstall()
{ {
//Delete configuration //Delete configuration
return (Configuration::deleteByName('blockcontactinfos_company') return (Configuration::deleteByName('blockcontactinfos_company')
AND Configuration::deleteByName('blockcontactinfos_address') AND Configuration::deleteByName('blockcontactinfos_phone') && Configuration::deleteByName('blockcontactinfos_address') && Configuration::deleteByName('blockcontactinfos_phone')
AND Configuration::deleteByName('blockcontactinfos_email') AND parent::uninstall()); && Configuration::deleteByName('blockcontactinfos_email') && parent::uninstall());
} }
public function getContent() public function getContent()
@@ -68,10 +68,10 @@ class blockcontactinfos extends Module
// If we try to update the settings // If we try to update the settings
if (isset($_POST['submitModule'])) if (isset($_POST['submitModule']))
{ {
Configuration::updateValue('blockcontactinfos_company', ((isset($_POST['company']) AND $_POST['company'] != '') ? $_POST['company'] : Configuration::get('PS_SHOP_NAME'))); Configuration::updateValue('blockcontactinfos_company', ((isset($_POST['company']) && $_POST['company'] != '') ? $_POST['company'] : Configuration::get('PS_SHOP_NAME')));
Configuration::updateValue('blockcontactinfos_address', ((isset($_POST['address']) AND $_POST['address'] != '') ? $_POST['address'] : '')); Configuration::updateValue('blockcontactinfos_address', ((isset($_POST['address']) && $_POST['address'] != '') ? $_POST['address'] : ''));
Configuration::updateValue('blockcontactinfos_phone', ((isset($_POST['phone']) AND $_POST['phone'] != '') ? $_POST['phone'] : '')); Configuration::updateValue('blockcontactinfos_phone', ((isset($_POST['phone']) && $_POST['phone'] != '') ? $_POST['phone'] : ''));
Configuration::updateValue('blockcontactinfos_email', ((isset($_POST['email']) AND $_POST['email'] != '') ? $_POST['email'] : Configuration::get('PS_SHOP_EMAIL'))); Configuration::updateValue('blockcontactinfos_email', ((isset($_POST['email']) && $_POST['email'] != '') ? $_POST['email'] : Configuration::get('PS_SHOP_EMAIL')));
$html .= '<div class="confirm">'.$this->l('Configuration updated').'</div>'; $html .= '<div class="confirm">'.$this->l('Configuration updated').'</div>';
} }
+3 -3
View File
@@ -46,7 +46,7 @@ class BlockCurrencies extends Module
public function install() public function install()
{ {
return (parent::install() AND $this->registerHook('top') AND $this->registerHook('header')); return parent::install() && $this->registerHook('top') && $this->registerHook('header');
} }
/** /**
@@ -58,7 +58,7 @@ class BlockCurrencies extends Module
public function hookTop($params) public function hookTop($params)
{ {
if (Configuration::get('PS_CATALOG_MODE')) if (Configuration::get('PS_CATALOG_MODE'))
return ; return;
if (!count(Currency::getCurrencies())) if (!count(Currency::getCurrencies()))
return ''; return '';
@@ -69,7 +69,7 @@ class BlockCurrencies extends Module
public function hookHeader($params) public function hookHeader($params)
{ {
if (Configuration::get('PS_CATALOG_MODE')) if (Configuration::get('PS_CATALOG_MODE'))
return ; return;
$this->context->controller->addCSS(($this->_path).'blockcurrencies.css', 'all'); $this->context->controller->addCSS(($this->_path).'blockcurrencies.css', 'all');
} }
} }
@@ -28,7 +28,7 @@
if (!defined('_PS_VERSION_')) if (!defined('_PS_VERSION_'))
exit; exit;
class blockcustomerprivacy extends Module class Blockcustomerprivacy extends Module
{ {
public function __construct() public function __construct()
{ {
@@ -49,7 +49,7 @@ class blockcustomerprivacy extends Module
public function install() public function install()
{ {
return (parent::install() AND $this->registerHook('createAccountForm') AND Configuration::updateValue('CUSTPRIV_MESSAGE', array())); return parent::install() && $this->registerHook('createAccountForm') && Configuration::updateValue('CUSTPRIV_MESSAGE', array());
} }
public function getContent() public function getContent()
@@ -61,10 +61,10 @@ class blockcustomerprivacy extends Module
if (Tools::isSubmit('submitCustPrivMess')) if (Tools::isSubmit('submitCustPrivMess'))
{ {
$message_trads = array(); $message_trads = array();
foreach($_POST as $key => $value) foreach ($_POST as $key => $value)
if (preg_match("/custpriv_message_/i", $key)) if (preg_match('/custpriv_message_/i', $key))
{ {
$id_lang = preg_split("/custpriv_message_/i", $key); $id_lang = preg_split('/custpriv_message_/i', $key);
$message_trads[(int)$id_lang[1]] = $value; $message_trads[(int)$id_lang[1]] = $value;
} }
Configuration::updateValue('CUSTPRIV_MESSAGE', $message_trads, true); Configuration::updateValue('CUSTPRIV_MESSAGE', $message_trads, true);
@@ -149,7 +149,7 @@ class blockcustomerprivacy extends Module
public function hookCreateAccountForm($params) public function hookCreateAccountForm($params)
{ {
if (!$this->active) if (!$this->active)
return ; return;
$this->smarty->assign(array( $this->smarty->assign(array(
'privacy_message' => Configuration::get('CUSTPRIV_MESSAGE', $this->context->language->id), 'privacy_message' => Configuration::get('CUSTPRIV_MESSAGE', $this->context->language->id),
+15 -16
View File
@@ -30,7 +30,7 @@ if (!defined('_PS_VERSION_'))
class BlockLanguages extends Module class BlockLanguages extends Module
{ {
function __construct() public function __construct()
{ {
$this->name = 'blocklanguages'; $this->name = 'blocklanguages';
$this->tab = 'front_office_features'; $this->tab = 'front_office_features';
@@ -44,9 +44,9 @@ class BlockLanguages extends Module
$this->description = $this->l('Adds a block for selecting a language.'); $this->description = $this->l('Adds a block for selecting a language.');
} }
function install() public function install()
{ {
return (parent::install() AND $this->registerHook('top') AND $this->registerHook('header')); return (parent::install() && $this->registerHook('top') && $this->registerHook('header'));
} }
/** /**
@@ -55,38 +55,37 @@ class BlockLanguages extends Module
* @param array $params Parameters * @param array $params Parameters
* @return string Content * @return string Content
*/ */
function hookTop($params) public function hookTop($params)
{ {
$languages = Language::getLanguages(true, $this->context->shop->getID()); $languages = Language::getLanguages(true, $this->context->shop->getID());
if (!count($languages)) if (!count($languages))
return; return;
$link = new Link(); $link = new Link();
if((int)Configuration::get('PS_REWRITING_SETTINGS')) if ((int)Configuration::get('PS_REWRITING_SETTINGS'))
{ {
$default_rewrite = array(); $default_rewrite = array();
$phpSelf = isset($_SERVER['PHP_SELF']) ? substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)) : ''; if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int)Tools::getValue('id_product')))
if ($phpSelf == 'product.php' AND $id_product = (int)Tools::getValue('id_product'))
{ {
$rewrite_infos = Product::getUrlRewriteInformations((int)$id_product); $rewrite_infos = Product::getUrlRewriteInformations((int)$id_product);
foreach ($rewrite_infos AS $infos) foreach ($rewrite_infos as $infos)
$default_rewrite[$infos['id_lang']] = $link->getProductLink((int)$id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int)$infos['id_lang']); $default_rewrite[$infos['id_lang']] = $link->getProductLink((int)$id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int)$infos['id_lang']);
} }
if ($phpSelf == 'category.php' AND $id_category = (int)Tools::getValue('id_category')) if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int)Tools::getValue('id_category')))
{ {
$rewrite_infos = Category::getUrlRewriteInformations((int)$id_category); $rewrite_infos = Category::getUrlRewriteInformations((int)$id_category);
foreach ($rewrite_infos AS $infos) foreach ($rewrite_infos as $infos)
$default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int)$id_category, $infos['link_rewrite'], $infos['id_lang']); $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int)$id_category, $infos['link_rewrite'], $infos['id_lang']);
} }
if ($phpSelf == 'cms.php' AND ($id_cms = (int)Tools::getValue('id_cms') OR $id_cms_category = (int)Tools::getValue('id_cms_category'))) if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int)Tools::getValue('id_cms')) || ($id_cms_category = (int)Tools::getValue('id_cms_category'))))
{ {
$rewrite_infos = (isset($id_cms) AND !isset($id_cms_category)) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category); $rewrite_infos = (isset($id_cms) && !isset($id_cms_category)) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category);
foreach ($rewrite_infos AS $infos) foreach ($rewrite_infos as $infos)
{ {
$arr_link = (isset($id_cms) AND !isset($id_cms_category)) ? $arr_link = (isset($id_cms) && !isset($id_cms_category)) ?
$link->getCMSLink($id_cms, $infos['link_rewrite'], NULL, $infos['id_lang']) : $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) :
$link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']); $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']);
$default_rewrite[$infos['id_lang']] = $arr_link; $default_rewrite[$infos['id_lang']] = $arr_link;
} }
@@ -98,7 +97,7 @@ class BlockLanguages extends Module
return $this->display(__FILE__, 'blocklanguages.tpl'); return $this->display(__FILE__, 'blocklanguages.tpl');
} }
function hookHeader($params) public function hookHeader($params)
{ {
$this->context->controller->addCSS($this->_path.'blocklanguages.css', 'all'); $this->context->controller->addCSS($this->_path.'blocklanguages.css', 'all');
} }
+39 -43
View File
@@ -50,28 +50,28 @@ class BlockLink extends Module
public function install() public function install()
{ {
if (!parent::install() OR if (!parent::install() ||
!$this->registerHook('leftColumn') OR !$this->registerHook('leftColumn') ||
!Db::getInstance()->execute(' !Db::getInstance()->execute('
CREATE TABLE '._DB_PREFIX_.'blocklink ( CREATE TABLE '._DB_PREFIX_.'blocklink (
`id_blocklink` int(2) NOT NULL AUTO_INCREMENT, `id_blocklink` int(2) NOT NULL AUTO_INCREMENT,
`url` varchar(255) NOT NULL, `url` varchar(255) NOT NULL,
`new_window` TINYINT(1) NOT NULL, `new_window` TINYINT(1) NOT NULL,
PRIMARY KEY(`id_blocklink`)) PRIMARY KEY(`id_blocklink`))
ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8') OR ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8') ||
!Db::getInstance()->execute(' !Db::getInstance()->execute('
CREATE TABLE '._DB_PREFIX_.'blocklink_shop ( CREATE TABLE '._DB_PREFIX_.'blocklink_shop (
`id_blocklink` int(2) NOT NULL AUTO_INCREMENT, `id_blocklink` int(2) NOT NULL AUTO_INCREMENT,
`id_shop` varchar(255) NOT NULL, `id_shop` varchar(255) NOT NULL,
PRIMARY KEY(`id_blocklink`, `id_shop`)) PRIMARY KEY(`id_blocklink`, `id_shop`))
ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8') OR ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8') ||
!Db::getInstance()->execute(' !Db::getInstance()->execute('
CREATE TABLE '._DB_PREFIX_.'blocklink_lang ( CREATE TABLE '._DB_PREFIX_.'blocklink_lang (
`id_blocklink` int(2) NOT NULL, `id_blocklink` int(2) NOT NULL,
`id_lang` int(2) NOT NULL, `id_lang` int(2) NOT NULL,
`text` varchar(64) NOT NULL, `text` varchar(64) NOT NULL,
PRIMARY KEY(`id_blocklink`, `id_lang`)) PRIMARY KEY(`id_blocklink`, `id_lang`))
ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8') OR ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8') ||
!Configuration::updateValue('PS_BLOCKLINK_TITLE', array('1' => 'Block link', '2' => 'Bloc lien'))) !Configuration::updateValue('PS_BLOCKLINK_TITLE', array('1' => 'Block link', '2' => 'Bloc lien')))
return false; return false;
return true; return true;
@@ -79,11 +79,11 @@ class BlockLink extends Module
public function uninstall() public function uninstall()
{ {
if (!parent::uninstall() OR if (!parent::uninstall() ||
!Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'blocklink') OR !Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'blocklink') ||
!Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'blocklink_lang') OR !Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'blocklink_lang') ||
!Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'blocklink_shop') OR !Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'blocklink_shop') ||
!Configuration::deleteByName('PS_BLOCKLINK_TITLE') OR !Configuration::deleteByName('PS_BLOCKLINK_TITLE') ||
!Configuration::deleteByName('PS_BLOCKLINK_URL')) !Configuration::deleteByName('PS_BLOCKLINK_URL'))
return false; return false;
return true; return true;
@@ -112,23 +112,23 @@ class BlockLink extends Module
public function getLinks() public function getLinks()
{ {
$result = array(); $result = array();
/* Get id and url */ // Get id and url
if (!$links = Db::getInstance()->executeS('SELECT `id_blocklink`, `url`, `new_window` if (!$links = Db::getInstance()->executeS('SELECT `id_blocklink`, `url`, `new_window`
FROM '._DB_PREFIX_.'blocklink'. FROM '._DB_PREFIX_.'blocklink'.
((int)Configuration::get('PS_BLOCKLINK_ORDERWAY') == 1 ? ' ORDER BY `id_blocklink` DESC' : ''))) ((int)Configuration::get('PS_BLOCKLINK_ORDERWAY') == 1 ? ' ORDER BY `id_blocklink` DESC' : '')))
return false; return false;
$i = 0; $i = 0;
foreach ($links AS $link) foreach ($links as $link)
{ {
$result[$i]['id'] = $link['id_blocklink']; $result[$i]['id'] = $link['id_blocklink'];
$result[$i]['url'] = $link['url']; $result[$i]['url'] = $link['url'];
$result[$i]['newWindow'] = $link['new_window']; $result[$i]['newWindow'] = $link['new_window'];
/* Get multilingual text */ // Get multilingual text
if (!$texts = Db::getInstance()->executeS('SELECT `id_lang`, `text` if (!$texts = Db::getInstance()->executeS('SELECT `id_lang`, `text`
FROM '._DB_PREFIX_.'blocklink_lang FROM '._DB_PREFIX_.'blocklink_lang
WHERE `id_blocklink`='.(int)$link['id_blocklink'])) WHERE `id_blocklink`='.(int)$link['id_blocklink']))
return false; return false;
foreach ($texts AS $text) foreach ($texts as $text)
$result[$i]['text_'.$text['id_lang']] = $text['text']; $result[$i]['text_'.$text['id_lang']] = $text['text'];
$i++; $i++;
} }
@@ -137,20 +137,19 @@ class BlockLink extends Module
public function addLink() public function addLink()
{ {
if ($id_link = Tools::getValue('id_link')) if ($id_link = Tools::getValue('id_link'))
{ {
/* Url registration */ // Url registration
if (!Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'blocklink SET `url`=\''.pSQL($_POST['url']).'\', `new_window`='.(isset($_POST['newWindow']) ? 1 : 0).' WHERE `id_blocklink`='.(int)$id_link)) if (!Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'blocklink SET `url`=\''.pSQL($_POST['url']).'\', `new_window`='.(isset($_POST['newWindow']) ? 1 : 0).' WHERE `id_blocklink`='.(int)$id_link))
return false; return false;
/* Multilingual text */ // Multilingual text
$languages = Language::getLanguages(); $languages = Language::getLanguages();
$defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT'));
if (!$languages) if (!$languages)
return false; return false;
if (!Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'blocklink_lang WHERE `id_blocklink` = '.(int)$id_link)) if (!Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'blocklink_lang WHERE `id_blocklink` = '.(int)$id_link))
return false ; return false;
foreach ($languages AS $language) foreach ($languages as $language)
if (!empty($_POST['text_'.$language['id_lang']])) if (!empty($_POST['text_'.$language['id_lang']]))
{ {
if (!Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'blocklink_lang VALUES ('.(int)$id_link.', '.(int)($language['id_lang']).', \''.pSQL($_POST['text_'.$language['id_lang']]).'\')')) if (!Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'blocklink_lang VALUES ('.(int)$id_link.', '.(int)($language['id_lang']).', \''.pSQL($_POST['text_'.$language['id_lang']]).'\')'))
@@ -162,17 +161,17 @@ class BlockLink extends Module
} }
else else
{ {
/* Url registration */ // Url registration
if (!Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'blocklink if (!Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'blocklink
VALUES (NULL, \''.pSQL($_POST['url']).'\', '.((isset($_POST['newWindow']) AND $_POST['newWindow']) == 'on' ? 1 : 0).')') OR VALUES (NULL, \''.pSQL($_POST['url']).'\', '.((isset($_POST['newWindow']) && $_POST['newWindow']) == 'on' ? 1 : 0).')') ||
!$id_link = Db::getInstance()->Insert_ID()) !$id_link = Db::getInstance()->Insert_ID())
return false; return false;
/* Multilingual text */ // Multilingual text
$languages = Language::getLanguages(); $languages = Language::getLanguages();
$defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT'));
if (!$languages) if (!$languages)
return false; return false;
foreach ($languages AS $language) foreach ($languages as $language)
if (!empty($_POST['text_'.$language['id_lang']])) if (!empty($_POST['text_'.$language['id_lang']]))
{ {
if (!Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'blocklink_lang if (!Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'blocklink_lang
@@ -206,7 +205,7 @@ class BlockLink extends Module
{ {
$languages = Language::getLanguages(); $languages = Language::getLanguages();
$result = array(); $result = array();
foreach ($languages AS $language) foreach ($languages as $language)
$result[$language['id_lang']] = $_POST['title_'.$language['id_lang']]; $result[$language['id_lang']] = $_POST['title_'.$language['id_lang']];
if (!Configuration::updateValue('PS_BLOCKLINK_TITLE', $result)) if (!Configuration::updateValue('PS_BLOCKLINK_TITLE', $result))
return false; return false;
@@ -214,14 +213,14 @@ class BlockLink extends Module
} }
public function getContent() public function getContent()
{ {
$this->_html = '<h2>'.$this->displayName.'</h2> $this->_html = '<h2>'.$this->displayName.'</h2>
<script type="text/javascript" src="'.$this->_path.'blocklink.js"></script>'; <script type="text/javascript" src="'.$this->_path.'blocklink.js"></script>';
/* Add a link */ // Add a link
if (isset($_POST['submitLinkAdd'])) if (isset($_POST['submitLinkAdd']))
{ {
if (empty($_POST['text_'.Configuration::get('PS_LANG_DEFAULT')]) OR empty($_POST['url'])) if (empty($_POST['text_'.Configuration::get('PS_LANG_DEFAULT')]) || empty($_POST['url']))
$this->_html .= $this->displayError($this->l('You must fill in all fields')); $this->_html .= $this->displayError($this->l('You must fill in all fields'));
elseif (!Validate::isUrl(str_replace('http://', '', $_POST['url']))) elseif (!Validate::isUrl(str_replace('http://', '', $_POST['url'])))
$this->_html .= $this->displayError($this->l('Bad URL')); $this->_html .= $this->displayError($this->l('Bad URL'));
@@ -231,13 +230,13 @@ class BlockLink extends Module
else else
$this->_html .= $this->displayError($this->l('An error occurred during link creation.')); $this->_html .= $this->displayError($this->l('An error occurred during link creation.'));
} }
/* Update the block title */ // Update the block title
elseif (isset($_POST['submitTitle'])) elseif (isset($_POST['submitTitle']))
{ {
if (empty($_POST['title_'.Configuration::get('PS_LANG_DEFAULT')])) if (empty($_POST['title_'.Configuration::get('PS_LANG_DEFAULT')]))
$this->_html .= $this->displayError($this->l('"title" field cannot be empty.')); $this->_html .= $this->displayError($this->l('"title" field cannot be empty.'));
elseif (!empty($_POST['title_url']) AND !Validate::isUrl(str_replace('http://', '', $_POST['title_url']))) elseif (!empty($_POST['title_url']) && !Validate::isUrl(str_replace('http://', '', $_POST['title_url'])))
$this->_html .= $this->displayError($this->l('The \'title\' field is invalid')); $this->_html .= $this->displayError($this->l('The \'title\' field is invalid'));
elseif (!Validate::isGenericName($_POST['title_'.Configuration::get('PS_LANG_DEFAULT')])) elseif (!Validate::isGenericName($_POST['title_'.Configuration::get('PS_LANG_DEFAULT')]))
$this->_html .= $this->displayError($this->l('The \'title\' field is invalid')); $this->_html .= $this->displayError($this->l('The \'title\' field is invalid'));
@@ -246,12 +245,11 @@ class BlockLink extends Module
else else
$this->_html .= $this->displayConfirmation($this->l('The block title has been updated.')); $this->_html .= $this->displayConfirmation($this->l('The block title has been updated.'));
} }
// Delete a link
/* Delete a link*/
elseif (Tools::getValue('delete_link') && isset($_GET['id'])) elseif (Tools::getValue('delete_link') && isset($_GET['id']))
{ {
if (!is_numeric($_GET['id']) OR !$this->deleteLink()) if (!is_numeric($_GET['id']) || !$this->deleteLink())
$this->_html .= $this->displayError($this->l('An error occurred during link deletion.')); $this->_html .= $this->displayError($this->l('An error occurred during link deletion.'));
else else
$this->_html .= $this->displayConfirmation($this->l('The link has been deleted.')); $this->_html .= $this->displayConfirmation($this->l('The link has been deleted.'));
@@ -343,14 +341,14 @@ class BlockLink extends Module
foreach ($languages as $language) foreach ($languages as $language)
$this->_html .= ' $this->_html .= '
<div id="title_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $defaultLanguage ? 'block' : 'none').'; float: left;"> <div id="title_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $defaultLanguage ? 'block' : 'none').'; float: left;">
<input type="text" name="title_'.$language['id_lang'].'" value="'.(($this->error AND isset($_POST['title'])) ? $_POST['title'] : Configuration::get('PS_BLOCKLINK_TITLE', $language['id_lang'])).'" /><sup> *</sup> <input type="text" name="title_'.$language['id_lang'].'" value="'.(($this->error && isset($_POST['title'])) ? $_POST['title'] : Configuration::get('PS_BLOCKLINK_TITLE', $language['id_lang'])).'" /><sup> *</sup>
</div>'; </div>';
$this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'title', true); $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'title', true);
$this->_html .= ' $this->_html .= '
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<label>'.$this->l('Block URL:').'</label> <label>'.$this->l('Block URL:').'</label>
<div class="margin-form"><input type="text" name="title_url" value="'.(($this->error AND isset($_POST['title_url'])) ? $_POST['title_url'] : $title_url).'" /></div> <div class="margin-form"><input type="text" name="title_url" value="'.(($this->error && isset($_POST['title_url'])) ? $_POST['title_url'] : $title_url).'" /></div>
<div class="margin-form"><input type="submit" class="button" name="submitTitle" value="'.$this->l('Update').'" /></div> <div class="margin-form"><input type="submit" class="button" name="submitTitle" value="'.$this->l('Update').'" /></div>
</form> </form>
</fieldset> </fieldset>
@@ -380,10 +378,10 @@ class BlockLink extends Module
var currentUrl = \''.AdminController::$currentIndex.'&configure='.$this->name.'\'; var currentUrl = \''.AdminController::$currentIndex.'&configure='.$this->name.'\';
var token=\''.Tools::getValue('token').'\'; var token=\''.Tools::getValue('token').'\';
var links = new Array();'; var links = new Array();';
foreach ($links AS $link) foreach ($links as $link)
{ {
$this->_html .= 'links['.$link['id'].'] = new Array(\''.addslashes($link['url']).'\', '.$link['newWindow']; $this->_html .= 'links['.$link['id'].'] = new Array(\''.addslashes($link['url']).'\', '.$link['newWindow'];
foreach ($languages AS $language) foreach ($languages as $language)
if (isset($link['text_'.$language['id_lang']])) if (isset($link['text_'.$language['id_lang']]))
$this->_html .= ', \''.addslashes($link['text_'.$language['id_lang']]).'\''; $this->_html .= ', \''.addslashes($link['text_'.$language['id_lang']]).'\'';
else else
@@ -408,7 +406,7 @@ class BlockLink extends Module
<td colspan="3">'.$this->l('There are no links.').'</td> <td colspan="3">'.$this->l('There are no links.').'</td>
</tr>'; </tr>';
else else
foreach ($links AS $link) foreach ($links as $link)
$this->_html .= ' $this->_html .= '
<tr> <tr>
<td>'.$link['id'].'</td> <td>'.$link['id'].'</td>
@@ -422,17 +420,15 @@ class BlockLink extends Module
$i = 0; $i = 0;
$nb = count($languages); $nb = count($languages);
$idLng = 0; $idLng = 0;
while($i < $nb) while ($i < $nb)
{ {
if ($languages[$i]['id_lang'] == (int)Configuration::get('PS_LANG_DEFAULT')) if ($languages[$i]['id_lang'] == (int)Configuration::get('PS_LANG_DEFAULT'))
{
$idLng = $i; $idLng = $i;
}
$i++; $i++;
} }
$this->_html .= ' $this->_html .= '
</table> </table>
<input type="hidden" id="languageFirst" value="'.$languages[0]['id_lang'].'" /> <input type="hidden" id="languageFirst" value="'.$languages[0]['id_lang'].'" />
<input type="hidden" id="languageNb" value="'.sizeof($languages).'" />'; <input type="hidden" id="languageNb" value="'.count($languages).'" />';
} }
} }
+12 -12
View File
@@ -30,7 +30,7 @@ if (!defined('_PS_VERSION_'))
class BlockManufacturer extends Module class BlockManufacturer extends Module
{ {
function __construct() public function __construct()
{ {
$this->name = 'blockmanufacturer'; $this->name = 'blockmanufacturer';
$this->tab = 'front_office_features'; $this->tab = 'front_office_features';
@@ -44,16 +44,16 @@ class BlockManufacturer extends Module
$this->description = $this->l('Displays a block of manufacturers/brands'); $this->description = $this->l('Displays a block of manufacturers/brands');
} }
function install() public function install()
{ {
Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT', true); Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT', true);
Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT_NB', 5); Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT_NB', 5);
Configuration::updateValue('MANUFACTURER_DISPLAY_FORM', true); Configuration::updateValue('MANUFACTURER_DISPLAY_FORM', true);
return (parent::install() AND $this->registerHook('leftColumn') AND $this->registerHook('header')); return parent::install() && $this->registerHook('leftColumn') && $this->registerHook('header');
} }
function hookLeftColumn($params) public function hookLeftColumn($params)
{ {
$this->smarty->assign(array( $this->smarty->assign(array(
'manufacturers' => Manufacturer::getManufacturers(), 'manufacturers' => Manufacturer::getManufacturers(),
'text_list' => Configuration::get('MANUFACTURER_DISPLAY_TEXT'), 'text_list' => Configuration::get('MANUFACTURER_DISPLAY_TEXT'),
@@ -64,12 +64,12 @@ class BlockManufacturer extends Module
return $this->display(__FILE__, 'blockmanufacturer.tpl'); return $this->display(__FILE__, 'blockmanufacturer.tpl');
} }
function hookRightColumn($params) public function hookRightColumn($params)
{ {
return $this->hookLeftColumn($params); return $this->hookLeftColumn($params);
} }
function getContent() public function getContent()
{ {
$output = '<h2>'.$this->displayName.'</h2>'; $output = '<h2>'.$this->displayName.'</h2>';
if (Tools::isSubmit('submitBlockManufacturers')) if (Tools::isSubmit('submitBlockManufacturers'))
@@ -77,9 +77,9 @@ class BlockManufacturer extends Module
$text_list = (int)(Tools::getValue('text_list')); $text_list = (int)(Tools::getValue('text_list'));
$text_nb = (int)(Tools::getValue('text_nb')); $text_nb = (int)(Tools::getValue('text_nb'));
$form_list = (int)(Tools::getValue('form_list')); $form_list = (int)(Tools::getValue('form_list'));
if ($text_list AND !Validate::isUnsignedInt($text_nb)) if ($text_list && !Validate::isUnsignedInt($text_nb))
$errors[] = $this->l('Invalid number of elements'); $errors[] = $this->l('Invalid number of elements');
elseif (!$text_list AND !$form_list) elseif (!$text_list && !$form_list)
$errors[] = $this->l('Please activate at least one system list'); $errors[] = $this->l('Please activate at least one system list');
else else
{ {
@@ -87,7 +87,7 @@ class BlockManufacturer extends Module
Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT_NB', $text_nb); Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT_NB', $text_nb);
Configuration::updateValue('MANUFACTURER_DISPLAY_FORM', $form_list); Configuration::updateValue('MANUFACTURER_DISPLAY_FORM', $form_list);
} }
if (isset($errors) AND sizeof($errors)) if (isset($errors) && count($errors))
$output .= $this->displayError(implode('<br />', $errors)); $output .= $this->displayError(implode('<br />', $errors));
else else
$output .= $this->displayConfirmation($this->l('Settings updated')); $output .= $this->displayConfirmation($this->l('Settings updated'));
@@ -123,7 +123,7 @@ class BlockManufacturer extends Module
return $output; return $output;
} }
function hookHeader($params) public function hookHeader($params)
{ {
$this->context->controller->addCSS(($this->_path).'blockmanufacturer.css', 'all'); $this->context->controller->addCSS(($this->_path).'blockmanufacturer.css', 'all');
} }
+1 -1
View File
@@ -56,7 +56,7 @@ class BlockMyAccount extends Module
public function uninstall() public function uninstall()
{ {
return (parent::uninstall() AND $this->removeMyAccountBlockHook()); return (parent::uninstall() && $this->removeMyAccountBlockHook());
} }
public function hookDisplayLeftColumn($params) public function hookDisplayLeftColumn($params)
@@ -28,7 +28,7 @@
if (!defined('_PS_VERSION_')) if (!defined('_PS_VERSION_'))
exit; exit;
class blockmyaccountfooter extends Module class Blockmyaccountfooter extends Module
{ {
public function __construct() public function __construct()
{ {
@@ -46,14 +46,14 @@ class blockmyaccountfooter extends Module
public function install() public function install()
{ {
if (!$this->addMyAccountBlockHook() OR !parent::install() OR !$this->registerHook('footer') OR !$this->registerHook('header')) if (!$this->addMyAccountBlockHook() || !parent::install() || !$this->registerHook('footer') || !$this->registerHook('header'))
return false; return false;
return true; return true;
} }
public function uninstall() public function uninstall()
{ {
return (parent::uninstall() AND $this->removeMyAccountBlockHook()); return parent::uninstall() && $this->removeMyAccountBlockHook();
} }
public function hookLeftColumn($params) public function hookLeftColumn($params)
@@ -84,11 +84,13 @@ class blockmyaccountfooter extends Module
{ {
return Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'hook` WHERE `name` = \'myAccountBlockfooter\''); return Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'hook` WHERE `name` = \'myAccountBlockfooter\'');
} }
function hookHeader($params)
public function hookHeader($params)
{ {
$this->context->controller->addCSS(($this->_path).'blockmyaccount.css', 'all'); $this->context->controller->addCSS(($this->_path).'blockmyaccount.css', 'all');
} }
function hookFooter($params)
public function hookFooter($params)
{ {
global $smarty; global $smarty;
@@ -99,8 +101,4 @@ class blockmyaccountfooter extends Module
)); ));
return $this->display(__FILE__, $this->name.'.tpl'); return $this->display(__FILE__, $this->name.'.tpl');
} }
} }
@@ -46,7 +46,7 @@ class BlockNewProducts extends Module
public function install() public function install()
{ {
if (parent::install() == false OR $this->registerHook('rightColumn') == false OR $this->registerHook('header') == false OR Configuration::updateValue('NEW_PRODUCTS_NBR', 5) == false) if (parent::install() == false || $this->registerHook('rightColumn') == false || $this->registerHook('header') == false || Configuration::updateValue('NEW_PRODUCTS_NBR', 5) == false)
return false; return false;
return true; return true;
} }
@@ -56,7 +56,7 @@ class BlockNewProducts extends Module
$output = '<h2>'.$this->displayName.'</h2>'; $output = '<h2>'.$this->displayName.'</h2>';
if (Tools::isSubmit('submitBlockNewProducts')) if (Tools::isSubmit('submitBlockNewProducts'))
{ {
if (!$productNbr = Tools::getValue('productNbr') OR empty($productNbr)) if (!($productNbr = Tools::getValue('productNbr')) || empty($productNbr))
$output .= '<div class="alert error">'.$this->l('Please fill in the "products displayed" field.').'</div>'; $output .= '<div class="alert error">'.$this->l('Please fill in the "products displayed" field.').'</div>';
elseif ((int)($productNbr) == 0) elseif ((int)($productNbr) == 0)
$output .= '<div class="alert error">'.$this->l('Invalid number.').'</div>'; $output .= '<div class="alert error">'.$this->l('Invalid number.').'</div>';
@@ -97,7 +97,7 @@ class BlockNewProducts extends Module
public function hookRightColumn($params) public function hookRightColumn($params)
{ {
$newProducts = Product::getNewProducts((int)($params['cookie']->id_lang), 0, (int)(Configuration::get('NEW_PRODUCTS_NBR'))); $newProducts = Product::getNewProducts((int)($params['cookie']->id_lang), 0, (int)(Configuration::get('NEW_PRODUCTS_NBR')));
if (!$newProducts AND !Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) if (!$newProducts && !Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY'))
return; return;
$this->smarty->assign(array( $this->smarty->assign(array(
+2 -2
View File
@@ -62,7 +62,7 @@ class Blocknewsletter extends Module
public function install() public function install()
{ {
if (parent::install() == false OR $this->registerHook('leftColumn') == false OR $this->registerHook('header') == false) if (parent::install() == false || $this->registerHook('leftColumn') == false || $this->registerHook('header') == false)
return false; return false;
Configuration::updateValue('NW_SALT', Tools::passwdGen(16)); Configuration::updateValue('NW_SALT', Tools::passwdGen(16));
@@ -188,7 +188,7 @@ class Blocknewsletter extends Module
*/ */
private function newsletterRegistration() private function newsletterRegistration()
{ {
if (empty($_POST['email']) OR !Validate::isEmail($_POST['email'])) if (empty($_POST['email']) || !Validate::isEmail($_POST['email']))
return $this->error = $this->l('Invalid e-mail address'); return $this->error = $this->l('Invalid e-mail address');
/* Unsubscription */ /* Unsubscription */
@@ -77,7 +77,7 @@ class BlockPaymentLogo extends Module
$cmss = CMS::listCms($this->context->language->id); $cmss = CMS::listCms($this->context->language->id);
if (!sizeof($cmss)) if (!count($cmss))
$html .= $this->displayError($this->l('No CMS page is available')); $html .= $this->displayError($this->l('No CMS page is available'));
else else
{ {
@@ -109,7 +109,7 @@ class BlockPaymentLogo extends Module
public function hookLeftColumn($params) public function hookLeftColumn($params)
{ {
if (Configuration::get('PS_CATALOG_MODE')) if (Configuration::get('PS_CATALOG_MODE'))
return ; return;
if (!Configuration::get('PS_PAYMENT_LOGO_CMS_ID')) if (!Configuration::get('PS_PAYMENT_LOGO_CMS_ID'))
@@ -133,7 +133,7 @@ class BlockPaymentLogo extends Module
public function hookHeader($params) public function hookHeader($params)
{ {
if (Configuration::get('PS_CATALOG_MODE')) if (Configuration::get('PS_CATALOG_MODE'))
return ; return;
$this->context->controller->addCSS(($this->_path).'blockpaymentlogo.css', 'all'); $this->context->controller->addCSS(($this->_path).'blockpaymentlogo.css', 'all');
} }
@@ -30,7 +30,7 @@ if (!defined('_PS_VERSION_'))
class BlockPermanentLinks extends Module class BlockPermanentLinks extends Module
{ {
function __construct() public function __construct()
{ {
$this->name = 'blockpermanentlinks'; $this->name = 'blockpermanentlinks';
$this->tab = 'front_office_features'; $this->tab = 'front_office_features';
@@ -44,9 +44,9 @@ class BlockPermanentLinks extends Module
$this->description = $this->l('Adds a block that displays permanent links such as sitemap, contact, etc.'); $this->description = $this->l('Adds a block that displays permanent links such as sitemap, contact, etc.');
} }
function install() public function install()
{ {
return (parent::install() AND $this->registerHook('top') AND $this->registerHook('header')); return (parent::install() && $this->registerHook('top') && $this->registerHook('header'));
} }
/** /**
@@ -55,7 +55,7 @@ class BlockPermanentLinks extends Module
* @param array $params Parameters * @param array $params Parameters
* @return string Content * @return string Content
*/ */
function hookTop($params) public function hookTop($params)
{ {
return $this->display(__FILE__, 'blockpermanentlinks-header.tpl'); return $this->display(__FILE__, 'blockpermanentlinks-header.tpl');
} }
@@ -66,22 +66,22 @@ class BlockPermanentLinks extends Module
* @param array $params Parameters * @param array $params Parameters
* @return string Content * @return string Content
*/ */
function hookLeftColumn($params) public function hookLeftColumn($params)
{ {
return $this->display(__FILE__, 'blockpermanentlinks.tpl'); return $this->display(__FILE__, 'blockpermanentlinks.tpl');
} }
function hookRightColumn($params) public function hookRightColumn($params)
{ {
return $this->hookLeftColumn($params); return $this->hookLeftColumn($params);
} }
function hookFooter($params) public function hookFooter($params)
{ {
return $this->display(__FILE__, 'blockpermanentlinks-footer.tpl'); return $this->display(__FILE__, 'blockpermanentlinks-footer.tpl');
} }
function hookHeader($params) public function hookHeader($params)
{ {
$this->context->controller->addCSS(($this->_path).'blockpermanentlinks.css', 'all'); $this->context->controller->addCSS(($this->_path).'blockpermanentlinks.css', 'all');
} }
+18 -22
View File
@@ -28,12 +28,12 @@
if (!defined('_CAN_LOAD_FILES_')) if (!defined('_CAN_LOAD_FILES_'))
exit; exit;
class blockreinsurance extends Module class Blockreinsurance extends Module
{ {
public function __construct() public function __construct()
{ {
$this->name = 'blockreinsurance'; $this->name = 'blockreinsurance';
if(version_compare(_PS_VERSION_, '1.4.0.0') >= 0) if (version_compare(_PS_VERSION_, '1.4.0.0') >= 0)
$this->tab = 'front_office_features'; $this->tab = 'front_office_features';
else else
$this->tab = 'Blocks'; $this->tab = 'Blocks';
@@ -47,7 +47,7 @@ class blockreinsurance extends Module
public function install() public function install()
{ {
return (parent::install() AND $this->installDB() AND Configuration::updateValue('blockreinsurance_nbblocks', 5) AND $this->registerHook('footer')); return (parent::install() && $this->installDB() && Configuration::updateValue('blockreinsurance_nbblocks', 5) && $this->registerHook('footer'));
} }
public function installDB() public function installDB()
@@ -63,8 +63,8 @@ class blockreinsurance extends Module
public function uninstall() public function uninstall()
{ {
//Delete configuration // Delete configuration
return (Configuration::deleteByName('blockreinsurance_nbblocks') AND $this->uninstallDB() AND parent::uninstall()); return (Configuration::deleteByName('blockreinsurance_nbblocks') && $this->uninstallDB() && parent::uninstall());
} }
public function uninstallDB() public function uninstallDB()
@@ -75,24 +75,24 @@ class blockreinsurance extends Module
public function addToDB() public function addToDB()
{ {
if(isset($_POST['nbblocks'])) if (isset($_POST['nbblocks']))
{ {
for($i = 1; $i <= (int)$_POST['nbblocks']; $i++) for ($i = 1; $i <= (int)$_POST['nbblocks']; $i++)
{ {
$filename = explode('.', $_FILES['info'.$i.'_file']['name']); $filename = explode('.', $_FILES['info'.$i.'_file']['name']);
if (isset($_FILES['info'.$i.'_file']) AND isset($_FILES['info'.$i.'_file']['tmp_name']) AND !empty($_FILES['info'.$i.'_file']['tmp_name'])) if (isset($_FILES['info'.$i.'_file']) && isset($_FILES['info'.$i.'_file']['tmp_name']) && !empty($_FILES['info'.$i.'_file']['tmp_name']))
{ {
if ($error = ImageManager::validateUpload($_FILES['info'.$i.'_file'])) if ($error = ImageManager::validateUpload($_FILES['info'.$i.'_file']))
return false; return false;
elseif (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['info'.$i.'_file']['tmp_name'], $tmpName)) elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES['info'.$i.'_file']['tmp_name'], $tmpName))
return false; return false;
elseif (!ImageManager::resize($tmpName, dirname(__FILE__).'/img/'.$filename[0].'.jpg')) elseif (!ImageManager::resize($tmpName, dirname(__FILE__).'/img/'.$filename[0].'.jpg'))
return false; return false;
unlink($tmpName); unlink($tmpName);
} }
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'reinsurance` (`filename`,`text`) Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'reinsurance` (`filename`,`text`)
VALUES ("'.((isset($filename[0]) AND $filename[0] != '') ? pSQL($filename[0]) : ''). VALUES ("'.((isset($filename[0]) && $filename[0] != '') ? pSQL($filename[0]) : '').
'", "'.((isset($_POST['info'.$i.'_text']) AND $_POST['info'.$i.'_text'] != '') ? pSQL($_POST['info'.$i.'_text']) : '').'")'); '", "'.((isset($_POST['info'.$i.'_text']) && $_POST['info'.$i.'_text'] != '') ? pSQL($_POST['info'.$i.'_text']) : '').'")');
} }
return true; return true;
} else } else
@@ -105,10 +105,8 @@ class blockreinsurance extends Module
while (false !== ($file = readdir($dir))) while (false !== ($file = readdir($dir)))
{ {
$path = dirname(__FILE__).'/img/'.$file; $path = dirname(__FILE__).'/img/'.$file;
if ($file != ".." AND $file != "." AND !is_dir($file)) if ($file != '..' && $file != '.' && !is_dir($file))
{
unlink($path); unlink($path);
}
} }
closedir($dir); closedir($dir);
@@ -125,8 +123,8 @@ class blockreinsurance extends Module
// If we try to update the settings // If we try to update the settings
if (isset($_POST['submitModule'])) if (isset($_POST['submitModule']))
{ {
Configuration::updateValue('blockreinsurance_nbblocks', ((isset($_POST['nbblocks']) AND $_POST['nbblocks'] != '') ? (int)$_POST['nbblocks'] : '')); Configuration::updateValue('blockreinsurance_nbblocks', ((isset($_POST['nbblocks']) && $_POST['nbblocks'] != '') ? (int)$_POST['nbblocks'] : ''));
if($this->removeFromDB() && $this->addToDB()) if ($this->removeFromDB() && $this->addToDB())
echo '<div class="conf confirm"><img src="../img/admin/ok.gif"/>'.$this->l('Configuration updated').'</div>'; echo '<div class="conf confirm"><img src="../img/admin/ok.gif"/>'.$this->l('Configuration updated').'</div>';
else else
echo '<div class="conf error"><img src="../img/admin/disabled.gif"/>'.$this->l('An error occurred during the save').'</div>'; echo '<div class="conf error"><img src="../img/admin/disabled.gif"/>'.$this->l('An error occurred during the save').'</div>';
@@ -165,22 +163,20 @@ class blockreinsurance extends Module
<fieldset class="width2"> <fieldset class="width2">
<select name="nbblocks">'; <select name="nbblocks">';
// Show by default 5 blocks maximum // Show by default 5 blocks maximum
for($i = 1; $i <= 5; $i++) for ($i = 1; $i <= 5; $i++)
{
$content .= '<option value="'.$i.'" '.(($i == $nb_blocks) ? 'selected="selected"' : '').'>'.$i.' '.$this->l('block(s)').'</option>'; $content .= '<option value="'.$i.'" '.(($i == $nb_blocks) ? 'selected="selected"' : '').'>'.$i.' '.$this->l('block(s)').'</option>';
}
$content .= '</select> $content .= '</select>
<div class="clear">&nbsp;</div>'; <div class="clear">&nbsp;</div>';
// Show by default 5 blocks maximum // Show by default 5 blocks maximum
for($i = 1; $i <= 5; $i++) for ($i = 1; $i <= 5; $i++)
{ {
$content .= '<div id="container_infos'.$i.'" class="container_infos"><h3>'.$this->l('Block number').' '.$i.'</h3>'. $content .= '<div id="container_infos'.$i.'" class="container_infos"><h3>'.$this->l('Block number').' '.$i.'</h3>'.
((!empty($infos[$i-1]) && $infos[$i-1]['filename'] != '') ? '<img src="'.Tools::getHttpHost(true)._MODULE_DIR_.$this->name.'/img/'.$infos[$i-1]['filename'].'.jpg" />' : ''). ((!empty($infos[$i - 1]) && $infos[$i - 1]['filename'] != '') ? '<img src="'.Tools::getHttpHost(true)._MODULE_DIR_.$this->name.'/img/'.$infos[$i - 1]['filename'].'.jpg" />' : '').
'<div class="clear">&nbsp;</div> '<div class="clear">&nbsp;</div>
<p><label for="info'.$i.'_file">'.$this->l('Image for this block').' :</label> <p><label for="info'.$i.'_file">'.$this->l('Image for this block').' :</label>
<input type="file" name="info'.$i.'_file" /></p> <input type="file" name="info'.$i.'_file" /></p>
<p><label for="info'.$i.'_text">'.$this->l('Alternative text for this block').' :</label> <p><label for="info'.$i.'_text">'.$this->l('Alternative text for this block').' :</label>
<input type="text" id="info'.$i.'_text" name="info'.$i.'_text" value="'.((!empty($infos[$i-1]) && $infos[$i-1]['text'] != '') ? $infos[$i-1]['text'] : '').'" /></p></div>'; <input type="text" id="info'.$i.'_text" name="info'.$i.'_text" value="'.((!empty($infos[$i - 1]) && $infos[$i - 1]['text'] != '') ? $infos[$i - 1]['text'] : '').'" /></p></div>';
} }
$content .= '<div class="clear">&nbsp;</div> $content .= '<div class="clear">&nbsp;</div>
<br /><center><input type="submit" name="submitModule" value="'.$this->l('Update settings').'" class="button" /></center> <br /><center><input type="submit" name="submitModule" value="'.$this->l('Update settings').'" class="button" /></center>