diff --git a/admin-dev/index.php b/admin-dev/index.php index d34d6af2b..b164e1459 100644 --- a/admin-dev/index.php +++ b/admin-dev/index.php @@ -116,7 +116,6 @@ if (empty($tab) and !sizeof($_POST)) } elseif (strncmp($key, $adminObj->table.'OrderBy', 7) === 0 OR strncmp($key, $adminObj->table.'Orderway', 12) === 0) $cookie->$key = $value; - $adminObj->smarty = $smarty; $adminObj->displayConf(); $adminObj->postProcess(); $adminObj->displayErrors(); diff --git a/admin-dev/tabs/AdminPreferences.php b/admin-dev/tabs/AdminPreferences.php index cd4031f9f..b969b7491 100644 --- a/admin-dev/tabs/AdminPreferences.php +++ b/admin-dev/tabs/AdminPreferences.php @@ -169,16 +169,17 @@ class AdminPreferences extends AdminTab */ protected function _postConfig($fields) { + $context = Context::getContext(); $languages = Language::getLanguages(false); if (!Configuration::get('PS_FORCE_SMARTY_2')) { $files = scandir(_PS_THEME_DIR_); foreach ($files AS $file) if (!preg_match('/^\..*/', $file)) - $this->smarty->clearCache($file); + $context->smarty->clearCache($file); } else - $this->smarty->clear_all_cache(); + $context->smarty->clear_all_cache(); /* Check required fields */ foreach ($fields AS $field => $values) diff --git a/classes/AdminTab.php b/classes/AdminTab.php index 93c26b3b4..b7427ec87 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -174,7 +174,6 @@ abstract class AdminTabCore public function __construct() { $context = Context::getContext(); - $context->tab = $this; $this->id = Tab::getCurrentTabId(); $this->_conf = array( diff --git a/classes/Cart.php b/classes/Cart.php index e494b128b..9f939b015 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -339,8 +339,17 @@ class CartCore extends ObjectModel return array(); // Product cache must be strictly compared to NULL, or else an empty cart will add dozens of queries if ($this->_products !== NULL AND !$refresh) + { + // Return product row with specified ID if it exists + if (is_int($id_product)) + { + foreach ($this->_products as $product) + if ($product['id_product'] == $id_product) + return array($product); + return array(); + } return $this->_products; - + } if (!$context) $context = Context::getContext(); @@ -632,7 +641,7 @@ class CartCore extends ObjectModel // refresh cache of self::_products $this->_products = $this->getProducts(true); $this->update(true); - + if ($product->customizable) return $this->_updateCustomizationQuantity((int)$quantity, (int)$id_customization, (int)$id_product, (int)$id_product_attribute, $operator); else @@ -642,16 +651,26 @@ class CartCore extends ObjectModel /* ** Customization management */ - protected function _updateCustomizationQuantity($quantity, $id_customization, $id_product, $id_product_attribute, $operator = 'up', Context $context = null) + protected function _updateCustomizationQuantity($quantity, $id_customization, $id_product, $id_product_attribute, $operator = 'up') { - if (!$context) - $context = Context::getContext(); - /* Getting datas */ - $files = $context->cookie->getFamily('pictures_'.(int)($id_product).'_'); - $textFields = $context->cookie->getFamily('textFields_'.(int)($id_product).'_'); - /* Customization addition */ - if (count($files) > 0 OR count($textFields) > 0) - return $this->_addCustomization((int)$id_product, (int)$id_product_attribute, $files, $textFields, (int)$quantity); + // Link customization to product combination when it is first added to cart + if (empty($id_customization)) + { + $customization = $this->getProductCustomization($id_product, null, false); + foreach ($customization as $field) + { + if ($field['quantity'] == 0) + { + Db::getInstance()->Execute(' + UPDATE `'._DB_PREFIX_.'customization` + SET `quantity` = '.(int)($quantity).', + `id_product_attribute` = '.(int)$id_product_attribute.', + `in_cart` = 1 + WHERE `id_customization` = '.(int)$field['id_customization']); + } + } + } + /* Deletion */ if (!empty($id_customization) AND (int)($quantity) < 1) return $this->_deleteCustomization((int)$id_customization, (int)$id_product, (int)$id_product_attribute); @@ -663,7 +682,10 @@ class CartCore extends ObjectModel { if ($operator == 'down' AND (int)($result['quantity']) - (int)($quantity) < 1) return Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'customization` WHERE `id_customization` = '.(int)$id_customization); - return Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'customization` SET `quantity` = `quantity` '.($operator == 'up' ? '+ ' : '- ').(int)($quantity).' WHERE `id_customization` = '.(int)($id_customization)); + return Db::getInstance()->Execute(' + UPDATE `'._DB_PREFIX_.'customization` + SET `quantity` = `quantity` '.($operator == 'up' ? '+ ' : '- ').(int)($quantity).' + WHERE `id_customization` = '.(int)($id_customization)); } } // refresh cache of self::_products @@ -672,33 +694,46 @@ class CartCore extends ObjectModel return true; } - public function _addCustomization($id_product, $id_product_attribute, $files, $textFields, $quantity) + public function _addCustomization($id_product, $id_product_attribute, $index, $type, $field, $quantity, $id_customization = null) { - if (!is_array($files) OR !is_array($textFields)) - die(Tools::displayError()); - /* Copying them inside the db */ - if (!Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'customization` (`id_cart`, `id_product`, `id_product_attribute`, `quantity`) VALUES ('.(int)($this->id).', '.(int)($id_product).', '.(int)($id_product_attribute).', '.(int)($quantity).')')) - return false; - if (!$id_customization = Db::getInstance()->Insert_ID()) - return false; - $query = 'INSERT INTO `'._DB_PREFIX_.'customized_data` (`id_customization`, `type`, `index`, `value`) VALUES '; - if (count($files)) - foreach ($files AS $key => $filename) + $exising_customization = Db::getInstance()->getRow(' + SELECT cu.id_customization, cd.index, cd.value, cd.type, cu.in_cart, cu.quantity FROM `'._DB_PREFIX_.'customization` cu + LEFT JOIN `'._DB_PREFIX_.'customized_data` cd + ON cu.`id_customization` = cd.`id_customization` + WHERE cu.id_cart = '.(int)$this->id.' + AND cu.id_product = '.(int)$id_product.' + AND type = '.(int)$type.' + AND `index` = '.(int)$index.' + AND in_cart = 0'); + + // If the customization field is alreay filled, delete it + if ($exising_customization) + { + if ($exising_customization['type'] == $type && $exising_customization['index'] == $index) { - $tmp = explode('_', $key); - $query .= '('.(int)($id_customization).', '._CUSTOMIZE_FILE_.', '.$tmp[2].', \''.$filename.'\'), '; + Db::getInstance()->Execute(' + DELETE FROM `'._DB_PREFIX_.'customized_data` + WHERE id_customization = '.(int)$exising_customization['id_customization'].' + AND type = '.(int)$exising_customization['type'].' + AND `index` = '.(int)$exising_customization['index']); + if ($type == _CUSTOMIZE_FILE_) + { + @unlink(_PS_UPLOAD_DIR_.$exising_customization['value']); + @unlink(_PS_UPLOAD_DIR_.$exising_customization['value'].'_small'); + } } - if (count($textFields)) - foreach ($textFields AS $key => $textFieldValue) - { - $tmp = explode('_', $key); - $query .= '('.(int)($id_customization).', '._CUSTOMIZE_TEXTFIELD_.', '.$tmp[2].', \''.$textFieldValue.'\'), '; - } - $query = rtrim($query, ', '); + $id_customization = $exising_customization['id_customization']; + }else + { + Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'customization` (`id_cart`, `id_product`, `id_product_attribute`, `quantity`) VALUES ('.(int)($this->id).', '.(int)($id_product).', '.(int)($id_product_attribute).', '.(int)($quantity).')'); + $id_customization = Db::getInstance()->Insert_ID(); + } + + $query = 'INSERT INTO `'._DB_PREFIX_.'customized_data` (`id_customization`, `type`, `index`, `value`) VALUES ('.(int)$id_customization.', '.(int)$type.', '.(int)$index.', \''.pSql($field).'\')'; + if (!$result = Db::getInstance()->Execute($query)) return false; - /* Deleting customized informations from the cart (we just copied them inside the db) */ - return Cart::deleteCustomizationInformations((int)($id_product)); + return true; } /** @@ -777,7 +812,7 @@ class CartCore extends ObjectModel } /** - * Delete a customization from the cart. If customization is a Picture (type=2), + * Delete a customization from the cart. If customization is a Picture, * then the image is also deleted * * @param integer $id_customization @@ -796,8 +831,9 @@ class CartCore extends ObjectModel FROM `'._DB_PREFIX_.'customized_data` WHERE `id_customization` = '.(int)($id_customization)); + // Delete customization picture if necessary if (isset($custData['type']) and $custData['type'] == 0) - $result &= $this->deletePictureToProduct($id_product,$custData['value']); + $result &= (@unlink(_PS_UPLOAD_DIR_.$custData['value']) && @unlink(_PS_UPLOAD_DIR_.$custData['value'].'_small')); $result &= Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'customized_data` @@ -1274,7 +1310,7 @@ class CartCore extends ObjectModel if (($discountObj->id_customer OR $discountObj->id_group) AND ($this->id_customer != $discountObj->id_customer AND !in_array($discountObj->id_group, $groups))) { - if (!$context->cookie->isLogged()) + if (!$context->customer->isLogged()) return Tools::displayError('You cannot use this voucher.').' - '.Tools::displayError('Please log in.'); return Tools::displayError('You cannot use this voucher.'); } @@ -1478,26 +1514,6 @@ class CartCore extends ObjectModel return $result['id_cart']; } - /* - * Add customer's pictures - * - * @return bool Always true - */ - public function addPictureToProduct($id_product, $index, $identifier, Context $context = null) - { - if (!$context) - $context = Context::getContext(); - - $varName = 'pictures_'.(int)($id_product).'_'.(int)($index); - if ($context->cookie->$varName) - { - @unlink(_PS_UPLOAD_DIR_.$context->cookie->$varName); - @unlink(_PS_UPLOAD_DIR_.$context->cookie->$varName.'_small'); - } - $context->cookie->$varName = $identifier; - return true; - } - /* * Add customer's text * @@ -1528,29 +1544,51 @@ class CartCore extends ObjectModel return true; } + /* + * Add customer's pictures + * + * @return bool Always true + */ + public function addPictureToProduct($id_product, $index, $type, $field) + { + $product_array = $this->getProducts(false, $id_product); + $id_customization = $this->_addCustomization($id_product, 0, $index, $type, $field, 0); + } + /* * Remove a customer's picture * * @return bool */ - public function deletePictureToProduct($id_product, $index, Context $context = null) + public function deletePictureToProduct($id_product, $index) { - if (!$context) - $context = Context::getContext(); - - $varName = 'pictures_'.(int)($id_product).'_'.(int)($index); - // if cookie->varName is empty, use index which is the name of the picture - $picture = !empty($context->cookie->$varName) ? $context->cookie->$varName : $index; - if ($picture) - { - if (!@unlink(_PS_UPLOAD_DIR_.$picture) OR !@unlink(_PS_UPLOAD_DIR_.$picture.'_small')) - return false; - unset($context->cookie->$varName); - return true; - } - return false; + $product_array = $this->getProducts(false, $id_product); + + if (isset($product_array[0]) && $product = $product_array[0]) + return $this->_deleteCustomization($product['id_customization'], $id_product, $product['id_product_attribute']); } - + + /** + * Return custom pictures in this cart for a specified product + * + * @param int $id_product + * @return array result rows + */ + public function getProductCustomization($id_product, $type = null, $in_cart = false) + { + $result = Db::getInstance()->ExecuteS(' + SELECT cu.id_customization, cd.index, cd.value, cd.type, cu.in_cart, cu.quantity FROM `'._DB_PREFIX_.'customization` cu + LEFT JOIN `'._DB_PREFIX_.'customized_data` cd + ON cu.`id_customization` = cd.`id_customization` + WHERE cu.id_cart = '.(int)$this->id.' + AND cu.id_product = '.(int)$id_product. + ($type == 0 ? ' AND type = 0' : ''). + ($type == 1 ? ' AND type = 1' : ''). + ' AND in_cart = '.($in_cart ? '1' : '0') + ); + return $result; + } + static public function deleteCustomizationInformations($id_product, Context $context = null) { if (!$context) diff --git a/classes/Country.php b/classes/Country.php index fba661bfc..7ce388654 100644 --- a/classes/Country.php +++ b/classes/Country.php @@ -122,7 +122,8 @@ class CountryCore extends ObjectModel { if (!Validate::isBool($active)) die(Tools::displayError()); - + if (!$context) + $context = Context::getContext(); $states = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT s.* FROM `'._DB_PREFIX_.'state` s diff --git a/classes/Customer.php b/classes/Customer.php index 2eea5f237..3a566463a 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -94,10 +94,16 @@ class CustomerCore extends ObjectModel public $days; public $months; + /** @var int customer id_country as determined by geolocation */ public $geoloc_id_country; + /** @var int customer id_state as determined by geolocation */ public $geoloc_id_state; + /** @var string customer postcode as determined by geolocation */ public $geoloc_postcode; + /** @var boolean is the customer logged in */ + public $logged = 0; + protected $tables = array ('customer'); protected $fieldsRequired = array('lastname', 'passwd', 'firstname', 'email'); @@ -712,4 +718,22 @@ class CustomerCore extends ObjectModel $this->passwd = Tools::encrypt($passwd); return true; } + + /** + * Check customer informations and return customer validity + * + * @parma boolean $withGuest + * @return boolean customer validity + */ + public function isLogged($withGuest = false) + { + if (!$withGuest AND $this->is_guest == 1) + return false; + + /* Customer is valid only if it can be load and if object password is the same as database one */ + if ($this->logged == 1 AND $this->id AND Validate::isUnsignedId($this->id) AND self::checkPassword($this->id, $this->passwd)) + return true; + return false; + } + } \ No newline at end of file diff --git a/classes/FrontController.php b/classes/FrontController.php index e902e4ba4..4b3aa4a23 100755 --- a/classes/FrontController.php +++ b/classes/FrontController.php @@ -28,7 +28,7 @@ class FrontControllerCore { public $errors = array(); - public $smarty; + protected static $smarty; protected static $cookie; protected static $link; protected static $cart; @@ -101,6 +101,12 @@ class FrontControllerCore $cookie = new Cookie('ps'); $context->cookie = $cookie; + + $protocol_link = (Configuration::get('PS_SSL_ENABLED') OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://'; + $protocol_content = ((isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://'; + $link = new Link($protocol_link, $protocol_content); + $context->link = $link; + if ($this->auth AND !$cookie->isLogged($this->guestAllowed)) Tools::redirect('index.php?controller=authentication'.($this->authRedirection ? '&back='.$this->authRedirection : '')); @@ -132,9 +138,7 @@ class FrontControllerCore } $currency = Tools::setCurrency($cookie); - $_MODULES = array(); - /* Cart already exists */ if ((int)$cookie->id_cart) { @@ -204,7 +208,7 @@ class FrontControllerCore setlocale(LC_CTYPE, $locale); setlocale(LC_TIME, $locale); setlocale(LC_NUMERIC, 'en_US.UTF-8'); - + if (Validate::isLoadedObject($currency)) $smarty->ps_currency = $currency; if (!Validate::isLoadedObject($language = new Language($cookie->id_lang))) @@ -223,11 +227,6 @@ class FrontControllerCore $navigationPipe = (Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>'); $smarty->assign('navigationPipe', $navigationPipe); - $protocol_link = (Configuration::get('PS_SSL_ENABLED') OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://'; - $protocol_content = ((isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://'; - $link = new Link($protocol_link, $protocol_content); - $context->link = $link; - if (!defined('_PS_BASE_URL_')) define('_PS_BASE_URL_', Tools::getShopDomain(true)); if (!defined('_PS_BASE_URL_SSL_')) @@ -306,10 +305,10 @@ class FrontControllerCore else $smarty->assign($assignKey, $assignValue); - // setting properties from global var + // shortcuts to context objects self::$cookie = $cookie; self::$cart = $cart; - $this->smarty = $smarty; + self::$smarty = $smarty; self::$link = $link; if ($this->maintenance) @@ -326,7 +325,10 @@ class FrontControllerCore $this->setMedia(); if (isset($cookie->id_customer) && (int)$cookie->id_customer) + { $customer = new Customer($cookie->id_customer); + $customer->logged = $cookie->logged; + } else $customer = new Customer(); @@ -340,7 +342,6 @@ class FrontControllerCore $context->customer = $customer; $context->cart = $cart; - $context->cookie = $cookie; $context->currency = $currency; $context->controller = $this; $context->country = $defaultCountry; @@ -352,7 +353,7 @@ class FrontControllerCore if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP')))) { header('HTTP/1.1 503 temporarily overloaded'); - $this->smarty->display(_PS_THEME_DIR_.'maintenance.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'maintenance.tpl'); exit; } } @@ -361,7 +362,7 @@ class FrontControllerCore protected function displayRestrictedCountryPage() { header('HTTP/1.1 503 temporarily overloaded'); - $this->smarty->display(_PS_THEME_DIR_.'restricted-country.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'restricted-country.tpl'); exit; } @@ -412,7 +413,7 @@ class FrontControllerCore if (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_) $this->restrictedCountry = true; elseif (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_) - $this->smarty->assign(array( + self::$smarty->assign(array( 'restricted_country_mode' => true, 'geolocation_country' => $record->country_name )); @@ -437,7 +438,7 @@ class FrontControllerCore elseif (Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_) $this->restrictedCountry = true; elseif (Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_) - $this->smarty->assign(array( + self::$smarty->assign(array( 'restricted_country_mode' => true, 'geolocation_country' => 'Undefined' )); @@ -475,19 +476,19 @@ class FrontControllerCore public function displayContent() { Tools::safePostVars(); - $this->smarty->assign('errors', $this->errors); + self::$smarty->assign('errors', $this->errors); } public function displayHeader() { if (!self::$initialized) $this->init(); - + $context = Context::getContext(); // P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies) header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"'); /* Hooks are volontary out the initialize array (need those variables already assigned) */ - $this->smarty->assign(array( + self::$smarty->assign(array( 'time' => time(), 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'static_token' => Tools::getToken(false), @@ -497,7 +498,7 @@ class FrontControllerCore 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'content_only' => (int)Tools::getValue('content_only') )); - $this->smarty->assign(array( + self::$smarty->assign(array( 'HOOK_HEADER' => Module::hookExec('header'), 'HOOK_TOP' => Module::hookExec('top'), 'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn') @@ -514,9 +515,9 @@ class FrontControllerCore $this->js_files = Tools::cccJs($this->js_files); } - $this->smarty->assign('css_files', $this->css_files); - $this->smarty->assign('js_files', array_unique($this->js_files)); - $this->smarty->display(_PS_THEME_DIR_.'header.tpl'); + self::$smarty->assign('css_files', $this->css_files); + self::$smarty->assign('js_files', array_unique($this->js_files)); + self::$smarty->display(_PS_THEME_DIR_.'header.tpl'); } public function displayFooter() @@ -524,16 +525,16 @@ class FrontControllerCore if (!self::$initialized) $this->init(); - $this->smarty->assign(array( + self::$smarty->assign(array( 'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn', array('cart' => self::$cart)), 'HOOK_FOOTER' => Module::hookExec('footer'), 'content_only' => (int)(Tools::getValue('content_only')))); - $this->smarty->display(_PS_THEME_DIR_.'footer.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'footer.tpl'); //live edit if (Tools::isSubmit('live_edit') AND $ad = Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_))) { - $this->smarty->assign(array('ad' => $ad, 'live_edit' => true)); - $this->smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl'); + self::$smarty->assign(array('ad' => $ad, 'live_edit' => true)); + self::$smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl'); } else Tools::displayError(); @@ -560,7 +561,7 @@ class FrontControllerCore if (!in_array($this->orderWay, $orderWayValues)) $this->orderWay = $orderWayValues[0]; - $this->smarty->assign(array( + self::$smarty->assign(array( 'orderby' => $this->orderBy, 'orderway' => $this->orderWay, 'orderbydefault' => $orderByValues[(int)(Configuration::get('PS_PRODUCTS_ORDER_BY'))], @@ -596,7 +597,7 @@ class FrontControllerCore $stop = (int)($this->p + $range); if ($stop > $pages_nb) $stop = (int)($pages_nb); - $this->smarty->assign('nb_products', $nbProducts); + self::$smarty->assign('nb_products', $nbProducts); $pagination_infos = array( 'pages_nb' => (int)($pages_nb), 'p' => (int)($this->p), @@ -606,7 +607,7 @@ class FrontControllerCore 'start' => (int)($start), 'stop' => (int)($stop) ); - $this->smarty->assign($pagination_infos); + self::$smarty->assign($pagination_infos); } public static function getCurrentCustomerGroups() diff --git a/classes/Message.php b/classes/Message.php index 2feed05d9..2b177b0ae 100644 --- a/classes/Message.php +++ b/classes/Message.php @@ -110,7 +110,7 @@ class MessageCore extends ObjectModel SELECT m.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname, (COUNT(mr.id_message) = 0 AND m.id_customer != 0) AS is_new_for_me FROM `'._DB_PREFIX_.'message` m LEFT JOIN `'._DB_PREFIX_.'customer` c ON m.`id_customer` = c.`id_customer` - LEFT JOIN `'._DB_PREFIX_.'message_readed` mr ON (mr.id_message = m.id_message AND mr.id_employee = '.(int)$context->employee->id.') + LEFT JOIN `'._DB_PREFIX_.'message_readed` mr ON (mr.`id_message` = m.`id_message` AND mr.`id_employee` = '.(isset($context->employee) ? (int)$context->employee->id : '\'\'').') LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = m.`id_employee` WHERE id_order = '.(int)$id_order.' '.(!$private ? ' AND m.`private` = 0' : '').' diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index 39ac5fcab..f054f2c05 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -219,6 +219,7 @@ abstract class ObjectModelCore if (!$result) return false; + /* Get object id in database */ $this->id = Db::getInstance()->Insert_ID(); $assos = Shop::getAssoTables(); diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 51113721d..bc653c69d 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -91,6 +91,8 @@ abstract class PaymentModuleCore extends Module public function validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod = 'Unknown', $message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false, $secure_key = false, Shop $shop = null) { $cart = new Cart((int)($id_cart)); + if (!$shop) + $shop = Context::getContext()->shop; // Does order already exists ? if (Validate::isLoadedObject($cart) AND $cart->OrderExists() == false) { diff --git a/classes/Product.php b/classes/Product.php index 9589a5118..0188d2d1d 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -416,11 +416,7 @@ class ProductCore extends ObjectModel public static function initPricesComputation($customer = NULL) { if ($customer) - { - if (!Validate::isLoadedObject($customer)) - die(Tools::displayError()); self::$_taxCalculationMethod = Group::getPriceDisplayMethod((int)($customer->id_default_group)); - } else self::$_taxCalculationMethod = Group::getDefaultPriceDisplayMethod(); } @@ -1738,7 +1734,7 @@ class ProductCore extends ObjectModel * When a non-user calls directly this method (e.g., payment module...) is on PrestaShop, he does not have already it BUT knows the cart ID * When called from the back office, cart ID can be inexistant */ - if (!$id_cart &&!isset($context->tab)) + if (!$id_cart &&!isset($context->employee)) die(Tools::displayError()); $cur_cart = new Cart($id_cart); } @@ -2901,29 +2897,27 @@ class ProductCore extends ObjectModel ** Customization management */ - public static function getAllCustomizedDatas($id_cart, $id_lang = null, Context $context = null) + public static function getAllCustomizedDatas($id_cart, $id_lang = null, $only_in_cart = true) { - if (!$context) - $context = Context::getContext(); - // No need to query if there isn't any real cart! if (!$id_cart) return false; if (!$id_lang) - $id_lang = $context->language->id; + $id_lang = Context::getContext()->language->id; if (!$result = Db::getInstance()->ExecuteS(' SELECT cd.`id_customization`, c.`id_product`, cfl.`id_customization_field`, c.`id_product_attribute`, cd.`type`, cd.`index`, cd.`value`, cfl.`name` FROM `'._DB_PREFIX_.'customized_data` cd NATURAL JOIN `'._DB_PREFIX_.'customization` c LEFT JOIN `'._DB_PREFIX_.'customization_field_lang` cfl ON (cfl.id_customization_field = cd.`index` AND id_lang = '.(int)($id_lang).') - WHERE c.`id_cart` = '.(int)$id_cart.' + WHERE c.`id_cart` = '.(int)$id_cart. + ($only_in_cart ? ' AND c.`in_cart` = 1' : '').' ORDER BY `id_product`, `id_product_attribute`, `type`, `index`')) return false; $customizedDatas = array(); foreach ($result AS $row) $customizedDatas[(int)($row['id_product'])][(int)($row['id_product_attribute'])][(int)($row['id_customization'])]['datas'][(int)($row['type'])][] = $row; - if (!$result = Db::getInstance()->ExecuteS('SELECT `id_product`, `id_product_attribute`, `id_customization`, `quantity`, `quantity_refunded`, `quantity_returned` FROM `'._DB_PREFIX_.'customization` WHERE `id_cart` = '.(int)($id_cart))) + if (!$result = Db::getInstance()->ExecuteS('SELECT `id_product`, `id_product_attribute`, `id_customization`, `quantity`, `quantity_refunded`, `quantity_returned` FROM `'._DB_PREFIX_.'customization` WHERE `id_cart` = '.(int)($id_cart).($only_in_cart ? ' AND `in_cart` = 1' : ''))) return false; foreach ($result AS $row) { @@ -3107,7 +3101,7 @@ class ProductCore extends ObjectModel return false; return true; } - + /** * Specify if a product is already in database * diff --git a/classes/Tools.php b/classes/Tools.php index 54b549a7c..fd9a4eead 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1861,7 +1861,7 @@ FileETag INode MTime Size { if (!$context) $context = Context::getContext(); - $smarty = $context->controller->smarty; + $smarty = $context->smarty; if (!Configuration::get('PS_SMARTY_CACHE')) return; if ($smarty->force_compile == 0 AND $smarty->caching == $level) @@ -1876,12 +1876,11 @@ FileETag INode MTime Size { if (!$context) $context = Context::getContext(); - $smarty = $context->controller->smarty; if (isset(self::$_forceCompile)) - $smarty->force_compile = (int)(self::$_forceCompile); + $context->smarty->force_compile = (int)(self::$_forceCompile); if (isset(self::$_caching)) - $smarty->caching = (int)(self::$_caching); + $context->smarty->caching = (int)(self::$_caching); } public static function isCallable($function) diff --git a/controllers/AddressController.php b/controllers/AddressController.php index 8ecad7be3..2de7b0e27 100644 --- a/controllers/AddressController.php +++ b/controllers/AddressController.php @@ -47,9 +47,9 @@ class AddressControllerCore extends FrontController parent::preProcess(); $context = Context::getContext(); if ($back = Tools::getValue('back')) - $this->smarty->assign('back', Tools::safeOutput($back)); + self::$smarty->assign('back', Tools::safeOutput($back)); if ($mod = Tools::getValue('mod')) - $this->smarty->assign('mod', Tools::safeOutput($mod)); + self::$smarty->assign('mod', Tools::safeOutput($mod)); if (Tools::isSubmit('ajax') AND Tools::isSubmit('type')) { @@ -78,7 +78,7 @@ class AddressControllerCore extends FrontController Tools::redirect('index.php?controller=addresses'); $this->errors[] = Tools::displayError('This address cannot be deleted.'); } - $this->smarty->assign(array('address' => $this->_address, 'id_address' => (int)$id_address)); + self::$smarty->assign(array('address' => $this->_address, 'id_address' => (int)$id_address)); } elseif (Tools::isSubmit('ajax')) exit; @@ -130,7 +130,7 @@ class AddressControllerCore extends FrontController $address->dni = NULL; if (Configuration::get('PS_TOKEN_ENABLE') == 1 AND strcmp(Tools::getToken(false), Tools::getValue('token')) AND - self::$cookie->isLogged(true) === true) + $context->customer->isLogged(true) === true) $this->errors[] = Tools::displayError('Invalid token'); if ((int)($country->contains_states) AND !(int)($address->id_state)) @@ -251,17 +251,17 @@ class AddressControllerCore extends FrontController $countriesList .= ''; if ((Configuration::get('VATNUMBER_MANAGEMENT') AND file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php')) && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT'))) - $this->smarty->assign('vat_display', 2); + self::$smarty->assign('vat_display', 2); else if(Configuration::get('VATNUMBER_MANAGEMENT')) - $this->smarty->assign('vat_display', 1); + self::$smarty->assign('vat_display', 1); else - $this->smarty->assign('vat_display', 0); + self::$smarty->assign('vat_display', 0); - $this->smarty->assign('ajaxurl', _MODULE_DIR_); + self::$smarty->assign('ajaxurl', _MODULE_DIR_); - $this->smarty->assign('vatnumber_ajax_call', (int)file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php')); + self::$smarty->assign('vatnumber_ajax_call', (int)file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php')); - $this->smarty->assign(array( + self::$smarty->assign(array( 'countries_list' => $countriesList, 'countries' => $countries, 'errors' => $this->errors, @@ -276,7 +276,7 @@ class AddressControllerCore extends FrontController $id_country = is_null($this->_address)? 0 : (int)$this->_address->id_country; $dlv_adr_fields = AddressFormat::getOrderedAddressFields($id_country, $split_all = true); - $this->smarty->assign('ordered_adr_fields', $dlv_adr_fields); + self::$smarty->assign('ordered_adr_fields', $dlv_adr_fields); } public function displayHeader() @@ -290,7 +290,7 @@ class AddressControllerCore extends FrontController parent::displayContent(); $this->_processAddressFormat(); - $this->smarty->display(_PS_THEME_DIR_.'address.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'address.tpl'); } public function displayFooter() diff --git a/controllers/AddressesController.php b/controllers/AddressesController.php index cc30e2893..817e003e6 100644 --- a/controllers/AddressesController.php +++ b/controllers/AddressesController.php @@ -47,7 +47,7 @@ class AddressesControllerCore extends FrontController public function process() { parent::process(); - + $context = Context::getContext(); $multipleAddressesFormated = array(); $ordered_fields = array(); $customer = $context->customer; @@ -56,7 +56,7 @@ class AddressesControllerCore extends FrontController die(Tools::displayError('Customer not found')); // Retro Compatibility Theme < 1.4.1 - $this->smarty->assign('addresses', $customer->getAddresses($context->language->id)); + self::$smarty->assign('addresses', $customer->getAddresses($context->language->id)); $customerAddressesDetailed = $customer->getAddresses($context->language->id); @@ -81,7 +81,7 @@ class AddressesControllerCore extends FrontController if (($key = array_search('Country:name', $ordered_fields))) $ordered_fields[$key] = 'country'; - $this->smarty->assign('addresses_style', array( + self::$smarty->assign('addresses_style', array( 'company' => 'address_company' ,'vat_number' => 'address_company' ,'firstname' => 'address_name' @@ -95,7 +95,7 @@ class AddressesControllerCore extends FrontController ,'alias' => 'address_title' )); - $this->smarty->assign(array( + self::$smarty->assign(array( 'multipleAddresses' => $multipleAddressesFormated, 'ordered_fields' => $ordered_fields)); } @@ -103,7 +103,7 @@ class AddressesControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'addresses.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'addresses.tpl'); } } diff --git a/controllers/AuthController.php b/controllers/AuthController.php index 0e39416fc..42f3a66ce 100644 --- a/controllers/AuthController.php +++ b/controllers/AuthController.php @@ -45,7 +45,7 @@ class AuthControllerCore extends FrontController if (Tools::getValue('create_account')) { $create_account = 1; - $this->smarty->assign('email_create', 1); + self::$smarty->assign('email_create', 1); } if (Tools::isSubmit('SubmitCreate')) @@ -61,7 +61,7 @@ class AuthControllerCore extends FrontController else { $create_account = 1; - $this->smarty->assign('email_create', Tools::safeOutput($email)); + self::$smarty->assign('email_create', Tools::safeOutput($email)); $_POST['email'] = $email; } @@ -71,7 +71,7 @@ class AuthControllerCore extends FrontController { $create_account = 1; if (Tools::isSubmit('submitAccount')) - $this->smarty->assign('email_create', 1); + self::$smarty->assign('email_create', 1); /* New Guest customer */ if (!Tools::getValue('is_new_customer', 1) AND !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) $this->errors[] = Tools::displayError('You cannot create a guest account.'); @@ -170,7 +170,7 @@ class AuthControllerCore extends FrontController array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname.' '.$customer->lastname)) $this->errors[] = Tools::displayError('Cannot send email'); } - $this->smarty->assign('confirmation', 1); + self::$smarty->assign('confirmation', 1); self::$cookie->id_customer = (int)($customer->id); self::$cookie->customer_lastname = $customer->lastname; self::$cookie->customer_firstname = $customer->firstname; @@ -310,14 +310,14 @@ class AuthControllerCore extends FrontController $selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT')); $countries = Country::getCountries((int)(self::$cookie->id_lang), true); - $this->smarty->assign(array( + self::$smarty->assign(array( 'countries' => $countries, 'sl_country' => (isset($selectedCountry) ? $selectedCountry : 0), 'vat_management' => Configuration::get('VATNUMBER_MANAGEMENT') )); /* Call a hook to display more information on form */ - $this->smarty->assign(array( + self::$smarty->assign(array( 'HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop') )); @@ -335,7 +335,7 @@ class AuthControllerCore extends FrontController $selectedDays = (int)($_POST['days']); $days = Tools::dateDays(); - $this->smarty->assign(array( + self::$smarty->assign(array( 'years' => $years, 'sl_year' => (isset($selectedYears) ? $selectedYears : 0), 'months' => $months, @@ -343,7 +343,7 @@ class AuthControllerCore extends FrontController 'days' => $days, 'sl_day' => (isset($selectedDays) ? $selectedDays : 0) )); - $this->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active); + self::$smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active); } public function setMedia() @@ -363,11 +363,11 @@ class AuthControllerCore extends FrontController $back .= (strpos($back, '?') !== false ? '&' : '?').'key='.$key; if (!empty($back)) { - $this->smarty->assign('back', Tools::safeOutput($back)); + self::$smarty->assign('back', Tools::safeOutput($back)); if (strpos($back, 'order.php') !== false) { $countries = Country::getCountries((int)(self::$cookie->id_lang), true); - $this->smarty->assign(array( + self::$smarty->assign(array( 'inOrderProcess' => true, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'sl_country' => (int)Tools::getValue('id_country', Configuration::get('PS_COUNTRY_DEFAULT')), @@ -382,7 +382,7 @@ class AuthControllerCore extends FrontController $this->processAddressFormat(); parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'authentication.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'authentication.tpl'); } protected function processAddressFormat() @@ -401,7 +401,7 @@ class AuthControllerCore extends FrontController $addressItems[] = trim($fieldName); foreach (array('inv', 'dlv') as $addressType) - $this->smarty->assign(array($addressType.'_adr_fields' => $addressFormat, $addressType.'_all_fields' => $addressItems)); + self::$smarty->assign(array($addressType.'_adr_fields' => $addressFormat, $addressType.'_all_fields' => $addressItems)); } } diff --git a/controllers/BestSalesController.php b/controllers/BestSalesController.php index 04a79d001..7b12d996e 100644 --- a/controllers/BestSalesController.php +++ b/controllers/BestSalesController.php @@ -40,7 +40,7 @@ class BestSalesControllerCore extends FrontController $nbProducts = (int)ProductSale::getNbSales(); $this->pagination($nbProducts); - $this->smarty->assign(array( + self::$smarty->assign(array( 'products' => ProductSale::getBestSales((int)self::$cookie->id_lang, (int)$this->p - 1, (int)$this->n, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, @@ -57,7 +57,7 @@ class BestSalesControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'best-sales.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'best-sales.tpl'); } } diff --git a/controllers/CMSController.php b/controllers/CMSController.php index 8d4ab522f..aa793366b 100644 --- a/controllers/CMSController.php +++ b/controllers/CMSController.php @@ -78,7 +78,7 @@ class CmsControllerCore extends FrontController self::$link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']); $default_rewrite[$infos['id_lang']] = $arr_link; } - $this->smarty->assign('lang_rewrite_urls', $default_rewrite); + self::$smarty->assign('lang_rewrite_urls', $default_rewrite); } } @@ -96,12 +96,12 @@ class CmsControllerCore extends FrontController { parent::process(); $parent_cat = new CMSCategory(1, (int)(self::$cookie->id_lang)); - $this->smarty->assign('id_current_lang', self::$cookie->id_lang); - $this->smarty->assign('home_title', $parent_cat->name); - $this->smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID')); + self::$smarty->assign('id_current_lang', self::$cookie->id_lang); + self::$smarty->assign('home_title', $parent_cat->name); + self::$smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID')); if ($this->assignCase == 1) { - $this->smarty->assign(array( + self::$smarty->assign(array( 'cms' => $this->cms, 'content_only' => (int)(Tools::getValue('content_only')), 'path' => ((isset($this->cms->id_cms_category) AND $this->cms->id_cms_category) ? Tools::getFullPath((int)($this->cms->id_cms_category), $this->cms->meta_title, 'CMS') : Tools::getFullPath(1, $this->cms->meta_title, 'CMS')) @@ -109,7 +109,7 @@ class CmsControllerCore extends FrontController } elseif ($this->assignCase == 2) { - $this->smarty->assign(array( + self::$smarty->assign(array( 'category' => $this->cms_category, 'sub_category' => $this->cms_category->getSubCategories((int)(self::$cookie->id_lang)), 'cms_pages' => CMS::getCMSPages((int)(self::$cookie->id_lang), (int)($this->cms_category->id) ), @@ -121,6 +121,6 @@ class CmsControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'cms.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'cms.tpl'); } } diff --git a/controllers/CartController.php b/controllers/CartController.php index f613abc96..5eed288bd 100644 --- a/controllers/CartController.php +++ b/controllers/CartController.php @@ -48,7 +48,7 @@ class CartControllerCore extends FrontController $result = array('carriers' => Carrier::getCarriersForOrder(Country::getIdZone((isset($deliveryAddress) AND (int)$deliveryAddress->id) ? (int)$deliveryAddress->id_country : (int)Configuration::get('PS_COUNTRY_DEFAULT')), $groups)); } $result['summary'] = $context->cart->getSummaryDetails(); - $result['customizedDatas'] = Product::getAllCustomizedDatas($context->cart->id); + $result['customizedDatas'] = Product::getAllCustomizedDatas($context->cart->id, null, true); $result['HOOK_SHOPPING_CART'] = Module::hookExec('shoppingCart', $result['summary']); $result['HOOK_SHOPPING_CART_EXTRA'] = Module::hookExec('shoppingCartExtra', $result['summary']); die(Tools::jsonEncode($result)); @@ -78,7 +78,7 @@ class CartControllerCore extends FrontController $orderTotal = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS); $this->cartDiscounts = $context->cart->getDiscounts(); foreach ($this->cartDiscounts AS $k => $this->cartDiscount) - if ($error = self::$cart->checkDiscountValidity(new Discount((int)($this->cartDiscount['id_discount'])), $this->cartDiscounts, $orderTotal, $context->$cart->getProducts(), false)) + if ($error = self::$cart->checkDiscountValidity(new Discount((int)($this->cartDiscount['id_discount'])), $this->cartDiscounts, $orderTotal, $context->cart->getProducts(), false)) $context->cart->deleteDiscount((int)($this->cartDiscount['id_discount'])); $add = Tools::getIsset('add') ? 1 : 0; @@ -251,6 +251,6 @@ class CartControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'errors.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'errors.tpl'); } } diff --git a/controllers/CategoryController.php b/controllers/CategoryController.php index 14c695a04..09d4bb01f 100644 --- a/controllers/CategoryController.php +++ b/controllers/CategoryController.php @@ -83,7 +83,7 @@ class CategoryControllerCore extends FrontController foreach ($rewrite_infos AS $infos) $default_rewrite[$infos['id_lang']] = self::$link->getCategoryLink((int)$id_category, $infos['link_rewrite'], $infos['id_lang']); - $this->smarty->assign('lang_rewrite_urls', $default_rewrite); + self::$smarty->assign('lang_rewrite_urls', $default_rewrite); } } @@ -99,13 +99,13 @@ class CategoryControllerCore extends FrontController elseif (!$this->category->checkAccess((int)(self::$cookie->id_customer))) $this->errors[] = Tools::displayError('You do not have access to this category.'); elseif (!$this->category->active) - $this->smarty->assign('category', $this->category); + self::$smarty->assign('category', $this->category); else { $rewrited_url = self::$link->getCategoryLink((int)$this->category->id, $this->category->link_rewrite); /* Scenes (could be externalised to another controler if you need them */ - $this->smarty->assign('scenes', Scene::getScenes((int)($this->category->id), (int)(self::$cookie->id_lang), true, false)); + self::$smarty->assign('scenes', Scene::getScenes((int)($this->category->id), (int)(self::$cookie->id_lang), true, false)); /* Scenes images formats */ if ($sceneImageTypes = ImageType::getImagesTypes('scenes')) @@ -117,18 +117,18 @@ class CategoryControllerCore extends FrontController elseif ($sceneImageType['name'] == 'large_scene') $largeSceneImageType = $sceneImageType; } - $this->smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL); - $this->smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL); + self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL); + self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL); } $this->category->description = Tools::nl2br($this->category->description); $subCategories = $this->category->getSubCategories((int)(self::$cookie->id_lang)); - $this->smarty->assign('category', $this->category); + self::$smarty->assign('category', $this->category); if (isset($subCategories) AND !empty($subCategories) AND $subCategories) { - $this->smarty->assign('subcategories', $subCategories); - $this->smarty->assign(array( + self::$smarty->assign('subcategories', $subCategories); + self::$smarty->assign(array( 'subcategories_nb_total' => sizeof($subCategories), 'subcategories_nb_half' => ceil(sizeof($subCategories) / 2))); } @@ -136,10 +136,10 @@ class CategoryControllerCore extends FrontController { $nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $this->pagination((int)$nbProducts); - $this->smarty->assign('nb_products', (int)$nbProducts); + self::$smarty->assign('nb_products', (int)$nbProducts); $cat_products = $this->category->getProducts((int)(self::$cookie->id_lang), (int)($this->p), (int)($this->n), $this->orderBy, $this->orderWay); } - $this->smarty->assign(array( + self::$smarty->assign(array( 'products' => (isset($cat_products) AND $cat_products) ? $cat_products : NULL, 'id_category' => (int)($this->category->id), 'id_category_parent' => (int)($this->category->id_parent), @@ -154,7 +154,7 @@ class CategoryControllerCore extends FrontController } } - $this->smarty->assign(array( + self::$smarty->assign(array( 'allow_oosp' => (int)(Configuration::get('PS_ORDER_OUT_OF_STOCK')), 'comparator_max_item' => (int)(Configuration::get('PS_COMPARATOR_MAX_ITEM')), 'suppliers' => Supplier::getSuppliers() @@ -164,7 +164,7 @@ class CategoryControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'category.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'category.tpl'); } } diff --git a/controllers/CompareController.php b/controllers/CompareController.php index 5f6a43e3b..17edff75a 100644 --- a/controllers/CompareController.php +++ b/controllers/CompareController.php @@ -96,24 +96,24 @@ class CompareControllerCore extends FrontController $hasProduct = true; $ordered_features = Feature::getFeaturesForComparison($ids, self::$cookie->id_lang); - $this->smarty->assign(array( + self::$smarty->assign(array( 'ordered_features' => $ordered_features, 'product_features' => $listFeatures, 'products' => $listProducts, 'width' => $width, 'homeSize' => Image::getSize('home') )); - $this->smarty->assign('HOOK_EXTRA_PRODUCT_COMPARISON', Module::hookExec('extraProductComparison', array('list_ids_product' => $ids))); + self::$smarty->assign('HOOK_EXTRA_PRODUCT_COMPARISON', Module::hookExec('extraProductComparison', array('list_ids_product' => $ids))); } } } - $this->smarty->assign('hasProduct', $hasProduct); + self::$smarty->assign('hasProduct', $hasProduct); } public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'products-comparison.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'products-comparison.tpl'); } } diff --git a/controllers/ContactController.php b/controllers/ContactController.php index 39a26c64a..0f1bf4395 100644 --- a/controllers/ContactController.php +++ b/controllers/ContactController.php @@ -41,7 +41,7 @@ class ContactControllerCore extends FrontController if (self::$cookie->isLogged()) { - $this->smarty->assign('isLogged', 1); + self::$smarty->assign('isLogged', 1); $customer = new Customer((int)(self::$cookie->id_customer)); if (!Validate::isLoadedObject($customer)) die(Tools::displayError('Customer not found')); @@ -68,8 +68,8 @@ class ContactControllerCore extends FrontController foreach ($products as $key => $val) $orderedProductList .= ''; - $this->smarty->assign('orderList', $orderList); - $this->smarty->assign('orderedProductList', $orderedProductList); + self::$smarty->assign('orderList', $orderList); + self::$smarty->assign('orderedProductList', $orderedProductList); } if (Tools::isSubmit('submitMessage')) @@ -152,7 +152,7 @@ class ContactControllerCore extends FrontController ORDER BY date_add DESC'); if ($old_message == htmlentities($message, ENT_COMPAT, 'UTF-8')) { - $this->smarty->assign('alreadySent', 1); + self::$smarty->assign('alreadySent', 1); $contact->email = ''; $contact->customer_service = 0; } @@ -160,7 +160,7 @@ class ContactControllerCore extends FrontController { if (Mail::Send((int)(self::$cookie->id_lang), 'contact', Mail::l('Message from contact form'), array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, ((int)(self::$cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment) AND Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from)) - $this->smarty->assign('confirmation', 1); + self::$smarty->assign('confirmation', 1); else $this->errors[] = Tools::displayError('An error occurred while sending message.'); } @@ -210,7 +210,7 @@ class ContactControllerCore extends FrontController { if (empty($contact->email)) Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from); - $this->smarty->assign('confirmation', 1); + self::$smarty->assign('confirmation', 1); } else $this->errors[] = Tools::displayError('An error occurred while sending message.'); @@ -235,7 +235,7 @@ class ContactControllerCore extends FrontController parent::process(); $email = Tools::safeOutput(Tools::getValue('from', ((isset(self::$cookie) AND isset(self::$cookie->email) AND Validate::isEmail(self::$cookie->email)) ? self::$cookie->email : ''))); - $this->smarty->assign(array( + self::$smarty->assign(array( 'errors' => $this->errors, 'email' => $email, 'fileupload' => Configuration::get('PS_CUSTOMER_SERVICE_FILE_UPLOAD') @@ -247,9 +247,9 @@ class ContactControllerCore extends FrontController $customerThread = Db::getInstance()->getRow(' SELECT cm.* FROM '._DB_PREFIX_.'customer_thread cm WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->id_current_shop.' AND token = \''.pSQL($token).'\''); - $this->smarty->assign('customerThread', $customerThread); + self::$smarty->assign('customerThread', $customerThread); } - $this->smarty->assign(array('contacts' => Contact::getContacts((int)self::$cookie->id_lang), + self::$smarty->assign(array('contacts' => Contact::getContacts((int)self::$cookie->id_lang), 'message' => html_entity_decode(Tools::getValue('message')) )); } @@ -258,7 +258,7 @@ class ContactControllerCore extends FrontController { $_POST = array_merge($_POST, $_GET); parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'contact-form.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'contact-form.tpl'); } } diff --git a/controllers/DiscountController.php b/controllers/DiscountController.php index 37d1e8257..9192c7a4a 100644 --- a/controllers/DiscountController.php +++ b/controllers/DiscountController.php @@ -47,13 +47,13 @@ class DiscountControllerCore extends FrontController if ($discount['quantity_for_user']) $nbDiscounts++; - $this->smarty->assign(array('nbDiscounts' => (int)($nbDiscounts), 'discount' => $discounts)); + self::$smarty->assign(array('nbDiscounts' => (int)($nbDiscounts), 'discount' => $discounts)); } public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'discount.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'discount.tpl'); } } diff --git a/controllers/GuestTrackingController.php b/controllers/GuestTrackingController.php index 789b0e516..9f0891ffb 100644 --- a/controllers/GuestTrackingController.php +++ b/controllers/GuestTrackingController.php @@ -60,13 +60,13 @@ class GuestTrackingControllerCore extends FrontController $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields); if ($order->total_discounts > 0) - $this->smarty->assign('total_old', (float)($order->total_paid - $order->total_discounts)); + self::$smarty->assign('total_old', (float)($order->total_paid - $order->total_discounts)); $products = $order->getProducts(); $customizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart)); Product::addCustomizationPrice($products, $customizedDatas); $this->processAddressFormat($addressDelivery, $addressInvoice); - $this->smarty->assign(array( + self::$smarty->assign(array( 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'order' => $order, 'return_allowed' => false, @@ -91,8 +91,8 @@ class GuestTrackingControllerCore extends FrontController 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues)); if ($carrier->url AND $order->shipping_number) - $this->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); - $this->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order))); + self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); + self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order))); Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order)); if (Tools::isSubmit('submitTransformGuestToCustomer')) @@ -105,7 +105,7 @@ class GuestTrackingControllerCore extends FrontController if (!Tools::getValue('password')) $this->errors[] = Tools::displayError('Invalid password'); else - $this->smarty->assign('transformSuccess', true); + self::$smarty->assign('transformSuccess', true); } } if (sizeof($this->errors)) @@ -113,7 +113,7 @@ class GuestTrackingControllerCore extends FrontController sleep(1); } - $this->smarty->assign(array( + self::$smarty->assign(array( 'action' => 'guest-tracking.php', 'errors' => $this->errors )); @@ -131,7 +131,7 @@ class GuestTrackingControllerCore extends FrontController { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'guest-tracking.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'guest-tracking.tpl'); } private function processAddressFormat(Address $delivery, Address $invoice) @@ -140,8 +140,8 @@ class GuestTrackingControllerCore extends FrontController $inv_adr_fields = AddressFormat::getOrderedAddressFields($invoice->id_country); $dlv_adr_fields = AddressFormat::getOrderedAddressFields($delivery->id_country); - $this->smarty->assign('inv_adr_fields', $inv_adr_fields); - $this->smarty->assign('dlv_adr_fields', $dlv_adr_fields); + self::$smarty->assign('inv_adr_fields', $inv_adr_fields); + self::$smarty->assign('dlv_adr_fields', $dlv_adr_fields); } } diff --git a/controllers/HistoryController.php b/controllers/HistoryController.php index bf07f799b..470325552 100644 --- a/controllers/HistoryController.php +++ b/controllers/HistoryController.php @@ -59,7 +59,7 @@ class HistoryControllerCore extends FrontController if (Validate::isLoadedObject($myOrder)) $order['virtual'] = $myOrder->isVirtual(false); } - $this->smarty->assign(array( + self::$smarty->assign(array( 'orders' => $orders, 'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')), 'slowValidation' => Tools::isSubmit('slowvalidation') @@ -69,7 +69,7 @@ class HistoryControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'history.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'history.tpl'); } } diff --git a/controllers/IdentityController.php b/controllers/IdentityController.php index 07f5f705a..5473671e4 100644 --- a/controllers/IdentityController.php +++ b/controllers/IdentityController.php @@ -84,7 +84,7 @@ class IdentityControllerCore extends FrontController { self::$cookie->customer_lastname = $customer->lastname; self::$cookie->customer_firstname = $customer->firstname; - $this->smarty->assign('confirmation', 1); + self::$smarty->assign('confirmation', 1); } else $this->errors[] = Tools::displayError('Cannot update information'); @@ -100,7 +100,7 @@ class IdentityControllerCore extends FrontController $birthday = array('-', '-', '-'); /* Generate years, months and days */ - $this->smarty->assign(array( + self::$smarty->assign(array( 'years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), @@ -110,7 +110,7 @@ class IdentityControllerCore extends FrontController 'errors' => $this->errors )); - $this->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active); + self::$smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active); } public function setMedia() @@ -122,7 +122,7 @@ class IdentityControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'identity.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'identity.tpl'); } } diff --git a/controllers/IndexController.php b/controllers/IndexController.php index c4c2a2ae2..d55c6c912 100644 --- a/controllers/IndexController.php +++ b/controllers/IndexController.php @@ -37,12 +37,12 @@ class IndexControllerCore extends FrontController public function process() { parent::process(); - $this->smarty->assign('HOOK_HOME', Module::hookExec('home')); + self::$smarty->assign('HOOK_HOME', Module::hookExec('home')); } public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'index.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'index.tpl'); } } diff --git a/controllers/ManufacturerController.php b/controllers/ManufacturerController.php index 01145546c..cc78afc44 100644 --- a/controllers/ManufacturerController.php +++ b/controllers/ManufacturerController.php @@ -44,7 +44,7 @@ class ManufacturerControllerCore extends FrontController { $nbProducts = $this->manufacturer->getProducts($id_manufacturer, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $this->pagination((int)$nbProducts); - $this->smarty->assign(array( + self::$smarty->assign(array( 'nb_products' => $nbProducts, 'products' => $this->manufacturer->getProducts($id_manufacturer, (int)self::$cookie->id_lang, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay), 'path' => ($this->manufacturer->active ? Tools::safeOutput($this->manufacturer->name) : ''), @@ -71,7 +71,7 @@ class ManufacturerControllerCore extends FrontController foreach ($data AS &$item) $item['image'] = (!file_exists($imgDir.'/'.$item['id_manufacturer'].'-medium.jpg')) ? Language::getIsoById((int)(self::$cookie->id_lang)).'-default' : $item['id_manufacturer']; - $this->smarty->assign(array( + self::$smarty->assign(array( 'pages_nb' => ceil($nbProducts / (int)($this->n)), 'nbManufacturers' => $nbProducts, 'mediumSize' => Image::getSize('medium'), @@ -80,7 +80,7 @@ class ManufacturerControllerCore extends FrontController )); } else - $this->smarty->assign('nbManufacturers', 0); + self::$smarty->assign('nbManufacturers', 0); } } @@ -94,9 +94,9 @@ class ManufacturerControllerCore extends FrontController { parent::displayContent(); if ($this->manufacturer) - $this->smarty->display(_PS_THEME_DIR_.'manufacturer.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'manufacturer.tpl'); else - $this->smarty->display(_PS_THEME_DIR_.'manufacturer-list.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'manufacturer-list.tpl'); } } diff --git a/controllers/MyAccountController.php b/controllers/MyAccountController.php index 3c87eb161..db4a1b30c 100644 --- a/controllers/MyAccountController.php +++ b/controllers/MyAccountController.php @@ -47,17 +47,17 @@ class MyAccountControllerCore extends FrontController { parent::process(); - $this->smarty->assign(array( + self::$smarty->assign(array( 'voucherAllowed' => (int)(Configuration::get('PS_VOUCHERS')), 'returnAllowed' => (int)(Configuration::get('PS_ORDER_RETURN')) )); - $this->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Module::hookExec('customerAccount')); + self::$smarty->assign('HOOK_CUSTOMER_ACCOUNT', Module::hookExec('customerAccount')); } public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'my-account.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'my-account.tpl'); } } diff --git a/controllers/NewProductsController.php b/controllers/NewProductsController.php index 97b14332a..d0b74ca7d 100644 --- a/controllers/NewProductsController.php +++ b/controllers/NewProductsController.php @@ -49,7 +49,7 @@ class NewProductsControllerCore extends FrontController $nbProducts = (int)Product::getNewProducts((int)self::$cookie->id_lang, (isset($this->p) ? (int)($this->p) - 1 : NULL), (isset($this->n) ? (int)($this->n) : NULL), true); $this->pagination($nbProducts); - $this->smarty->assign(array( + self::$smarty->assign(array( 'products' => Product::getNewProducts((int)(self::$cookie->id_lang), (int)($this->p) - 1, (int)($this->n), false, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int)($nbProducts), @@ -60,7 +60,7 @@ class NewProductsControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'new-products.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'new-products.tpl'); } } diff --git a/controllers/OrderConfirmationController.php b/controllers/OrderConfirmationController.php index 234210ab3..41165322e 100644 --- a/controllers/OrderConfirmationController.php +++ b/controllers/OrderConfirmationController.php @@ -68,7 +68,7 @@ class OrderConfirmationControllerCore extends FrontController public function process() { parent::process(); - $this->smarty->assign(array( + self::$smarty->assign(array( 'is_guest' => self::$cookie->is_guest, 'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation((int)($this->id_order)), 'HOOK_PAYMENT_RETURN' => Hook::paymentReturn((int)($this->id_order), (int)($this->id_module)) @@ -76,7 +76,7 @@ class OrderConfirmationControllerCore extends FrontController if (self::$cookie->is_guest) { - $this->smarty->assign(array( + self::$smarty->assign(array( 'id_order' => $this->id_order, 'id_order_formatted' => sprintf('#%06d', $this->id_order) )); @@ -88,7 +88,7 @@ class OrderConfirmationControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'order-confirmation.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'order-confirmation.tpl'); } } diff --git a/controllers/OrderController.php b/controllers/OrderController.php index c8a1ea01e..525e6209a 100644 --- a/controllers/OrderController.php +++ b/controllers/OrderController.php @@ -69,7 +69,7 @@ class OrderControllerCore extends ParentOrderController Tools::redirect('index.php?controller=authentication&back='.urlencode('order.php&step='.$this->step)); if ($this->nbProducts) - $this->smarty->assign('virtual_cart', $isVirtualCart); + self::$smarty->assign('virtual_cart', $isVirtualCart); } public function displayHeader() @@ -86,7 +86,7 @@ class OrderControllerCore extends ParentOrderController switch ((int)$this->step) { case -1; - $this->smarty->assign('empty', 1); + self::$smarty->assign('empty', 1); break; case 1: $this->_assignAddress(); @@ -134,7 +134,7 @@ class OrderControllerCore extends ParentOrderController $invoiceAddressFields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country); $deliveryAddressFields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country); - $this->smarty->assign(array( + self::$smarty->assign(array( 'inv_adr_fields' => $invoiceAddressFields, 'dlv_adr_fields' => $deliveryAddressFields)); } @@ -145,7 +145,7 @@ class OrderControllerCore extends ParentOrderController parent::displayContent(); - $this->smarty->assign(array( + self::$smarty->assign(array( 'currencySign' => $context->currency->sign, 'currencyRate' => $context->currency->conversion_rate, 'currencyFormat' => $context->currency->format, @@ -155,20 +155,20 @@ class OrderControllerCore extends ParentOrderController switch ((int)$this->step) { case -1: - $this->smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl'); break; case 1: $this->processAddressFormat(); - $this->smarty->display(_PS_THEME_DIR_.'order-address.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'order-address.tpl'); break; case 2: - $this->smarty->display(_PS_THEME_DIR_.'order-carrier.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'order-carrier.tpl'); break; case 3: - $this->smarty->display(_PS_THEME_DIR_.'order-payment.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'order-payment.tpl'); break; default: - $this->smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl'); break; } } @@ -237,7 +237,7 @@ class OrderControllerCore extends ParentOrderController if (sizeof($this->errors)) { - $this->smarty->assign('errors', $this->errors); + self::$smarty->assign('errors', $this->errors); $this->_assignCarrier(); $this->step = 2; $this->displayContent(); @@ -252,7 +252,7 @@ class OrderControllerCore extends ParentOrderController { parent::_assignAddress(); - $this->smarty->assign('cart', self::$cart); + self::$smarty->assign('cart', self::$cart); if (self::$cookie->is_guest) Tools::redirect('index.php?controller=order&step=2'); } @@ -269,7 +269,7 @@ class OrderControllerCore extends ParentOrderController // Assign wrapping and TOS $this->_assignWrappingAndTOS(); - $this->smarty->assign('is_guest' ,(isset(self::$cookie->is_guest) ? self::$cookie->is_guest : 0)); + self::$smarty->assign('is_guest' ,(isset(self::$cookie->is_guest) ? self::$cookie->is_guest : 0)); } /* Payment step */ @@ -281,8 +281,8 @@ class OrderControllerCore extends ParentOrderController Hook::backBeforePayment('order.php?step=3'); /* We may need to display an order summary */ - $this->smarty->assign(self::$cart->getSummaryDetails()); - $this->smarty->assign(array( + self::$smarty->assign(self::$cart->getSummaryDetails()); + self::$smarty->assign(array( 'total_price' => (float)($orderTotal), 'taxes_enabled' => (int)(Configuration::get('PS_TAX')) )); diff --git a/controllers/OrderDetailController.php b/controllers/OrderDetailController.php index 09a04f676..1f866fea3 100644 --- a/controllers/OrderDetailController.php +++ b/controllers/OrderDetailController.php @@ -114,7 +114,7 @@ class OrderDetailControllerCore extends FrontController $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields); if ($order->total_discounts > 0) - $this->smarty->assign('total_old', (float)($order->total_paid - $order->total_discounts)); + self::$smarty->assign('total_old', (float)($order->total_paid - $order->total_discounts)); $products = $order->getProducts(); $customizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart)); @@ -122,7 +122,7 @@ class OrderDetailControllerCore extends FrontController $customer = new Customer($order->id_customer); - $this->smarty->assign(array( + self::$smarty->assign(array( 'shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int)($order->isReturnable()), @@ -150,8 +150,8 @@ class OrderDetailControllerCore extends FrontController 'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC), 'customizedDatas' => $customizedDatas)); if ($carrier->url AND $order->shipping_number) - $this->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); - $this->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order))); + self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); + self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order))); Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order)); unset($carrier); @@ -173,7 +173,7 @@ class OrderDetailControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'order-detail.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'order-detail.tpl'); } public function displayFooter() diff --git a/controllers/OrderFollowController.php b/controllers/OrderFollowController.php index 691ceab7e..3c19be032 100644 --- a/controllers/OrderFollowController.php +++ b/controllers/OrderFollowController.php @@ -76,17 +76,17 @@ class OrderFollowControllerCore extends FrontController $ordersReturn = OrderReturn::getOrdersReturn((int)(self::$cookie->id_customer)); if (Tools::isSubmit('errorQuantity')) - $this->smarty->assign('errorQuantity', true); + self::$smarty->assign('errorQuantity', true); elseif (Tools::isSubmit('errorMsg')) - $this->smarty->assign('errorMsg', true); + self::$smarty->assign('errorMsg', true); elseif (Tools::isSubmit('errorDetail1')) - $this->smarty->assign('errorDetail1', true); + self::$smarty->assign('errorDetail1', true); elseif (Tools::isSubmit('errorDetail2')) - $this->smarty->assign('errorDetail2', true); + self::$smarty->assign('errorDetail2', true); elseif (Tools::isSubmit('errorNotReturnable')) - $this->smarty->assign('errorNotReturnable',true); + self::$smarty->assign('errorNotReturnable',true); - $this->smarty->assign('ordersReturn', $ordersReturn); + self::$smarty->assign('ordersReturn', $ordersReturn); } public function setMedia() @@ -100,7 +100,7 @@ class OrderFollowControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'order-follow.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'order-follow.tpl'); } } diff --git a/controllers/OrderOpcController.php b/controllers/OrderOpcController.php index 9fc708c27..4762e97bc 100644 --- a/controllers/OrderOpcController.php +++ b/controllers/OrderOpcController.php @@ -35,7 +35,7 @@ class OrderOpcControllerCore extends ParentOrderController { parent::preProcess(); if ($this->nbProducts) - $this->smarty->assign('virtual_cart', false); + self::$smarty->assign('virtual_cart', false); $this->isLogged = (bool)((int)(self::$cookie->id_customer) AND Customer::customerIdExistsStatic((int)(self::$cookie->id_customer))); if (self::$cart->nbProducts()) @@ -122,7 +122,7 @@ class OrderOpcControllerCore extends ParentOrderController include_once(_PS_MODULE_DIR_.'blockuserinfo/blockuserinfo.php'); $blockUserInfo = new BlockUserInfo(); } - $this->smarty->assign('isVirtualCart', self::$cart->isVirtualCart()); + self::$smarty->assign('isVirtualCart', self::$cart->isVirtualCart()); $this->_processAddressFormat(); $this->_assignAddress(); // Wrapping fees @@ -131,7 +131,7 @@ class OrderOpcControllerCore extends ParentOrderController $wrapping_fees_tax_inc = $wrapping_fees * (1 + (((float)($wrapping_fees_tax->rate) / 100))); $return = array( 'summary' => self::$cart->getSummaryDetails(), - 'order_opc_adress' => $this->smarty->fetch(_PS_THEME_DIR_.'order-address.tpl'), + 'order_opc_adress' => self::$smarty->fetch(_PS_THEME_DIR_.'order-address.tpl'), 'block_user_info' => (isset($blockUserInfo) ? $blockUserInfo->hookTop(array()) : ''), 'carrier_list' => $this->_getCarrierList(), 'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'), @@ -234,7 +234,7 @@ class OrderOpcControllerCore extends ParentOrderController $selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT')); $countries = Country::getCountries((int)(self::$cookie->id_lang), true); - $this->smarty->assign(array( + self::$smarty->assign(array( 'isLogged' => $this->isLogged, 'isGuest' => isset(self::$cookie->is_guest) ? self::$cookie->is_guest : 0, 'countries' => $countries, @@ -247,7 +247,7 @@ class OrderOpcControllerCore extends ParentOrderController $years = Tools::dateYears(); $months = Tools::dateMonths(); $days = Tools::dateDays(); - $this->smarty->assign(array( + self::$smarty->assign(array( 'years' => $years, 'months' => $months, 'days' => $days, @@ -255,7 +255,7 @@ class OrderOpcControllerCore extends ParentOrderController /* Load guest informations */ if ($this->isLogged AND self::$cookie->is_guest) - $this->smarty->assign('guestInformations', $this->_getGuestInformations()); + self::$smarty->assign('guestInformations', $this->_getGuestInformations()); if ($this->isLogged) $this->_assignAddress(); // ADDRESS @@ -265,7 +265,7 @@ class OrderOpcControllerCore extends ParentOrderController $this->_assignPayment(); Tools::safePostVars(); - $this->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active); + self::$smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active); } public function displayHeader() @@ -279,7 +279,7 @@ class OrderOpcControllerCore extends ParentOrderController parent::displayContent(); $this->_processAddressFormat(); - $this->smarty->display(_PS_THEME_DIR_.'order-opc.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'order-opc.tpl'); } public function displayFooter() @@ -330,7 +330,7 @@ class OrderOpcControllerCore extends ParentOrderController if (!$this->isLogged) { $carriers = Carrier::getCarriersForOrder(Country::getIdZone((int)Configuration::get('PS_COUNTRY_DEFAULT'))); - $this->smarty->assign(array( + self::$smarty->assign(array( 'checked' => $this->_setDefaultCarrierSelection($carriers), 'carriers' => $carriers, 'default_carrier' => (int)(Configuration::get('PS_CARRIER_DEFAULT')), @@ -344,7 +344,7 @@ class OrderOpcControllerCore extends ParentOrderController protected function _assignPayment() { - $this->smarty->assign(array( + self::$smarty->assign(array( 'HOOK_TOP_PAYMENT' => ($this->isLogged ? Module::hookExec('paymentTop') : ''), 'HOOK_PAYMENT' => $this->_getPaymentMethods() )); @@ -448,8 +448,8 @@ class OrderOpcControllerCore extends ParentOrderController foreach(explode(' ',$fields_line) as $field_item) ${$adr_type.'_all_fields'}[] = trim($field_item); - $this->smarty->assign($adr_type.'_adr_fields', ${$adr_type.'_adr_fields'}); - $this->smarty->assign($adr_type.'_all_fields', ${$adr_type.'_all_fields'}); + self::$smarty->assign($adr_type.'_adr_fields', ${$adr_type.'_adr_fields'}); + self::$smarty->assign($adr_type.'_all_fields', ${$adr_type.'_all_fields'}); } } diff --git a/controllers/OrderReturnController.php b/controllers/OrderReturnController.php index 014f286b6..91ff15761 100644 --- a/controllers/OrderReturnController.php +++ b/controllers/OrderReturnController.php @@ -55,7 +55,7 @@ class OrderReturnControllerCore extends FrontController if (Validate::isLoadedObject($order)) { $state = new OrderReturnState((int)($orderRet->state)); - $this->smarty->assign(array( + self::$smarty->assign(array( 'orderRet' => $orderRet, 'order' => $order, 'state_name' => $state->name[(int)(self::$cookie->id_lang)], @@ -72,7 +72,7 @@ class OrderReturnControllerCore extends FrontController $this->errors[] = Tools::displayError('Cannot find this order return'); } - $this->smarty->assign(array( + self::$smarty->assign(array( 'errors' => $this->errors, 'nbdaysreturn' => (int)(Configuration::get('PS_ORDER_RETURN_NB_DAYS')) )); @@ -87,7 +87,7 @@ class OrderReturnControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'order-return.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'order-return.tpl'); } public function displayFooter() diff --git a/controllers/OrderSlipController.php b/controllers/OrderSlipController.php index b28c65dd4..76dc412ec 100644 --- a/controllers/OrderSlipController.php +++ b/controllers/OrderSlipController.php @@ -48,13 +48,13 @@ class OrderSlipControllerCore extends FrontController public function process() { parent::process(); - $this->smarty->assign('ordersSlip', OrderSlip::getOrdersSlip((int)(self::$cookie->id_customer))); + self::$smarty->assign('ordersSlip', OrderSlip::getOrdersSlip((int)(self::$cookie->id_customer))); } public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'order-slip.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'order-slip.tpl'); } } diff --git a/controllers/PageNotFoundController.php b/controllers/PageNotFoundController.php index d2dc97e09..bbcd27c3b 100644 --- a/controllers/PageNotFoundController.php +++ b/controllers/PageNotFoundController.php @@ -29,7 +29,7 @@ class PageNotFoundControllerCore extends FrontController { public function displayContent() { - $this->smarty->display(_PS_THEME_DIR_.'404.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'404.tpl'); } } diff --git a/controllers/ParentOrderController.php b/controllers/ParentOrderController.php index 061fdfdfb..92ddd612a 100644 --- a/controllers/ParentOrderController.php +++ b/controllers/ParentOrderController.php @@ -109,7 +109,7 @@ class ParentOrderControllerCore extends FrontController Tools::redirect('index.php?controller=order-opc'); } } - $this->smarty->assign(array( + self::$smarty->assign(array( 'errors' => $this->errors, 'discount_name' => Tools::safeOutput($discountName) )); @@ -125,7 +125,7 @@ class ParentOrderControllerCore extends FrontController $this->_setNoCarrier(); } - $this->smarty->assign('back', Tools::safeOutput(Tools::getValue('back'))); + self::$smarty->assign('back', Tools::safeOutput(Tools::getValue('back'))); } public function setMedia() @@ -234,7 +234,7 @@ class ParentOrderControllerCore extends FrontController { $context = Context::getContext(); if (file_exists(_PS_SHIP_IMG_DIR_.$context->cart->id_carrier.'.jpg')) - $this->smarty->assign('carrierPicture', 1); + self::$smarty->assign('carrierPicture', 1); $summary = $context->cart->getSummaryDetails(); $customizedDatas = Product::getAllCustomizedDatas($context->cart->id); @@ -260,14 +260,14 @@ class ParentOrderControllerCore extends FrontController $total_free_ship = 0; break; } - $this->smarty->assign('free_ship', $total_free_ship); + self::$smarty->assign('free_ship', $total_free_ship); } // for compatibility with 1.2 themes foreach($summary['products'] AS $key => $product) $summary['products'][$key]['quantity'] = $product['cart_quantity']; - $this->smarty->assign($summary); - $this->smarty->assign(array( + self::$smarty->assign($summary); + self::$smarty->assign(array( 'token_cart' => Tools::getToken(false), 'isVirtualCart' => $context->cart->isVirtualCart(), 'productNumber' => $context->cart->nbProducts(), @@ -283,7 +283,7 @@ class ParentOrderControllerCore extends FrontController 'currencyRate' => $context->currency->conversion_rate, 'currencyFormat' => $context->currency->format, 'currencyBlank' => $context->currency->blank)); - $this->smarty->assign(array( + self::$smarty->assign(array( 'HOOK_SHOPPING_CART' => Module::hookExec('shoppingCart', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Module::hookExec('shoppingCartExtra', $summary) )); @@ -319,7 +319,7 @@ class ParentOrderControllerCore extends FrontController unset($tmpAddress); } - $this->smarty->assign(array( + self::$smarty->assign(array( 'addresses' => $customerAddresses, 'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList)); @@ -343,7 +343,7 @@ class ParentOrderControllerCore extends FrontController { $deliveryAddress = new Address((int)($context->cart->id_address_delivery)); if (Validate::isLoadedObject($deliveryAddress) AND ($deliveryAddress->id_customer == $customer->id)) - $this->smarty->assign('delivery', $deliveryAddress); + self::$smarty->assign('delivery', $deliveryAddress); } /* If invoice address is valid in cart, assign it to Smarty */ @@ -351,11 +351,11 @@ class ParentOrderControllerCore extends FrontController { $invoiceAddress = new Address((int)($context->cart->id_address_invoice)); if (Validate::isLoadedObject($invoiceAddress) AND ($invoiceAddress->id_customer == $customer->id)) - $this->smarty->assign('invoice', $invoiceAddress); + self::$smarty->assign('invoice', $invoiceAddress); } } if ($oldMessage = Message::getMessageByCartId((int)($context->cart->id))) - $this->smarty->assign('oldMessage', $oldMessage['message']); + self::$smarty->assign('oldMessage', $oldMessage['message']); } protected function _assignCarrier() @@ -365,7 +365,7 @@ class ParentOrderControllerCore extends FrontController $id_zone = Address::getZoneById($address->id); $carriers = Carrier::getCarriersForOrder($id_zone, $context->customer->getGroups()); - $this->smarty->assign(array( + self::$smarty->assign(array( 'checked' => $this->_setDefaultCarrierSelection($carriers), 'carriers' => $carriers, 'default_carrier' => (int)(Configuration::get('PS_CARRIER_DEFAULT')), @@ -390,7 +390,7 @@ class ParentOrderControllerCore extends FrontController else $this->link_conditions .= '&content_only=1'; - $this->smarty->assign(array( + self::$smarty->assign(array( 'checkedTOS' => (int)($context->cookie->checkedTOS), 'recyclablePackAllowed' => (int)(Configuration::get('PS_RECYCLABLE_PACK')), 'giftAllowed' => (int)(Configuration::get('PS_GIFT_WRAPPING')), @@ -405,7 +405,7 @@ class ParentOrderControllerCore extends FrontController protected function _assignPayment() { - $this->smarty->assign(array( + self::$smarty->assign(array( 'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'), 'HOOK_PAYMENT' => Module::hookExecPayment() )); diff --git a/controllers/PasswordController.php b/controllers/PasswordController.php index 213a66891..f587f5b91 100644 --- a/controllers/PasswordController.php +++ b/controllers/PasswordController.php @@ -63,7 +63,7 @@ class PasswordControllerCore extends FrontController '{url}' => self::$link->getPageLink('password', true, NULL, 'token='.$customer->secure_key.'&id_customer='.(int)$customer->id)), $customer->email, $customer->firstname.' '.$customer->lastname)) - $this->smarty->assign(array('confirmation' => 2, 'email' => $customer->email)); + self::$smarty->assign(array('confirmation' => 2, 'email' => $customer->email)); else $this->errors[] = Tools::displayError('Error occurred when sending the e-mail.'); } @@ -92,7 +92,7 @@ class PasswordControllerCore extends FrontController '{passwd}' => $password), $customer->email, $customer->firstname.' '.$customer->lastname)) - $this->smarty->assign(array('confirmation' => 1, 'email' => $customer->email)); + self::$smarty->assign(array('confirmation' => 1, 'email' => $customer->email)); else $this->errors[] = Tools::displayError('Error occurred when sending the e-mail.'); } @@ -110,7 +110,7 @@ class PasswordControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'password.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'password.tpl'); } } diff --git a/controllers/PricesDropController.php b/controllers/PricesDropController.php index 2622bb808..1c27da2fc 100644 --- a/controllers/PricesDropController.php +++ b/controllers/PricesDropController.php @@ -48,7 +48,7 @@ class PricesDropControllerCore extends FrontController $nbProducts = Product::getPricesDrop((int)self::$cookie->id_lang, NULL, NULL, true); $this->pagination($nbProducts); - $this->smarty->assign(array( + self::$smarty->assign(array( 'products' => Product::getPricesDrop((int)self::$cookie->id_lang, (int)$this->p - 1, (int)$this->n, false, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, @@ -59,7 +59,7 @@ class PricesDropControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'prices-drop.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'prices-drop.tpl'); } } diff --git a/controllers/ProductController.php b/controllers/ProductController.php index 403e5ae6f..4998f97a9 100644 --- a/controllers/ProductController.php +++ b/controllers/ProductController.php @@ -89,7 +89,7 @@ class ProductControllerCore extends FrontController foreach ($rewrite_infos AS $infos) $default_rewrite[$infos['id_lang']] = $context->link->getProductLink((int)$id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int)$infos['id_lang']); - $this->smarty->assign('lang_rewrite_urls', $default_rewrite); + self::$smarty->assign('lang_rewrite_urls', $default_rewrite); } } @@ -113,33 +113,44 @@ class ProductControllerCore extends FrontController $this->errors[] = Tools::displayError('You do not have access to this product.'); else { - $this->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int)($this->product->id))); + self::$smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int)($this->product->id))); if (!$this->product->active) - $this->smarty->assign('adminActionDisplay', true); + self::$smarty->assign('adminActionDisplay', true); /* rewrited url set */ $rewrited_url = $context->link->getProductLink($this->product->id, $this->product->link_rewrite); /* Product pictures management */ require_once('images.inc.php'); - $this->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']))); + self::$smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']))); if (Tools::isSubmit('submitCustomizedDatas')) { + // If cart has not been saved, we need to do it so that customization fields can have an id_cart + // We check that the cookie exists first to avoid ghost carts + if (!$context->cart->id && isset($_COOKIE[$context->cookie->getName()])) + { + $context->cart->add(); + $context->cookie->id_cart = (int)$context->cart->id; + } $this->pictureUpload($this->product, $context->cart); $this->textRecord($this->product, $context->cart); $this->formTargetFormat(); } - elseif (isset($_GET['deletePicture']) AND !$context->cart->deletePictureToProduct((int)($this->product->id), (int)(Tools::getValue('deletePicture')))) + elseif (isset($_GET['deletePicture']) AND !$context->cart->deletePictureToProduct($this->product->id, Tools::getValue('deletePicture'))) $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture'); - $files = self::$cookie->getFamily('pictures_'.(int)($this->product->id)); + $files = self::$cart->getProductCustomization($this->product->id, 0, false); + $pictures = array(); + foreach($files as $file) + $pictures['pictures_'.$this->product->id.'_'.$file['index']] = $file['value']; + $textFields = self::$cookie->getFamily('textFields_'.(int)($this->product->id)); foreach ($textFields as $key => $textField) $textFields[$key] = str_replace('
', "\n", $textField); - $this->smarty->assign(array( - 'pictures' => $files, + self::$smarty->assign(array( + 'pictures' => $pictures, 'textFields' => $textFields)); $productPriceWithTax = Product::getPriceStatic($id_product, true, NULL, 6); @@ -173,7 +184,7 @@ class ProductControllerCore extends FrontController if (isset($category) AND Validate::isLoadedObject($category)) { - $this->smarty->assign(array( + self::$smarty->assign(array( 'path' => Tools::getPath((int)$category->id, $this->product->name, true), 'category' => $category, 'subCategories' => $category->getSubCategories((int)(self::$cookie->id_lang), true), @@ -182,9 +193,9 @@ class ProductControllerCore extends FrontController 'return_category_name' => Tools::safeOutput($category->name))); } else - $this->smarty->assign('path', Tools::getPath((int)$this->product->id_category_default, $this->product->name)); + self::$smarty->assign('path', Tools::getPath((int)$this->product->id_category_default, $this->product->name)); - $this->smarty->assign('return_link', (isset($category->id) AND $category->id) ? Tools::safeOutput($context->link->getCategoryLink($category)) : 'javascript: history.back();'); + self::$smarty->assign('return_link', (isset($category->id) AND $category->id) ? Tools::safeOutput($context->link->getCategoryLink($category)) : 'javascript: history.back();'); $lang = Configuration::get('PS_LANG_DEFAULT'); if (Pack::isPack((int)($this->product->id), (int)($lang)) AND !Pack::isInStock((int)($this->product->id), (int)($lang))) @@ -197,14 +208,14 @@ class ProductControllerCore extends FrontController // Tax $tax = (float)(Tax::getProductTaxRate((int)($this->product->id), $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')})); - $this->smarty->assign('tax_rate', $tax); + self::$smarty->assign('tax_rate', $tax); $ecotax_rate = (float) Tax::getProductEcotaxRate($context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); $ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2); if (Product::$_taxCalculationMethod == PS_TAX_INC && (int)Configuration::get('PS_TAX')) $ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2); - $this->smarty->assign(array( + self::$smarty->assign(array( 'quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int)($this->product->id), $this->id_current_shop, (int)(self::$cookie->id_currency), $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (float)($tax)), 'product' => $this->product, 'ecotax_tax_inc' => $ecotaxTaxAmount, @@ -221,7 +232,7 @@ class ProductControllerCore extends FrontController 'group_reduction' => $group_reduction, 'col_img_dir' => _PS_COL_IMG_DIR_, )); - $this->smarty->assign(array( + self::$smarty->assign(array( 'HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'), 'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'), 'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($this->product), @@ -237,7 +248,7 @@ class ProductControllerCore extends FrontController { if ($image['cover']) { - $this->smarty->assign('mainImage', $images[0]); + self::$smarty->assign('mainImage', $images[0]); $cover = $image; $cover['id_image'] = (Configuration::get('PS_LEGACY_IMAGES') ? ($this->product->id.'-'.$image['id_image']) : $image['id_image']); $cover['id_image_only'] = (int)($image['id_image']); @@ -247,14 +258,14 @@ class ProductControllerCore extends FrontController if (!isset($cover)) $cover = array('id_image' => $context->language->iso_code.'-default', 'legend' => 'No picture', 'title' => 'No picture'); $size = Image::getSize('large'); - $this->smarty->assign(array( + self::$smarty->assign(array( 'cover' => $cover, 'imgWidth' => (int)($size['width']), 'mediumSize' => Image::getSize('medium'), 'largeSize' => Image::getSize('large'), 'accessories' => $this->product->getAccessories((int)(self::$cookie->id_lang)))); if (sizeof($productImages)) - $this->smarty->assign('images', $productImages); + self::$smarty->assign('images', $productImages); /* Attributes / Groups & colors */ $colors = array(); @@ -328,7 +339,7 @@ class ProductControllerCore extends FrontController $combinations[$id_product_attribute]['list'] = $attributeList; } - $this->smarty->assign(array( + self::$smarty->assign(array( 'groups' => $groups, 'combinaisons' => $combinations, /* Kept for compatibility purpose only */ 'combinations' => $combinations, @@ -336,18 +347,18 @@ class ProductControllerCore extends FrontController 'combinationImages' => $combinationImages)); } - $this->smarty->assign(array( + self::$smarty->assign(array( 'no_tax' => Tax::excludeTaxeOption() OR !Tax::getProductTaxRate((int)$this->product->id, $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), 'customizationFields' => $this->product->getCustomizationFields((int)(self::$cookie->id_lang)) )); // Pack management - $this->smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int)(self::$cookie->id_lang), true) : array()); - $this->smarty->assign('packs', Pack::getPacksTable($this->product->id, (int)(self::$cookie->id_lang), true, 1)); + self::$smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int)(self::$cookie->id_lang), true) : array()); + self::$smarty->assign('packs', Pack::getPacksTable($this->product->id, (int)(self::$cookie->id_lang), true, 1)); } } - $this->smarty->assign(array( + self::$smarty->assign(array( 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int)(Configuration::get('PS_ORDER_OUT_OF_STOCK')), 'errors' => $this->errors, @@ -368,18 +379,19 @@ class ProductControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'product.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'product.tpl'); } public function pictureUpload(Product $product, Cart $cart) { - if (!$fieldIds = $this->product->getCustomizationFieldIds()) + if (!$fieldIds = $product->getCustomizationFieldIds()) return false; $authorizedFileFields = array(); foreach ($fieldIds AS $fieldId) if ($fieldId['type'] == _CUSTOMIZE_FILE_) $authorizedFileFields[(int)($fieldId['id_customization_field'])] = 'file'.(int)($fieldId['id_customization_field']); $indexes = array_flip($authorizedFileFields); + $id_customization = null; foreach ($_FILES AS $fieldName => $file) if (in_array($fieldName, $authorizedFileFields) AND isset($file['tmp_name']) AND !empty($file['tmp_name'])) { @@ -398,7 +410,10 @@ class ProductControllerCore extends FrontController elseif (!chmod(_PS_UPLOAD_DIR_.$fileName, 0777) OR !chmod(_PS_UPLOAD_DIR_.$fileName.'_small', 0777)) $this->errors[] = Tools::displayError('An error occurred during the image upload.'); else - $cart->addPictureToProduct((int)($this->product->id), $indexes[$fieldName], $fileName); + { + // Store customization in database + $cart->addPictureToProduct($this->product->id, $indexes[$fieldName], 0, $fileName); + } unlink($tmpName); } return true; @@ -432,8 +447,8 @@ class ProductControllerCore extends FrontController if (strncmp($field, 'group_', 6) == 0) $customizationFormTarget = preg_replace('/&group_([[:digit:]]+)=([[:digit:]]+)/', '', $customizationFormTarget); if (isset($_POST['quantityBackup'])) - $this->smarty->assign('quantityBackup', (int)($_POST['quantityBackup'])); - $this->smarty->assign('customizationFormTarget', $customizationFormTarget); + self::$smarty->assign('quantityBackup', (int)($_POST['quantityBackup'])); + self::$smarty->assign('customizationFormTarget', $customizationFormTarget); } public function formatQuantityDiscounts($specificPrices, $price, $taxRate) diff --git a/controllers/SearchController.php b/controllers/SearchController.php index bbd6b1ff1..d8c9e530f 100644 --- a/controllers/SearchController.php +++ b/controllers/SearchController.php @@ -62,7 +62,7 @@ class SearchControllerCore extends FrontController Module::hookExec('search', array('expr' => $query, 'total' => $search['total'])); $nbProducts = $search['total']; $this->pagination($nbProducts); - $this->smarty->assign(array( + self::$smarty->assign(array( 'products' => $search['result'], // DEPRECATED (since to 1.4), not use this: conflict with block_cart module 'search_products' => $search['result'], 'nbProducts' => $search['total'], @@ -79,7 +79,7 @@ class SearchControllerCore extends FrontController Module::hookExec('search', array('expr' => $query, 'total' => $search['total'])); $nbProducts = $search['total']; $this->pagination($nbProducts); - $this->smarty->assign(array( + self::$smarty->assign(array( 'products' => $search['result'], // DEPRECATED (since to 1.4), not use this: conflict with block_cart module 'search_products' => $search['result'], 'nbProducts' => $search['total'], @@ -92,7 +92,7 @@ class SearchControllerCore extends FrontController $this->pagination($nbProducts); $result = Search::searchTag((int)(self::$cookie->id_lang), $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay); Module::hookExec('search', array('expr' => $tag, 'total' => sizeof($result))); - $this->smarty->assign(array( + self::$smarty->assign(array( 'search_tag' => $tag, 'products' => $result, // DEPRECATED (since to 1.4), not use this: conflict with block_cart module 'search_products' => $result, @@ -101,13 +101,13 @@ class SearchControllerCore extends FrontController } else { - $this->smarty->assign(array( + self::$smarty->assign(array( 'products' => array(), 'search_products' => array(), 'pages_nb' => 1, 'nbProducts' => 0)); } - $this->smarty->assign('add_prod_display', Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY')); + self::$smarty->assign('add_prod_display', Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY')); } public function displayHeader() @@ -115,13 +115,13 @@ class SearchControllerCore extends FrontController if (!$this->instantSearch AND !$this->ajaxSearch) parent::displayHeader(); else - $this->smarty->assign('static_token', Tools::getToken(false)); + self::$smarty->assign('static_token', Tools::getToken(false)); } public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'search.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'search.tpl'); } public function displayFooter() diff --git a/controllers/SitemapController.php b/controllers/SitemapController.php index 5a6d4e800..5e236db52 100644 --- a/controllers/SitemapController.php +++ b/controllers/SitemapController.php @@ -44,20 +44,22 @@ class SitemapControllerCore extends FrontController public function process() { parent::process(); - $this->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); - $this->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory(Context::getContext()->language->id, 1, 1, 1)); - $this->smarty->assign('voucherAllowed', (int)Configuration::get('PS_VOUCHERS')); + + self::$smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); + self::$smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory(Context::getContext()->language->id, 1, 1, 1)); + self::$smarty->assign('voucherAllowed', (int)Configuration::get('PS_VOUCHERS')); + $blockmanufacturer = Module::getInstanceByName('blockmanufacturer'); $blocksupplier = Module::getInstanceByName('blocksupplier'); - $this->smarty->assign('display_manufacturer_link', (((int)$blockmanufacturer->id) ? true : false)); - $this->smarty->assign('display_supplier_link', (((int)$blocksupplier->id) ? true : false)); - $this->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); - $this->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); + self::$smarty->assign('display_manufacturer_link', (((int)$blockmanufacturer->id) ? true : false)); + self::$smarty->assign('display_supplier_link', (((int)$blocksupplier->id) ? true : false)); + self::$smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); + self::$smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); } public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'sitemap.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'sitemap.tpl'); } } diff --git a/controllers/StoresController.php b/controllers/StoresController.php index 457d441b3..adac36d33 100644 --- a/controllers/StoresController.php +++ b/controllers/StoresController.php @@ -120,10 +120,10 @@ class StoresControllerCore extends FrontController $hours_datas['hours'] = $hours[(int)($i) - 1]; $days_datas[] = $hours_datas; } - $this->smarty->assign('days_datas', $days_datas); - $this->smarty->assign('id_country', $store['id_country']); + self::$smarty->assign('days_datas', $days_datas); + self::$smarty->assign('id_country', $store['id_country']); - $other .= $this->smarty->fetch(_PS_THEME_DIR_.'store_infos.tpl'); + $other .= self::$smarty->fetch(_PS_THEME_DIR_.'store_infos.tpl'); } $newnode->setAttribute('addressNoHtml', strip_tags(str_replace('
', ' ', $address))); @@ -143,10 +143,10 @@ class StoresControllerCore extends FrontController die($dom->saveXML()); } else - $this->smarty->assign('hasStoreIcon', file_exists(dirname(__FILE__).'/../img/logo_stores.gif')); + self::$smarty->assign('hasStoreIcon', file_exists(dirname(__FILE__).'/../img/logo_stores.gif')); } - $this->smarty->assign(array('distance_unit' => $distanceUnit, 'simplifiedStoresDiplay' => $simplifiedStoreLocator, 'stores' => $stores, 'mediumSize' => Image::getSize('medium'))); + self::$smarty->assign(array('distance_unit' => $distanceUnit, 'simplifiedStoresDiplay' => $simplifiedStoreLocator, 'stores' => $stores, 'mediumSize' => Image::getSize('medium'))); } private function _processStoreAddress($store) @@ -191,7 +191,7 @@ class StoresControllerCore extends FrontController { parent::process(); - $this->smarty->assign(array( + self::$smarty->assign(array( 'defaultLat' => (float)Configuration::get('PS_STORES_CENTER_LAT'), 'defaultLong' => (float)Configuration::get('PS_STORES_CENTER_LONG'), 'searchUrl' => Context::getContext()->link->getPageLink('stores') @@ -210,6 +210,6 @@ class StoresControllerCore extends FrontController public function displayContent() { parent::displayContent(); - $this->smarty->display(_PS_THEME_DIR_.'stores.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'stores.tpl'); } } diff --git a/controllers/SupplierController.php b/controllers/SupplierController.php index 2861d7dab..89a4deb22 100644 --- a/controllers/SupplierController.php +++ b/controllers/SupplierController.php @@ -44,7 +44,7 @@ class SupplierControllerCore extends FrontController { $nbProducts = $this->supplier->getProducts($id_supplier, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $this->pagination((int)$nbProducts); - $this->smarty->assign(array( + self::$smarty->assign(array( 'nb_products' => $nbProducts, 'products' => $this->supplier->getProducts($id_supplier, (int)self::$cookie->id_lang, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay), 'path' => ($this->supplier->active ? Tools::safeOutput($this->supplier->name) : ''), @@ -70,7 +70,7 @@ class SupplierControllerCore extends FrontController foreach ($data AS &$item) $item['image'] = (!file_exists($imgDir.'/'.$item['id_supplier'].'-medium.jpg')) ? Language::getIsoById((int)(self::$cookie->id_lang)).'-default' : $item['id_supplier']; - $this->smarty->assign(array( + self::$smarty->assign(array( 'pages_nb' => ceil($nbProducts / (int)($this->n)), 'nbSuppliers' => $nbProducts, 'mediumSize' => Image::getSize('medium'), @@ -79,7 +79,7 @@ class SupplierControllerCore extends FrontController )); } else - $this->smarty->assign('nbSuppliers', 0); + self::$smarty->assign('nbSuppliers', 0); } } @@ -93,9 +93,9 @@ class SupplierControllerCore extends FrontController { parent::displayContent(); if ($this->supplier) - $this->smarty->display(_PS_THEME_DIR_.'supplier.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'supplier.tpl'); else - $this->smarty->display(_PS_THEME_DIR_.'supplier-list.tpl'); + self::$smarty->display(_PS_THEME_DIR_.'supplier-list.tpl'); } } diff --git a/footer.php b/footer.php index f8e5be2df..144e132f7 100644 --- a/footer.php +++ b/footer.php @@ -24,6 +24,5 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ - $controller = new FrontController(); $controller->displayFooter(); diff --git a/modules/blocklink/blocklink.php b/modules/blocklink/blocklink.php index 0dcca9fa4..282be431a 100644 --- a/modules/blocklink/blocklink.php +++ b/modules/blocklink/blocklink.php @@ -335,7 +335,7 @@ class BlockLink extends Module $this->_html .= '