// Log edited, this modification on Module::displayTemplate was reverted in a better one

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10675 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-11-25 16:09:13 +00:00
parent 93f4be96b0
commit fe435bdeea
8 changed files with 53 additions and 30 deletions
+27 -4
View File
@@ -1198,10 +1198,8 @@ abstract class ModuleCore
return self::_isTemplateOverloadedStatic($this->name, $template); 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) if (($overloaded = self::_isTemplateOverloadedStatic(basename($file, '.php'), $template)) === NULL)
$result = Tools::displayError('No template found for module').' '.basename($file,'.php'); $result = Tools::displayError('No template found for module').' '.basename($file,'.php');
else else
@@ -1211,7 +1209,7 @@ abstract class ModuleCore
'module_template_dir' => ($overloaded ? _THEME_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( $smarty_subtemplate = $this->context->smarty->createTemplate(
($overloaded ? _PS_THEME_DIR_.'modules/'.basename($file, '.php') : _PS_MODULE_DIR_.basename($file, '.php')).'/'.$template, ($overloaded ? _PS_THEME_DIR_.'modules/'.basename($file, '.php') : _PS_MODULE_DIR_.basename($file, '.php')).'/'.$template,
$cacheId, $cacheId,
$compileId, $compileId,
@@ -1223,6 +1221,31 @@ abstract class ModuleCore
return $result; 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) * Get realpath of a template of current module (check if template is overriden too)
* *
+1 -1
View File
@@ -68,7 +68,7 @@ else
$smarty->assign('this_path', __PS_BASE_URI__.'modules/cashondelivery/'); $smarty->assign('this_path', __PS_BASE_URI__.'modules/cashondelivery/');
$template = 'validation.tpl'; $template = 'validation.tpl';
echo Module::display('cashondelivery', $template); echo Module::displayTemplate('cashondelivery', $template);
} }
include(dirname(__FILE__).'/../../footer.php'); include(dirname(__FILE__).'/../../footer.php');
@@ -42,7 +42,7 @@ if ((int)Context::getContext()->customer->id)
{ {
$smarty->assign('favoriteProducts', FavoriteProduct::getFavoriteProducts((int)Context::getContext()->customer->id, (int)Context::getContext()->language->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'); include(dirname(__FILE__).'/../../footer.php');
+1 -1
View File
@@ -159,6 +159,6 @@ $smarty->assign(array(
'minimalLoyalty' => (float)Configuration::get('PS_LOYALTY_MINIMAL'), 'minimalLoyalty' => (float)Configuration::get('PS_LOYALTY_MINIMAL'),
'categories' => $categoriesNames)); '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'); include(dirname(__FILE__).'/../../footer.php');
+1 -1
View File
@@ -32,6 +32,6 @@ include(dirname(__FILE__).'/../../header.php');
$smarty->assign('iso_code', Tools::strtolower(Context::getContext()->language->iso_code)); $smarty->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'); include(dirname(__FILE__).'/../../footer.php');
+1 -1
View File
@@ -1318,7 +1318,7 @@ class PayPal extends PaymentModule
public static function display($file, $template, $cacheId = NULL, $compileId = NULL) public static function display($file, $template, $cacheId = NULL, $compileId = NULL)
{ {
if (substr(_PS_VERSION_, 0, 3) != '1.3') if (substr(_PS_VERSION_, 0, 3) != '1.3')
return parent::display($file, $template); return parent::displayTemplate($file, $template);
global $smarty; global $smarty;
$previousTemplate = $smarty->currentTemplate; $previousTemplate = $smarty->currentTemplate;
@@ -185,7 +185,7 @@ $smarty->assign(array(
'mails_exists' => (isset($mails_exists) ? $mails_exists : 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');
@@ -44,7 +44,7 @@ if (file_exists($xmlFile))
} }
} }
echo Module::display(dirname(__FILE__).'/referralprogram', 'referralprogram-rules.tpl'); echo Module::displayTemplate(dirname(__FILE__).'/referralprogram', 'referralprogram-rules.tpl');
if (!Tools::getValue('width') AND !Tools::getValue('height')) if (!Tools::getValue('width') AND !Tools::getValue('height'))
require_once(dirname(__FILE__).'/../../footer.php'); require_once(dirname(__FILE__).'/../../footer.php');