This commit is contained in:
Manuel Raynaud
2014-04-22 12:41:22 +02:00
parent 05bb8ecb80
commit 0435478ae8
17 changed files with 1654 additions and 1654 deletions

View File

@@ -27,11 +27,12 @@ use Thelia\Tools\URL;
class TranslationsController extends BaseAdminController class TranslationsController extends BaseAdminController
{ {
/** /**
* @param string $item_name the modume code * @param string $item_name the modume code
* @return Module the module object * @return Module the module object
* @throws \InvalidArgumentException if module was not found * @throws \InvalidArgumentException if module was not found
*/ */
protected function getModule($item_name) { protected function getModule($item_name)
{
if (null !== $module = ModuleQuery::create()->findPk($item_name)) if (null !== $module = ModuleQuery::create()->findPk($item_name))
return $module; return $module;
@@ -40,8 +41,8 @@ class TranslationsController extends BaseAdminController
); );
} }
protected function getModuleTemplateNames(Module $module, $template_type)
protected function getModuleTemplateNames(Module $module, $template_type) { {
$templates = $templates =
TemplateHelper::getInstance()->getList( TemplateHelper::getInstance()->getList(
$template_type, $template_type,
@@ -96,14 +97,12 @@ class TranslationsController extends BaseAdminController
$domain = $module->getTranslationDomain(); $domain = $module->getTranslationDomain();
$i18n_directory = $module->getAbsoluteI18nPath(); $i18n_directory = $module->getAbsoluteI18nPath();
$walkMode = TemplateHelper::WALK_MODE_PHP; $walkMode = TemplateHelper::WALK_MODE_PHP;
} } elseif ($module_part == 'admin-includes') {
else if ($module_part == 'admin-includes') {
$directory = $module->getAbsoluteAdminIncludesPath(); $directory = $module->getAbsoluteAdminIncludesPath();
$domain = $module->getAdminIncludesTranslationDomain(); $domain = $module->getAdminIncludesTranslationDomain();
$i18n_directory = $module->getAbsoluteAdminIncludesI18nPath(); $i18n_directory = $module->getAbsoluteAdminIncludesI18nPath();
$walkMode = TemplateHelper::WALK_MODE_TEMPLATE; $walkMode = TemplateHelper::WALK_MODE_TEMPLATE;
} } elseif (! empty($module_part)) {
else if (! empty($module_part)) {
// Front or back office template, form of $module_part is [bo|fo].subdir-name // Front or back office template, form of $module_part is [bo|fo].subdir-name
list($type, $subdir) = explode('.', $module_part); list($type, $subdir) = explode('.', $module_part);
@@ -111,13 +110,11 @@ class TranslationsController extends BaseAdminController
$directory = $module->getAbsoluteBackOfficeTemplatePath($subdir); $directory = $module->getAbsoluteBackOfficeTemplatePath($subdir);
$domain = $module->getBackOfficeTemplateTranslationDomain($subdir); $domain = $module->getBackOfficeTemplateTranslationDomain($subdir);
$i18n_directory = $module->getAbsoluteBackOfficeI18nTemplatePath($subdir); $i18n_directory = $module->getAbsoluteBackOfficeI18nTemplatePath($subdir);
} } elseif ($type == 'fo') {
else if ($type == 'fo') {
$directory = $module->getAbsoluteFrontOfficeTemplatePath($subdir); $directory = $module->getAbsoluteFrontOfficeTemplatePath($subdir);
$domain = $module->getFrontOfficeTemplateTranslationDomain($subdir); $domain = $module->getFrontOfficeTemplateTranslationDomain($subdir);
$i18n_directory = $module->getAbsoluteFrontOfficeI18nTemplatePath($subdir); $i18n_directory = $module->getAbsoluteFrontOfficeI18nTemplatePath($subdir);
} } else {
else {
throw new \InvalidArgumentException("Undefined module template type: '$type'."); throw new \InvalidArgumentException("Undefined module template type: '$type'.");
} }

View File

@@ -132,10 +132,10 @@ abstract class BaseLoop
/** /**
* Provides a getter to loop parameter values * Provides a getter to loop parameter values
* *
* @param string $name the method name (only getArgname is supported) * @param string $name the method name (only getArgname is supported)
* @param mixed $arguments this parameter is ignored * @param mixed $arguments this parameter is ignored
* *
* @return mixed the argument value * @return mixed the argument value
* @throws \InvalidArgumentException if the parameter is unknown or the method name is not supported. * @throws \InvalidArgumentException if the parameter is unknown or the method name is not supported.
*/ */
public function __call($name, $arguments) public function __call($name, $arguments)
@@ -230,7 +230,7 @@ abstract class BaseLoop
* *
* @param string $argumentName the argument name * @param string $argumentName the argument name
* *
* @return Argument the loop argument. * @return Argument the loop argument.
* @throws \InvalidArgumentException if argument is not found in loop argument list * @throws \InvalidArgumentException if argument is not found in loop argument list
*/ */
protected function getArg($argumentName) protected function getArg($argumentName)
@@ -251,7 +251,7 @@ abstract class BaseLoop
* @param string $argumentName the argument name * @param string $argumentName the argument name
* *
* @throws \InvalidArgumentException if argument is not found in loop argument list * @throws \InvalidArgumentException if argument is not found in loop argument list
* @return mixed the loop argument value * @return mixed the loop argument value
*/ */
protected function getArgValue($argumentName) protected function getArgValue($argumentName)
{ {
@@ -263,7 +263,7 @@ abstract class BaseLoop
* @param PropelModelPager $pagination the pagination part * @param PropelModelPager $pagination the pagination part
* *
* @return array|PropelModelPager|ObjectCollection * @return array|PropelModelPager|ObjectCollection
* @throws \InvalidArgumentException if the search mode is undefined. * @throws \InvalidArgumentException if the search mode is undefined.
*/ */
protected function search(ModelCriteria $search, &$pagination = null) protected function search(ModelCriteria $search, &$pagination = null)
{ {
@@ -356,7 +356,7 @@ abstract class BaseLoop
} }
/** /**
* @param ModelCriteria $search * @param ModelCriteria $search
* @param PropelModelPager $pagination * @param PropelModelPager $pagination
* *
* @return array|PropelModelPager * @return array|PropelModelPager

View File

@@ -59,7 +59,7 @@ class TheliaLoop extends AbstractSmartyPlugin
} }
/** /**
* @param string $loopName * @param string $loopName
* @return PropelModelPager * @return PropelModelPager
* @throws \InvalidArgumentException if no pagination was found for loop * @throws \InvalidArgumentException if no pagination was found for loop
*/ */
@@ -77,10 +77,10 @@ class TheliaLoop extends AbstractSmartyPlugin
/** /**
* Process the count function: executes a loop and return the number of items found * Process the count function: executes a loop and return the number of items found
* *
* @param array $params parameters array * @param array $params parameters array
* @param \Smarty_Internal_Template $template * @param \Smarty_Internal_Template $template
* *
* @return int the item count * @return int the item count
* @throws \InvalidArgumentException if a parameter is missing * @throws \InvalidArgumentException if a parameter is missing
* *
*/ */
@@ -104,10 +104,10 @@ class TheliaLoop extends AbstractSmartyPlugin
/** /**
* Process {loop name="loop name" type="loop type" ... } ... {/loop} block * Process {loop name="loop name" type="loop type" ... } ... {/loop} block
* *
* @param array $params * @param array $params
* @param string $content * @param string $content
* @param \Smarty_Internal_Template $template * @param \Smarty_Internal_Template $template
* @param boolean $repeat * @param boolean $repeat
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* *
@@ -209,11 +209,11 @@ class TheliaLoop extends AbstractSmartyPlugin
/** /**
* Process {elseloop rel="loopname"} ... {/elseloop} block * Process {elseloop rel="loopname"} ... {/elseloop} block
* *
* @param array $params loop parameters * @param array $params loop parameters
* @param string $content loop text content * @param string $content loop text content
* @param \Smarty_Internal_Template $template the Smarty object * @param \Smarty_Internal_Template $template the Smarty object
* @param boolean $repeat repeat indicator (see Smarty doc.) * @param boolean $repeat repeat indicator (see Smarty doc.)
* @return string the loop output * @return string the loop output
*/ */
public function theliaElseloop($params, $content, /** @noinspection PhpUnusedParameterInspection */ $template, &$repeat) public function theliaElseloop($params, $content, /** @noinspection PhpUnusedParameterInspection */ $template, &$repeat)
{ {
@@ -228,11 +228,11 @@ class TheliaLoop extends AbstractSmartyPlugin
/** /**
* Process {ifloop rel="loopname"} ... {/ifloop} block * Process {ifloop rel="loopname"} ... {/ifloop} block
* *
* @param array $params loop parameters * @param array $params loop parameters
* @param string $content loop text content * @param string $content loop text content
* @param \Smarty_Internal_Template $template the Smarty object * @param \Smarty_Internal_Template $template the Smarty object
* @param boolean $repeat repeat indicator (see Smarty doc.) * @param boolean $repeat repeat indicator (see Smarty doc.)
* @return string the loop output * @return string the loop output
*/ */
public function theliaIfLoop($params, $content, /** @noinspection PhpUnusedParameterInspection */ $template, &$repeat) public function theliaIfLoop($params, $content, /** @noinspection PhpUnusedParameterInspection */ $template, &$repeat)
{ {
@@ -247,11 +247,11 @@ class TheliaLoop extends AbstractSmartyPlugin
/** /**
* Process {pageloop rel="loopname"} ... {/pageloop} block * Process {pageloop rel="loopname"} ... {/pageloop} block
* *
* @param array $params loop parameters * @param array $params loop parameters
* @param string $content loop text content * @param string $content loop text content
* @param \Smarty_Internal_Template $template the Smarty object * @param \Smarty_Internal_Template $template the Smarty object
* @param boolean $repeat repeat indicator (see Smarty doc.) * @param boolean $repeat repeat indicator (see Smarty doc.)
* @return string the loop output * @return string the loop output
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function theliaPageLoop($params, $content, $template, &$repeat) public function theliaPageLoop($params, $content, $template, &$repeat)
@@ -337,9 +337,9 @@ class TheliaLoop extends AbstractSmartyPlugin
* Check if a loop has returned results. The loop shoud have been executed before, or an * Check if a loop has returned results. The loop shoud have been executed before, or an
* InvalidArgumentException is thrown * InvalidArgumentException is thrown
* *
* @param array $params * @param array $params
* *
* @return boolean true if the loop is empty * @return boolean true if the loop is empty
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
protected function checkEmptyLoop($params) protected function checkEmptyLoop($params)

View File

@@ -29,7 +29,7 @@ class Translation extends AbstractSmartyPlugin
/** /**
* Set the default translation domain * Set the default translation domain
* *
* @param array $params * @param array $params
* @param \Smarty_Internal_Template $smarty * @param \Smarty_Internal_Template $smarty
* @return string * @return string
*/ */
@@ -41,7 +41,7 @@ class Translation extends AbstractSmartyPlugin
/** /**
* Process translate function * Process translate function
* *
* @param array $params * @param array $params
* @param \Smarty_Internal_Template $smarty * @param \Smarty_Internal_Template $smarty
* @return string * @return string
*/ */

View File

@@ -242,6 +242,7 @@ class SmartyParser extends Smarty implements ParserInterface
if (false === $this->templateExists($realTemplateName) || false === $this->checkTemplate($realTemplateName)) { if (false === $this->templateExists($realTemplateName) || false === $this->checkTemplate($realTemplateName)) {
throw new ResourceNotFoundException(Translator::getInstance()->trans("Template file %file cannot be found.", array('%file' => $realTemplateName))); throw new ResourceNotFoundException(Translator::getInstance()->trans("Template file %file cannot be found.", array('%file' => $realTemplateName)));
} }
return $this->internalRenderer('file', $realTemplateName, $parameters); return $this->internalRenderer('file', $realTemplateName, $parameters);
} }

View File

@@ -77,7 +77,8 @@ class TemplateDefinition
} }
} }
public function getTranslationDomain() { public function getTranslationDomain()
{
return $this->translationDomainPrefix . strtolower($this->getName()); return $this->translationDomainPrefix . strtolower($this->getName());
} }

View File

@@ -96,7 +96,7 @@ class TemplateHelper
/** /**
* Return a list of existing templates for a given template type * Return a list of existing templates for a given template type
* *
* @param int $templateType the template type * @param int $templateType the template type
* @param string the template base (module or core, default to core). * @param string the template base (module or core, default to core).
* @return TemplateDefinition[] of \Thelia\Core\Template\TemplateDefinition * @return TemplateDefinition[] of \Thelia\Core\Template\TemplateDefinition
*/ */
@@ -126,8 +126,7 @@ class TemplateHelper
$list[] = new TemplateDefinition($file->getFilename(), $templateType); $list[] = new TemplateDefinition($file->getFilename(), $templateType);
} }
} } catch (\UnexpectedValueException $ex) {
catch (\UnexpectedValueException $ex) {
// Ignore the exception and continue // Ignore the exception and continue
} }
} }

