Merge branch 'master' of git://github.com/thelia/thelia
* 'master' of git://github.com/thelia/thelia: fix typo Implemented mail messages templates and layouts Email template + test email add REF to product_sale_element loop and fix product tempalte Correct link "Go to admin page" alike thelia is installed in the root of virtual host or in a subdirectory Add correct url(subdiretory included) in config page Use getUriForPath() instead getSchemeAndHttpHost() for proper redirection for cases where Thelia is installed in a subdirectory
This commit is contained in:
@@ -68,12 +68,14 @@ class RegisterRouterPass implements CompilerPassInterface
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$moduleBaseDir = $module->getBaseDir();
|
||||
if (file_exists(THELIA_MODULE_DIR . "/" . $moduleBaseDir . "/Config/routing.xml")) {
|
||||
$routingConfigFilePath = $module->getAbsoluteBaseDir() . DS . "Config" . DS . "routing.xml";
|
||||
|
||||
if (file_exists($routingConfigFilePath)) {
|
||||
$definition = new Definition(
|
||||
$container->getParameter("router.class"),
|
||||
array(
|
||||
new Reference("router.module.xmlLoader"),
|
||||
$moduleBaseDir . "/Config/routing.xml",
|
||||
$routingConfigFilePath,
|
||||
array(
|
||||
"cache_dir" => $container->getParameter("kernel.cache_dir"),
|
||||
"debug" => $container->getParameter("kernel.debug"),
|
||||
|
||||
@@ -22,13 +22,18 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Message;
|
||||
|
||||
use Thelia\Core\Event\Message\MessageCreateEvent;
|
||||
|
||||
class MessageUpdateEvent extends MessageCreateEvent
|
||||
{
|
||||
protected $message_id;
|
||||
|
||||
protected $html_layout_file_name;
|
||||
protected $html_template_file_name;
|
||||
|
||||
protected $text_layout_file_name;
|
||||
protected $text_template_file_name;
|
||||
|
||||
protected $text_message;
|
||||
protected $html_message;
|
||||
protected $subject;
|
||||
@@ -85,4 +90,52 @@ class MessageUpdateEvent extends MessageCreateEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
public function getHtmlLayoutFileName()
|
||||
{
|
||||
return $this->html_layout_file_name;
|
||||
}
|
||||
|
||||
public function setHtmlLayoutFileName($html_layout_file_name)
|
||||
{
|
||||
$this->html_layout_file_name = $html_layout_file_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHtmlTemplateFileName()
|
||||
{
|
||||
return $this->html_template_file_name;
|
||||
}
|
||||
|
||||
public function setHtmlTemplateFileName($html_template_file_name)
|
||||
{
|
||||
$this->html_template_file_name = $html_template_file_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTextLayoutFileName()
|
||||
{
|
||||
return $this->text_layout_file_name;
|
||||
}
|
||||
|
||||
public function setTextLayoutFileName($text_layout_file_name)
|
||||
{
|
||||
$this->text_layout_file_name = $text_layout_file_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTextTemplateFileName()
|
||||
{
|
||||
return $this->text_template_file_name;
|
||||
}
|
||||
|
||||
public function setTextTemplateFileName($text_template_file_name)
|
||||
{
|
||||
$this->text_template_file_name = $text_template_file_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -165,7 +165,7 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
|
||||
/* if not ; test if it uses admin inclusion : module_configuration.html */
|
||||
if(false === $hasConfigurationInterface) {
|
||||
if(file_exists( sprintf("%s/%s/AdminIncludes/%s.html", THELIA_MODULE_DIR, $module->getBaseDir(), "module_configuration"))) {
|
||||
if(file_exists( sprintf("%s/AdminIncludes/%s.html", $module->getAbsoluteBaseDir(), "module_configuration"))) {
|
||||
$hasConfigurationInterface = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +174,7 @@ class ProductSaleElements extends BaseLoop implements PropelSearchLoopInterface
|
||||
->set("IS_NEW" , $PSEValue->getNewness() === 1 ? 1 : 0)
|
||||
->set("IS_DEFAULT" , $PSEValue->getIsDefault() === 1 ? 1 : 0)
|
||||
->set("WEIGHT" , $PSEValue->getWeight())
|
||||
->set("REF" , $PSEValue->getRef())
|
||||
->set("EAN_CODE" , $PSEValue->getEanCode())
|
||||
->set("PRICE" , $price)
|
||||
->set("PRICE_TAX" , $taxedPrice - $price)
|
||||
|
||||
@@ -93,7 +93,7 @@ class Template extends BaseLoop implements ArraySearchLoopInterface
|
||||
$loopResultRow
|
||||
->set("NAME" , $template->getName())
|
||||
->set("RELATIVE_PATH" , $template->getPath())
|
||||
->set("ABSOLUTE_PATH" , THELIA_TEMPLATE_DIR . $template->getPath())
|
||||
->set("ABSOLUTE_PATH" , $template->getAbsolutePath())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -54,7 +54,7 @@ class Module extends AbstractSmartyPlugin
|
||||
continue;
|
||||
}
|
||||
|
||||
$file = sprintf("%s/%s/AdminIncludes/%s.html", THELIA_MODULE_DIR, $module->getBaseDir(), $location);
|
||||
$file = sprintf("%s/AdminIncludes/%s.html", $module->getAbsoluteBaseDir(), $location);
|
||||
|
||||
if (file_exists($file)) {
|
||||
$content .= file_get_contents($file);
|
||||
|
||||
@@ -16,6 +16,7 @@ use Thelia\Core\Template\ParserContext;
|
||||
use Thelia\Core\Template\TemplateDefinition;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Template\TemplateHelper;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -125,10 +126,10 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
$this->setTemplateDir(array());
|
||||
|
||||
/* add main template directory */
|
||||
$this->addTemplateDir(THELIA_TEMPLATE_DIR . $this->template, 0);
|
||||
$this->addTemplateDir($templateDefinition->getAbsolutePath(), 0);
|
||||
|
||||
/* define config directory */
|
||||
$configDirectory = THELIA_TEMPLATE_DIR . $this->template . '/configs';
|
||||
$configDirectory = $templateDefinition->getAbsoluteConfigPath();
|
||||
$this->setConfigDir($configDirectory);
|
||||
|
||||
/* add modules template directories */
|
||||
@@ -165,17 +166,16 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a rendered template file
|
||||
* Return a rendered template, either from file or ftom a string
|
||||
*
|
||||
* @param string $realTemplateName the template name (from the template directory)
|
||||
* @param string $resourceType either 'string' (rendering from a string) or 'file' (rendering a file)
|
||||
* @param string $resourceContent the resource content (a text, or a template file name)
|
||||
* @param array $parameters an associative array of names / value pairs
|
||||
*
|
||||
* @return string the rendered template text
|
||||
*/
|
||||
public function render($realTemplateName, array $parameters = array())
|
||||
protected function internalRenderer($resourceType, $resourceContent, array $parameters)
|
||||
{
|
||||
if(false === $this->templateExists($realTemplateName)) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
// Assign the parserContext variables
|
||||
foreach ($this->parserContext as $var => $value) {
|
||||
$this->assign($var, $value);
|
||||
@@ -183,7 +183,35 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
|
||||
$this->assign($parameters);
|
||||
|
||||
return $this->fetch(sprintf("file:%s", $realTemplateName));
|
||||
return $this->fetch(sprintf("%s:%s", $resourceType, $resourceContent));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a rendered template file
|
||||
*
|
||||
* @param string $realTemplateName the template name (from the template directory)
|
||||
* @param array $parameters an associative array of names / value pairs
|
||||
* @return string the rendered template text
|
||||
*/
|
||||
public function render($realTemplateName, array $parameters = array()) {
|
||||
|
||||
if(false === $this->templateExists($realTemplateName)) {
|
||||
throw new ResourceNotFoundException(Translator::getInstance()->trans("Template file %file cannot be found.", array('%file', $realTemplateName)));
|
||||
}
|
||||
|
||||
return $this->internalRenderer('file', $realTemplateName, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a rendered template text
|
||||
*
|
||||
* @param string $templateText the template text
|
||||
* @param array $parameters an associative array of names / value pairs
|
||||
* @return string the rendered template text
|
||||
*/
|
||||
public function renderString($templateText, array $parameters = array()) {
|
||||
return $this->internalRenderer('string', $templateText, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,10 +28,12 @@ class TemplateDefinition
|
||||
const FRONT_OFFICE = 1;
|
||||
const BACK_OFFICE = 2;
|
||||
const PDF = 3;
|
||||
const EMAIL = 4;
|
||||
|
||||
const FRONT_OFFICE_SUBDIR = 'frontOffice/';
|
||||
const BACK_OFFICE_SUBDIR = 'backOffice/';
|
||||
const PDF_SUBDIR = 'pdf/';
|
||||
const EMAIL_SUBDIR = 'email/';
|
||||
|
||||
/**
|
||||
* @var the template directory name (e.g. 'default')
|
||||
@@ -64,6 +66,9 @@ class TemplateDefinition
|
||||
case TemplateDefinition::PDF:
|
||||
$this->path = self::PDF_SUBDIR . $name;
|
||||
break;
|
||||
case TemplateDefinition::EMAIL:
|
||||
$this->path = self::EMAIL_SUBDIR . $name;
|
||||
break;
|
||||
default:
|
||||
$this->path = $name;
|
||||
break;
|
||||
@@ -85,11 +90,28 @@ class TemplateDefinition
|
||||
return $this->getPath() . DS . 'I18n';
|
||||
}
|
||||
|
||||
public function getAbsoluteI18nPath() {
|
||||
return THELIA_TEMPLATE_DIR . $this->getI18nPath();
|
||||
}
|
||||
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function getAbsolutePath() {
|
||||
return THELIA_TEMPLATE_DIR . $this->getPath();
|
||||
}
|
||||
|
||||
public function getConfigPath()
|
||||
{
|
||||
return $this->getPath() . DS . 'configs';
|
||||
}
|
||||
|
||||
public function getAbsoluteConfigPath() {
|
||||
return THELIA_TEMPLATE_DIR . $this->getConfigPath();
|
||||
}
|
||||
|
||||
public function setPath($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
@@ -106,5 +128,4 @@ class TemplateDefinition
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,16 @@ class TemplateHelper
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateDefinition
|
||||
*/
|
||||
public function getActiveMailTemplate() {
|
||||
return new TemplateDefinition(
|
||||
ConfigQuery::read('active-mail-template', 'default'),
|
||||
TemplateDefinition::EMAIL
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateDefinition
|
||||
*/
|
||||
|
||||
@@ -145,15 +145,15 @@ class Thelia extends Kernel
|
||||
|
||||
$code = ucfirst($module->getCode());
|
||||
|
||||
$loader = new XmlFileLoader($container, new FileLocator(THELIA_MODULE_DIR . "/" . $code . "/Config"));
|
||||
$loader = new XmlFileLoader($container, new FileLocator($module->getAbsoluteConfigPath()));
|
||||
$loader->load("config.xml");
|
||||
|
||||
if (is_dir($dir = THELIA_MODULE_DIR . "/" . $code . "/I18n")) {
|
||||
if (is_dir($dir = $module->getAbsoluteI18nPath())) {
|
||||
$translationDirs[] = $dir;
|
||||
}
|
||||
|
||||
/* is there a front-office template directory ? */
|
||||
$frontOfficeModuleTemplateDirectory = sprintf("%s%s%stemplates%s%s", THELIA_MODULE_DIR, $code, DS, DS, TemplateDefinition::FRONT_OFFICE_SUBDIR);
|
||||
$frontOfficeModuleTemplateDirectory = sprintf("%s%stemplates%s%s", $module->getAbsoluteBaseDir(), DS, DS, TemplateDefinition::FRONT_OFFICE_SUBDIR);
|
||||
if (is_dir($frontOfficeModuleTemplateDirectory)) {
|
||||
try {
|
||||
$moduleFrontOfficeTemplateBrowser = new \DirectoryIterator($frontOfficeModuleTemplateDirectory);
|
||||
@@ -178,7 +178,7 @@ class Thelia extends Kernel
|
||||
}
|
||||
|
||||
/* is there a back-office template directory ? */
|
||||
$backOfficeModuleTemplateDirectory = sprintf("%s%s%stemplates%s%s", THELIA_MODULE_DIR, $code, DS, DS, TemplateDefinition::BACK_OFFICE_SUBDIR);
|
||||
$backOfficeModuleTemplateDirectory = sprintf("%s%stemplates%s%s", $module->getAbsoluteBaseDir(), DS, DS, TemplateDefinition::BACK_OFFICE_SUBDIR);
|
||||
if (is_dir($backOfficeModuleTemplateDirectory)) {
|
||||
try {
|
||||
$moduleBackOfficeTemplateBrowser = new \DirectoryIterator($backOfficeModuleTemplateDirectory);
|
||||
@@ -210,18 +210,20 @@ class Thelia extends Kernel
|
||||
//core translation
|
||||
$translationDirs[] = THELIA_ROOT . "core/lib/Thelia/Config/I18n";
|
||||
|
||||
$th = TemplateHelper::getInstance();
|
||||
|
||||
// admin template
|
||||
if (is_dir($dir = THELIA_TEMPLATE_DIR . TemplateHelper::getInstance()->getActiveAdminTemplate()->getI18nPath())) {
|
||||
if (is_dir($dir = $th->getActiveAdminTemplate()->getAbsoluteI18nPath())) {
|
||||
$translationDirs[] = $dir;
|
||||
}
|
||||
|
||||
// front template
|
||||
if (is_dir($dir = THELIA_TEMPLATE_DIR . TemplateHelper::getInstance()->getActiveFrontTemplate()->getI18nPath())) {
|
||||
if (is_dir($dir = $th->getActiveFrontTemplate()->getAbsoluteI18nPath())) {
|
||||
$translationDirs[] = $dir;
|
||||
}
|
||||
|
||||
// PDF template
|
||||
if (is_dir($dir = THELIA_TEMPLATE_DIR . TemplateHelper::getInstance()->getActivePdfTemplate()->getI18nPath())) {
|
||||
if (is_dir($dir = $th->getActivePdfTemplate()->getAbsoluteI18nPath())) {
|
||||
$translationDirs[] = $dir;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user