// Blocktopmenu is now compliant with multishop
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10470 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1,4 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/*/*
|
||||||
|
* 2007-2011 PrestaShop
|
||||||
|
*
|
||||||
|
* NOTICE OF LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||||
|
* that is bundled with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://opensource.org/licenses/afl-3.0.php
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@prestashop.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* DISCLAIMER
|
||||||
|
*
|
||||||
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||||
|
* versions in the future. If you wish to customize PrestaShop for your
|
||||||
|
* needs please refer to http://www.prestashop.com for more information.
|
||||||
|
*
|
||||||
|
* @author PrestaShop SA <contact@prestashop.com>
|
||||||
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
|
* @version Release: $Revision: 7095 $
|
||||||
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*/
|
||||||
|
|
||||||
include _PS_MODULE_DIR_.'blocktopmenu/menutoplinks.class.php';
|
include _PS_MODULE_DIR_.'blocktopmenu/menutoplinks.class.php';
|
||||||
class blocktopmenu extends Module
|
class blocktopmenu extends Module
|
||||||
{
|
{
|
||||||
@@ -28,20 +54,22 @@ class blocktopmenu extends Module
|
|||||||
|
|
||||||
public function installDb()
|
public function installDb()
|
||||||
{
|
{
|
||||||
Db::getInstance()->execute('
|
return (Db::getInstance()->execute('
|
||||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'linksmenutop` (
|
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'linksmenutop` (
|
||||||
`id_link` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
`id_link` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`id_shop` INT UNSIGNED NOT NULL,
|
||||||
`new_window` TINYINT( 1 ) NOT NULL,
|
`new_window` TINYINT( 1 ) NOT NULL,
|
||||||
`link` VARCHAR( 128 ) NOT NULL
|
`link` VARCHAR( 128 ) NOT NULL,
|
||||||
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;');
|
INDEX (`id_shop`)
|
||||||
Db::getInstance()->execute('
|
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;') AND
|
||||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'linksmenutop_lang` (
|
Db::getInstance()->execute('
|
||||||
`id_link` INT NOT NULL ,
|
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'linksmenutop_lang` (
|
||||||
`id_lang` INT NOT NULL ,
|
`id_link` INT NOT NULL,
|
||||||
`label` VARCHAR( 128 ) NOT NULL ,
|
`id_lang` INT NOT NULL,
|
||||||
INDEX ( `id_link` , `id_lang` )
|
`id_shop` INT NOT NULL,
|
||||||
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;');
|
`label` VARCHAR( 128 ) NOT NULL ,
|
||||||
return true;
|
INDEX ( `id_link` , `id_lang`, `id_shop`)
|
||||||
|
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uninstall()
|
public function uninstall()
|
||||||
@@ -64,7 +92,6 @@ class blocktopmenu extends Module
|
|||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
global $cookie;
|
global $cookie;
|
||||||
|
|
||||||
if(Tools::isSubmit('submitBlocktopmenu'))
|
if(Tools::isSubmit('submitBlocktopmenu'))
|
||||||
{
|
{
|
||||||
if(Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', Tools::getValue('items')))
|
if(Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', Tools::getValue('items')))
|
||||||
@@ -81,21 +108,25 @@ class blocktopmenu extends Module
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MenuTopLinks::add(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0));
|
MenuTopLinks::add(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0), (int)$this->context->shop->id);
|
||||||
$this->_html .= $this->displayConfirmation($this->l('The link has been added'));
|
$this->_html .= $this->displayConfirmation($this->l('The link has been added'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(Tools::isSubmit('submitBlocktopmenuRemove'))
|
if(Tools::isSubmit('submitBlocktopmenuRemove'))
|
||||||
{
|
{
|
||||||
$id_link = Tools::getValue('id_link', 0);
|
$id_link = Tools::getValue('id_link', 0);
|
||||||
MenuTopLinks::remove($id_link);
|
MenuTopLinks::remove($id_link, (int)$this->context->shop->id);
|
||||||
Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK'.$id_link.',', 'LNK'.$id_link), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS')));
|
Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK'.$id_link.',', 'LNK'.$id_link), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS')));
|
||||||
$this->_html .= $this->displayConfirmation($this->l('The link has been removed'));
|
$this->_html .= $this->displayConfirmation($this->l('The link has been removed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_html .= '
|
$this->_html .= '
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
<div class="multishop_info">
|
||||||
|
'.$this->l('The modifications will be applied to').' '.(Context::shop() == Shop::CONTEXT_SHOP ? $this->l('shop:').' '.$this->context->shop->name : $this->l('all shops')).'.
|
||||||
|
</div>
|
||||||
<legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>
|
<legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>
|
||||||
<form action="'.$_SERVER['REQUEST_URI'].'" method="post" id="form">
|
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" id="form">
|
||||||
<div style="display: none">
|
<div style="display: none">
|
||||||
<label>'.$this->l('Items').'</label>
|
<label>'.$this->l('Items').'</label>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
@@ -149,7 +180,7 @@ class blocktopmenu extends Module
|
|||||||
// END Products
|
// END Products
|
||||||
// BEGIN Menu Top Links
|
// BEGIN Menu Top Links
|
||||||
$this->_html .= '<optgroup label="'.$this->l('Menu Top Links').'">';
|
$this->_html .= '<optgroup label="'.$this->l('Menu Top Links').'">';
|
||||||
$links = MenuTopLinks::gets($cookie->id_lang);
|
$links = MenuTopLinks::gets($cookie->id_lang, null, (int)$this->context->shop->id);
|
||||||
foreach($links as $link)
|
foreach($links as $link)
|
||||||
$this->_html .= '<option value="LNK'.$link['id_link'].'" style="margin-left:10px;">'.$link['label'].'</option>';
|
$this->_html .= '<option value="LNK'.$link['id_link'].'" style="margin-left:10px;">'.$link['label'].'</option>';
|
||||||
$this->_html .= '</optgroup>';
|
$this->_html .= '</optgroup>';
|
||||||
@@ -221,7 +252,7 @@ class blocktopmenu extends Module
|
|||||||
$this->_html .= '
|
$this->_html .= '
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><img src="../img/admin/add.gif" alt="" title="" />'.$this->l('Add Menu Top Link').'</legend>
|
<legend><img src="../img/admin/add.gif" alt="" title="" />'.$this->l('Add Menu Top Link').'</legend>
|
||||||
<form action="'.$_SERVER['REQUEST_URI'].'" method="post" id="form">
|
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" id="form">
|
||||||
<label>'.$this->l('Label').'</label>
|
<label>'.$this->l('Label').'</label>
|
||||||
<div class="margin-form">';
|
<div class="margin-form">';
|
||||||
foreach ($languages as $language)
|
foreach ($languages as $language)
|
||||||
@@ -262,7 +293,7 @@ class blocktopmenu extends Module
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>';
|
<tbody>';
|
||||||
$links = MenuTopLinks::gets($cookie->id_lang);
|
$links = MenuTopLinks::gets($cookie->id_lang, null, $this->context->shop->id);
|
||||||
foreach($links as $link)
|
foreach($links as $link)
|
||||||
{
|
{
|
||||||
$this->_html .= '
|
$this->_html .= '
|
||||||
@@ -282,108 +313,125 @@ class blocktopmenu extends Module
|
|||||||
$this->_html .= '</tbody>
|
$this->_html .= '</tbody>
|
||||||
</table>
|
</table>
|
||||||
</fieldset>';
|
</fieldset>';
|
||||||
echo $this->_html;
|
return $this->_html;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getMenuItems()
|
private function getMenuItems()
|
||||||
{
|
{
|
||||||
$items = Configuration::get('MOD_BLOCKTOPMENU_ITEMS');
|
if (Context::shop() == Shop::CONTEXT_SHOP)
|
||||||
$items = explode(',', $items);
|
{
|
||||||
return $items;
|
if (!Configuration::isOverridenByCurrentContext('MOD_BLOCKTOPMENU_ITEMS'))
|
||||||
|
$items_shop = Configuration::get('MOD_BLOCKTOPMENU_ITEMS');
|
||||||
|
}
|
||||||
|
if (!isset($items_shop))
|
||||||
|
$items_shop = '';
|
||||||
|
|
||||||
|
$items_shop = explode(',', $items_shop);
|
||||||
|
$items_global = Configuration::getGlobalValue('MOD_BLOCKTOPMENU_ITEMS');
|
||||||
|
$items_global = explode(',', $items_global);
|
||||||
|
|
||||||
|
return array('global' => $items_global, 'shop' => $items_shop);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function makeMenuOption()
|
private function makeMenuOption()
|
||||||
{
|
{
|
||||||
global $cookie;
|
global $cookie;
|
||||||
foreach($this->getMenuItems() as $item)
|
foreach($this->getMenuItems() as $type => $items)
|
||||||
{
|
{
|
||||||
$id = (int)substr($item, 3, strlen($item));
|
foreach ($items as $item)
|
||||||
switch(substr($item, 0, 3))
|
{
|
||||||
{
|
$id = (int)substr($item, 3, strlen($item));
|
||||||
case'CAT':
|
$disabled = ((Context::shop() == Shop::CONTEXT_SHOP && $type == 'global') ? ' disabled="disabled"': '');
|
||||||
$this->getCategoryOption($id, $cookie->id_lang, false);
|
switch(substr($item, 0, 3))
|
||||||
break;
|
{
|
||||||
case'PRD':
|
case'CAT':
|
||||||
$product = new Product($id, true, $cookie->id_lang);
|
$this->getCategoryOption($id, $cookie->id_lang, false);
|
||||||
if(!is_null($product->id))
|
break;
|
||||||
$this->_html .= '<option value="PRD'.$id.'">'.$product->name.'</option>'.PHP_EOL;
|
case'PRD':
|
||||||
break;
|
$product = new Product($id, true, $cookie->id_lang);
|
||||||
case'CMS':
|
if(!is_null($product->id))
|
||||||
$cms = CMS::getLinks($cookie->id_lang, array($id));
|
$this->_html .= '<option value="PRD'.$id.'"'.$disabled.'>'.$product->name.'</option>'.PHP_EOL;
|
||||||
if(count($cms))
|
break;
|
||||||
$this->_html .= '<option value="CMS'.$id.'">'.$cms[0]['meta_title'].'</option>'.PHP_EOL;
|
case'CMS':
|
||||||
break;
|
$cms = CMS::getLinks($cookie->id_lang, array($id));
|
||||||
case'MAN':
|
if(count($cms))
|
||||||
$manufacturer = new Manufacturer($id, $cookie->id_lang);
|
$this->_html .= '<option value="CMS'.$id.'"'.$disabled.'>'.$cms[0]['meta_title'].'</option>'.PHP_EOL;
|
||||||
if(!is_null($manufacturer->id))
|
break;
|
||||||
$this->_html .= '<option value="MAN'.$id.'">'.$manufacturer->name.'</option>'.PHP_EOL;
|
case'MAN':
|
||||||
break;
|
$manufacturer = new Manufacturer($id, $cookie->id_lang);
|
||||||
case'SUP':
|
if(!is_null($manufacturer->id))
|
||||||
$supplier = new Supplier($id, $cookie->id_lang);
|
$this->_html .= '<option value="MAN'.$id.'"'.$disabled.'>'.$manufacturer->name.'</option>'.PHP_EOL;
|
||||||
if(!is_null($supplier->id))
|
break;
|
||||||
$this->_html .= '<option value="SUP'.$id.'">'.$supplier->name.'</option>'.PHP_EOL;
|
case'SUP':
|
||||||
break;
|
$supplier = new Supplier($id, $cookie->id_lang);
|
||||||
case'LNK':
|
if(!is_null($supplier->id))
|
||||||
$link = MenuTopLinks::get($id, $cookie->id_lang);
|
$this->_html .= '<option value="SUP'.$id.'"'.$disabled.'>'.$supplier->name.'</option>'.PHP_EOL;
|
||||||
if(count($link))
|
break;
|
||||||
$this->_html .= '<option value="LNK'.$id.'">'.$link[0]['label'].'</option>'.PHP_EOL;
|
case'LNK':
|
||||||
break;
|
$link = MenuTopLinks::get($id, $cookie->id_lang, (int)$this->context->shop->id);
|
||||||
|
if(count($link))
|
||||||
|
$this->_html .= '<option value="LNK'.$id.'"'.$disabled.'>'.$link[0]['label'].'</option>'.PHP_EOL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function makeMenu()
|
private function makeMenu()
|
||||||
{
|
{
|
||||||
global $cookie, $page_name;
|
global $cookie, $page_name;
|
||||||
foreach($this->getMenuItems() as $item)
|
foreach($this->getMenuItems() as $type => $items)
|
||||||
{
|
{
|
||||||
$id = (int)substr($item, 3, strlen($item));
|
foreach ($items as $item)
|
||||||
switch(substr($item, 0, 3))
|
{
|
||||||
{
|
$id = (int)substr($item, 3, strlen($item));
|
||||||
case'CAT':
|
switch(substr($item, 0, 3))
|
||||||
$this->getCategory($id, $cookie->id_lang);
|
{
|
||||||
break;
|
case'CAT':
|
||||||
case'PRD':
|
$this->getCategory($id, $cookie->id_lang);
|
||||||
$selected = ($page_name == 'product' && (Tools::getValue('id_product') == $id)) ? ' class="sfHover"' : '';
|
break;
|
||||||
$product = new Product($id, true, $cookie->id_lang);
|
case'PRD':
|
||||||
if(!is_null($product->id))
|
$selected = ($page_name == 'product' && (Tools::getValue('id_product') == $id)) ? ' class="sfHover"' : '';
|
||||||
$this->_menu .= '<li'.$selected.'><a href="'.$product->getLink().'">'.$product->name.'</a></li>'.PHP_EOL;
|
$product = new Product($id, true, $cookie->id_lang);
|
||||||
break;
|
if(!is_null($product->id))
|
||||||
case'CMS':
|
$this->_menu .= '<li'.$selected.'><a href="'.$product->getLink().'">'.$product->name.'</a></li>'.PHP_EOL;
|
||||||
$selected = ($page_name == 'cms' && (Tools::getValue('id_cms') == $id)) ? ' class="sfHover"' : '';
|
break;
|
||||||
$cms = CMS::getLinks($cookie->id_lang, array($id));
|
case'CMS':
|
||||||
if(count($cms))
|
$selected = ($page_name == 'cms' && (Tools::getValue('id_cms') == $id)) ? ' class="sfHover"' : '';
|
||||||
$this->_menu .= '<li'.$selected.'><a href="'.$cms[0]['link'].'">'.$cms[0]['meta_title'].'</a></li>'.PHP_EOL;
|
$cms = CMS::getLinks($cookie->id_lang, array($id));
|
||||||
break;
|
if(count($cms))
|
||||||
case'MAN':
|
$this->_menu .= '<li'.$selected.'><a href="'.$cms[0]['link'].'">'.$cms[0]['meta_title'].'</a></li>'.PHP_EOL;
|
||||||
$selected = ($page_name == 'manufacturer' && (Tools::getValue('id_manufacturer') == $id)) ? ' class="sfHover"' : '';
|
break;
|
||||||
$manufacturer = new Manufacturer($id, $cookie->id_lang);
|
case'MAN':
|
||||||
if(!is_null($manufacturer->id))
|
$selected = ($page_name == 'manufacturer' && (Tools::getValue('id_manufacturer') == $id)) ? ' class="sfHover"' : '';
|
||||||
{
|
$manufacturer = new Manufacturer($id, $cookie->id_lang);
|
||||||
if (intval(Configuration::get('PS_REWRITING_SETTINGS')))
|
if(!is_null($manufacturer->id))
|
||||||
$manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name, false);
|
{
|
||||||
else
|
if (intval(Configuration::get('PS_REWRITING_SETTINGS')))
|
||||||
$manufacturer->link_rewrite = 0;
|
$manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name, false);
|
||||||
$link = new Link;
|
else
|
||||||
$this->_menu .= '<li'.$selected.'><a href="'.$link->getManufacturerLink($id, $manufacturer->link_rewrite).'">'.$manufacturer->name.'</a></li>'.PHP_EOL;
|
$manufacturer->link_rewrite = 0;
|
||||||
}
|
$link = new Link;
|
||||||
break;
|
$this->_menu .= '<li'.$selected.'><a href="'.$link->getManufacturerLink($id, $manufacturer->link_rewrite).'">'.$manufacturer->name.'</a></li>'.PHP_EOL;
|
||||||
case'SUP':
|
}
|
||||||
$selected = ($page_name == 'supplier' && (Tools::getValue('id_supplier') == $id)) ? ' class="sfHover"' : '';
|
break;
|
||||||
$supplier = new Supplier($id, $cookie->id_lang);
|
case'SUP':
|
||||||
if(!is_null($supplier->id))
|
$selected = ($page_name == 'supplier' && (Tools::getValue('id_supplier') == $id)) ? ' class="sfHover"' : '';
|
||||||
{
|
$supplier = new Supplier($id, $cookie->id_lang);
|
||||||
$link = new Link;
|
if(!is_null($supplier->id))
|
||||||
$this->_menu .= '<li'.$selected.'><a href="'.$link->getSupplierLink($id, $supplier->link_rewrite).'">'.$supplier->name.'</a></li>'.PHP_EOL;
|
{
|
||||||
}
|
$link = new Link;
|
||||||
break;
|
$this->_menu .= '<li'.$selected.'><a href="'.$link->getSupplierLink($id, $supplier->link_rewrite).'">'.$supplier->name.'</a></li>'.PHP_EOL;
|
||||||
case'LNK':
|
}
|
||||||
$link = MenuTopLinks::get($id, $cookie->id_lang);
|
break;
|
||||||
if(count($link))
|
case'LNK':
|
||||||
$this->_menu .= '<li><a href="'.$link[0]['link'].'"'.(($link[0]['new_window']) ? ' target="_blank"': '').'>'.$link[0]['label'].'</a></li>'.PHP_EOL;
|
$link = MenuTopLinks::get($id, $cookie->id_lang, (int)$this->context->shop->id);
|
||||||
break;
|
if(count($link))
|
||||||
}
|
$this->_menu .= '<li><a href="'.$link[0]['link'].'"'.(($link[0]['new_window']) ? ' target="_blank"': '').'>'.$link[0]['label'].'</a></li>'.PHP_EOL;
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCategoryOption($id_category, $id_lang, $children = true)
|
private function getCategoryOption($id_category, $id_lang, $children = true)
|
||||||
@@ -440,4 +488,4 @@ class blocktopmenu extends Module
|
|||||||
return $this->display(__FILE__, 'blocktopmenu.tpl');
|
return $this->display(__FILE__, 'blocktopmenu.tpl');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,4 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/*
|
||||||
|
* 2007-2011 PrestaShop
|
||||||
|
*
|
||||||
|
* NOTICE OF LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||||
|
* that is bundled with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://opensource.org/licenses/afl-3.0.php
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@prestashop.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* DISCLAIMER
|
||||||
|
*
|
||||||
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||||
|
* versions in the future. If you wish to customize PrestaShop for your
|
||||||
|
* needs please refer to http://www.prestashop.com for more information.
|
||||||
|
*
|
||||||
|
* @author PrestaShop SA <contact@prestashop.com>
|
||||||
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
|
* @version Release: $Revision: 7095 $
|
||||||
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*/
|
||||||
|
|
||||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||||
@@ -9,4 +34,4 @@ header("Pragma: no-cache");
|
|||||||
|
|
||||||
header("Location: ../");
|
header("Location: ../");
|
||||||
exit;
|
exit;
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,22 +1,50 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/*
|
||||||
|
* 2007-2011 PrestaShop
|
||||||
|
*
|
||||||
|
* NOTICE OF LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||||
|
* that is bundled with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://opensource.org/licenses/afl-3.0.php
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@prestashop.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* DISCLAIMER
|
||||||
|
*
|
||||||
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||||
|
* versions in the future. If you wish to customize PrestaShop for your
|
||||||
|
* needs please refer to http://www.prestashop.com for more information.
|
||||||
|
*
|
||||||
|
* @author PrestaShop SA <contact@prestashop.com>
|
||||||
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
|
* @version Release: $Revision: 7095 $
|
||||||
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*/
|
||||||
|
|
||||||
class MenuTopLinks
|
class MenuTopLinks
|
||||||
{
|
{
|
||||||
public static function gets($id_lang, $id_link = null)
|
public static function gets($id_lang, $id_link = null, $id_shop)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->executeS('
|
return Db::getInstance()->executeS('
|
||||||
SELECT l.id_link, l.new_window, l.link, ll.label
|
SELECT l.id_link, l.new_window, l.link, ll.label
|
||||||
FROM '._DB_PREFIX_.'linksmenutop l
|
FROM '._DB_PREFIX_.'linksmenutop l
|
||||||
LEFT JOIN '._DB_PREFIX_.'linksmenutop_lang ll ON (l.id_link = ll.id_link AND ll.id_lang = "'.$id_lang.'")
|
LEFT JOIN '._DB_PREFIX_.'linksmenutop_lang ll ON (l.id_link = ll.id_link AND ll.id_lang = '.(int)$id_lang.' AND ll.id_shop='.(int)$id_shop.')
|
||||||
'.((!is_null($id_link)) ? 'WHERE l.id_link = "'.$id_link.'"' : '').'
|
WHERE 1
|
||||||
|
'.((!is_null($id_link)) ? ' AND l.id_link = "'.(int)$id_link.'"' : '').'
|
||||||
|
AND l.id_shop IN (0, '.(int)$id_shop.')
|
||||||
');
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get($id_link, $id_lang)
|
public static function get($id_link, $id_lang, $id_shop)
|
||||||
{
|
{
|
||||||
return self::gets($id_lang, $id_link);
|
return self::gets($id_lang, $id_link, $id_shop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function add($link, $label, $newWindow = 0)
|
public static function add($link, $label, $newWindow = 0, $id_shop)
|
||||||
{
|
{
|
||||||
if(!is_array($label))
|
if(!is_array($label))
|
||||||
return false;
|
return false;
|
||||||
@@ -25,7 +53,8 @@ class MenuTopLinks
|
|||||||
_DB_PREFIX_.'linksmenutop',
|
_DB_PREFIX_.'linksmenutop',
|
||||||
array(
|
array(
|
||||||
'new_window'=>(int)$newWindow,
|
'new_window'=>(int)$newWindow,
|
||||||
'link'=>$link
|
'link'=>pSQL($link),
|
||||||
|
'id_shop' => (int)$id_shop
|
||||||
),
|
),
|
||||||
'INSERT'
|
'INSERT'
|
||||||
);
|
);
|
||||||
@@ -35,19 +64,20 @@ class MenuTopLinks
|
|||||||
Db::getInstance()->autoExecute(
|
Db::getInstance()->autoExecute(
|
||||||
_DB_PREFIX_.'linksmenutop_lang',
|
_DB_PREFIX_.'linksmenutop_lang',
|
||||||
array(
|
array(
|
||||||
'id_link'=>$id_link,
|
'id_link'=>(int)$id_link,
|
||||||
'id_lang'=>$id_lang,
|
'id_lang'=>(int)$id_lang,
|
||||||
'label'=>$label
|
'id_shop'=>(int)$id_shop,
|
||||||
|
'label'=>pSQL($label)
|
||||||
),
|
),
|
||||||
'INSERT'
|
'INSERT'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function remove($id_link)
|
public static function remove($id_link, $id_shop)
|
||||||
{
|
{
|
||||||
Db::getInstance()->delete(_DB_PREFIX_.'linksmenutop', "id_link = '{$id_link}'");
|
Db::getInstance()->delete(_DB_PREFIX_.'linksmenutop', 'id_link = '.(int)$id_link.' AND id_shop = '.(int)$id_shop);
|
||||||
Db::getInstance()->delete(_DB_PREFIX_.'linksmenutop_lang', "id_link = '{$id_link}'");
|
Db::getInstance()->delete(_DB_PREFIX_.'linksmenutop_lang', 'id_link = '.(int)$id_link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user