Fixed template loop
This commit is contained in:
@@ -59,9 +59,9 @@ class Template extends BaseLoop implements ArraySearchLoopInterface
|
|||||||
{
|
{
|
||||||
return new ArgumentCollection(
|
return new ArgumentCollection(
|
||||||
new Argument(
|
new Argument(
|
||||||
'template_type',
|
'template-type',
|
||||||
new Type\TypeCollection(
|
new Type\TypeCollection(
|
||||||
new Type\EnumListType(array(
|
new Type\EnumType(array(
|
||||||
'front-office',
|
'front-office',
|
||||||
'back-office',
|
'back-office',
|
||||||
'pdf',
|
'pdf',
|
||||||
@@ -73,7 +73,7 @@ class Template extends BaseLoop implements ArraySearchLoopInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function buildArray() {
|
public function buildArray() {
|
||||||
$type = $this->getArg(template_type);
|
$type = $this->getArg('template-type')->getValue();
|
||||||
|
|
||||||
if ($type == 'front-office')
|
if ($type == 'front-office')
|
||||||
$templateType = TemplateDefinition::FRONT_OFFICE;
|
$templateType = TemplateDefinition::FRONT_OFFICE;
|
||||||
|
|||||||
@@ -88,7 +88,10 @@ class SmartyAssetsManager
|
|||||||
|
|
||||||
public function computeAssetUrl($assetType, $params, \Smarty_Internal_Template $template)
|
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 */
|
/* we trick here relative thinking for file attribute */
|
||||||
$file = ltrim($file, '/');
|
$file = ltrim($file, '/');
|
||||||
@@ -96,10 +99,6 @@ class SmartyAssetsManager
|
|||||||
$file = substr($file, 3);
|
$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;
|
$smartyParser = $template->smarty;
|
||||||
$templateDefinition = $smartyParser->getTemplateDefinition();
|
$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() {
|
public static function getStandardTemplatesSubdirsIterator() {
|
||||||
return self::$standardTemplatesSubdirs;
|
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) {
|
public function getList($templateType) {
|
||||||
|
|
||||||
$list = $exclude = array();
|
$list = $exclude = array();
|
||||||
|
|
||||||
if ($templateType == TemplateDefinition::BACK_OFFICE) {
|
$tplIterator = TemplateDefinition::getStandardTemplatesSubdirsIterator();
|
||||||
$baseDir = THELIA_TEMPLATE_DIR.TemplateDefinition::BACK_OFFICE_SUBDIR;
|
|
||||||
|
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.
|
* @param Module $module the Module.
|
||||||
*/
|
*/
|
||||||
protected function addStandardModuleTemplatesToParserEnvironment($parser, $module) {
|
protected function addStandardModuleTemplatesToParserEnvironment($parser, $module) {
|
||||||
$stdTpls = TemplateDefinition::getStandardTemplatesSubdirs();
|
$stdTpls = TemplateDefinition::getStandardTemplatesSubdirsIterator();
|
||||||
|
|
||||||
foreach($stdTpls as $templateType => $templateSubdirName) {
|
foreach($stdTpls as $templateType => $templateSubdirName) {
|
||||||
$this->addModuleTemplateToParserEnvironment($parser, $module, $templateType, $templateSubdirName);
|
$this->addModuleTemplateToParserEnvironment($parser, $module, $templateType, $templateSubdirName);
|
||||||
|
|||||||
Reference in New Issue
Block a user