// 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);
}
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)
*
+4 -4
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -43,7 +43,7 @@ foreach (Module::getPaymentModules() as $module)
}
if (!$authorized)
die(Tools::displayError('This payment method is not available.'));
$customer = new Customer((int)$cart->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');
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -35,14 +35,14 @@ require_once(dirname(__FILE__).'/FavoriteProduct.php');
if (!Context::getContext()->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');
+10 -10
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -59,20 +59,20 @@ if (Tools::getValue('transform-points') == 'true' AND $customerPoints > 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');
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -32,6 +32,6 @@ include(dirname(__FILE__).'/../../header.php');
$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');
+1 -1
View File
@@ -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;
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -185,8 +185,8 @@ $smarty->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');
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -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'))
require_once(dirname(__FILE__).'/../../footer.php');