Fixed template loop
This commit is contained in:
@@ -59,9 +59,9 @@ class Template extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
new Argument(
|
||||
'template_type',
|
||||
'template-type',
|
||||
new Type\TypeCollection(
|
||||
new Type\EnumListType(array(
|
||||
new Type\EnumType(array(
|
||||
'front-office',
|
||||
'back-office',
|
||||
'pdf',
|
||||
@@ -73,7 +73,7 @@ class Template extends BaseLoop implements ArraySearchLoopInterface
|
||||
}
|
||||
|
||||
public function buildArray() {
|
||||
$type = $this->getArg(template_type);
|
||||
$type = $this->getArg('template-type')->getValue();
|
||||
|
||||
if ($type == 'front-office')
|
||||
$templateType = TemplateDefinition::FRONT_OFFICE;
|
||||
|
||||
@@ -88,7 +88,10 @@ class SmartyAssetsManager
|
||||
|
||||
public function computeAssetUrl($assetType, $params, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$file = $params['file'];
|
||||
$file = $params['file'];
|
||||
$assetOrigin = isset($params['source']) ? $params['source'] : "0";
|
||||
$filters = isset($params['filters']) ? $params['filters'] : '';
|
||||
$debug = isset($params['debug']) ? trim(strtolower($params['debug'])) == 'true' : false;
|
||||
|
||||
/* we trick here relative thinking for file attribute */
|
||||
$file = ltrim($file, '/');
|
||||
@@ -96,10 +99,6 @@ class SmartyAssetsManager
|
||||
$file = substr($file, 3);
|
||||
}
|
||||
|
||||
$assetOrigin = isset($params['source']) ? $params['source'] : "0";
|
||||
$filters = isset($params['filters']) ? $params['filters'] : '';
|
||||
$debug = isset($params['debug']) ? trim(strtolower($params['debug'])) == 'true' : false;
|
||||
|
||||
$smartyParser = $template->smarty;
|
||||
$templateDefinition = $smartyParser->getTemplateDefinition();
|
||||
|
||||
|
||||
@@ -137,9 +137,9 @@ class TemplateDefinition
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the standard templates subdir names
|
||||
* Returns an iterator on the standard templates subdir names
|
||||
*/
|
||||
public static function getStandardTemplatesSubdirs() {
|
||||
return self::$standardTemplatesSubdirs;
|
||||
public static function getStandardTemplatesSubdirsIterator() {
|
||||
return new \ArrayIterator(self::$standardTemplatesSubdirs);
|
||||
}
|
||||
}
|
||||
@@ -98,36 +98,40 @@ class TemplateHelper
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of existing templates for a given template type
|
||||
*
|
||||
* @param int $templateType the template type
|
||||
* @return An array of \Thelia\Core\Template\TemplateDefinition
|
||||
*/
|
||||
public function getList($templateType) {
|
||||
|
||||
$list = $exclude = array();
|
||||
|
||||
if ($templateType == TemplateDefinition::BACK_OFFICE) {
|
||||
$baseDir = THELIA_TEMPLATE_DIR.TemplateDefinition::BACK_OFFICE_SUBDIR;
|
||||
$tplIterator = TemplateDefinition::getStandardTemplatesSubdirsIterator();
|
||||
|
||||
foreach($tplIterator as $type => $subdir) {
|
||||
|
||||
if ($templateType == $type) {
|
||||
|
||||
$baseDir = THELIA_TEMPLATE_DIR.$subdir;
|
||||
|
||||
// Every subdir of the basedir is supposed to be a template.
|
||||
$di = new \DirectoryIterator($baseDir);
|
||||
|
||||
foreach ($di as $file) {
|
||||
// Ignore 'dot' elements
|
||||
if ($file->isDot() || ! $file->isDir()) continue;
|
||||
|
||||
// Ignore reserved directory names
|
||||
if (in_array($file->getFilename()."/", $exclude)) continue;
|
||||
|
||||
$list[] = new TemplateDefinition($file->getFilename(), $templateType);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
else if ($templateType == TemplateDefinition::PDF) {
|
||||
$baseDir = THELIA_TEMPLATE_DIR.TemplateDefinition::PDF_SUBDIR;
|
||||
}
|
||||
else {
|
||||
$baseDir = THELIA_TEMPLATE_DIR.TemplateDefinition::FRONT_OFFICE_SUBDIR;
|
||||
|
||||
$exclude = array(TemplateDefinition::BACK_OFFICE_SUBDIR, TemplateDefinition::PDF_SUBDIR);
|
||||
}
|
||||
|
||||
// Every subdir of the basedir is supposed to be a template.
|
||||
$di = new \DirectoryIterator($baseDir);
|
||||
|
||||
foreach ($di as $file) {
|
||||
// Ignore 'dot' elements
|
||||
if ($file->isDot() || ! $file->isDir()) continue;
|
||||
|
||||
// Ignore reserved directory names
|
||||
if (in_array($file->getFilename()."/", $exclude)) continue;
|
||||
|
||||
$list[] = new TemplateDefinition($file->getFilename(), $templateType);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ class Thelia extends Kernel
|
||||
* @param Module $module the Module.
|
||||
*/
|
||||
protected function addStandardModuleTemplatesToParserEnvironment($parser, $module) {
|
||||
$stdTpls = TemplateDefinition::getStandardTemplatesSubdirs();
|
||||
$stdTpls = TemplateDefinition::getStandardTemplatesSubdirsIterator();
|
||||
|
||||
foreach($stdTpls as $templateType => $templateSubdirName) {
|
||||
$this->addModuleTemplateToParserEnvironment($parser, $module, $templateType, $templateSubdirName);
|
||||
|
||||
Reference in New Issue
Block a user