diff --git a/core/lib/Thelia/Command/BaseModuleGenerate.php b/core/lib/Thelia/Command/BaseModuleGenerate.php index 1a27d9e4c..7d487d4cc 100755 --- a/core/lib/Thelia/Command/BaseModuleGenerate.php +++ b/core/lib/Thelia/Command/BaseModuleGenerate.php @@ -42,7 +42,7 @@ abstract class BaseModuleGenerate extends ContainerAwareCommand 'Config', 'Model', 'Loop', - 'AdminModule' + 'AdminIncludes' ); protected function verifyExistingModule() diff --git a/core/lib/Thelia/Config/Resources/command.xml b/core/lib/Thelia/Config/Resources/command.xml new file mode 100644 index 000000000..308a1c50c --- /dev/null +++ b/core/lib/Thelia/Config/Resources/command.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 0cf616126..e75ab8ebb 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -4,188 +4,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -211,7 +29,7 @@ - null + @@ -238,83 +56,6 @@ - - - - - %kernel.environment% - - - - - - - - - - - - - - - - %thelia.parser.loops% - - - - - - - - - - - - - - - %thelia.parser.forms% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -328,45 +69,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/lib/Thelia/Config/Resources/coupon.xml b/core/lib/Thelia/Config/Resources/coupon.xml new file mode 100644 index 000000000..fc327911c --- /dev/null +++ b/core/lib/Thelia/Config/Resources/coupon.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/lib/Thelia/Config/Resources/form.xml b/core/lib/Thelia/Config/Resources/form.xml new file mode 100644 index 000000000..8577bf145 --- /dev/null +++ b/core/lib/Thelia/Config/Resources/form.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/lib/Thelia/Config/Resources/loop.xml b/core/lib/Thelia/Config/Resources/loop.xml new file mode 100644 index 000000000..fe2c333d4 --- /dev/null +++ b/core/lib/Thelia/Config/Resources/loop.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/lib/Thelia/Config/Resources/smarty-plugin.xml b/core/lib/Thelia/Config/Resources/smarty-plugin.xml new file mode 100644 index 000000000..0d0b7ed15 --- /dev/null +++ b/core/lib/Thelia/Config/Resources/smarty-plugin.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + %kernel.environment% + + + + + + + + + + + + + + + + %thelia.parser.loops% + + + + + + + + + + + + + + + %thelia.parser.forms% + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/lib/Thelia/Config/Resources/translation.xml b/core/lib/Thelia/Config/Resources/translation.xml new file mode 100644 index 000000000..2fdef3882 --- /dev/null +++ b/core/lib/Thelia/Config/Resources/translation.xml @@ -0,0 +1,62 @@ + + + + + + Symfony\Component\Translation\Loader\PhpFileLoader + Symfony\Component\Translation\Loader\YamlFileLoader + Symfony\Component\Translation\Loader\XliffFileLoader + Symfony\Component\Translation\Loader\PoFileLoader + Symfony\Component\Translation\Loader\MoFileLoader + Symfony\Component\Translation\Loader\QtFileLoader + Symfony\Component\Translation\Loader\CsvFileLoader + Symfony\Component\Translation\Loader\IcuResFileLoader + Symfony\Component\Translation\Loader\IcuDatFileLoader + Symfony\Component\Translation\Loader\IniFileLoader + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index ad8d46ba0..5fc11c814 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -199,7 +199,7 @@ class BaseAdminController extends BaseController $parser = $this->container->get("thelia.parser"); // Define the template thant shoud be used - $parser->setTemplate($template ?: ConfigQuery::read('base_admin_template', 'admin/default')); + $parser->setTemplate($template ?: ConfigQuery::read('base-admin-template', 'admin/default')); return $parser; } diff --git a/core/lib/Thelia/Core/Bundle/TheliaBundle.php b/core/lib/Thelia/Core/Bundle/TheliaBundle.php index dcdcdd5d2..9a536f88d 100755 --- a/core/lib/Thelia/Core/Bundle/TheliaBundle.php +++ b/core/lib/Thelia/Core/Bundle/TheliaBundle.php @@ -31,6 +31,7 @@ use Thelia\Core\DependencyInjection\Compiler\RegisterListenersPass; use Thelia\Core\DependencyInjection\Compiler\RegisterParserPluginPass; use Thelia\Core\DependencyInjection\Compiler\RegisterRouterPass; use Thelia\Core\DependencyInjection\Compiler\RegisterCouponConditionPass; +use Thelia\Core\DependencyInjection\Compiler\TranslatorPass; /** * First Bundle use in Thelia @@ -63,6 +64,9 @@ class TheliaBundle extends Bundle ->addCompilerPass(new RegisterParserPluginPass()) ->addCompilerPass(new RegisterRouterPass()) ->addCompilerPass(new RegisterCouponPass()) - ->addCompilerPass(new RegisterCouponConditionPass()); + ->addCompilerPass(new RegisterCouponConditionPass()) + ->addCompilerPass(new TranslatorPass()) + + ; } } diff --git a/core/lib/Thelia/Core/DependencyInjection/Compiler/TranslatorPass.php b/core/lib/Thelia/Core/DependencyInjection/Compiler/TranslatorPass.php new file mode 100644 index 000000000..e007f9961 --- /dev/null +++ b/core/lib/Thelia/Core/DependencyInjection/Compiler/TranslatorPass.php @@ -0,0 +1,60 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\DependencyInjection\Compiler; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + + +/** + * Class TranslatorPass + * @package Thelia\Core\DependencyInjection\Compiler + * @author Manuel Raynaud + */ +class TranslatorPass implements CompilerPassInterface +{ + + /** + * You can modify the container here before it is dumped to PHP code. + * + * @param ContainerBuilder $container + * + * @api + */ + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition('thelia.translator')) { + return; + } + + $translator = $container->getDefinition('thelia.translator'); + + foreach($container->findTaggedServiceIds('translation.loader') as $id => $attributes) { + $translator->addMethodCall('addLoader', array($attributes[0]['alias'], new Reference($id))); + if (isset($attributes[0]['legacy-alias'])) { + $translator->addMethodCall('addLoader', array($attributes[0]['legacy-alias'], new Reference($id))); + } + } + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php index 244d09166..3b432cea9 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php @@ -27,6 +27,8 @@ use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Tools\URL; use Thelia\Core\Security\SecurityContext; +use Thelia\Model\Config; +use Thelia\Model\ConfigQuery; /** * This class implements variour admin template utilities @@ -42,6 +44,26 @@ class AdminUtilities extends AbstractSmartyPlugin $this->securityContext = $securityContext; } + protected function fetch_snippet($smarty, $templateName, $variablesArray) { + + $data = ''; + + $snippet_path = sprintf('%s/%s/%s.html', + THELIA_TEMPLATE_DIR, + ConfigQuery::read('base-admin-template', 'admin/default'), + $templateName + ); + + if (false !== $snippet_content = file_get_contents($snippet_path)) { + + $smarty->assign($variablesArray); + + $data = $smarty->fetch(sprintf('string:%s', $snippet_content)); + } + + return $data; + } + public function generatePositionChangeBlock($params, &$smarty) { // The required permissions @@ -70,15 +92,15 @@ class AdminUtilities extends AbstractSmartyPlugin */ if ($permissions == null || $this->securityContext->isGranted("ADMIN", array($resource), array($access))) { - return sprintf( - '%s', - URL::getInstance()->absoluteUrl($path, array('mode' => 'up', $url_parameter => $id)), - $in_place_edit_class, - $id, - $position, - URL::getInstance()->absoluteUrl($path, array('mode' => 'down', $url_parameter => $id)) - ); - } else { + + return $this->fetch_snippet($smarty, 'includes/admin-utilities-position-block', array( + 'admin_utilities_go_up_url' => URL::getInstance()->absoluteUrl($path, array('mode' => 'up', $url_parameter => $id)), + 'admin_utilities_in_place_edit_class' => $in_place_edit_class, + 'admin_utilities_object_id' => $id, + 'admin_utilities_current_position' => $position, + 'admin_utilities_go_down_url' => URL::getInstance()->absoluteUrl($path, array('mode' => 'down', $url_parameter => $id)) + )); + } else { return $position; } } @@ -111,21 +133,20 @@ class AdminUtilities extends AbstractSmartyPlugin $request_parameter_name = $this->getParam($params, 'request_parameter_name', 'order'); if ($current_order == $order) { - $icon = 'up'; + $sort_direction = 'up'; $order_change = $reverse_order; } elseif ($current_order == $reverse_order) { - $icon = 'down'; + $sort_direction = 'down'; $order_change = $order; } else { $order_change = $order; } - if (! empty($icon)) - $output = sprintf(' ', $icon); - else - $output = ''; - - return sprintf('%s%s', $output, URL::getInstance()->absoluteUrl($path, array($request_parameter_name => $order_change)), $label); + return $this->fetch_snippet($smarty, 'includes/admin-utilities-sortable-column-header', array( + 'admin_utilities_sort_direction' => $sort_direction, + 'admin_utilities_sorting_url' => URL::getInstance()->absoluteUrl($path, array($request_parameter_name => $order_change)), + 'admin_utilities_header_text' => $label + )); } /** diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php index 23f9ed231..beb9a6b25 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php @@ -47,7 +47,7 @@ class Module extends AbstractSmartyPlugin foreach ($modules as $module) { - $file = THELIA_MODULE_DIR . "/". ucfirst($module->getCode()) . "/ModuleAdmin/".$location.".html"; + $file = THELIA_MODULE_DIR . "/". ucfirst($module->getCode()) . "/AdminIncludes/".$location.".html"; if(file_exists($file)) { $content .= file_get_contents($file); } diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index 1bc1e7649..3d476ad30 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -35,6 +35,7 @@ namespace Thelia\Core; use Propel\Runtime\Connection\ConnectionWrapper; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\Finder\Finder; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Yaml\Yaml; @@ -46,6 +47,7 @@ use Thelia\Config\DatabaseConfiguration; use Thelia\Config\DefinePropel; use Thelia\Core\TheliaContainerBuilder; use Thelia\Core\DependencyInjection\Loader\XmlFileLoader; +use Thelia\Model\ConfigQuery; use Symfony\Component\Config\FileLocator; use Propel\Runtime\Propel; @@ -110,12 +112,19 @@ class Thelia extends Kernel { $loader = new XmlFileLoader($container, new FileLocator(THELIA_ROOT . "/core/lib/Thelia/Config/Resources")); - $loader->load("config.xml"); - $loader->load("routing.xml"); - $loader->load("action.xml"); + $finder = Finder::create() + ->name('*.xml') + ->depth(0) + ->in(THELIA_ROOT . "/core/lib/Thelia/Config/Resources"); + + foreach($finder as $file) { + $loader->load($file->getBaseName()); + } + if (defined("THELIA_INSTALL_MODE") === false) { $modules = \Thelia\Model\ModuleQuery::getActivated(); - + $translator = $container->getDefinition('thelia.translator'); + $dirs = array(); foreach ($modules as $module) { try { @@ -131,10 +140,38 @@ class Thelia extends Kernel $loader = new XmlFileLoader($container, new FileLocator(THELIA_MODULE_DIR . "/" . ucfirst($module->getCode()) . "/Config")); $loader->load("config.xml"); + + if (is_dir($dir = THELIA_MODULE_DIR . "/" . ucfirst($module->getCode()) . "/I18n")) { + $dirs[] = $dir; + } } catch (\InvalidArgumentException $e) { // FIXME: process module configuration exception } } + + //Load translation from templates + //admin template + if(is_dir($dir = THELIA_TEMPLATE_DIR . '/admin/default/I18n')) { + $dirs[] = $dir; + } + + //front template + $template = ConfigQuery::getActiveTemplate(); + if(is_dir($dir = THELIA_TEMPLATE_DIR . $template . "/I18n")) { + $dirs[] = $dir; + } + + if ($dirs) { + $finder = Finder::create() + ->files() + ->depth(0) + ->in($dirs); + + foreach ($finder as $file) { + list($locale, $format) = explode('.', $file->getBaseName(), 2); + $translator->addMethodCall('addResource', array($format, (string) $file, $locale)); + } + } } } diff --git a/core/lib/Thelia/Core/Translation/Translator.php b/core/lib/Thelia/Core/Translation/Translator.php index 22dc47afd..444604e28 100755 --- a/core/lib/Thelia/Core/Translation/Translator.php +++ b/core/lib/Thelia/Core/Translation/Translator.php @@ -1,18 +1,28 @@ container = $container; // Allow singleton style calls once intanciated. // For this to work, the Translator service has to be instanciated very early. This is done manually // in TheliaHttpKernel, by calling $this->container->get('thelia.translator'); + parent::__construct(null); self::$instance = $this; } @@ -28,6 +38,11 @@ class Translator extends BaseTranslator return self::$instance; } + public function getLocale() + { + return $this->container->get('request')->getSession()->getLang()->getLocale(); + } + /** * {@inheritdoc} * diff --git a/install/insert.sql b/install/insert.sql index 71dc0c745..7ceb6ce34 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -8,6 +8,7 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat ('session_config.default', '1', 1, 1, NOW(), NOW()), ('verifyStock', '1', 0, 0, NOW(), NOW()), ('active-template', 'default', 0, 0, NOW(), NOW()), +('base-admin-template', 'admin/default', 0, 0, NOW(), NOW()), ('default_lang_without_translation', '1', 1, 1, NOW(), NOW()), ('rewriting_enable', '0', 0, 0, NOW(), NOW()), ('imagine_graphic_driver', 'gd', 0, 0, NOW(), NOW()), diff --git a/local/modules/TheliaDebugBar/AdminIncludes/footer_js.html b/local/modules/TheliaDebugBar/AdminIncludes/footer_js.html new file mode 100644 index 000000000..6f897e091 --- /dev/null +++ b/local/modules/TheliaDebugBar/AdminIncludes/footer_js.html @@ -0,0 +1,4 @@ +{* Include debug bar smarty calls *} + +{debugbar_renderjs} +{debugbar_renderresult} diff --git a/local/modules/TheliaDebugBar/AdminIncludes/head_css.html b/local/modules/TheliaDebugBar/AdminIncludes/head_css.html new file mode 100644 index 000000000..23d047f7e --- /dev/null +++ b/local/modules/TheliaDebugBar/AdminIncludes/head_css.html @@ -0,0 +1,3 @@ +{* Include debug bar smarty calls *} + +{debugbar_rendercss} \ No newline at end of file diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index d2081d829..e84084513 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -26,8 +26,6 @@ {/stylesheets} - {debugbar_rendercss} - {block name="after-bootstrap-css"}{/block} {* -- Admin CSS section ------------------------------------------------- *} @@ -245,11 +243,6 @@ } - - - {debugbar_renderjs} - {debugbar_renderresult} - {block name="after-javascript-include"}{/block} {javascripts file='assets/js/bootstrap/bootstrap.js'} diff --git a/templates/admin/default/configuration.html b/templates/admin/default/configuration.html index ff9622c45..d0e3c880c 100644 --- a/templates/admin/default/configuration.html +++ b/templates/admin/default/configuration.html @@ -165,12 +165,12 @@ {/loop} -{* {loop type="auth" name="pcc8" role="ADMIN" resource="admin.configuration.system-logs" access="VIEW"} + {loop type="auth" name="pcc8" role="ADMIN" resource="admin.configuration.system-logs" access="VIEW"} {intl l='System logs'} - {/loop}*} + {/loop} {module_include location='system_configuration_bottom'} diff --git a/templates/admin/default/includes/admin-utilities-position-block.html b/templates/admin/default/includes/admin-utilities-position-block.html new file mode 100644 index 000000000..c1277f212 --- /dev/null +++ b/templates/admin/default/includes/admin-utilities-position-block.html @@ -0,0 +1,7 @@ +{* +This snippet is used by the AdminUtilities Smarty plugin to generate +the position maagement block in tables +*} + +{$admin_utilities_current_position} + \ No newline at end of file diff --git a/templates/admin/default/includes/admin-utilities-sortable-column-header.html b/templates/admin/default/includes/admin-utilities-sortable-column-header.html new file mode 100644 index 000000000..0dce13492 --- /dev/null +++ b/templates/admin/default/includes/admin-utilities-sortable-column-header.html @@ -0,0 +1,10 @@ +{* +This snippet is used by the AdminUtilities Smarty plugin to generate +the header on a sortable column +*} +{if $admin_utilities_sort_direction == 'up'} + +{else if $admin_utilities_sort_direction == 'down'} + +{/if} +{$admin_utilities_header_text} \ No newline at end of file diff --git a/templates/admin/default/modules.html b/templates/admin/default/modules.html index ca94be812..d82bce399 100644 --- a/templates/admin/default/modules.html +++ b/templates/admin/default/modules.html @@ -9,7 +9,7 @@
- +
{module_include location='modules_top'}