Refactored templates processing
This commit is contained in:
@@ -30,9 +30,6 @@ namespace Thelia\Core\Template;
|
||||
|
||||
interface ParserInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function render($realTemplateName, array $parameters = array());
|
||||
|
||||
public function setContent($content);
|
||||
@@ -40,4 +37,26 @@ interface ParserInterface
|
||||
public function getStatus();
|
||||
|
||||
public function setStatus($status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a template directory to the current template list
|
||||
*
|
||||
* @param unknown $templateType the template type (
|
||||
*
|
||||
* @param string $templateName the template name
|
||||
* @param string $templateDirectory path to the template dirtectory
|
||||
* @param unknown $key ???
|
||||
* @param string $unshift ??? Etienne ?
|
||||
*/
|
||||
public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false);
|
||||
|
||||
|
||||
/**
|
||||
* Return the registeted template directories for a givent template type
|
||||
*
|
||||
* @param unknown $templateType
|
||||
* @throws InvalidArgumentException if the tempmateType is not defined
|
||||
* @return array: an array of defined templates directories for the given template type
|
||||
*/
|
||||
public function getTemplateDirectories($templateType);
|
||||
}
|
||||
@@ -57,77 +57,38 @@ class SmartyAssetsManager
|
||||
public function prepareAssets($assets_directory, \Smarty_Internal_Template $template)
|
||||
{
|
||||
self::$assetsDirectory = $assets_directory;
|
||||
|
||||
$smartyParser = $template->smarty;
|
||||
$templateDefinition = $smartyParser->getTemplateDefinition();
|
||||
switch($templateDefinition->getType()) {
|
||||
case TemplateDefinition::FRONT_OFFICE:
|
||||
$frontOfficeTemplateDirectories = $smartyParser->getFrontOfficeTemplateDirectories();
|
||||
if(isset($frontOfficeTemplateDirectories[$templateDefinition->getName()])) {
|
||||
/* create assets foreach directory : main @ modules */
|
||||
foreach($frontOfficeTemplateDirectories[$templateDefinition->getName()] as $key => $directory) {
|
||||
$tpl_path = $directory . DS . self::$assetsDirectory;
|
||||
$asset_dir_absolute_path = realpath($tpl_path);
|
||||
if(false !== $asset_dir_absolute_path) {
|
||||
$this->assetsManager->prepareAssets(
|
||||
$asset_dir_absolute_path,
|
||||
$this->web_root . $this->path_relative_to_web_root,
|
||||
$templateDefinition->getPath(),
|
||||
$key
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the registered template directories for the current template path
|
||||
$templateDirectories = $smartyParser->getTemplateDirectories($templateDefinition->getType());
|
||||
|
||||
if (isset($templateDirectories[$templateDefinition->getName()])) {
|
||||
|
||||
/* create assets foreach registered directory : main @ modules */
|
||||
foreach($templateDirectories[$templateDefinition->getName()] as $key => $directory) {
|
||||
|
||||
$tpl_path = $directory . DS . self::$assetsDirectory;
|
||||
|
||||
$asset_dir_absolute_path = realpath($tpl_path);
|
||||
|
||||
if (false !== $asset_dir_absolute_path) {
|
||||
|
||||
$this->assetsManager->prepareAssets(
|
||||
$asset_dir_absolute_path,
|
||||
$this->web_root . $this->path_relative_to_web_root,
|
||||
$templateDefinition->getPath(),
|
||||
$key
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case TemplateDefinition::BACK_OFFICE:
|
||||
$backOfficeTemplateDirectories = $smartyParser->getBackOfficeTemplateDirectories();
|
||||
if(isset($backOfficeTemplateDirectories[$templateDefinition->getName()])) {
|
||||
/* create assets foreach directory : main @ modules */
|
||||
foreach($backOfficeTemplateDirectories[$templateDefinition->getName()] as $key => $directory) {
|
||||
$tpl_path = $directory . DS . self::$assetsDirectory;
|
||||
$asset_dir_absolute_path = realpath($tpl_path);
|
||||
if(false !== $asset_dir_absolute_path) {
|
||||
$this->assetsManager->prepareAssets(
|
||||
$asset_dir_absolute_path,
|
||||
$this->web_root . $this->path_relative_to_web_root,
|
||||
$templateDefinition->getPath(),
|
||||
$key
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TemplateDefinition::PDF:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// $tpl_dir = dirname($template->source->filepath);
|
||||
//
|
||||
// $tpl_path = $tpl_dir . DS . self::$assetsDirectory;
|
||||
// $asset_dir_absolute_path = realpath($tpl_path);
|
||||
// if ($asset_dir_absolute_path === false) {
|
||||
// /* no assets for current template */
|
||||
// $tpl_path = THELIA_TEMPLATE_DIR . DS . $template->smarty->getTemplate();
|
||||
// $asset_dir_absolute_path = realpath($tpl_path);
|
||||
// }
|
||||
//
|
||||
// if ($asset_dir_absolute_path === false) {
|
||||
// throw new \Exception("Failed to get real path of '" . $tpl_path . "'");
|
||||
// }
|
||||
//
|
||||
// $this->assetsManager->prepareAssets(
|
||||
// $asset_dir_absolute_path,
|
||||
// $this->web_root . $this->path_relative_to_web_root
|
||||
// );
|
||||
}
|
||||
|
||||
public function computeAssetUrl($assetType, $params, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$file = $params['file'];
|
||||
$file = $params['file'];
|
||||
|
||||
/* we trick here relative thinking for file attribute */
|
||||
$file = ltrim($file, '/');
|
||||
@@ -142,40 +103,13 @@ class SmartyAssetsManager
|
||||
$smartyParser = $template->smarty;
|
||||
$templateDefinition = $smartyParser->getTemplateDefinition();
|
||||
|
||||
// // Get template base path
|
||||
// $tpl_path = $template->source->filepath;
|
||||
//
|
||||
// // Get basedir
|
||||
// $tpl_dir = dirname($tpl_path);
|
||||
//
|
||||
// // Create absolute dir path
|
||||
// $assetDir = realpath($tpl_dir) . DS . dirname($file);
|
||||
// $asset_file = basename($file);
|
||||
$templateDirectories = $smartyParser->getTemplateDirectories($templateDefinition->getType());
|
||||
|
||||
$assetSource = false;
|
||||
switch($templateDefinition->getType()) {
|
||||
case TemplateDefinition::FRONT_OFFICE:
|
||||
$frontOfficeTemplateDirectories = $smartyParser->getFrontOfficeTemplateDirectories();
|
||||
if(isset($frontOfficeTemplateDirectories[$templateDefinition->getName()][$assetOrigin])) {
|
||||
$assetSource = $frontOfficeTemplateDirectories[$templateDefinition->getName()][$assetOrigin];
|
||||
}
|
||||
break;
|
||||
|
||||
case TemplateDefinition::BACK_OFFICE:
|
||||
$backOfficeTemplateDirectories = $smartyParser->getbackOfficeTemplateDirectories();
|
||||
if(isset($backOfficeTemplateDirectories[$templateDefinition->getName()][$assetOrigin])) {
|
||||
$assetSource = $backOfficeTemplateDirectories[$templateDefinition->getName()][$assetOrigin];
|
||||
}
|
||||
break;
|
||||
|
||||
case TemplateDefinition::PDF:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
if (! isset($templateDirectories[$templateDefinition->getName()][$assetOrigin])) {
|
||||
throw new \Exception("Failed to get real path of '/".dirname($file)."'");
|
||||
}
|
||||
|
||||
if ($assetSource === false) throw new \Exception("Failed to get real path of '/".dirname($file)."'");
|
||||
$assetSource = $templateDirectories[$templateDefinition->getName()][$assetOrigin];
|
||||
|
||||
$url = $this->assetsManager->processAsset(
|
||||
$assetSource . DS . $file,
|
||||
@@ -204,4 +138,4 @@ class SmartyAssetsManager
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ use Thelia\Core\Template\ParserContext;
|
||||
use Thelia\Core\Template\TemplateDefinition;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Template\TemplateHelper;
|
||||
use Imagine\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -33,6 +34,8 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
protected $backOfficeTemplateDirectories = array();
|
||||
protected $frontOfficeTemplateDirectories = array();
|
||||
|
||||
protected $templateDirectories = array();
|
||||
|
||||
/**
|
||||
* @var TemplateDefinition
|
||||
*/
|
||||
@@ -94,19 +97,43 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* Add a template directory to the current template list
|
||||
*
|
||||
* @param unknown $templateType the template type (a TemplateDefinition type constant)
|
||||
* @param string $templateName the template name
|
||||
* @param string $templateDirectory path to the template dirtectory
|
||||
* @param unknown $key ???
|
||||
* @param string $unshift ??? Etienne ?
|
||||
*/
|
||||
public function getFrontOfficeTemplateDirectories()
|
||||
{
|
||||
return $this->frontOfficeTemplateDirectories;
|
||||
public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false) {
|
||||
|
||||
if(true === $unshift && isset($this->templateDirectories[$templateType][$templateName])) {
|
||||
|
||||
$this->templateDirectories[$templateType][$templateName] = array_merge(
|
||||
array(
|
||||
$key => $templateDirectory,
|
||||
),
|
||||
$this->templateDirectories[$templateType][$templateName]
|
||||
);
|
||||
} else {
|
||||
$this->templateDirectories[$templateType][$templateName][$key] = $templateDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* Return the registeted template directories for a givent template type
|
||||
*
|
||||
* @param unknown $templateType
|
||||
* @throws InvalidArgumentException
|
||||
* @return multitype:
|
||||
*/
|
||||
public function getBackOfficeTemplateDirectories()
|
||||
public function getTemplateDirectories($templateType)
|
||||
{
|
||||
return $this->backOfficeTemplateDirectories;
|
||||
if (! isset($this->templateDirectories[$templateType])) {
|
||||
throw new InvalidArgumentException("Failed to get template type %", $templateType);
|
||||
}
|
||||
|
||||
return $this->templateDirectories[$templateType];
|
||||
}
|
||||
|
||||
public function removeBlankLines($tpl_source, \Smarty_Internal_Template $template)
|
||||
@@ -123,34 +150,6 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function addBackOfficeTemplateDirectory($templateName, $templateDirectory, $key, $unshift = false)
|
||||
{
|
||||
if(true === $unshift && isset($this->backOfficeTemplateDirectories[$templateName])) {
|
||||
$this->backOfficeTemplateDirectories[$templateName] = array_merge(
|
||||
array(
|
||||
$key => $templateDirectory,
|
||||
),
|
||||
$this->backOfficeTemplateDirectories[$templateName]
|
||||
);
|
||||
} else {
|
||||
$this->backOfficeTemplateDirectories[$templateName][$key] = $templateDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
public function addFrontOfficeTemplateDirectory($templateName, $templateDirectory, $key, $unshift = false)
|
||||
{
|
||||
if(true === $unshift && isset($this->frontOfficeTemplateDirectories[$templateName])) {
|
||||
$this->frontOfficeTemplateDirectories[$templateName] = array_merge(
|
||||
array(
|
||||
$key => $templateDirectory,
|
||||
),
|
||||
$this->frontOfficeTemplateDirectories[$templateName]
|
||||
);
|
||||
} else {
|
||||
$this->frontOfficeTemplateDirectories[$templateName][$key] = $templateDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TemplateDefinition $templateDefinition
|
||||
*/
|
||||
@@ -166,40 +165,19 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
$this->setConfigDir($configDirectory);
|
||||
|
||||
/* add modules template directories */
|
||||
switch($templateDefinition->getType()) {
|
||||
case TemplateDefinition::FRONT_OFFICE:
|
||||
/* add main template directory */
|
||||
$this->addFrontOfficeTemplateDirectory($templateDefinition->getName(), THELIA_TEMPLATE_DIR . $this->getTemplate(), '0', true);
|
||||
$this->addTemplateDirectory(
|
||||
$templateDefinition->getType(),
|
||||
$templateDefinition->getName(),
|
||||
THELIA_TEMPLATE_DIR . $this->getTemplate(),
|
||||
'0',
|
||||
true
|
||||
);
|
||||
|
||||
/* do not pass array directly to addTemplateDir since we cant control on keys */
|
||||
if(isset($this->frontOfficeTemplateDirectories[$templateDefinition->getName()])) {
|
||||
foreach($this->frontOfficeTemplateDirectories[$templateDefinition->getName()] as $key => $directory) {
|
||||
$this->addTemplateDir($directory, $key);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TemplateDefinition::BACK_OFFICE:
|
||||
/* add main template directory */
|
||||
$this->addBackOfficeTemplateDirectory($templateDefinition->getName(), THELIA_TEMPLATE_DIR . $this->getTemplate(), '0', true);
|
||||
|
||||
/* do not pass array directly to addTemplateDir since we cant control on keys */
|
||||
if(isset($this->backOfficeTemplateDirectories[$templateDefinition->getName()])) {
|
||||
foreach($this->backOfficeTemplateDirectories[$templateDefinition->getName()] as $key => $directory) {
|
||||
$this->addTemplateDir($directory, $key);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TemplateDefinition::PDF:
|
||||
/* add main template directory */
|
||||
$this->addTemplateDir(THELIA_TEMPLATE_DIR . $this->getTemplate(), 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* add main template directory */
|
||||
$this->addTemplateDir(THELIA_TEMPLATE_DIR . $this->getTemplate(), 0);
|
||||
break;
|
||||
/* do not pass array directly to addTemplateDir since we cant control on keys */
|
||||
if (isset($this->templateDirectories[$templateDefinition->getType()][$templateDefinition->getName()])) {
|
||||
foreach($this->templateDirectories[$templateDefinition->getType()][$templateDefinition->getName()] as $key => $directory) {
|
||||
$this->addTemplateDir($directory, $key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,13 @@ class TemplateDefinition
|
||||
const PDF_SUBDIR = 'pdf/';
|
||||
const EMAIL_SUBDIR = 'email/';
|
||||
|
||||
protected static $standardTemplatesSubdirs = array(
|
||||
self::FRONT_OFFICE => self::FRONT_OFFICE_SUBDIR,
|
||||
self::BACK_OFFICE => self::BACK_OFFICE_SUBDIR,
|
||||
self::PDF => self::PDF_SUBDIR,
|
||||
self::EMAIL => self::EMAIL_SUBDIR,
|
||||
);
|
||||
|
||||
/**
|
||||
* @var the template directory name (e.g. 'default')
|
||||
*/
|
||||
@@ -128,4 +135,11 @@ class TemplateDefinition
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the standard templates subdir names
|
||||
*/
|
||||
public static function getStandardTemplatesSubdirs() {
|
||||
return self::$standardTemplatesSubdirs;
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,18 @@ class TemplateHelper
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array which contains all standard template definitions
|
||||
*/
|
||||
public function getStandardTemplateDefinitions() {
|
||||
return array(
|
||||
$this->getActiveFrontTemplate(),
|
||||
$this->getActiveAdminTemplate(),
|
||||
$this->getActivePdfTemplate(),
|
||||
$this->getActiveMailTemplate(),
|
||||
);
|
||||
}
|
||||
|
||||
public function getList($templateType) {
|
||||
|
||||
$list = $exclude = array();
|
||||
|
||||
@@ -55,6 +55,7 @@ use Symfony\Component\Config\FileLocator;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\Connection\ConnectionManagerSingle;
|
||||
use Thelia\Core\Template\TemplateHelper;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
class Thelia extends Kernel
|
||||
{
|
||||
@@ -105,6 +106,61 @@ class Thelia extends Kernel
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all module's standard templates to the parser environment
|
||||
*
|
||||
* @param TheliaParser $parser the parser
|
||||
* @param Module $module the Module.
|
||||
*/
|
||||
protected function addStandardModuleTemplatesToParserEnvironment($parser, $module) {
|
||||
$stdTpls = TemplateDefinition::getStandardTemplatesSubdirs();
|
||||
|
||||
foreach($stdTpls as $templateType => $templateSubdirName) {
|
||||
$this->addModuleTemplateToParserEnvironment($parser, $module, $templateType, $templateSubdirName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a module template directory to the parser environment
|
||||
*
|
||||
* @param TheliaParser $parser the parser
|
||||
* @param Module $module the Module.
|
||||
* @param string $templateType the template type (one of the TemplateDefinition type constants)
|
||||
* @param string $templateSubdirName the template subdirectory name (one of the TemplateDefinition::XXX_SUBDIR constants)
|
||||
*/
|
||||
protected function addModuleTemplateToParserEnvironment($parser, $module, $templateType, $templateSubdirName) {
|
||||
|
||||
// Get template path
|
||||
$templateDirectory = $module->getAbsoluteTemplateDirectoryPath($templateSubdirName);
|
||||
|
||||
try {
|
||||
$templateDirBrowser = new \DirectoryIterator($templateDirectory);
|
||||
|
||||
$code = ucfirst($module->getCode());
|
||||
|
||||
/* browse the directory */
|
||||
foreach ($templateDirBrowser as $templateDirContent) {
|
||||
|
||||
/* is it a directory which is not . or .. ? */
|
||||
if ($templateDirContent->isDir() && ! $templateDirContent->isDot()) {
|
||||
|
||||
$parser->addMethodCall(
|
||||
'addTemplateDirectory',
|
||||
array(
|
||||
$templateType,
|
||||
$templateDirContent->getFilename(),
|
||||
$templateDirContent->getPathName(),
|
||||
$code
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\UnexpectedValueException $ex) {
|
||||
// The directory does not exists, ignore it.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Load some configuration
|
||||
@@ -129,22 +185,19 @@ class Thelia extends Kernel
|
||||
|
||||
$translationDirs = array();
|
||||
$parser = $container->getDefinition('thelia.parser');
|
||||
|
||||
foreach ($modules as $module) {
|
||||
|
||||
try {
|
||||
|
||||
$defintion = new Definition();
|
||||
$defintion->setClass($module->getFullNamespace());
|
||||
$defintion->addMethodCall("setContainer", array(new Reference('service_container')));
|
||||
$definition = new Definition();
|
||||
$definition->setClass($module->getFullNamespace());
|
||||
$definition->addMethodCall("setContainer", array(new Reference('service_container')));
|
||||
|
||||
$container->setDefinition(
|
||||
"module.".$module->getCode(),
|
||||
$defintion
|
||||
$definition
|
||||
);
|
||||
|
||||
|
||||
$code = ucfirst($module->getCode());
|
||||
|
||||
$loader = new XmlFileLoader($container, new FileLocator($module->getAbsoluteConfigPath()));
|
||||
$loader->load("config.xml");
|
||||
|
||||
@@ -152,79 +205,24 @@ class Thelia extends Kernel
|
||||
$translationDirs[] = $dir;
|
||||
}
|
||||
|
||||
/* is there a front-office template directory ? */
|
||||
$frontOfficeModuleTemplateDirectory = sprintf("%s%stemplates%s%s", $module->getAbsoluteBaseDir(), DS, DS, TemplateDefinition::FRONT_OFFICE_SUBDIR);
|
||||
if (is_dir($frontOfficeModuleTemplateDirectory)) {
|
||||
try {
|
||||
$moduleFrontOfficeTemplateBrowser = new \DirectoryIterator($frontOfficeModuleTemplateDirectory);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
throw $e;
|
||||
}
|
||||
$this->addStandardModuleTemplatesToParserEnvironment($parser, $module);
|
||||
|
||||
/* browse the directory */
|
||||
foreach ($moduleFrontOfficeTemplateBrowser as $moduleFrontOfficeTemplateContent) {
|
||||
/* is it a directory which is not . or .. ? */
|
||||
if ($moduleFrontOfficeTemplateContent->isDir() && !$moduleFrontOfficeTemplateContent->isDot()) {
|
||||
$parser->addMethodCall(
|
||||
'addFrontOfficeTemplateDirectory',
|
||||
array(
|
||||
$moduleFrontOfficeTemplateContent->getFilename(),
|
||||
$moduleFrontOfficeTemplateContent->getPathName(),
|
||||
$code,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* is there a back-office template directory ? */
|
||||
$backOfficeModuleTemplateDirectory = sprintf("%s%stemplates%s%s", $module->getAbsoluteBaseDir(), DS, DS, TemplateDefinition::BACK_OFFICE_SUBDIR);
|
||||
if (is_dir($backOfficeModuleTemplateDirectory)) {
|
||||
try {
|
||||
$moduleBackOfficeTemplateBrowser = new \DirectoryIterator($backOfficeModuleTemplateDirectory);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
/* browse the directory */
|
||||
foreach ($moduleBackOfficeTemplateBrowser as $moduleBackOfficeTemplateContent) {
|
||||
/* is it a directory which is not . or .. ? */
|
||||
if ($moduleBackOfficeTemplateContent->isDir() && !$moduleBackOfficeTemplateContent->isDot()) {
|
||||
$parser->addMethodCall(
|
||||
'addBackOfficeTemplateDirectory',
|
||||
array(
|
||||
$moduleBackOfficeTemplateContent->getFilename(),
|
||||
$moduleBackOfficeTemplateContent->getPathName(),
|
||||
$code,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// TODO: process module configuration exception
|
||||
Tlog::getInstance()->addError(sprintf("Failed to load module %s: %s", $module->getCode(), $e->getMessage()), $e);
|
||||
}
|
||||
}
|
||||
|
||||
// Load translation from templates
|
||||
//core translation
|
||||
// core translation
|
||||
$translationDirs[] = THELIA_ROOT . "core/lib/Thelia/Config/I18n";
|
||||
|
||||
// Standard templates (front, back, pdf, mail)
|
||||
$th = TemplateHelper::getInstance();
|
||||
|
||||
// admin template
|
||||
if (is_dir($dir = $th->getActiveAdminTemplate()->getAbsoluteI18nPath())) {
|
||||
$translationDirs[] = $dir;
|
||||
}
|
||||
|
||||
// front template
|
||||
if (is_dir($dir = $th->getActiveFrontTemplate()->getAbsoluteI18nPath())) {
|
||||
$translationDirs[] = $dir;
|
||||
}
|
||||
|
||||
// PDF template
|
||||
if (is_dir($dir = $th->getActivePdfTemplate()->getAbsoluteI18nPath())) {
|
||||
$translationDirs[] = $dir;
|
||||
foreach($th->getStandardTemplateDefinitions() as $templateDefinition) {
|
||||
if (is_dir($dir = $templateDefinition->getAbsoluteI18nPath())) {
|
||||
$translationDirs[] = $dir;
|
||||
}
|
||||
}
|
||||
|
||||
if ($translationDirs) {
|
||||
|
||||
@@ -60,6 +60,15 @@ class Module extends BaseModule
|
||||
return THELIA_MODULE_DIR . $this->getI18nPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the absolute path to one of the module's template directories
|
||||
*
|
||||
* @param int $templateSubdirName the name of the, probably one of TemplateDefinition::xxx_SUBDIR constants
|
||||
*/
|
||||
public function getAbsoluteTemplateDirectoryPath($templateSubdirName) {
|
||||
return sprintf("%s%stemplates%s%s", $this->getAbsoluteBaseDir(), DS, DS, $templateSubdirName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next position relative to module type
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user