diff --git a/classes/Module.php b/classes/Module.php index 8fb91713f..00fe0e32f 100644 --- a/classes/Module.php +++ b/classes/Module.php @@ -1198,10 +1198,8 @@ abstract class ModuleCore return self::_isTemplateOverloadedStatic($this->name, $template); } - public function display($file, $template, $cacheId = NULL, $compileId = NULL) + public function display($file, $template, $cacheId = null, $compileId = null) { - $context = Context::getContext(); - if (($overloaded = self::_isTemplateOverloadedStatic(basename($file, '.php'), $template)) === NULL) $result = Tools::displayError('No template found for module').' '.basename($file,'.php'); else @@ -1211,7 +1209,7 @@ abstract class ModuleCore 'module_template_dir' => ($overloaded ? _THEME_DIR_ : __PS_BASE_URI__).'modules/'.basename($file, '.php').'/' )); - $smarty_subtemplate = $context->smarty->createTemplate( + $smarty_subtemplate = $this->context->smarty->createTemplate( ($overloaded ? _PS_THEME_DIR_.'modules/'.basename($file, '.php') : _PS_MODULE_DIR_.basename($file, '.php')).'/'.$template, $cacheId, $compileId, @@ -1223,6 +1221,31 @@ abstract class ModuleCore return $result; } + public static function displayTemplate($file, $template, $cacheId = null, $compileId = null) + { + $context = Context::getContext(); + + if (($overloaded = self::_isTemplateOverloadedStatic(basename($file, '.php'), $template)) === NULL) + $result = Tools::displayError('No template found for module').' '.basename($file,'.php'); + else + { + $context->smarty->assign(array( + 'module_dir' => __PS_BASE_URI__.'modules/'.basename($file, '.php').'/', + 'module_template_dir' => ($overloaded ? _THEME_DIR_ : __PS_BASE_URI__).'modules/'.basename($file, '.php').'/' + )); + + $smarty_subtemplate = $context->smarty->createTemplate( + ($overloaded ? _PS_THEME_DIR_.'modules/'.basename($file, '.php') : _PS_MODULE_DIR_.basename($file, '.php')).'/'.$template, + $cacheId, + $compileId, + $context->smarty + ); + + $result = $smarty_subtemplate->fetch(); + } + return $result; + } + /** * Get realpath of a template of current module (check if template is overriden too) * diff --git a/modules/cashondelivery/validation.php b/modules/cashondelivery/validation.php index fa0b68c7c..c132260ef 100644 --- a/modules/cashondelivery/validation.php +++ b/modules/cashondelivery/validation.php @@ -1,6 +1,6 @@ id_customer); if (!Validate::isLoadedObject($customer)) @@ -60,7 +60,7 @@ if (Tools::getValue('confirm')) } else { - /* or ask for confirmation */ + /* or ask for confirmation */ $smarty->assign(array( 'total' => $cart->getOrderTotal(true, Cart::BOTH), 'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/cashondelivery/' @@ -68,7 +68,7 @@ else $smarty->assign('this_path', __PS_BASE_URI__.'modules/cashondelivery/'); $template = 'validation.tpl'; - echo Module::display('cashondelivery', $template); + echo Module::displayTemplate('cashondelivery', $template); } include(dirname(__FILE__).'/../../footer.php'); diff --git a/modules/favoriteproducts/favoriteproducts-account.php b/modules/favoriteproducts/favoriteproducts-account.php index 9dff31435..c5fae9172 100644 --- a/modules/favoriteproducts/favoriteproducts-account.php +++ b/modules/favoriteproducts/favoriteproducts-account.php @@ -1,6 +1,6 @@ customer->isLogged()) Tools::redirect('authentication.php?back=modules/favoriteproducts/favoriteproducts.php'); - + include(dirname(__FILE__).'/../../header.php'); if ((int)Context::getContext()->customer->id) -{ +{ $smarty->assign('favoriteProducts', FavoriteProduct::getFavoriteProducts((int)Context::getContext()->customer->id, (int)Context::getContext()->language->id)); - echo Module::display(dirname(__FILE__).'/favoriteproducts.php', 'favoriteproducts-account.tpl'); + echo Module::displayTemplate(dirname(__FILE__).'/favoriteproducts.php', 'favoriteproducts-account.tpl'); } include(dirname(__FILE__).'/../../footer.php'); diff --git a/modules/loyalty/loyalty-program.php b/modules/loyalty/loyalty-program.php index 3afec988f..75adbb8f9 100644 --- a/modules/loyalty/loyalty-program.php +++ b/modules/loyalty/loyalty-program.php @@ -1,6 +1,6 @@ 0) $cartRule->reduction_amount = LoyaltyModule::getVoucherValue((int)$customerPoints); $cartRule->quantity = 1; $cartRule->quantity_per_user = 1; - - /* If merchandise returns are allowed, the voucher musn't be usable before this max return date */ + + /* If merchandise returns are allowed, the voucher musn't be usable before this max return date */ $dateFrom = Db::getInstance()->getValue(' SELECT UNIX_TIMESTAMP(date_add) n - FROM '._DB_PREFIX_.'loyalty + FROM '._DB_PREFIX_.'loyalty WHERE id_cart_rule = 0 AND id_customer = '.(int)$cookie->id_customer.' ORDER BY date_add DESC'); - + if (Configuration::get('PS_ORDER_RETURN')) $dateFrom += 60 * 60 * 24 * (int)Configuration::get('PS_ORDER_RETURN_NB_DAYS'); $cartRule->date_from = date('Y-m-d H:i:s', $dateFrom); $cartRule->date_to = date('Y-m-d H:i:s', $dateFrom + 31536000); // + 1 year - + $cartRule->minimum_amount = (float)Configuration::get('PS_LOYALTY_MINIMAL'); $cartRule->active = 1; @@ -84,13 +84,13 @@ if (Tools::getValue('transform-points') == 'true' AND $customerPoints > 0) $languages = Language::getLanguages(true); $default_text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', (int)Configuration::get('PS_LANG_DEFAULT')); - + foreach ($languages AS $language) { $text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', (int)$language['id_lang']); $cartRule->name[(int)$language['id_lang']] = $text ? strval($text) : strval($default_text); } - + if (is_array($categories) AND sizeof($categories)) $cartRule->add(true, false, $categories); else @@ -152,13 +152,13 @@ else $categoriesNames = Tools::truncate(implode(', ', $categoriesNames), 100).'.'; else $categoriesNames = null; -} +} $smarty->assign(array( 'nbDiscounts' => (int)$nbDiscounts, 'discounts' => $discounts, 'minimalLoyalty' => (float)Configuration::get('PS_LOYALTY_MINIMAL'), 'categories' => $categoriesNames)); -echo Module::display(dirname(__FILE__).'/loyalty.php', 'loyalty.tpl'); +echo Module::displayTemplate(dirname(__FILE__).'/loyalty.php', 'loyalty.tpl'); include(dirname(__FILE__).'/../../footer.php'); diff --git a/modules/paypal/about.php b/modules/paypal/about.php index efd0dfeec..28d08b753 100644 --- a/modules/paypal/about.php +++ b/modules/paypal/about.php @@ -1,6 +1,6 @@ assign('iso_code', Tools::strtolower(Context::getContext()->language->iso_code)); -echo Module::display(dirname(__FILE__).'/paypal', 'about.tpl'); +echo Module::displayTemplate(dirname(__FILE__).'/paypal', 'about.tpl'); include(dirname(__FILE__).'/../../footer.php'); \ No newline at end of file diff --git a/modules/paypal/paypal.php b/modules/paypal/paypal.php index bf4e655cc..063e468ed 100644 --- a/modules/paypal/paypal.php +++ b/modules/paypal/paypal.php @@ -1318,7 +1318,7 @@ class PayPal extends PaymentModule public static function display($file, $template, $cacheId = NULL, $compileId = NULL) { if (substr(_PS_VERSION_, 0, 3) != '1.3') - return parent::display($file, $template); + return parent::displayTemplate($file, $template); global $smarty; $previousTemplate = $smarty->currentTemplate; diff --git a/modules/referralprogram/referralprogram-program.php b/modules/referralprogram/referralprogram-program.php index c27320215..3097d5853 100644 --- a/modules/referralprogram/referralprogram-program.php +++ b/modules/referralprogram/referralprogram-program.php @@ -1,6 +1,6 @@ assign(array( 'mails_exists' => (isset($mails_exists) ? $mails_exists : array()) )); -echo Module::display(dirname(__FILE__).'/referralprogram.php', 'referralprogram-program.tpl'); +echo Module::displayTemplate(dirname(__FILE__).'/referralprogram.php', 'referralprogram-program.tpl'); -include(dirname(__FILE__).'/../../footer.php'); +include(dirname(__FILE__).'/../../footer.php'); diff --git a/modules/referralprogram/referralprogram-rules.php b/modules/referralprogram/referralprogram-rules.php index ea15fe66a..3bc3c666b 100644 --- a/modules/referralprogram/referralprogram-rules.php +++ b/modules/referralprogram/referralprogram-rules.php @@ -1,6 +1,6 @@