View File

@@ -217,7 +217,7 @@ class Thelia extends Kernel
$module->getAbsoluteTemplateBasePath() $module->getAbsoluteTemplateBasePath()
); );
foreach($templates as $template) { foreach ($templates as $template) {
$translationDirs[$module->getBackOfficeTemplateTranslationDomain($template->getName())] = $translationDirs[$module->getBackOfficeTemplateTranslationDomain($template->getName())] =
$module->getAbsoluteBackOfficeI18nTemplatePath($template->getName()); $module->getAbsoluteBackOfficeI18nTemplatePath($template->getName());
} }
@@ -229,7 +229,7 @@ class Thelia extends Kernel
$module->getAbsoluteTemplateBasePath() $module->getAbsoluteTemplateBasePath()
); );
foreach($templates as $template) { foreach ($templates as $template) {
$translationDirs[$module->getFrontOfficeTemplateTranslationDomain($template->getName())] = $translationDirs[$module->getFrontOfficeTemplateTranslationDomain($template->getName())] =
$module->getAbsoluteFrontOfficeI18nTemplatePath($template->getName()); $module->getAbsoluteFrontOfficeI18nTemplatePath($template->getName());
} }
@@ -279,8 +279,7 @@ class Thelia extends Kernel
$translator->addMethodCall('addResource', array($format, (string) $file, $locale, $domain)); $translator->addMethodCall('addResource', array($format, (string) $file, $locale, $domain));
} }
} } catch (\InvalidArgumentException $ex) {
catch (\InvalidArgumentException $ex) {
// Ignore missing I18n directories // Ignore missing I18n directories
Tlog::getInstance()->addWarning("loadTranslation: missing $dir directory"); Tlog::getInstance()->addWarning("loadTranslation: missing $dir directory");
} }

