[~] Hook::get replaced by Hook::getIdByName

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7916 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
fBrignoli
2011-08-05 14:49:18 +00:00
parent 01868b944c
commit 13da28a2a8
6 changed files with 202 additions and 178 deletions
+52 -31
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2011 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -29,42 +29,64 @@ class HookCore extends ObjectModel
{ {
/** @var string Name */ /** @var string Name */
public $name; public $name;
protected $fieldsRequired = array('name'); protected $fieldsRequired = array('name');
protected $fieldsSize = array('name' => 32); protected $fieldsSize = array('name' => 32);
protected $fieldsValidate = array('name' => 'isHookName'); protected $fieldsValidate = array('name' => 'isHookName');
protected $table = 'hook'; protected $table = 'hook';
protected $identifier = 'id_hook'; protected $identifier = 'id_hook';
static $preloadModulesFromHooks = null; static $preloadModulesFromHooks = null;
public function getFields() public function getFields()
{ {
parent::validateFields(); parent::validateFields();
$fields['name'] = pSQL($this->name); $fields['name'] = pSQL($this->name);
return $fields; return $fields;
} }
/** /**
* Return hook ID from name * Return hook ID from name
* *
* @param string $hookName Hook name * @param string $hookName Hook name
* @return integer Hook ID * @return integer Hook ID
*
* @deprecated since 1.5
*/ */
static public function get($hookName) static public function get($hookName)
{ {
Tools::displayAsDeprecated();
if (!Validate::isHookName($hookName)) if (!Validate::isHookName($hookName))
die(Tools::displayError()); die(Tools::displayError());
$result = Db::getInstance()->getRow(' $result = Db::getInstance()->getRow('
SELECT `id_hook`, `name` SELECT `id_hook`, `name`
FROM `'._DB_PREFIX_.'hook` FROM `'._DB_PREFIX_.'hook`
WHERE `name` = \''.pSQL($hookName).'\''); WHERE `name` = \''.pSQL($hookName).'\'');
return ($result ? $result['id_hook'] : false); return ($result ? $result['id_hook'] : false);
} }
/**
* Return hook ID from name
*
* @param string $hook_name Hook name
* @return integer Hook ID
*/
public static function getIdByName($hook_name)
{
if (!Validate::isHookName($hook_name))
die(Tools::displayError());
$result = Db::getInstance()->getRow('
SELECT `id_hook`, `name`
FROM `'._DB_PREFIX_.'hook`
WHERE `name` = \''.pSQL($hook_name).'\'');
return ($result ? $result['id_hook'] : false);
}
static public function getHooks($position = false) static public function getHooks($position = false)
{ {
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
@@ -105,7 +127,7 @@ class HookCore extends ObjectModel
); );
} }
} }
static public function getModulesFromHook($hookID, $moduleID = null) static public function getModulesFromHook($hookID, $moduleID = null)
{ {
Hook::preloadModulesFromHooks(); Hook::preloadModulesFromHooks();
@@ -115,7 +137,7 @@ class HookCore extends ObjectModel
return (isset($list[$moduleID])) ? array($list[$moduleID]) : array(); return (isset($list[$moduleID])) ? array($list[$moduleID]) : array();
return $list; return $list;
} }
static public function newOrder($cart, $order, $customer, $currency, $orderStatus) static public function newOrder($cart, $order, $customer, $currency, $orderStatus)
{ {
return Module::hookExec('newOrder', array( return Module::hookExec('newOrder', array(
@@ -135,7 +157,7 @@ class HookCore extends ObjectModel
$return = Module::hookExec('updateOrderStatus', array('newOrderStatus' => $newOS, 'id_order' => (int)($order->id))) AND $return; $return = Module::hookExec('updateOrderStatus', array('newOrderStatus' => $newOS, 'id_order' => (int)($order->id))) AND $return;
return $return; return $return;
} }
static public function postUpdateOrderStatus($newOrderStatusId, $id_order) static public function postUpdateOrderStatus($newOrderStatusId, $id_order)
{ {
$order = new Order((int)($id_order)); $order = new Order((int)($id_order));
@@ -146,7 +168,7 @@ class HookCore extends ObjectModel
/** /**
* Called when quantity of a product is updated. * Called when quantity of a product is updated.
* *
* @param Product * @param Product
* @param Order * @param Order
*/ */
@@ -154,37 +176,37 @@ class HookCore extends ObjectModel
{ {
return Module::hookExec('updateQuantity', array('product' => $product, 'order' => $order)); return Module::hookExec('updateQuantity', array('product' => $product, 'order' => $order));
} }
static public function productFooter($product, $category) static public function productFooter($product, $category)
{ {
return Module::hookExec('productFooter', array('product' => $product, 'category' => $category)); return Module::hookExec('productFooter', array('product' => $product, 'category' => $category));
} }
static public function productOutOfStock($product) static public function productOutOfStock($product)
{ {
return Module::hookExec('productOutOfStock', array('product' => $product)); return Module::hookExec('productOutOfStock', array('product' => $product));
} }
static public function addProduct($product) static public function addProduct($product)
{ {
return Module::hookExec('addProduct', array('product' => $product)); return Module::hookExec('addProduct', array('product' => $product));
} }
static public function updateProduct($product) static public function updateProduct($product)
{ {
return Module::hookExec('updateProduct', array('product' => $product)); return Module::hookExec('updateProduct', array('product' => $product));
} }
static public function deleteProduct($product) static public function deleteProduct($product)
{ {
return Module::hookExec('deleteProduct', array('product' => $product)); return Module::hookExec('deleteProduct', array('product' => $product));
} }
static public function updateProductAttribute($id_product_attribute) static public function updateProductAttribute($id_product_attribute)
{ {
return Module::hookExec('updateProductAttribute', array('id_product_attribute' => $id_product_attribute)); return Module::hookExec('updateProductAttribute', array('id_product_attribute' => $id_product_attribute));
} }
static public function orderConfirmation($id_order) static public function orderConfirmation($id_order)
{ {
if (Validate::isUnsignedId($id_order)) if (Validate::isUnsignedId($id_order))
@@ -192,20 +214,20 @@ class HookCore extends ObjectModel
$params = array(); $params = array();
$order = new Order((int)$id_order); $order = new Order((int)$id_order);
$currency = new Currency((int)$order->id_currency); $currency = new Currency((int)$order->id_currency);
if (Validate::isLoadedObject($order)) if (Validate::isLoadedObject($order))
{ {
$params['total_to_pay'] = $order->total_paid; $params['total_to_pay'] = $order->total_paid;
$params['currency'] = $currency->sign; $params['currency'] = $currency->sign;
$params['objOrder'] = $order; $params['objOrder'] = $order;
$params['currencyObj'] = $currency; $params['currencyObj'] = $currency;
return Module::hookExec('orderConfirmation', $params); return Module::hookExec('orderConfirmation', $params);
} }
} }
return false; return false;
} }
static public function paymentReturn($id_order, $id_module) static public function paymentReturn($id_order, $id_module)
{ {
if (Validate::isUnsignedId($id_order) AND Validate::isUnsignedId($id_module)) if (Validate::isUnsignedId($id_order) AND Validate::isUnsignedId($id_module))
@@ -213,14 +235,14 @@ class HookCore extends ObjectModel
$params = array(); $params = array();
$order = new Order((int)($id_order)); $order = new Order((int)($id_order));
$currency = new Currency((int)($order->id_currency)); $currency = new Currency((int)($order->id_currency));
if (Validate::isLoadedObject($order)) if (Validate::isLoadedObject($order))
{ {
$params['total_to_pay'] = $order->total_paid; $params['total_to_pay'] = $order->total_paid;
$params['currency'] = $currency->sign; $params['currency'] = $currency->sign;
$params['objOrder'] = $order; $params['objOrder'] = $order;
$params['currencyObj'] = $currency; $params['currencyObj'] = $currency;
return Module::hookExec('paymentReturn', $params, (int)($id_module)); return Module::hookExec('paymentReturn', $params, (int)($id_module));
} }
} }
@@ -233,7 +255,7 @@ class HookCore extends ObjectModel
return false; return false;
return Module::hookExec('PDFInvoice', array('pdf' => $pdf, 'id_order' => $id_order)); return Module::hookExec('PDFInvoice', array('pdf' => $pdf, 'id_order' => $id_order));
} }
static public function backBeforePayment($module) static public function backBeforePayment($module)
{ {
$params['module'] = strval($module); $params['module'] = strval($module);
@@ -241,7 +263,7 @@ class HookCore extends ObjectModel
return false; return false;
return Module::hookExec('backBeforePayment', $params); return Module::hookExec('backBeforePayment', $params);
} }
static public function updateCarrier($id_carrier, $carrier) static public function updateCarrier($id_carrier, $carrier)
{ {
if (!Validate::isUnsignedId($id_carrier) OR !is_object($carrier)) if (!Validate::isUnsignedId($id_carrier) OR !is_object($carrier))
@@ -250,4 +272,3 @@ class HookCore extends ObjectModel
} }
} }
+25 -26
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2011 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -111,8 +111,8 @@ class MoneyBookers extends PaymentModule
public function install() public function install()
{ {
if (!parent::install() OR if (!parent::install() OR
!$this->registerHook('payment') OR !$this->registerHook('payment') OR
!$this->registerHook('paymentReturn')) !$this->registerHook('paymentReturn'))
return false; return false;
Configuration::updateValue('MB_HIDE_LOGIN', 1); Configuration::updateValue('MB_HIDE_LOGIN', 1);
@@ -157,28 +157,28 @@ class MoneyBookers extends PaymentModule
'max_redirects' => 10, 'max_redirects' => 10,
'timeout' => $timeout, 'timeout' => $timeout,
'header' => array( 'header' => array(
'Accept-language: en', 'Accept-language: en',
'Cookie: foo=bar'))); 'Cookie: foo=bar')));
if (is_callable('curl_init') && ($ch = curl_init())) if (is_callable('curl_init') && ($ch = curl_init()))
{ {
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$content = curl_exec($ch); $content = curl_exec($ch);
curl_close($ch); curl_close($ch);
} }
else else
{ {
// Check availability of the context options // Check availability of the context options
if (!is_array($contextOptions) || !count($contextOptions)) if (!is_array($contextOptions) || !count($contextOptions))
$contextOptions = $defaultContextOptions; $contextOptions = $defaultContextOptions;
// Create a stream context // Create a stream context
$stream_context = stream_context_create($contextOptions); $stream_context = stream_context_create($contextOptions);
if (($fp = @fopen($url, $mode, false, $stream_context))) if (($fp = @fopen($url, $mode, false, $stream_context)))
{ {
$content = fgets($fp, 4096); $content = fgets($fp, 4096);
@@ -187,7 +187,7 @@ class MoneyBookers extends PaymentModule
else if (!($content = @file_get_contents($url, false, $stream_context))) else if (!($content = @file_get_contents($url, false, $stream_context)))
if (($fp = @fsockopen($url, 80, $errnom, $errstr, $timeout))) if (($fp = @fsockopen($url, 80, $errnom, $errstr, $timeout)))
{ {
preg_match('@^(?:http://)?([^/]+)@i', $url, $matches); preg_match('@^(?:http://)?([^/]+)@i', $url, $matches);
$host = $matches[1]; $host = $matches[1];
$out = "GET / HTTP/1.1\r\n"; $out = "GET / HTTP/1.1\r\n";
$out .= "Host: ".$host."\r\n"; $out .= "Host: ".$host."\r\n";
@@ -218,7 +218,7 @@ class MoneyBookers extends PaymentModule
if (isset($_POST['mb_email_to_validate']) && if (isset($_POST['mb_email_to_validate']) &&
!empty($_POST['mb_email_to_validate'])) !empty($_POST['mb_email_to_validate']))
{ {
try try
{ {
$url = 'http://moneybookers.prestashop.com/email_check.php?email='.$_POST['mb_email_to_validate'].'&url=http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__; $url = 'http://moneybookers.prestashop.com/email_check.php?email='.$_POST['mb_email_to_validate'].'&url=http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__;
$content = $this->_fetchWebContent($url); $content = $this->_fetchWebContent($url);
@@ -237,7 +237,7 @@ class MoneyBookers extends PaymentModule
} }
} }
catch(Exception $e) catch(Exception $e)
{ {
$errors[] = $this->l('Unable to contact activation server, please try again later.'); $errors[] = $this->l('Unable to contact activation server, please try again later.');
} }
} }
@@ -317,13 +317,13 @@ class MoneyBookers extends PaymentModule
{ {
foreach(array('leftColumn', 'rightColumn') as $hookName) foreach(array('leftColumn', 'rightColumn') as $hookName)
if ($this->isRegisteredInHook($hookName)) if ($this->isRegisteredInHook($hookName))
$this->unregisterHook(Hook::get($hookName)); $this->unregisterHook(Hook::getIdByName($hookName));
if (Tools::getValue('logo_position') == self::LEFT_COLUMN) if (Tools::getValue('logo_position') == self::LEFT_COLUMN)
$this->registerHook('leftColumn'); $this->registerHook('leftColumn');
else if (Tools::getValue('logo_position') == self::RIGHT_COLUMN) else if (Tools::getValue('logo_position') == self::RIGHT_COLUMN)
$this->registerHook('rightColumn'); $this->registerHook('rightColumn');
} }
/* Display errors */ /* Display errors */
if (sizeof($errors)) if (sizeof($errors))
{ {
@@ -351,9 +351,9 @@ class MoneyBookers extends PaymentModule
self::DISABLE => $this->l('Disable'), self::DISABLE => $this->l('Disable'),
self::LEFT_COLUMN => $this->l('Left Column'), self::LEFT_COLUMN => $this->l('Left Column'),
self::RIGHT_COLUMN => $this->l('Right Column')); self::RIGHT_COLUMN => $this->l('Right Column'));
$currentLogoBlockPosition = ($this->isRegisteredInHook('leftColumn')) ? self::LEFT_COLUMN : $currentLogoBlockPosition = ($this->isRegisteredInHook('leftColumn')) ? self::LEFT_COLUMN :
(($this->isRegisteredInHook('rightColumn')) ? self::RIGHT_COLUMN : -1); (($this->isRegisteredInHook('rightColumn')) ? self::RIGHT_COLUMN : -1);
/* Display settings form */ /* Display settings form */
$output .= ' $output .= '
@@ -368,7 +368,7 @@ class MoneyBookers extends PaymentModule
<fieldset class="width2" style="margin: 20px 0; width: 800px;"> <fieldset class="width2" style="margin: 20px 0; width: 800px;">
<legend><img src="'.__PS_BASE_URI__.'modules/moneybookers/logo.gif" alt="" />'.$this->l('Settings').'</legend> <legend><img src="'.__PS_BASE_URI__.'modules/moneybookers/logo.gif" alt="" />'.$this->l('Settings').'</legend>
<div class="margin-form" style="margin:0; padding:0 0 1em 20px"> <div class="margin-form" style="margin:0; padding:0 0 1em 20px">
<b>'.$this->l('Select the logo position').'</b> : <b>'.$this->l('Select the logo position').'</b> :
<select name="logo_position">'; <select name="logo_position">';
foreach($blockPositionList as $position => $translation) foreach($blockPositionList as $position => $translation)
{ {
@@ -380,8 +380,8 @@ class MoneyBookers extends PaymentModule
$iso_code = strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))); $iso_code = strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')));
$landingPage = ($iso_code == 'en' || $iso_code == 'us') ? 'http://www.moneybookers.com/ads/partners/index.html?p=Prestashop' : $landingPage = ($iso_code == 'en' || $iso_code == 'us') ? 'http://www.moneybookers.com/ads/partners/index.html?p=Prestashop' :
'http://www.moneybookers.com/ads/partners/'.$iso_code.'/index.html?p=Prestashop'; 'http://www.moneybookers.com/ads/partners/'.$iso_code.'/index.html?p=Prestashop';
$output .= ' $output .= '
</select> </select>
<p>'.$this->l('Change youpr logo position in the Front Office. Works with').' <p>'.$this->l('Change youpr logo position in the Front Office. Works with').'
@@ -424,7 +424,7 @@ class MoneyBookers extends PaymentModule
<tr><td colspan="3" style="border-top: 1px solid black;"><small>'.$this->l('For merchants over €100,000 fees can be negotiated.').' Contact: ecommerce@moneybookers.com</small></td></tr> <tr><td colspan="3" style="border-top: 1px solid black;"><small>'.$this->l('For merchants over €100,000 fees can be negotiated.').' Contact: ecommerce@moneybookers.com</small></td></tr>
</table> </table>
<br /> <br />
'.$this->l('To view the last update of the detailed fees').'<a href="'.$landingPage.'"> <b>'.$this->l('Click here').'</b></a> '.$this->l('To view the last update of the detailed fees').'<a href="'.$landingPage.'"> <b>'.$this->l('Click here').'</b></a>
<p align="left"> <p align="left">
** '.$this->l('Moneybookers eWallet').'<br /> ** '.$this->l('Moneybookers eWallet').'<br />
@@ -562,7 +562,7 @@ class MoneyBookers extends PaymentModule
$imgPath = __PS_BASE_URI__.'modules/moneybookers/logo-skrill.png'; $imgPath = __PS_BASE_URI__.'modules/moneybookers/logo-skrill.png';
return '<div style="text-align:center;"><img src="'.$imgPath.'" width=150 /></div>'; return '<div style="text-align:center;"><img src="'.$imgPath.'" width=150 /></div>';
} }
public function hookRightColumn($params) public function hookRightColumn($params)
{ {
return $this->_displayLogoBlock(self::RIGHT_COLUMN); return $this->_displayLogoBlock(self::RIGHT_COLUMN);
@@ -597,7 +597,7 @@ class MoneyBookers extends PaymentModule
{ {
$localMethods = Configuration::get('MB_LOCAL_METHODS'); $localMethods = Configuration::get('MB_LOCAL_METHODS');
$interMethods = Configuration::get('MB_INTER_METHODS'); $interMethods = Configuration::get('MB_INTER_METHODS');
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'display_mode' => (int)(Configuration::get('MB_DISPLAY_MODE')), 'display_mode' => (int)(Configuration::get('MB_DISPLAY_MODE')),
'local' => $localMethods ? explode('|', $localMethods) : array(), 'local' => $localMethods ? explode('|', $localMethods) : array(),
@@ -662,11 +662,11 @@ class MoneyBookers extends PaymentModule
case _PS_OS_OUTOFSTOCK_: case _PS_OS_OUTOFSTOCK_:
$this->context->smarty->assign('status', 'ok'); $this->context->smarty->assign('status', 'ok');
break; break;
case _PS_OS_BANKWIRE_: case _PS_OS_BANKWIRE_:
$this->context->smarty->assign('status', 'pending'); $this->context->smarty->assign('status', 'pending');
break; break;
case _PS_OS_ERROR_: case _PS_OS_ERROR_:
default: default:
$this->context->smarty->assign('status', 'failed'); $this->context->smarty->assign('status', 'failed');
@@ -677,4 +677,3 @@ class MoneyBookers extends PaymentModule
} }
} }
+41 -38
View File
@@ -268,7 +268,7 @@ class shopimporter extends ImportModule
unset($exportModules[$key]); unset($exportModules[$key]);
$html = '<script type="text/javascript">var globalAjaxShopImporterToken = "'.sha1(_COOKIE_KEY_.'ajaxShopImporter').'";</script> $html = '<script type="text/javascript">var globalAjaxShopImporterToken = "'.sha1(_COOKIE_KEY_.'ajaxShopImporter').'";</script>
<script type="text/javascript" src="../modules/shopimporter/shopimporter.js"></script> <script type="text/javascript" src="../modules/shopimporter/shopimporter.js"></script>
<script src="'._PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js"></script> <script src="'._PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var conf = new Array(); '; var conf = new Array(); ';
$i = 0; $i = 0;
@@ -449,10 +449,10 @@ class shopimporter extends ImportModule
$defaultIdLand = $importModule->getDefaultIdLang(); $defaultIdLand = $importModule->getDefaultIdLang();
$defaultLanguageImport = new Language(Language::getIdByIso($languages[$defaultIdLand]['iso_code'])); $defaultLanguageImport = new Language(Language::getIdByIso($languages[$defaultIdLand]['iso_code']));
if ($defaultLanguage->iso_code != $defaultLanguageImport->iso_code) if ($defaultLanguage->iso_code != $defaultLanguageImport->iso_code)
$errors[] = $this->l('Default language doesn\'t match : ').'<br>'.Configuration::get('PS_SHOP_NAME').' : '.$defaultLanguage->name.' ≠ $errors[] = $this->l('Default language doesn\'t match : ').'<br>'.Configuration::get('PS_SHOP_NAME').' : '.$defaultLanguage->name.' ≠
'.$importModule->displayName.' : '.$defaultLanguageImport->name.'<br>'.$this->l('Please change default language in your configuration'); '.$importModule->displayName.' : '.$defaultLanguageImport->name.'<br>'.$this->l('Please change default language in your configuration');
} }
if (Tools::isSubmit('syncCurrency')) if (Tools::isSubmit('syncCurrency'))
{ {
$defaultIdCurrency = $importModule->getDefaultIdCurrency(); $defaultIdCurrency = $importModule->getDefaultIdCurrency();
@@ -461,7 +461,7 @@ class shopimporter extends ImportModule
$defaultCurrencyImport = new Currency((int)Currency::getIdByIsoCode($currencies[$defaultIdCurrency]['iso_code'])); $defaultCurrencyImport = new Currency((int)Currency::getIdByIsoCode($currencies[$defaultIdCurrency]['iso_code']));
else else
$defaultCurrencyImport = new Currency((int)Currency::getIdByIsoCodeNum($currencies[$defaultIdCurrency]['iso_code_num'])); $defaultCurrencyImport = new Currency((int)Currency::getIdByIsoCodeNum($currencies[$defaultIdCurrency]['iso_code_num']));
$defaultCurrency = new Currency((int)Configuration::get('PS_CURRENCY_DEFAULT')); $defaultCurrency = new Currency((int)Configuration::get('PS_CURRENCY_DEFAULT'));
if ($defaultCurrency->iso_code != $defaultCurrencyImport->iso_code) if ($defaultCurrency->iso_code != $defaultCurrencyImport->iso_code)
$errors[] = $this->l('Default currency doesn\'t match : ').'<br>'.Configuration::get('PS_SHOP_NAME').' : '.$defaultCurrency->name.' ≠ '.$importModule->displayName.' : '.$defaultCurrencyImport->name.'<br>'.$this->l('Please change default currency in your configuration'); $errors[] = $this->l('Default currency doesn\'t match : ').'<br>'.Configuration::get('PS_SHOP_NAME').' : '.$defaultCurrency->name.' ≠ '.$importModule->displayName.' : '.$defaultCurrencyImport->name.'<br>'.$this->l('Please change default currency in your configuration');
@@ -472,7 +472,7 @@ class shopimporter extends ImportModule
else else
die('{"hasError" : true, "error" : ["FATAL ERROR"], "datas" : []}'); die('{"hasError" : true, "error" : ["FATAL ERROR"], "datas" : []}');
} }
foreach($fields as $key => $field) foreach($fields as $key => $field)
{ {
$id = $this->supportedImports[strtolower($className)]['identifier']; $id = $this->supportedImports[strtolower($className)]['identifier'];
@@ -492,7 +492,7 @@ class shopimporter extends ImportModule
array_unshift($errors[sizeof($errors)-1], $field[$id]); array_unshift($errors[sizeof($errors)-1], $field[$id]);
} }
} }
if (sizeof($errors) > 0) if (sizeof($errors) > 0)
{ {
$json['hasError'] = true; $json['hasError'] = true;
$json['error'] = $errors; $json['error'] = $errors;
@@ -528,14 +528,14 @@ class shopimporter extends ImportModule
if ($className == 'Category' AND (sizeof($fields) != (int)Tools::getValue('nbr_import'))) if ($className == 'Category' AND (sizeof($fields) != (int)Tools::getValue('nbr_import')))
$this->updateCat(); $this->updateCat();
} }
if (sizeof($errors) > 0 AND is_array($errors)) if (sizeof($errors) > 0 AND is_array($errors))
{ {
$json['hasError'] = true; $json['hasError'] = true;
$json['error'] = $errors; $json['error'] = $errors;
} }
die(Tools::jsonEncode($json)); die(Tools::jsonEncode($json));
} }
private function saveObject($className, $items) private function saveObject($className, $items)
{ {
$return = array(); $return = array();
@@ -547,7 +547,7 @@ class shopimporter extends ImportModule
{ {
$object = new $className; $object = new $className;
$id = $item[$this->supportedImports[strtolower($className)]['identifier']]; $id = $item[$this->supportedImports[strtolower($className)]['identifier']];
if (array_key_exists('foreign_key', $this->supportedImports[strtolower($className)])) if (array_key_exists('foreign_key', $this->supportedImports[strtolower($className)]))
$this->replaceForeignKey($item, $table); $this->replaceForeignKey($item, $table);
$matchIdLang = $this->getMatchIdLang(1); $matchIdLang = $this->getMatchIdLang(1);
foreach($item as $key => $val) foreach($item as $key => $val)
@@ -584,7 +584,7 @@ class shopimporter extends ImportModule
} }
return $return; return $return;
} }
private function saveOrders($items) private function saveOrders($items)
{ {
$this->saveObject('cart', $items); $this->saveObject('cart', $items);
@@ -637,12 +637,12 @@ class shopimporter extends ImportModule
$item['order_history'][$k][$key] = $foreignKey[$key][$val]; $item['order_history'][$k][$key] = $foreignKey[$key][$val];
else else
$item['order_history'][$k][$key] = 0; $item['order_history'][$k][$key] = 0;
Db::getInstance()->autoExecute(_DB_PREFIX_.'order_history', $item['order_history'][$k],'INSERT'); Db::getInstance()->autoExecute(_DB_PREFIX_.'order_history', $item['order_history'][$k],'INSERT');
} }
} }
} }
private function insertAssociation($table, $items) private function insertAssociation($table, $items)
{ {
foreach($this->supportedImports[$table]['association'] AS $association) foreach($this->supportedImports[$table]['association'] AS $association)
@@ -675,7 +675,7 @@ class shopimporter extends ImportModule
} }
} }
} }
private function saveMatchId($className, $psId, $matchId) private function saveMatchId($className, $psId, $matchId)
{ {
$table = $this->supportedImports[$className]['table']; $table = $this->supportedImports[$className]['table'];
@@ -683,7 +683,7 @@ class shopimporter extends ImportModule
$identifier = $this->supportedImports[$className]['identifier']; $identifier = $this->supportedImports[$className]['identifier'];
Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.pSQL($table).' SET `'.pSQL($identifier).'_'.pSQL($moduleName).'` = '.(int)$matchId.' WHERE `'.pSQL($identifier).'` = '.(int)$psId); Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.pSQL($table).' SET `'.pSQL($identifier).'_'.pSQL($moduleName).'` = '.(int)$matchId.' WHERE `'.pSQL($identifier).'` = '.(int)$psId);
} }
private function getMatchId($className) private function getMatchId($className)
{ {
$table = $this->supportedImports[$className]['table']; $table = $this->supportedImports[$className]['table'];
@@ -695,7 +695,7 @@ class shopimporter extends ImportModule
$match[$return[$identifier.'_'.$moduleName]] = $return[$identifier]; $match[$return[$identifier.'_'.$moduleName]] = $return[$identifier];
return $match; return $match;
} }
private function getDefaultId($table) private function getDefaultId($table)
{ {
$defaultId = 1; $defaultId = 1;
@@ -703,7 +703,7 @@ class shopimporter extends ImportModule
$defaultId = Configuration::get($this->supportedImports[strtolower($table)]['defaultId']); $defaultId = Configuration::get($this->supportedImports[strtolower($table)]['defaultId']);
return $defaultId; return $defaultId;
} }
private function copyImg($item, $className) private function copyImg($item, $className)
{ {
require_once('../../images.inc.php'); require_once('../../images.inc.php');
@@ -737,7 +737,7 @@ class shopimporter extends ImportModule
$tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'import'); $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'import');
if (@copy($image, $tmpfile)) if (@copy($image, $tmpfile))
{ {
$imagesTypes = ImageType::getImagesTypes($type); $imagesTypes = ImageType::getImagesTypes($type);
imageResize($tmpfile, $path.(int)$matchId[$item[$identifier]].'.jpg'); imageResize($tmpfile, $path.(int)$matchId[$item[$identifier]].'.jpg');
if ($className == 'Product') if ($className == 'Product')
@@ -767,16 +767,16 @@ class shopimporter extends ImportModule
@unlink($tmpfile); @unlink($tmpfile);
$cover = 0; $cover = 0;
} }
} }
private function replaceForeignKey(&$item, $table) private function replaceForeignKey(&$item, $table)
{ {
if ($table == 'product_attribute') if ($table == 'product_attribute')
$table2 = 'combination'; $table2 = 'combination';
else else
$table2 = $table; $table2 = $table;
$foreingKey = $this->supportedImports[$table2]['foreign_key']; $foreingKey = $this->supportedImports[$table2]['foreign_key'];
$foreingKeyValue = $this->getForeignKey($table, $foreingKey); $foreingKeyValue = $this->getForeignKey($table, $foreingKey);
foreach($foreingKey as $key) foreach($foreingKey as $key)
@@ -793,7 +793,7 @@ class shopimporter extends ImportModule
$item[$key2] = $this->getDefaultId($table); $item[$key2] = $this->getDefaultId($table);
} }
} }
private function alterTable($className) private function alterTable($className)
{ {
$query =''; $query ='';
@@ -816,7 +816,7 @@ class shopimporter extends ImportModule
Db::getInstance()->Execute($query); Db::getInstance()->Execute($query);
} }
} }
private function updateCat() private function updateCat()
{ {
$moduleName = Tools::getValue('moduleName'); $moduleName = Tools::getValue('moduleName');
@@ -825,7 +825,7 @@ class shopimporter extends ImportModule
INNER JOIN INNER JOIN
'._DB_PREFIX_.'category c2 '._DB_PREFIX_.'category c2
ON ON
c.id_parent = c2.id_category_'.pSQL($moduleName).' c.id_parent = c2.id_category_'.pSQL($moduleName).'
SET SET
c.id_parent = c2.id_category c.id_parent = c2.id_category
WHERE c.id_category_'.pSQL($moduleName).' != 0'); WHERE c.id_category_'.pSQL($moduleName).' != 0');
@@ -838,7 +838,7 @@ class shopimporter extends ImportModule
$cat->update(); $cat->update();
} }
} }
private function getForeignKey($className, $foreign_key = null) private function getForeignKey($className, $foreign_key = null)
{ {
$moduleName = Tools::getValue('moduleName'); $moduleName = Tools::getValue('moduleName');
@@ -859,7 +859,7 @@ class shopimporter extends ImportModule
$return = Db::getInstance()->ExecuteS('SELECT `'.pSQL($key2).'_'.pSQL($moduleName).'`, `'.pSQL($key2).'` FROM `'._DB_PREFIX_.pSQL($from).'` WHERE `'.pSQL($key2).'_'.pSQL($moduleName).'` != 0'); $return = Db::getInstance()->ExecuteS('SELECT `'.pSQL($key2).'_'.pSQL($moduleName).'`, `'.pSQL($key2).'` FROM `'._DB_PREFIX_.pSQL($from).'` WHERE `'.pSQL($key2).'_'.pSQL($moduleName).'` != 0');
if (!empty($return)) if (!empty($return))
foreach($return AS $name => $val) foreach($return AS $name => $val)
$match[$key][$val[$key2.'_'.$moduleName]] = $val[$key2]; $match[$key][$val[$key2.'_'.$moduleName]] = $val[$key2];
} }
return $match; return $match;
} }
@@ -874,7 +874,7 @@ class shopimporter extends ImportModule
$match[$val[$id.'_'.$moduleName]] = $val[$id]; $match[$val[$id.'_'.$moduleName]] = $val[$id];
return $match; return $match;
} }
private function getMatchIdLang($order = 1) private function getMatchIdLang($order = 1)
{ {
$moduleName = Tools::getValue('moduleName'); $moduleName = Tools::getValue('moduleName');
@@ -931,7 +931,7 @@ class shopimporter extends ImportModule
} }
else else
$returnErrors[] = $this->l('the field').' <b>'.call_user_func(array($className, 'displayFieldName'), $field, $className).'</b> '.$this->l('is invalid'); $returnErrors[] = $this->l('the field').' <b>'.call_user_func(array($className, 'displayFieldName'), $field, $className).'</b> '.$this->l('is invalid');
if ((sizeof($rules['requiredLang']) OR sizeof($rules['sizeLang']) OR sizeof($rules['validateLang']))) if ((sizeof($rules['requiredLang']) OR sizeof($rules['sizeLang']) OR sizeof($rules['validateLang'])))
{ {
$matchIdLang = $this->getMatchIdLang(0); $matchIdLang = $this->getMatchIdLang(0);
@@ -1037,7 +1037,7 @@ class shopimporter extends ImportModule
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'lang` Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'lang`
SET `id_lang_'.pSQL($moduleName).'` = '.(int)$language['id_lang'].' SET `id_lang_'.pSQL($moduleName).'` = '.(int)$language['id_lang'].'
WHERE `id_lang` = '.(int)$newId); WHERE `id_lang` = '.(int)$newId);
} }
} }
} }
@@ -1129,12 +1129,12 @@ class shopimporter extends ImportModule
Product::cleanPositions((int)($categ['id_category'])); Product::cleanPositions((int)($categ['id_category']));
} }
} }
public function getDefaultIdLang() public function getDefaultIdLang()
{ {
return; return;
} }
private function generateData($size = 1, $type) private function generateData($size = 1, $type)
{ {
$type = str_replace('is', '', $type); $type = str_replace('is', '', $type);
@@ -1197,7 +1197,7 @@ class shopimporter extends ImportModule
$return .= substr($str, mt_rand(0, strlen($str)), 1); $return .= substr($str, mt_rand(0, strlen($str)), 1);
break; break;
case 'StateIsoCode'; case 'StateIsoCode';
break; break;
case 'Email': case 'Email':
$a = mt_rand(4, 10); $a = mt_rand(4, 10);
@@ -1218,9 +1218,9 @@ class shopimporter extends ImportModule
$return .= '1970-01-01 00:00:00'; $return .= '1970-01-01 00:00:00';
break; break;
} }
return $return; return $return;
} }
private function cartToOrder($items, $foreignKey) private function cartToOrder($items, $foreignKey)
{ {
$this->alterTable('order'); $this->alterTable('order');
@@ -1231,13 +1231,13 @@ class shopimporter extends ImportModule
$order->id_customer = (int)$foreignKey['id_customer'][$item['id_customer']]; $order->id_customer = (int)$foreignKey['id_customer'][$item['id_customer']];
$order->id_address_invoice = (int)$foreignKey['id_address_invoice'][$item['id_address_invoice']]; $order->id_address_invoice = (int)$foreignKey['id_address_invoice'][$item['id_address_invoice']];
$order->id_address_delivery = (int)$foreignKey['id_address_delivery'][$item['id_address_delivery']]; $order->id_address_delivery = (int)$foreignKey['id_address_delivery'][$item['id_address_delivery']];
$vat_address = new Address((int)$foreignKey['id_address_delivery'][$item['id_address_delivery']]); $vat_address = new Address((int)$foreignKey['id_address_delivery'][$item['id_address_delivery']]);
$id_zone = Address::getZoneById((int)$vat_address->id); $id_zone = Address::getZoneById((int)$vat_address->id);
$order->id_currency = (int)$item['id_currency']; $order->id_currency = (int)$item['id_currency'];
$order->id_lang = (int)$item['id_lang']; $order->id_lang = (int)$item['id_lang'];
$order->id_cart = (int)$foreignKey['id_cart'][$item['id_cart']]; $order->id_cart = (int)$foreignKey['id_cart'][$item['id_cart']];
$customer = new Customer((int)$order->id_customer); $customer = new Customer((int)$order->id_customer);
$order->secure_key = pSQL($customer->secure_key); $order->secure_key = pSQL($customer->secure_key);
if (!strlen(trim($item['payment']))) if (!strlen(trim($item['payment'])))
@@ -1246,24 +1246,27 @@ class shopimporter extends ImportModule
$order->payment = utf8_encode(html_entity_decode(strip_tags(Tools::substr($item['payment'], 0, 32)))); $order->payment = utf8_encode(html_entity_decode(strip_tags(Tools::substr($item['payment'], 0, 32))));
if (isset($this->name)) if (isset($this->name))
$order->module = $this->name; $order->module = $this->name;
$carrier = new Carrier((int)$item['id_carrier']);
$currency = new Currency($order->id_currency); $currency = new Currency($order->id_currency);
$order->conversion_rate = $currency->conversion_rate; $order->conversion_rate = $currency->conversion_rate;
$order->total_products = (float)$item['total_products']; $order->total_products = (float)$item['total_products'];
$order->total_products_wt = (float)$item['total_products_wt']; $order->total_products_wt = (float)$item['total_products_wt'];
$order->total_discounts = (float)$item['total_discounts']; $order->total_discounts = (float)$item['total_discounts'];
$order->total_shipping = (float)$item['total_shipping']; $order->total_shipping = (float)$item['total_shipping'];
$order->carrier_tax_rate = (float)Tax::getCarrierTaxRate((int)$item['id_carrier'], (int)$item[Configuration::get('PS_TAX_ADDRESS_TYPE')]); $order->carrier_tax_rate = (float)$carrier->getTaxesRate(new Address((int)$item[Configuration::get('PS_TAX_ADDRESS_TYPE')]));
$order->total_wrapping = (float)$item['total_wrapping']; $order->total_wrapping = (float)$item['total_wrapping'];
$order->total_paid = (float)$item['total_paid']; $order->total_paid = (float)$item['total_paid'];
$order->total_paid_real = (float)$item['total_paid_real']; $order->total_paid_real = (float)$item['total_paid_real'];
$order->invoice_date = '0000-00-00 00:00:00'; $order->invoice_date = '0000-00-00 00:00:00';
$order->delivery_date = '0000-00-00 00:00:00'; $order->delivery_date = '0000-00-00 00:00:00';
$order->save(false, false); $order->save(false, false);
$this->saveMatchId('order', (int)$order->id, (int)$item['id_cart']); $this->saveMatchId('order', (int)$order->id, (int)$item['id_cart']);
} }
} }
} }
?> ?>
+74 -73
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2011 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -41,17 +41,17 @@ class ThemeInstallator extends Module
** index ** index
*/ */
private $page; private $page;
/* /*
** Config File ** Config File
*/ */
private $xml; private $xml;
public function __construct() public function __construct()
{ {
set_time_limit(0); set_time_limit(0);
ini_set('memory_limit', '2G'); ini_set('memory_limit', '2G');
$this->name = 'themeinstallator'; $this->name = 'themeinstallator';
$this->version = '1.4'; $this->version = '1.4';
$this->author = 'PrestaShop'; $this->author = 'PrestaShop';
@@ -64,7 +64,7 @@ class ThemeInstallator extends Module
$this->displayName = $this->l('Import/export a theme'); $this->displayName = $this->l('Import/export a theme');
$this->description = $this->l('Export or Install a theme and its modules on your shop.'); $this->description = $this->l('Export or Install a theme and its modules on your shop.');
} }
private function getTheNativeModules() private function getTheNativeModules()
{ {
$xml = simplexml_load_string(Tools::file_get_contents('http://www.prestashop.com/xml/modules_list.xml')); $xml = simplexml_load_string(Tools::file_get_contents('http://www.prestashop.com/xml/modules_list.xml'));
@@ -73,7 +73,7 @@ class ThemeInstallator extends Module
foreach ($xml->modules as $row) foreach ($xml->modules as $row)
foreach ($row->module as $row2) foreach ($row->module as $row2)
$natives[] = (string)$row2['name']; $natives[] = (string)$row2['name'];
if (count($natives > 0)) if (count($natives > 0))
return $natives; return $natives;
// use this list if we can't contact the prestashop.com server // use this list if we can't contact the prestashop.com server
@@ -90,7 +90,7 @@ class ThemeInstallator extends Module
'trackingfront', 'watermark'); 'trackingfront', 'watermark');
return $natives; return $natives;
} }
private function deleteDirectory($dirname) private function deleteDirectory($dirname)
{ {
$files = scandir($dirname); $files = scandir($dirname);
@@ -104,7 +104,7 @@ class ThemeInstallator extends Module
} }
rmdir($dirname); rmdir($dirname);
} }
private function recurseCopy($src, $dst) private function recurseCopy($src, $dst)
{ {
if (!$dir = opendir($src)) if (!$dir = opendir($src))
@@ -121,7 +121,7 @@ class ThemeInstallator extends Module
} }
closedir($dir); closedir($dir);
} }
/* /*
** Checks if module is installed ** Checks if module is installed
** Returns true if module is active ** Returns true if module is active
@@ -145,7 +145,7 @@ class ThemeInstallator extends Module
return true; return true;
return false; return false;
} }
private function deleteTmpFiles() private function deleteTmpFiles()
{ {
if (file_exists(_IMPORT_FOLDER_.'doc')) if (file_exists(_IMPORT_FOLDER_.'doc'))
@@ -156,26 +156,26 @@ class ThemeInstallator extends Module
self::deleteDirectory(_IMPORT_FOLDER_.'modules'); self::deleteDirectory(_IMPORT_FOLDER_.'modules');
if (file_exists(_IMPORT_FOLDER_.'themes')) if (file_exists(_IMPORT_FOLDER_.'themes'))
self::deleteDirectory(_IMPORT_FOLDER_.'themes'); self::deleteDirectory(_IMPORT_FOLDER_.'themes');
if (file_exists(_EXPORT_FOLDER_.'archive.zip')) if (file_exists(_EXPORT_FOLDER_.'archive.zip'))
unlink(_EXPORT_FOLDER_.'archive.zip'); unlink(_EXPORT_FOLDER_.'archive.zip');
} }
private function init_defines() private function init_defines()
{ {
global $cookie; global $cookie;
define('_EXPORT_FOLDER_', dirname(__FILE__).'/export/'); define('_EXPORT_FOLDER_', dirname(__FILE__).'/export/');
define('_IMPORT_FOLDER_', dirname(__FILE__).'/import/'); define('_IMPORT_FOLDER_', dirname(__FILE__).'/import/');
$this->page = 1; $this->page = 1;
if (!file_exists(_EXPORT_FOLDER_) OR !is_dir(_EXPORT_FOLDER_)) if (!file_exists(_EXPORT_FOLDER_) OR !is_dir(_EXPORT_FOLDER_))
mkdir(_EXPORT_FOLDER_, 0777); mkdir(_EXPORT_FOLDER_, 0777);
if (!file_exists(_IMPORT_FOLDER_) OR !is_dir(_IMPORT_FOLDER_)) if (!file_exists(_IMPORT_FOLDER_) OR !is_dir(_IMPORT_FOLDER_))
mkdir(_IMPORT_FOLDER_, 0777); mkdir(_IMPORT_FOLDER_, 0777);
if (!Tools::isSubmit('cancelExport') AND (Tools::isSubmit('exportTheme') OR Tools::isSubmit('submitExport'))) if (!Tools::isSubmit('cancelExport') AND (Tools::isSubmit('exportTheme') OR Tools::isSubmit('submitExport')))
$this->page = 'exportPage'; $this->page = 'exportPage';
$this->_html = '<form action="'.AdminTab::$currentIndex.'&configure='.$this->name.'&token='.Tools::htmlentitiesUTF8(Tools::getValue('token')).'" method="POST" enctype=multipart/form-data>'; $this->_html = '<form action="'.AdminTab::$currentIndex.'&configure='.$this->name.'&token='.Tools::htmlentitiesUTF8(Tools::getValue('token')).'" method="POST" enctype=multipart/form-data>';
if (Tools::isSubmit('modulesToExport') OR Tools::isSubmit('submitModules')) if (Tools::isSubmit('modulesToExport') OR Tools::isSubmit('submitModules'))
$this->to_export = Tools::getValue('modulesToExport'); $this->to_export = Tools::getValue('modulesToExport');
if (Tools::isSubmit('submitThemes')) if (Tools::isSubmit('submitThemes'))
@@ -192,7 +192,7 @@ class ThemeInstallator extends Module
define('MAX_COMPATIBILITY_VER', 7); define('MAX_COMPATIBILITY_VER', 7);
define('ARCHIVE_NAME', _IMPORT_FOLDER_.'uploaded.zip'); define('ARCHIVE_NAME', _IMPORT_FOLDER_.'uploaded.zip');
define('XMLFILENAME', 'Config.xml'); define('XMLFILENAME', 'Config.xml');
$this->_msg = ''; $this->_msg = '';
$this->to_enable = false; $this->to_enable = false;
$this->to_disable = false; $this->to_disable = false;
@@ -205,7 +205,7 @@ class ThemeInstallator extends Module
echo parent::displayError('<b>'.$theme.'</b> is not a valid theme to export'); echo parent::displayError('<b>'.$theme.'</b> is not a valid theme to export');
} }
} }
private function handleInformations() private function handleInformations()
{ {
if (Tools::isSubmit('submitImport1')) if (Tools::isSubmit('submitImport1'))
@@ -272,7 +272,7 @@ class ThemeInstallator extends Module
} }
self::deleteTmpFiles(); self::deleteTmpFiles();
} }
private function checkXmlFields() private function checkXmlFields()
{ {
if (!file_exists(_IMPORT_FOLDER_.XMLFILENAME) OR !$xml = simplexml_load_file(_IMPORT_FOLDER_.XMLFILENAME)) if (!file_exists(_IMPORT_FOLDER_.XMLFILENAME) OR !$xml = simplexml_load_file(_IMPORT_FOLDER_.XMLFILENAME))
@@ -290,7 +290,7 @@ class ThemeInstallator extends Module
return false; return false;
return true; return true;
} }
public function getContentExport() public function getContentExport()
{ {
$this->theme_list = scandir(_PS_ALL_THEMES_DIR_); $this->theme_list = scandir(_PS_ALL_THEMES_DIR_);
@@ -314,7 +314,7 @@ class ThemeInstallator extends Module
self::VariationInformationForm(); self::VariationInformationForm();
return $this->_html; return $this->_html;
} }
/* /*
** Main function ** Main function
*/ */
@@ -341,7 +341,7 @@ class ThemeInstallator extends Module
} }
return $this->errors.$this->_msg.$this->_html; return $this->errors.$this->_msg.$this->_html;
} }
/* /*
** Checker si le dossier doc existe : Si oui appeler la fonction ! ** Checker si le dossier doc existe : Si oui appeler la fonction !
*/ */
@@ -349,7 +349,7 @@ class ThemeInstallator extends Module
{ {
$docname = array(); $docname = array();
$docpath = array(); $docpath = array();
foreach ($this->xml->docs->doc as $row) foreach ($this->xml->docs->doc as $row)
{ {
$docname[] = strval($row['name']); $docname[] = strval($row['name']);
@@ -372,7 +372,7 @@ class ThemeInstallator extends Module
<p class="clear">&nbsp;</p>'; <p class="clear">&nbsp;</p>';
$this->_html .= $doc; $this->_html .= $doc;
} }
private function getModules() private function getModules()
{ {
$this->native_modules = self::getTheNativeModules(); $this->native_modules = self::getTheNativeModules();
@@ -386,7 +386,7 @@ class ThemeInstallator extends Module
$this->to_disable[] = strval($row['name']); $this->to_disable[] = strval($row['name']);
} }
} }
private function updateImages() private function updateImages()
{ {
foreach ($this->xml->images->image as $row) foreach ($this->xml->images->image as $row)
@@ -422,7 +422,7 @@ class ThemeInstallator extends Module
} }
return true; return true;
} }
private function _displayForm4() private function _displayForm4()
{ {
$xml = simplexml_load_file(_IMPORT_FOLDER_.XMLFILENAME); $xml = simplexml_load_file(_IMPORT_FOLDER_.XMLFILENAME);
@@ -433,7 +433,7 @@ class ThemeInstallator extends Module
$position = array(); $position = array();
$msg = ''; $msg = '';
$shopID = $this->context->shop->getID(); $shopID = $this->context->shop->getID();
foreach ($this->xml->modules->hooks->hook as $row) foreach ($this->xml->modules->hooks->hook as $row)
{ {
$hookedModule[] = strval($row['module']); $hookedModule[] = strval($row['module']);
@@ -465,7 +465,7 @@ class ThemeInstallator extends Module
Db::getInstance()->Execute('INSERT IGNORE INTO '._DB_PREFIX_.'module_shop (id_module, id_shop) VALUES('.(int)$obj->id.', '.$shopID.')'); Db::getInstance()->Execute('INSERT IGNORE INTO '._DB_PREFIX_.'module_shop (id_module, id_shop) VALUES('.(int)$obj->id.', '.$shopID.')');
$msg .= '<i>- '.pSQL($row).'</i><br />'; $msg .= '<i>- '.pSQL($row).'</i><br />';
Db::getInstance()->Execute(' Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'hook_module` DELETE FROM `'._DB_PREFIX_.'hook_module`
WHERE `id_module` = '.pSQL($obj->id).' AND id_shop = '.$shopID); WHERE `id_module` = '.pSQL($obj->id).' AND id_shop = '.$shopID);
$count = -1; $count = -1;
while (isset($hookedModule[++$count])) while (isset($hookedModule[++$count]))
@@ -473,12 +473,12 @@ class ThemeInstallator extends Module
{ {
Db::getInstance()->Execute(' Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'hook_module` (`id_module`, `id_shop`, `id_hook`, `position`) INSERT INTO `'._DB_PREFIX_.'hook_module` (`id_module`, `id_shop`, `id_hook`, `position`)
VALUES ('.(int)$obj->id.', '.$shopID.', '.(int)Hook::get($hook[$count]).', '.(int)$position[$count].')'); VALUES ('.(int)$obj->id.', '.$shopID.', '.(int)Hook::getIdByName($hook[$count]).', '.(int)$position[$count].')');
if ($exceptions[$count]) if ($exceptions[$count])
foreach ($exceptions[$count] as $file_name) foreach ($exceptions[$count] as $file_name)
Db::getInstance()->Execute(' Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'hook_module_exceptions` (`id_module`, `id_hook`, `file_name`) INSERT INTO `'._DB_PREFIX_.'hook_module_exceptions` (`id_module`, `id_hook`, `file_name`)
VALUES ('.(int)$obj->id.', '.(int)Hook::get($hook[$count]).', "'.pSQL($file_name).'")'); VALUES ('.(int)$obj->id.', '.(int)Hook::getIdByName($hook[$count]).', "'.pSQL($file_name).'")');
} }
} }
if (($val = (int)(Tools::getValue('nativeModules'))) != 1) if (($val = (int)(Tools::getValue('nativeModules'))) != 1)
@@ -495,7 +495,7 @@ class ThemeInstallator extends Module
$msg .= '<b>'.$this->l('The following modules have been disabled').' :</b><br />'; $msg .= '<b>'.$this->l('The following modules have been disabled').' :</b><br />';
$msg .= '<i>- '.pSQL($row).'</i><br />'; $msg .= '<i>- '.pSQL($row).'</i><br />';
Db::getInstance()->Execute(' Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'module_shop` DELETE FROM `'._DB_PREFIX_.'module_shop`
WHERE `id_module` = '.pSQL($obj->id).' AND id_shop = '.$shopID); WHERE `id_module` = '.pSQL($obj->id).' AND id_shop = '.$shopID);
} }
} }
@@ -518,7 +518,7 @@ class ThemeInstallator extends Module
$msg .= '<b>'.$this->l('The following modules have been enabled').' :</b><br />'; $msg .= '<b>'.$this->l('The following modules have been enabled').' :</b><br />';
$msg .= '<i>- '.pSQL($row).'</i><br />'; $msg .= '<i>- '.pSQL($row).'</i><br />';
Db::getInstance()->Execute(' Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'hook_module` DELETE FROM `'._DB_PREFIX_.'hook_module`
WHERE `id_module` = '.pSQL($obj->id).' AND id_shop = '.$shopID); WHERE `id_module` = '.pSQL($obj->id).' AND id_shop = '.$shopID);
$count = -1; $count = -1;
while (isset($hookedModule[++$count])) while (isset($hookedModule[++$count]))
@@ -526,12 +526,12 @@ class ThemeInstallator extends Module
{ {
Db::getInstance()->Execute(' Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'hook_module` (`id_module`, `id_shop`, `id_hook`, `position`) INSERT INTO `'._DB_PREFIX_.'hook_module` (`id_module`, `id_shop`, `id_hook`, `position`)
VALUES ('.(int)$obj->id.', '.$shopID.', '.(int)Hook::get($hook[$count]).', '.(int)$position[$count].')'); VALUES ('.(int)$obj->id.', '.$shopID.', '.(int)Hook::getIdByName($hook[$count]).', '.(int)$position[$count].')');
foreach ($exceptions[$count] as $filename) foreach ($exceptions[$count] as $filename)
if (!empty($filename)) if (!empty($filename))
Db::getInstance()->Execute(' Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'hook_module_exceptions` (`id_module`, id_shop, `id_hook`, `file_name`) INSERT INTO `'._DB_PREFIX_.'hook_module_exceptions` (`id_module`, id_shop, `id_hook`, `file_name`)
VALUES ('.(int)$obj->id.', '.$shopID.', '.(int)Hook::get($hook[$count]).', "'.pSQL($filename).'")'); VALUES ('.(int)$obj->id.', '.$shopID.', '.(int)Hook::getIdByName($hook[$count]).', "'.pSQL($filename).'")');
} }
} }
} }
@@ -546,9 +546,9 @@ class ThemeInstallator extends Module
<input type="submit" class="button" name="submitThemes" value="'.$this->l('Previous').'" /> <input type="submit" class="button" name="submitThemes" value="'.$this->l('Previous').'" />
<input type="submit" class="button" name="Finish" value="'.$this->l('Finish').'" /> <input type="submit" class="button" name="Finish" value="'.$this->l('Finish').'" />
</form>'; </form>';
} }
private function _displayForm3() private function _displayForm3()
{ {
$xml = simplexml_load_file(_IMPORT_FOLDER_.XMLFILENAME); $xml = simplexml_load_file(_IMPORT_FOLDER_.XMLFILENAME);
@@ -603,7 +603,7 @@ class ThemeInstallator extends Module
<li><input type="radio" name="nativeModules" value="3" id="nativemoduleconfig3" /> <label style="display:bock;float:none" for="nativemoduleconfig3">'.$this->l('Both').'</label> <li><input type="radio" name="nativeModules" value="3" id="nativemoduleconfig3" /> <label style="display:bock;float:none" for="nativemoduleconfig3">'.$this->l('Both').'</label>
</ul> </ul>
</fieldset> </fieldset>
<p>&nbsp;</p>'; <p>&nbsp;</p>';
$this->_html .= ' $this->_html .= '
<fieldset> <fieldset>
<legend>'.$this->l('Theme images configuration').'</legend> <legend>'.$this->l('Theme images configuration').'</legend>
@@ -620,7 +620,7 @@ class ThemeInstallator extends Module
</fieldset> </fieldset>
</form>'; </form>';
} }
private function _displayForm2() private function _displayForm2()
{ {
global $cookie; global $cookie;
@@ -680,18 +680,18 @@ class ThemeInstallator extends Module
'; ';
$this->_html .= '</form>'; $this->_html .= '</form>';
} }
private function _displayForm1() private function _displayForm1()
{ {
$tmp = scandir(_PS_ALL_THEMES_DIR_); $tmp = scandir(_PS_ALL_THEMES_DIR_);
$themeList = array(); $themeList = array();
foreach ($tmp as $row) foreach ($tmp as $row)
if (is_dir(_PS_ALL_THEMES_DIR_.$row) AND file_exists(_PS_ALL_THEMES_DIR_.$row.'/index.tpl') AND $row != 'prestashop') if (is_dir(_PS_ALL_THEMES_DIR_.$row) AND file_exists(_PS_ALL_THEMES_DIR_.$row.'/index.tpl') AND $row != 'prestashop')
$themeList[] = $row; $themeList[] = $row;
if (count($themeList) > 0) if (count($themeList) > 0)
{ {
$tmp = ''; $tmp = '';
foreach ($themeList as $row) foreach ($themeList as $row)
$tmp .= '<option value="'.$row.'" '.($row == _THEME_NAME_ ? 'selected="selected"' : '').'>'.$row.'</option>'; $tmp .= '<option value="'.$row.'" '.($row == _THEME_NAME_ ? 'selected="selected"' : '').'>'.$row.'</option>';
$this->_html .= ' $this->_html .= '
@@ -756,7 +756,7 @@ class ThemeInstallator extends Module
*/ */
private function displayInformations() private function displayInformations()
{ {
$this->_html .= '<input type="hidden" name="mainTheme" value="'.Tools::getValue('mainTheme').'" />'; $this->_html .= '<input type="hidden" name="mainTheme" value="'.Tools::getValue('mainTheme').'" />';
if ($this->error === false AND class_exists('ZipArchive', false) AND ($zip = new ZipArchive())) if ($this->error === false AND class_exists('ZipArchive', false) AND ($zip = new ZipArchive()))
{ {
@@ -767,7 +767,7 @@ class ThemeInstallator extends Module
$this->_html .= parent::displayConfirmation('Fill this formular to export this theme: <b>'.Tools::getValue('mainTheme').'</b> in a ZIP file'); $this->_html .= parent::displayConfirmation('Fill this formular to export this theme: <b>'.Tools::getValue('mainTheme').'</b> in a ZIP file');
} }
} }
private function archiveThisFile($obj, $file, $serverPath, $archivePath) private function archiveThisFile($obj, $file, $serverPath, $archivePath)
{ {
if (is_dir($serverPath.$file)) if (is_dir($serverPath.$file))
@@ -780,12 +780,12 @@ class ThemeInstallator extends Module
else if (!$obj->addFile($serverPath.$file, $archivePath.$file)) else if (!$obj->addFile($serverPath.$file, $archivePath.$file))
$this->error = true; $this->error = true;
} }
/* /*
** Generate Archive ! ** Generate Archive !
*/ */
private function generateArchive() private function generateArchive()
{ {
$count = 0; $count = 0;
$zip = new ZipArchive(); $zip = new ZipArchive();
$zip_file_name = md5(time()).".zip"; $zip_file_name = md5(time()).".zip";
@@ -821,7 +821,7 @@ class ThemeInstallator extends Module
} }
$this->_html .= parent::displayError($this->l('An error occurred during the archive generation')); $this->_html .= parent::displayError($this->l('An error occurred during the archive generation'));
} }
/* /*
** XML Generation, all vars should be GOOD at this point ** XML Generation, all vars should be GOOD at this point
*/ */
@@ -854,7 +854,7 @@ class ThemeInstallator extends Module
$variation->addAttribute('from', $array[2]); $variation->addAttribute('from', $array[2]);
$variation->addAttribute('to', $array[3]); $variation->addAttribute('to', $array[3]);
} }
$docs = $theme->addChild('docs'); $docs = $theme->addChild('docs');
if (isset($this->user_doc)) if (isset($this->user_doc))
foreach ($this->user_doc as $row) foreach ($this->user_doc as $row)
@@ -864,7 +864,7 @@ class ThemeInstallator extends Module
$doc->addAttribute('name', $array[0]); $doc->addAttribute('name', $array[0]);
$doc->addAttribute('path', $array[1]); $doc->addAttribute('path', $array[1]);
} }
$modules = $theme->addChild('modules'); $modules = $theme->addChild('modules');
if (isset($this->to_export)) if (isset($this->to_export))
foreach ($this->to_export as $row) foreach ($this->to_export as $row)
@@ -886,7 +886,7 @@ class ThemeInstallator extends Module
$module->addAttribute('action', 'disable'); $module->addAttribute('action', 'disable');
$module->addAttribute('name', $row); $module->addAttribute('name', $row);
} }
$hooks = $modules->addChild('hooks'); $hooks = $modules->addChild('hooks');
foreach ($this->to_hook as $row) foreach ($this->to_hook as $row)
{ {
@@ -898,7 +898,7 @@ class ThemeInstallator extends Module
if (!empty($array[3])) if (!empty($array[3]))
$hook->addAttribute('exceptions', $array[3]); $hook->addAttribute('exceptions', $array[3]);
} }
$images = $theme->addChild('images'); $images = $theme->addChild('images');
foreach ($this->image_list as $row) foreach ($this->image_list as $row)
{ {
@@ -920,7 +920,7 @@ class ThemeInstallator extends Module
** Init modules and Hooks ** Init modules and Hooks
*/ */
private function _initList() private function _initList()
{ {
$this->native_modules = self::getTheNativeModules(); $this->native_modules = self::getTheNativeModules();
$this->module_list = Db::getInstance()->ExecuteS('SELECT id_module, name, active FROM `'._DB_PREFIX_.'module`'); $this->module_list = Db::getInstance()->ExecuteS('SELECT id_module, name, active FROM `'._DB_PREFIX_.'module`');
$this->hook_list = Db::getInstance()->ExecuteS(' $this->hook_list = Db::getInstance()->ExecuteS('
@@ -933,7 +933,7 @@ class ThemeInstallator extends Module
ORDER BY name_module'); ORDER BY name_module');
foreach ($this->hook_list as &$row) foreach ($this->hook_list as &$row)
$row['exceptions'] = trim(preg_replace('/(,,+)/', ',', $row['exceptions']), ','); $row['exceptions'] = trim(preg_replace('/(,,+)/', ',', $row['exceptions']), ',');
} }
/* /*
@@ -951,7 +951,7 @@ class ThemeInstallator extends Module
if ($array['active'] == 1) if ($array['active'] == 1)
$this->to_enable[] = $array['name']; $this->to_enable[] = $array['name'];
else else
$this->to_disable[] = $array['name']; $this->to_disable[] = $array['name'];
} }
else if ($array['active'] == 1) else if ($array['active'] == 1)
$this->to_install[] = $array['name']; $this->to_install[] = $array['name'];
@@ -967,7 +967,7 @@ class ThemeInstallator extends Module
$flag = 1; $flag = 1;
break; break;
} }
if ($flag == 0) if ($flag == 0)
$this->to_disable[] = $str; $this->to_disable[] = $str;
} }
} }
@@ -986,7 +986,7 @@ class ThemeInstallator extends Module
if ($tmp['name_module'] == $string) if ($tmp['name_module'] == $string)
$this->to_hook[] = $string.';'.$tmp['name_hook'].';'.$tmp['position'].';'.$tmp['exceptions']; $this->to_hook[] = $string.';'.$tmp['name_hook'].';'.$tmp['position'].';'.$tmp['exceptions'];
} }
/* /*
** Fill Image var ** Fill Image var
*/ */
@@ -1001,7 +1001,7 @@ class ThemeInstallator extends Module
($row['suppliers'] == 1 ? 'true' : 'false').';'. ($row['suppliers'] == 1 ? 'true' : 'false').';'.
($row['scenes'] == 1 ? 'true' : 'false'); ($row['scenes'] == 1 ? 'true' : 'false');
} }
/* /*
** Takes current and submited theme's informations ** Takes current and submited theme's informations
*/ */
@@ -1022,7 +1022,7 @@ class ThemeInstallator extends Module
$this->variations[] = $name.'¤'.$dir.'¤'.$from.'¤'.$to; $this->variations[] = $name.'¤'.$dir.'¤'.$from.'¤'.$to;
} }
} }
private function getDocumentation() private function getDocumentation()
{ {
$count = 0; $count = 0;
@@ -1039,7 +1039,7 @@ class ThemeInstallator extends Module
{ {
$mail = Tools::getValue('email'); $mail = Tools::getValue('email');
$website = Tools::getValue('website'); $website = Tools::getValue('website');
if ($mail AND !preg_match('#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#', $mail)) if ($mail AND !preg_match('#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#', $mail))
$this->_html .= parent::displayError($this->l('There is an error in your e-mail syntax!')); $this->_html .= parent::displayError($this->l('There is an error in your e-mail syntax!'));
else if ($website AND (!Validate::isURL($website) OR !Validate::isAbsoluteUrl($website))) else if ($website AND (!Validate::isURL($website) OR !Validate::isAbsoluteUrl($website)))
@@ -1050,7 +1050,7 @@ class ThemeInstallator extends Module
return true; return true;
return false; return false;
} }
/* /*
** Checks posted documentation ** Checks posted documentation
*/ */
@@ -1076,7 +1076,7 @@ class ThemeInstallator extends Module
return false; return false;
return true; return true;
} }
/* /*
** Checks theme's and author's name syntax, existence and length ** Checks theme's and author's name syntax, existence and length
*/ */
@@ -1085,7 +1085,7 @@ class ThemeInstallator extends Module
$author = Tools::getValue('author_name'); $author = Tools::getValue('author_name');
$name = Tools::getValue('theme_name'); $name = Tools::getValue('theme_name');
$count = 0; $count = 0;
if (!$author OR !Validate::isGenericName($author) OR strlen($author) > MAX_NAME_LENGTH) if (!$author OR !Validate::isGenericName($author) OR strlen($author) > MAX_NAME_LENGTH)
$this->_html .= parent::displayError($this->l('Please enter a valid author name')); $this->_html .= parent::displayError($this->l('Please enter a valid author name'));
else if (!$name OR !Validate::isGenericName($name) OR strlen($name) > MAX_NAME_LENGTH) else if (!$name OR !Validate::isGenericName($name) OR strlen($name) > MAX_NAME_LENGTH)
@@ -1107,9 +1107,9 @@ class ThemeInstallator extends Module
{ {
$count = 0; $count = 0;
$exp = "#^[0-9]+[.]+[0-9.]*[0-9]$#"; $exp = "#^[0-9]+[.]+[0-9.]*[0-9]$#";
if (!preg_match("#^[0-9][.][0-9]$#", Tools::getValue('version')) OR if (!preg_match("#^[0-9][.][0-9]$#", Tools::getValue('version')) OR
!preg_match($exp, Tools::getValue('compa_from')) OR !preg_match($exp, Tools::getValue('compa_to')) OR !preg_match($exp, Tools::getValue('compa_from')) OR !preg_match($exp, Tools::getValue('compa_to')) OR
version_compare(Tools::getValue('compa_from'), Tools::getValue('compa_to')) == 1) version_compare(Tools::getValue('compa_from'), Tools::getValue('compa_to')) == 1)
$this->_html .= parent::displayError($this->l('Syntax error on version field. Only digits and points are allowed and the compatibility should be increasing or equal.')); $this->_html .= parent::displayError($this->l('Syntax error on version field. Only digits and points are allowed and the compatibility should be increasing or equal.'));
while ($this->error === false AND Tools::isSubmit('myvar_'.++$count)) while ($this->error === false AND Tools::isSubmit('myvar_'.++$count))
@@ -1125,14 +1125,14 @@ class ThemeInstallator extends Module
return false; return false;
return true; return true;
} }
private function ModulesInformationForm() private function ModulesInformationForm()
{ {
if ($this->to_install AND count($this->to_install)) if ($this->to_install AND count($this->to_install))
{ {
$tmp = ''; $tmp = '';
foreach ($this->to_install as $key => $val) foreach ($this->to_install as $key => $val)
$tmp .= '<input type="checkbox" name="modulesToExport[]" value="'.$val.'" id="'.$val.'" '.(in_array($val, $this->to_export) ? 'checked="checked"' : "").'/> <label style="display:bock;float:none" for="'.$val.'">'.$val.'</label><br />'; $tmp .= '<input type="checkbox" name="modulesToExport[]" value="'.$val.'" id="'.$val.'" '.(in_array($val, $this->to_export) ? 'checked="checked"' : "").'/> <label style="display:bock;float:none" for="'.$val.'">'.$val.'</label><br />';
$this->_html .= ' $this->_html .= '
<fieldset> <fieldset>
<legend>'.$this->l('Modules').'</legend> <legend>'.$this->l('Modules').'</legend>
@@ -1142,7 +1142,7 @@ class ThemeInstallator extends Module
<p class="clear">&nbsp;</p>'; <p class="clear">&nbsp;</p>';
} }
} }
private function AuthorInformationForm() private function AuthorInformationForm()
{ {
global $cookie; global $cookie;
@@ -1170,14 +1170,14 @@ class ThemeInstallator extends Module
</fieldset> </fieldset>
<div class="clear">&nbsp;</div>'; <div class="clear">&nbsp;</div>';
} }
private function ThemeInformationForm() private function ThemeInformationForm()
{ {
global $cookie; global $cookie;
$defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT'));
$languages = Language::getLanguages(); $languages = Language::getLanguages();
$iso = Language::getIsoById((int)($cookie->id_lang)); $iso = Language::getIsoById((int)($cookie->id_lang));
$divLangName = 'title'; $divLangName = 'title';
$val = Tools::getValue('theme_name') ? Tools::getValue('theme_name') : Tools::getValue('mainTheme'); $val = Tools::getValue('theme_name') ? Tools::getValue('theme_name') : Tools::getValue('mainTheme');
@@ -1211,7 +1211,7 @@ class ThemeInstallator extends Module
<p class="clear">'.$this->l('Your theme\'s version').'</p> <p class="clear">'.$this->l('Your theme\'s version').'</p>
</div>'; </div>';
$val = Tools::getValue('compa_from') ? Tools::getValue('compa_from') : DEFAULT_COMPATIBILITY_FROM; $val = Tools::getValue('compa_from') ? Tools::getValue('compa_from') : DEFAULT_COMPATIBILITY_FROM;
$val2 = Tools::getValue('compa_to') ? Tools::getValue('compa_to') : DEFAULT_COMPATIBILITY_TO; $val2 = Tools::getValue('compa_to') ? Tools::getValue('compa_to') : DEFAULT_COMPATIBILITY_TO;
$this->_html .= ' $this->_html .= '
<div style="float: left;"> <div style="float: left;">
<label>'.$this->l('Compatible From').'</label> <label>'.$this->l('Compatible From').'</label>
@@ -1227,7 +1227,7 @@ class ThemeInstallator extends Module
</div> </div>
<p class="clear">&nbsp;</p>'; <p class="clear">&nbsp;</p>';
} }
private function DocInformationForm() private function DocInformationForm()
{ {
$val = Tools::htmlentitiesUTF8(Tools::getValue('documentation')); $val = Tools::htmlentitiesUTF8(Tools::getValue('documentation'));
@@ -1243,7 +1243,7 @@ class ThemeInstallator extends Module
'; ';
$this->_html .= '<p class="clear">&nbsp;</p>'; $this->_html .= '<p class="clear">&nbsp;</p>';
} }
private function VariationInformationForm() private function VariationInformationForm()
{ {
$script = _MODULE_DIR_.$this->name.'/script.js'; $script = _MODULE_DIR_.$this->name.'/script.js';
@@ -1290,3 +1290,4 @@ class ThemeInstallator extends Module
</form>'; </form>';
} }
} }
+9 -9
View File
@@ -202,7 +202,7 @@ XML;
$price->addChild('reduction_percent', ($specificPrice AND $specificPrice['reduction_type'] == 'percentage') ? $specificPrice['reduction'] * 100 : 0.00); $price->addChild('reduction_percent', ($specificPrice AND $specificPrice['reduction_type'] == 'percentage') ? $specificPrice['reduction'] * 100 : 0.00);
$price->addChild('reduction_price', ($specificPrice AND $specificPrice['reduction_type'] == 'amount') ? (float)$specificPrice['reduction'] : 0.00); $price->addChild('reduction_price', ($specificPrice AND $specificPrice['reduction_type'] == 'amount') ? (float)$specificPrice['reduction'] : 0.00);
$price->addChild('display-on-sale', (int)$sqlProduct['on_sale']); $price->addChild('display-on-sale', (int)$sqlProduct['on_sale']);
$product->addChild('downloadable', $sqlProduct['id_product_download'] >= 1 ? 1 : 0); $product->addChild('downloadable', $sqlProduct['id_product_download'] >= 1 ? 1 : 0);
$pack = Db::getInstance()->ExecuteS(' $pack = Db::getInstance()->ExecuteS('
@@ -241,7 +241,7 @@ XML;
{ {
if (isset($imagesAlreadyDone[$imageSQL['id_image']])) if (isset($imagesAlreadyDone[$imageSQL['id_image']]))
continue; continue;
$imagesAlreadyDone[(int)$imageSQL['id_image']] = 1; $imagesAlreadyDone[(int)$imageSQL['id_image']] = 1;
$image = $product->addChild('image'); $image = $product->addChild('image');
@@ -363,7 +363,7 @@ XML;
} }
} }
if (!empty($group['attributes'])) if (!empty($group['attributes']))
{ {
foreach ($group['attributes'] AS $id_attribute => $attribute) foreach ($group['attributes'] AS $id_attribute => $attribute)
{ {
@@ -408,7 +408,7 @@ XML;
LEFT JOIN '._DB_PREFIX_.'product_attribute_image pi ON (pa.id_product_attribute = pi.id_product_attribute) LEFT JOIN '._DB_PREFIX_.'product_attribute_image pi ON (pa.id_product_attribute = pi.id_product_attribute)
WHERE pa.id_product = '.(int)$sqlProduct['id_product']); WHERE pa.id_product = '.(int)$sqlProduct['id_product']);
if(!empty($productAttributes)) if(!empty($productAttributes))
{ {
foreach ($productAttributes AS $productAttribute) foreach ($productAttributes AS $productAttribute)
{ {
@@ -427,7 +427,7 @@ XML;
$image->addAttribute('ref-id', $productAttribute['id_image']); $image->addAttribute('ref-id', $productAttribute['id_image']);
} }
if (isset($combinaison[$id_product_attribute]) && !empty($combinaison[$id_product_attribute])) if (isset($combinaison[$id_product_attribute]) && !empty($combinaison[$id_product_attribute]))
{ {
foreach ($combinaison[$id_product_attribute] AS $id_group_attribute => $id_attribute) foreach ($combinaison[$id_product_attribute] AS $id_group_attribute => $id_attribute)
{ {
@@ -504,7 +504,7 @@ XML;
} }
closedir($dh); closedir($dh);
} }
$out .= '<div class="clear"></div></div></div>'; $out .= '<div class="clear"></div></div></div>';
return $out; return $out;
} }
@@ -671,13 +671,13 @@ XML;
if (Tools::getValue('trpd_hook_position') == 0) if (Tools::getValue('trpd_hook_position') == 0)
{ {
Configuration::updateValue('TREEPODIA_HOOK', 0); Configuration::updateValue('TREEPODIA_HOOK', 0);
$this->unregisterHook(Hook::get('productFooter')); $this->unregisterHook(Hook::getIdByName('productFooter'));
$this->registerHook('extraLeft'); $this->registerHook('extraLeft');
} }
else else
{ {
Configuration::updateValue('TREEPODIA_HOOK', 1); Configuration::updateValue('TREEPODIA_HOOK', 1);
$this->unregisterHook(Hook::get('extraLeft')); $this->unregisterHook(Hook::getIdByName('extraLeft'));
$this->registerHook('productFooter'); $this->registerHook('productFooter');
} }
@@ -713,7 +713,7 @@ XML;
$result = ''; $result = '';
while (!feof($socket)) while (!feof($socket))
$result .= trim(fgets($socket, 1024)); $result .= trim(fgets($socket, 1024));
fclose($socket); fclose($socket);
} }
+1 -1
View File
@@ -91,7 +91,7 @@ class TrustedShops extends Module
break; break;
} }
$return = ($return) ? (parent::install() AND $this->registerHook('orderConfirmation') AND $this->registerHook('newOrder') AND $this->registerHook('rightColumn') AND $this->registerHook('paymentTop') AND $this->registerHook('orderConfirmation')) : $return; $return = ($return) ? (parent::install() AND $this->registerHook('orderConfirmation') AND $this->registerHook('newOrder') AND $this->registerHook('rightColumn') AND $this->registerHook('paymentTop') AND $this->registerHook('orderConfirmation')) : $return;
$id_hook = Hook::get('payment'); $id_hook = Hook::getIdByName('payment');
$this->updatePosition($id_hook, 0, 1); $this->updatePosition($id_hook, 0, 1);
return $return; return $return;
} }