[*] Classes: modules templates are now executed in a local space

// Remove Gender::getStaticImage()
This commit is contained in:
rMalie committed 2011-11-25 16:02:20 +00:00
1 parent 6e8e1f6c3d
commit e7ee121ee6
2 files changed
+23 -12

No files matched your search

+3 -8
View File
@@ -85,15 +85,10 @@ class GenderCore extends ObjectModel
return ObjectModel::hydrateCollection('Gender', $results, $id_lang); return ObjectModel::hydrateCollection('Gender', $results, $id_lang);
} }
public static function getStaticImage($id, $use_unknown = false)
{
if (!file_exists(_PS_GENDERS_DIR_.$id.'.jpg'))
return ($use_unknown) ? _PS_ADMIN_IMG_.'unknown.gif' : false;
return _THEME_GENDERS_DIR_.$id.'.jpg';
}
public function getImage($use_unknown = false) public function getImage($use_unknown = false)
{ {
return Gender::getStaticImage($this->id, $use_unknown); if (!file_exists(_PS_GENDERS_DIR_.$this->id.'.jpg'))
return ($use_unknown) ? _PS_ADMIN_IMG_.'unknown.gif' : false;
return _THEME_GENDERS_DIR_.$this->id.'.jpg';
} }
} }
+20 -4
View File
@@ -95,6 +95,11 @@ abstract class ModuleCore
/** @var Context */ /** @var Context */
protected $context; protected $context;
/**
* @var Smarty_Data
*/
protected $smarty;
/** /**
* Constructor * Constructor
* *
@@ -104,6 +109,7 @@ abstract class ModuleCore
public function __construct($name = null, Context $context = null) public function __construct($name = null, Context $context = null)
{ {
$this->context = $context ? $context : Context::getContext(); $this->context = $context ? $context : Context::getContext();
$this->smarty = $this->context->smarty->createData($this->context->smarty);
if ($this->name == NULL) if ($this->name == NULL)
$this->name = $this->id; $this->name = $this->id;
@@ -1192,17 +1198,27 @@ abstract class ModuleCore
return self::_isTemplateOverloadedStatic($this->name, $template); return self::_isTemplateOverloadedStatic($this->name, $template);
} }
public static function display($file, $template, $cacheId = NULL, $compileId = NULL) public function display($file, $template, $cacheId = NULL, $compileId = NULL)
{ {
$context = Context::getContext(); $context = Context::getContext();
$context->smarty->assign('module_dir', __PS_BASE_URI__.'modules/'.basename($file, '.php').'/');
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
{ {
$context->smarty->assign('module_template_dir', ($overloaded ? _THEME_DIR_ : __PS_BASE_URI__).'modules/'.basename($file, '.php').'/'); $this->smarty->assign(array(
$result = $context->smarty->fetch(($overloaded ? _PS_THEME_DIR_.'modules/'.basename($file, '.php') : _PS_MODULE_DIR_.basename($file, '.php')).'/'.$template, $cacheId, $compileId); '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,
$this->smarty
);
$result = $smarty_subtemplate->fetch();
} }
return $result; return $result;
} }