View File

@@ -16,17 +16,18 @@ class Module extends BaseModule
const ADMIN_INCLUDES_DIRECTORY_NAME = "AdminIncludes"; const ADMIN_INCLUDES_DIRECTORY_NAME = "AdminIncludes";
public function postSave(ConnectionInterface $con = null) public function postSave(ConnectionInterface $con = null)
{ {
ModuleQuery::resetActivated(); ModuleQuery::resetActivated();
} }
public function getTranslationDomain() { public function getTranslationDomain()
{
return strtolower($this->getCode()); return strtolower($this->getCode());
} }
public function getAdminIncludesTranslationDomain() { public function getAdminIncludesTranslationDomain()
{
return $this->getTranslationDomain().'.ai'; return $this->getTranslationDomain().'.ai';
} }
@@ -48,7 +49,8 @@ class Module extends BaseModule
); );
} }
public function getBackOfficeTemplateTranslationDomain($templateName) { public function getBackOfficeTemplateTranslationDomain($templateName)
{
return $this->getTranslationDomain(). '.bo.' . $templateName; return $this->getTranslationDomain(). '.bo.' . $templateName;
} }
@@ -70,7 +72,8 @@ class Module extends BaseModule
); );
} }
public function getFrontOfficeTemplateTranslationDomain($templateName) { public function getFrontOfficeTemplateTranslationDomain($templateName)
{
return $this->getTranslationDomain(). '.fo.' . $templateName; return $this->getTranslationDomain(). '.fo.' . $templateName;
} }
@@ -151,7 +154,7 @@ class Module extends BaseModule
/** /**
* Return the absolute path to one of the module's template directories * 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 * @param int $templateSubdirName the name of the, probably one of TemplateDefinition::xxx_SUBDIR constants
* @return string a path * @return string a path
*/ */
public function getAbsoluteTemplateDirectoryPath($templateSubdirName) public function getAbsoluteTemplateDirectoryPath($templateSubdirName)

View File

@@ -159,7 +159,7 @@ class BaseModule extends ContainerAware implements BaseModuleInterface
* Sets a module titles for various languages * Sets a module titles for various languages
* *
* @param Module $module the module. * @param Module $module the module.
* @param array $titles an associative array of locale => title_string * @param array $titles an associative array of locale => title_string
*/ */
public function setTitle(Module $module, $titles) public function setTitle(Module $module, $titles)
{ {

View File

@@ -35,7 +35,7 @@ interface DeliveryModuleInterface extends BaseModuleInterface
* *
* @param Country $country the country to deliver to. * @param Country $country the country to deliver to.
* *
* @return float the delivery price * @return float the delivery price
* @throws DeliveryException if the postage price cannot be calculated. * @throws DeliveryException if the postage price cannot be calculated.
*/ */
public function getPostage(Country $country); public function getPostage(Country $country);