// Context part 12

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7649 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2011-07-19 09:28:11 +00:00
parent 8a0a62ae03
commit 89213e18e5
53 changed files with 184 additions and 196 deletions
+1 -3
View File
@@ -1469,8 +1469,6 @@ abstract class AdminTabCore
* active : allow to toggle status
*/
$context = Context::getContext();
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$id_category = 1; // default categ
$irow = 0;
@@ -1543,7 +1541,7 @@ abstract class AdminTabCore
elseif (isset($params['icon']) AND (isset($params['icon'][$tr[$key]]) OR isset($params['icon']['default'])))
echo '<img src="../img/admin/'.(isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default'].'" alt="'.$tr[$key]).'" title="'.$tr[$key].'" />';
elseif (isset($params['price']))
echo Tools::displayPrice($tr[$key], (isset($params['currency']) ? Currency::getCurrencyInstance((int)($tr['id_currency'])) : $currency), false);
echo Tools::displayPrice($tr[$key], (isset($params['currency']) ? Currency::getCurrencyInstance($tr['id_currency']) : $context->currency), false);
elseif (isset($params['float']))
echo rtrim(rtrim($tr[$key], '0'), '.');
elseif (isset($params['type']) AND $params['type'] == 'date')
+4 -5
View File
@@ -684,14 +684,13 @@ class CarrierCore extends ObjectModel
return false;
}
public function getRangeSuffix()
public function getRangeSuffix($context = null)
{
if (!$context)
$context = Context::getContext();
$suffix = Configuration::get('PS_WEIGHT_UNIT');
if ($this->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE)
{
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$suffix = $currency->sign;
}
$suffix = $context->currency->sign;
return $suffix;
}
+3
View File
@@ -65,6 +65,9 @@ class ContextCore
/** @var Shop */
public $shop;
/** @var Smarty */
public $smarty;
/**
* Get a singleton context
+1 -1
View File
@@ -366,7 +366,7 @@ class CurrencyCore extends ObjectModel
static public function getCurrencyInstance($id)
{
if (!array_key_exists($id, self::$currencies))
self::$currencies[(int)($id)] = new Currency((int)($id));
self::$currencies[(int)($id)] = new Currency($id);
return self::$currencies[(int)($id)];
}
}
+1 -1
View File
@@ -138,7 +138,7 @@ class FrontControllerCore
/* Cart already exists */
if ((int)$cookie->id_cart)
{
$cart = new Cart((int)$cookie->id_cart);
$cart = new Cart($cookie->id_cart);
if ($cart->OrderExists())
unset($cookie->id_cart, $cart, $cookie->checkedTOS);
/* Delete product of cart, if user can't make an order from his country */
+6 -6
View File
@@ -1084,16 +1084,16 @@ abstract class ModuleCore
$previousTemplate = $context->smarty->currentTemplate;
$context->smarty->currentTemplate = substr(basename($template), 0, -4);
}
$context->controller->smarty->assign('module_dir', __PS_BASE_URI__.'modules/'.basename($file, '.php').'/');
$context->smarty->assign('module_dir', __PS_BASE_URI__.'modules/'.basename($file, '.php').'/');
if (($overloaded = self::_isTemplateOverloadedStatic(basename($file, '.php'), $template)) === NULL)
$result = Tools::displayError('No template found for module').' '.basename($file,'.php');
else
{
$context->controller->smarty->assign('module_template_dir', ($overloaded ? _THEME_DIR_ : __PS_BASE_URI__).'modules/'.basename($file, '.php').'/');
$result = $context->controller->smarty->fetch(($overloaded ? _PS_THEME_DIR_.'modules/'.basename($file, '.php') : _PS_MODULE_DIR_.basename($file, '.php')).'/'.$template, $cacheId, $compileId);
$context->smarty->assign('module_template_dir', ($overloaded ? _THEME_DIR_ : __PS_BASE_URI__).'modules/'.basename($file, '.php').'/');
$result = $context->smarty->fetch(($overloaded ? _PS_THEME_DIR_.'modules/'.basename($file, '.php') : _PS_MODULE_DIR_.basename($file, '.php')).'/'.$template, $cacheId, $compileId);
}
if (Configuration::get('PS_FORCE_SMARTY_2')) /* Keep a backward compatibility for Smarty v2 */
$context->controller->smarty->currentTemplate = $previousTemplate;
$context->smarty->currentTemplate = $previousTemplate;
return $result;
}
@@ -1108,10 +1108,10 @@ abstract class ModuleCore
/* Use Smarty 3 API calls */
if (!Configuration::get('PS_FORCE_SMARTY_2')) /* PHP version > 5.1.2 */
return $context->controller->smarty->isCached($this->_getApplicableTemplateDir($template).$template, $cacheId, $compileId);
return $context->smarty->isCached($this->_getApplicableTemplateDir($template).$template, $cacheId, $compileId);
/* or keep a backward compatibility if PHP version < 5.1.2 */
else
return $context->controller->smarty->is_cached($this->_getApplicableTemplateDir($template).$template, $cacheId, $compileId);
return $context->smarty->is_cached($this->_getApplicableTemplateDir($template).$template, $cacheId, $compileId);
}
protected function _clearCache($template, $cacheId = NULL, $compileId = NULL)