diff --git a/core/lib/Thelia/Command/CacheClear.php b/core/lib/Thelia/Command/CacheClear.php index 82a7cbd7f..37e853f05 100755 --- a/core/lib/Thelia/Command/CacheClear.php +++ b/core/lib/Thelia/Command/CacheClear.php @@ -24,6 +24,7 @@ namespace Thelia\Command; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Exception\IOException; @@ -44,7 +45,14 @@ class CacheClear extends ContainerAwareCommand { $this ->setName("cache:clear") - ->setDescription("Invalidate all caches"); + ->setDescription("Invalidate all caches") + ->addOption( + "without-assets", + null, + InputOption::VALUE_NONE, + "remove cache assets" + ) + ; } protected function execute(InputInterface $input, OutputInterface $output) @@ -52,20 +60,28 @@ class CacheClear extends ContainerAwareCommand $cacheDir = $this->getContainer()->getParameter("kernel.cache_dir"); - if (!is_writable($cacheDir)) { - throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $cacheDir)); - } - - $output->writeln(sprintf("Clearing cache in %s directory", $cacheDir)); - - $fs = new Filesystem(); - try { - $fs->remove($cacheDir); - - $output->writeln("cache cleared successfully"); - } catch (IOException $e) { - $output->writeln(sprintf("error during clearing cache : %s", $e->getMessage())); + $this->clearCache($cacheDir, $output); + if(!$input->getOption("without-assets")) { + $this->clearCache(THELIA_WEB_DIR . "/assets", $output); } } + + protected function clearCache($dir, OutputInterface $output) + { + if (!is_writable($dir)) { + throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $dir)); + } + + $output->writeln(sprintf("Clearing cache in %s directory", $dir)); + + $fs = new Filesystem(); + try { + $fs->remove($dir); + + $output->writeln(sprintf("%s cache dir cleared successfully", $dir)); + } catch (IOException $e) { + $output->writeln(sprintf("error during clearing cache : %s", $e->getMessage())); + } + } } diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 030d0374a..974de091c 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -129,6 +129,7 @@ + %kernel.environment% diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 313fb3a57..2257a9459 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -113,10 +113,19 @@ Thelia\Controller\Admin\CurrencyController::deleteAction - + + Thelia\Controller\Admin\AttributeController::defaultAction + + + + + Thelia\Controller\Admin\CurrencyController::updatePositionAction + + + diff --git a/core/lib/Thelia/Controller/Admin/AttributeController.php b/core/lib/Thelia/Controller/Admin/AttributeController.php new file mode 100644 index 000000000..d2c1ea351 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/AttributeController.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\MessageDeleteEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Tools\URL; +use Thelia\Core\Event\MessageUpdateEvent; +use Thelia\Core\Event\MessageCreateEvent; +use Thelia\Log\Tlog; +use Thelia\Form\Exception\FormValidationException; +use Thelia\Core\Security\Exception\AuthorizationException; +use Thelia\Model\MessageQuery; +use Thelia\Form\MessageModificationForm; +use Thelia\Form\MessageCreationForm; + +/** + * Manages messages sent by mail + * + * @author Franck Allimant + */ +class AttributeController extends BaseAdminController +{ + /** + * The default action is displaying the messages list. + * + * @return Symfony\Component\HttpFoundation\Response the response + */ + public function defaultAction() { + + if (null !== $response = $this->checkAuth("admin.configuration.attributes.view")) return $response; + + return $this->render('product_attributes'); + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/ConfigController.php index a67ecbaaa..b84368c2f 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigController.php +++ b/core/lib/Thelia/Controller/Admin/ConfigController.php @@ -241,7 +241,7 @@ class ConfigController extends BaseAdminController if ($this->getRequest()->get('save_mode') == 'stay') { $this->redirectToRoute( - "admin.configuration.variables.change", + "admin.configuration.variables.update", array('variable_id' => $variable_id) ); } diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 853776214..5fbcc56d2 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -215,7 +215,7 @@ class BaseController extends ContainerAware $route = $this->container->get($routerName)->getRouteCollection()->get($routeId); if ($route == null) { - throw new InvalidArgumentException(sprintf("Route ID '%s' does not exists.", $routeId)); + throw new \InvalidArgumentException(sprintf("Route ID '%s' does not exists.", $routeId)); } return $route->getPath(); diff --git a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php index fbb93440a..cd7f06ac8 100755 --- a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php +++ b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php @@ -43,15 +43,16 @@ class AsseticHelper * Generates assets from $asset_path in $output_path, using $filters. * * @param string $asset_path the full path to the asset file (or file collection) - * @param unknown $output_path the full disk path to the output directory (shoud be visible to web server) - * @param unknown $output_url the URL to the generated asset directory - * @param unknown $asset_type the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension. - * @param unknown $filters a list of filters, as defined below (see switch($filter_name) ...) - * @param unknown $debug true / false + * @param string $output_path the full disk path to the output directory (shoud be visible to web server) + * @param string $output_url the URL to the generated asset directory + * @param string $asset_type the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension. + * @param array $filters a list of filters, as defined below (see switch($filter_name) ...) + * @param boolean $debug true / false + * @param boolean $dev_mode true / false. If true, assets are not cached and always compiled. * @throws \InvalidArgumentException if an invalid filter name is found * @return string The URL to the generated asset file. */ - public function asseticize($asset_path, $output_path, $output_url, $asset_type, $filters, $debug) + public function asseticize($asset_path, $output_path, $output_url, $asset_type, $filters, $debug, $dev_mode = false) { $asset_name = basename($asset_path); $asset_dir = dirname($asset_path); @@ -112,6 +113,7 @@ class AsseticHelper $asset = $factory->createAsset($asset_name); $asset_target_path = $asset->getTargetPath(); + $target_file = sprintf("%s/%s", $output_path, $asset_target_path); // As it seems that assetic cannot handle a real file cache, let's do the job ourselves. @@ -124,7 +126,7 @@ class AsseticHelper // // before generating 3bc974a-ad3ef47.css, delete 3bc974a-* files. // - if (! file_exists($target_file)) { + if ($dev_mode == true || ! file_exists($target_file)) { // Delete previous version of the file list($commonPart, $dummy) = explode('-', $asset_target_path); @@ -143,8 +145,6 @@ class AsseticHelper } } - //$cache = new AssetCache($asset, new FilesystemCache($output_path)); - $writer = new AssetWriter($output_path); $writer->writeAsset($asset); diff --git a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php index 17fe122d3..f19eded95 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php +++ b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php @@ -34,18 +34,22 @@ class SmartyAssetsManager private $web_root; private $path_relative_to_web_root; + private $developmentMode; /** * Creates a new SmartyAssetsManager instance * - * @param string $web_root the disk path to the web root - * @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated + * @param string $web_root the disk path to the web root + * @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated + * @param boolean $developmentMode true / false. If true, assets are not cached, and always generated. */ - public function __construct($web_root, $path_relative_to_web_root) + public function __construct($web_root, $path_relative_to_web_root, $developmentMode) { $this->web_root = $web_root; $this->path_relative_to_web_root = $path_relative_to_web_root; + $this->developmentMode = $developmentMode; + $this->assetic_manager = new AsseticHelper(); } @@ -73,7 +77,8 @@ class SmartyAssetsManager URL::getInstance()->absoluteUrl($this->path_relative_to_web_root, null, URL::PATH_TO_FILE /* path only */), $assetType, $filters, - $debug + $debug, + $this->developmentMode ); return $url; diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php index 12ac13276..bb9770520 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php @@ -121,7 +121,7 @@ class AdminUtilities extends AbstractSmartyPlugin } if (! empty($icon)) - $output = sprintf(' ', $icon); + $output = sprintf(' ', $icon); else $output = ''; diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php index f8ea1c2ef..b7bb95b83 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php @@ -32,13 +32,13 @@ class Assetic extends AbstractSmartyPlugin { public $assetManager; - public function __construct() + public function __construct($developmentMode) { $web_root = THELIA_WEB_DIR; $asset_dir_from_web_root = ConfigQuery::read('asset_dir_from_web_root', 'assets'); - $this->assetManager = new SmartyAssetsManager($web_root, $asset_dir_from_web_root); + $this->assetManager = new SmartyAssetsManager($web_root, $asset_dir_from_web_root, $developmentMode == 'dev'); } public function blockJavascripts($params, $content, \Smarty_Internal_Template $template, &$repeat) diff --git a/core/lib/Thelia/Form/BaseDescForm.php b/core/lib/Thelia/Form/BaseDescForm.php index c4f4f90c3..2b35f3e6e 100644 --- a/core/lib/Thelia/Form/BaseDescForm.php +++ b/core/lib/Thelia/Form/BaseDescForm.php @@ -43,12 +43,31 @@ abstract class BaseDescForm extends BaseForm ->add("title", "text", array( "constraints" => array( new NotBlank() + ), + "label" => "Title", + "label_attr" => array( + "for" => "title" ) ) ) - ->add("chapo", "text", array()) - ->add("description", "text", array()) - ->add("postscriptum", "text", array()) + ->add("chapo", "text", array( + "label" => "Summary", + "label_attr" => array( + "for" => "summary" + ) + )) + ->add("description", "text", array( + "label" => "Detailed description", + "label_attr" => array( + "for" => "detailed_description" + ) + )) + ->add("postscriptum", "text", array( + "label" => "Conclusion", + "label_attr" => array( + "for" => "conclusion" + ) + )) ; } } \ No newline at end of file diff --git a/core/lib/Thelia/Form/CategoryCreationForm.php b/core/lib/Thelia/Form/CategoryCreationForm.php index 9935eec19..a125ad090 100755 --- a/core/lib/Thelia/Form/CategoryCreationForm.php +++ b/core/lib/Thelia/Form/CategoryCreationForm.php @@ -32,6 +32,10 @@ class CategoryCreationForm extends BaseForm ->add("title", "text", array( "constraints" => array( new NotBlank() + ), + "label" => "Category title *", + "label_attr" => array( + "for" => "title" ) )) ->add("parent", "integer", array( diff --git a/core/lib/Thelia/Form/ConfigCreationForm.php b/core/lib/Thelia/Form/ConfigCreationForm.php index 5594830bc..b2a0c11bb 100644 --- a/core/lib/Thelia/Form/ConfigCreationForm.php +++ b/core/lib/Thelia/Form/ConfigCreationForm.php @@ -40,11 +40,19 @@ class ConfigCreationForm extends BaseForm $this->formBuilder ->add("name", "text", array( - "constraints" => $name_constraints + "constraints" => $name_constraints, + "label" => "Name *", + "label_attr" => array( + "for" => "name" + ) )) ->add("title", "text", array( "constraints" => array( new Constraints\NotBlank() + ), + "label" => "Purpose *", + "label_attr" => array( + "for" => "purpose" ) )) ->add("locale", "hidden", array( @@ -52,9 +60,16 @@ class ConfigCreationForm extends BaseForm new Constraints\NotBlank() ) )) - ->add("value", "text", array()) + ->add("value", "text", array( + "label" => "Value *", + "label_attr" => array( + "for" => "value" + ) + )) ->add("hidden", "hidden", array()) - ->add("secured", "hidden", array()) + ->add("secured", "hidden", array( + "label" => "Prevent variable modification or deletion, except for super-admin" + )) ; } diff --git a/core/lib/Thelia/Form/ConfigModificationForm.php b/core/lib/Thelia/Form/ConfigModificationForm.php index dd0a0e42f..295c0403d 100644 --- a/core/lib/Thelia/Form/ConfigModificationForm.php +++ b/core/lib/Thelia/Form/ConfigModificationForm.php @@ -44,11 +44,22 @@ class ConfigModificationForm extends BaseDescForm ->add("name", "text", array( "constraints" => array( new NotBlank() + ), + "label" => "Name", + "label_attr" => array( + "for" => "name" + ) + )) + ->add("value", "text", array( + "label" => "Value", + "label_attr" => array( + "for" => "value" ) )) - ->add("value", "text", array()) ->add("hidden", "hidden", array()) - ->add("secured", "hidden", array()) + ->add("secured", "hidden", array( + "label" => "Prevent variable modification or deletion, except for super-admin" + )) ; } diff --git a/core/lib/Thelia/Form/MessageCreationForm.php b/core/lib/Thelia/Form/MessageCreationForm.php index a3444c733..6ce84cb06 100644 --- a/core/lib/Thelia/Form/MessageCreationForm.php +++ b/core/lib/Thelia/Form/MessageCreationForm.php @@ -40,11 +40,19 @@ class MessageCreationForm extends BaseForm $this->formBuilder ->add("name", "text", array( - "constraints" => $name_constraints + "constraints" => $name_constraints, + "label" => "Name *", + "label_attr" => array( + "for" => "name" + ) )) ->add("title", "text", array( "constraints" => array( new Constraints\NotBlank() + ), + "label" => "Purpose *", + "label_attr" => array( + "for" => "purpose" ) )) ->add("locale", "hidden", array( diff --git a/core/lib/Thelia/Form/MessageModificationForm.php b/core/lib/Thelia/Form/MessageModificationForm.php index 539a8babc..a23f66e28 100644 --- a/core/lib/Thelia/Form/MessageModificationForm.php +++ b/core/lib/Thelia/Form/MessageModificationForm.php @@ -33,13 +33,43 @@ class MessageModificationForm extends BaseForm { $this->formBuilder ->add("id" , "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) - ->add("name" , "text" , array("constraints" => array(new NotBlank()))) - ->add("secured" , "text" , array()) + ->add("name" , "text" , array( + "constraints" => array(new NotBlank()), + "label" => "Name *", + "label_attr" => array( + "for" => "name" + ) + )) + ->add("secured" , "text" , array( + "label" => "Prevent mailing template modification or deletion, except for super-admin" + )) ->add("locale" , "text" , array()) - ->add("title" , "text" , array("constraints" => array(new NotBlank()))) - ->add("subject" , "text" , array("constraints" => array(new NotBlank()))) - ->add("html_message" , "text" , array()) - ->add("text_message" , "text" , array()) + ->add("title" , "text" , array( + "constraints" => array(new NotBlank()), + "label" => "Title *", + "label_attr" => array( + "for" => "title" + ) + )) + ->add("subject" , "text" , array( + "constraints" => array(new NotBlank()), + "label" => "Message subject *", + "label_attr" => array( + "for" => "subject" + ) + )) + ->add("html_message" , "text" , array( + "label" => "HTML Message", + "label_attr" => array( + "for" => "html_message" + ) + )) + ->add("text_message" , "text" , array( + "label" => "Text Message", + "label_attr" => array( + "for" => "text_message" + ) + )) ; } diff --git a/core/lib/Thelia/Tests/Command/CacheClearTest.php b/core/lib/Thelia/Tests/Command/CacheClearTest.php index ed2e512b6..741fad299 100755 --- a/core/lib/Thelia/Tests/Command/CacheClearTest.php +++ b/core/lib/Thelia/Tests/Command/CacheClearTest.php @@ -47,6 +47,7 @@ class CacheClearTest extends \PHPUnit_Framework_TestCase $fs = new Filesystem(); $fs->mkdir($this->cache_dir); + $fs->mkdir(THELIA_WEB_DIR . "/assets"); } public function testCacheClear() diff --git a/templates/admin/default/assets/img/flags/en.gif b/templates/admin/default/assets/img/flags/en.gif index 3a7661fdb..91b2b0090 100755 Binary files a/templates/admin/default/assets/img/flags/en.gif and b/templates/admin/default/assets/img/flags/en.gif differ diff --git a/templates/admin/default/assets/img/flags/es.gif b/templates/admin/default/assets/img/flags/es.gif index 9ac64ad37..bdf09f8f7 100755 Binary files a/templates/admin/default/assets/img/flags/es.gif and b/templates/admin/default/assets/img/flags/es.gif differ diff --git a/templates/admin/default/assets/img/flags/fr.gif b/templates/admin/default/assets/img/flags/fr.gif index 46f4d122d..2f6cf9ea3 100755 Binary files a/templates/admin/default/assets/img/flags/fr.gif and b/templates/admin/default/assets/img/flags/fr.gif differ diff --git a/templates/admin/default/assets/img/flags/it.gif b/templates/admin/default/assets/img/flags/it.gif index fddb02499..cdd750a54 100755 Binary files a/templates/admin/default/assets/img/flags/it.gif and b/templates/admin/default/assets/img/flags/it.gif differ diff --git a/templates/admin/default/assets/js/bootstrap-switch/bootstrap-switch.js b/templates/admin/default/assets/js/bootstrap-switch/bootstrap-switch.js new file mode 100644 index 000000000..1538f9df1 --- /dev/null +++ b/templates/admin/default/assets/js/bootstrap-switch/bootstrap-switch.js @@ -0,0 +1,382 @@ +/*! ============================================================ + * bootstrapSwitch v1.8 by Larentis Mattia @SpiritualGuru + * http://www.larentis.eu/ + * + * Enhanced for radiobuttons by Stein, Peter @BdMdesigN + * http://www.bdmdesign.org/ + * + * Project site: + * http://www.larentis.eu/switch/ + * ============================================================ + * Licensed under the Apache License, Version 2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * ============================================================ */ + +!function ($) { + "use strict"; + + $.fn['bootstrapSwitch'] = function (method) { + var inputSelector = 'input[type!="hidden"]'; + var methods = { + init: function () { + return this.each(function () { + var $element = $(this) + , $div + , $switchLeft + , $switchRight + , $label + , $form = $element.closest('form') + , myClasses = "" + , classes = $element.attr('class') + , color + , moving + , onLabel = "ON" + , offLabel = "OFF" + , icon = false + , textLabel = false; + + $.each(['switch-mini', 'switch-small', 'switch-large'], function (i, el) { + if (classes.indexOf(el) >= 0) + myClasses = el; + }); + + $element.addClass('has-switch'); + + if ($element.data('on') !== undefined) + color = "switch-" + $element.data('on'); + + if ($element.data('on-label') !== undefined) + onLabel = $element.data('on-label'); + + if ($element.data('off-label') !== undefined) + offLabel = $element.data('off-label'); + + if ($element.data('label-icon') !== undefined) + icon = $element.data('label-icon'); + + if ($element.data('text-label') !== undefined) + textLabel = $element.data('text-label'); + + $switchLeft = $('') + .addClass("switch-left") + .addClass(myClasses) + .addClass(color) + .html(onLabel); + + color = ''; + if ($element.data('off') !== undefined) + color = "switch-" + $element.data('off'); + + $switchRight = $('') + .addClass("switch-right") + .addClass(myClasses) + .addClass(color) + .html(offLabel); + + $label = $('