Merge branch 'master' of github.com:thelia/thelia
This commit is contained in:
@@ -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 <info>%s</info> directory", $cacheDir));
|
||||
|
||||
$fs = new Filesystem();
|
||||
try {
|
||||
$fs->remove($cacheDir);
|
||||
|
||||
$output->writeln("<info>cache cleared successfully</info>");
|
||||
} 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 <info>%s</info> directory", $dir));
|
||||
|
||||
$fs = new Filesystem();
|
||||
try {
|
||||
$fs->remove($dir);
|
||||
|
||||
$output->writeln(sprintf("<info>%s cache dir cleared successfully</info>", $dir));
|
||||
} catch (IOException $e) {
|
||||
$output->writeln(sprintf("error during clearing cache : %s", $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@
|
||||
|
||||
<service id="smarty.plugin.assetic" class="Thelia\Core\Template\Smarty\Plugins\Assetic" >
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
<argument>%kernel.environment%</argument>
|
||||
</service>
|
||||
|
||||
<service id="smarty.plugin.theliasyntax" class="Thelia\Core\Template\Smarty\Plugins\TheliaSyntax" >
|
||||
|
||||
@@ -113,10 +113,19 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\CurrencyController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.currencies.update-position" path="/admin/configuration/currencies/update-position">
|
||||
<route id="admin.configuration.attribute" path="/admin/configuration/product_attributes">
|
||||
<default key="_controller">Thelia\Controller\Admin\AttributeController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<!-- attribute and feature routes management -->
|
||||
|
||||
<route id="admin.configuration.currencies.update-position" path="/admin/configuration/product_attributes">
|
||||
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
<!-- end attribute and feature routes management -->
|
||||
|
||||
<!-- The default route, to display a template -->
|
||||
|
||||
<route id="admin.processTemplate" path="/admin/{template}">
|
||||
|
||||
57
core/lib/Thelia/Controller/Admin/AttributeController.php
Normal file
57
core/lib/Thelia/Controller/Admin/AttributeController.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
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 <franck@cqfdev.fr>
|
||||
*/
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -121,7 +121,7 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
}
|
||||
|
||||
if (! empty($icon))
|
||||
$output = sprintf('<i class="icon icon-chevron-%s"></i> ', $icon);
|
||||
$output = sprintf('<i class="glyphicon glyphicon-chevron-%s"></i> ', $icon);
|
||||
else
|
||||
$output = '';
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user