Merge branch 'master' of github.com:thelia/thelia
This commit is contained in:
@@ -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" >
|
||||
|
||||
@@ -46,16 +46,6 @@ class DefaultController extends BaseFrontController
|
||||
*/
|
||||
public function noAction(Request $request)
|
||||
{
|
||||
if(ConfigQuery::isRewritingEnable()) {
|
||||
|
||||
/* Does the query GET parameters match a rewritten URL ? */
|
||||
$rewrittenUrl = URL::getInstance()->retrieveCurrent($request);
|
||||
if($rewrittenUrl->rewrittenUrl !== null) {
|
||||
/* 301 redirection to rewritten URL */
|
||||
$this->redirect($rewrittenUrl->rewrittenUrl, 301);
|
||||
}
|
||||
}
|
||||
|
||||
$view = null;
|
||||
|
||||
if (! $view = $request->query->get('view')) {
|
||||
@@ -71,5 +61,15 @@ class DefaultController extends BaseFrontController
|
||||
$request->attributes->set("_view", "index");
|
||||
}
|
||||
|
||||
if(ConfigQuery::isRewritingEnable()) {
|
||||
if($request->attributes->get('_rewritten', false) === false) {
|
||||
/* Does the query GET parameters match a rewritten URL ? */
|
||||
$rewrittenUrl = URL::getInstance()->retrieveCurrent($request);
|
||||
if($rewrittenUrl->rewrittenUrl !== null) {
|
||||
/* 301 redirection to rewritten URL */
|
||||
$this->redirect($rewrittenUrl->rewrittenUrl, 301);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ use Thelia\Tools\URL;
|
||||
* Class RewritingRouter
|
||||
* @package Thelia\Core\Routing
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class RewritingRouter implements RouterInterface, RequestMatcherInterface
|
||||
{
|
||||
@@ -170,7 +171,6 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface
|
||||
if(ConfigQuery::isRewritingEnable()) {
|
||||
try {
|
||||
$rewrittenUrlData = URL::getInstance()->resolve($request->getPathInfo());
|
||||
var_dump($rewrittenUrlData); exit;
|
||||
} catch(UrlRewritingException $e) {
|
||||
switch($e->getCode()) {
|
||||
case UrlRewritingException::URL_NOT_FOUND :
|
||||
@@ -205,13 +205,14 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface
|
||||
|
||||
return array (
|
||||
'_controller' => 'Thelia\\Controller\\Front\\DefaultController::noAction',
|
||||
'_route' => 'rewrite'
|
||||
'_route' => 'rewrite',
|
||||
'_rewritten' => true,
|
||||
);
|
||||
}
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
protected function redirect($url, $code = 302)
|
||||
protected function redirect($url, $status = 302)
|
||||
{
|
||||
Redirect::exec($url, $status);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -68,14 +68,14 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides access to user attributes using the accessors.
|
||||
* @param $objectLabel
|
||||
* @param $user
|
||||
* @param $params
|
||||
*
|
||||
* @param array $params
|
||||
* @param unknown $smarty
|
||||
* @return string the value of the requested attribute
|
||||
* @throws InvalidArgumentException if the object does not have the requested attribute.
|
||||
* @return string
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function userDataAccess($objectLabel, $user, $params)
|
||||
protected function userDataAccess($objectLabel, $user, $params)
|
||||
{
|
||||
$attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr'));
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
|
||||
protected function getCurrentUrl()
|
||||
{
|
||||
return URL::getInstance()->retrieveCurrent()->toString();
|
||||
return URL::getInstance()->retrieveCurrent($this->request)->toString();
|
||||
}
|
||||
|
||||
protected function getReturnToUrl()
|
||||
|
||||
@@ -58,6 +58,8 @@ class RewritingResolver
|
||||
|
||||
public function load($rewrittenUrl)
|
||||
{
|
||||
$rewrittenUrl = ltrim($rewrittenUrl, '/');
|
||||
|
||||
$this->search = $this->rewritingUrlQuery->getResolverSearch($rewrittenUrl);
|
||||
|
||||
if($this->search->count() == 0) {
|
||||
|
||||
@@ -66,6 +66,7 @@ class RewritingRetriever
|
||||
$allParametersWithoutView[$view . '_id'] = $viewId;
|
||||
}
|
||||
|
||||
$this->rewrittenUrl = null;
|
||||
$this->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
|
||||
if($this->search !== null) {
|
||||
$this->rewrittenUrl = $this->search->getUrl();
|
||||
@@ -93,6 +94,7 @@ class RewritingRetriever
|
||||
$allParametersWithoutView[$view . '_id'] = $viewId;
|
||||
}
|
||||
|
||||
$this->rewrittenUrl = null;
|
||||
$this->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
|
||||
if($this->search !== null) {
|
||||
$this->rewrittenUrl = $this->search->getUrl();
|
||||
|
||||
@@ -204,20 +204,20 @@ class URL
|
||||
public function retrieveCurrent(Request $request)
|
||||
{
|
||||
if(ConfigQuery::isRewritingEnable()) {
|
||||
$view = $request->query->get('view', null);
|
||||
$view = $request->attributes->get('_view', null);
|
||||
$viewLocale = $request->query->get('locale', null);
|
||||
$viewId = $view === null ? null : $request->query->get($view . '_id', null);
|
||||
|
||||
$allOtherParameters = $request->query->all();
|
||||
if($view !== null) {
|
||||
unset($allOtherParameters['view']);
|
||||
if($viewId !== null) {
|
||||
unset($allOtherParameters[$view . '_id']);
|
||||
}
|
||||
}
|
||||
if($viewLocale !== null) {
|
||||
unset($allOtherParameters['locale']);
|
||||
}
|
||||
if($viewId !== null) {
|
||||
unset($allOtherParameters[$view . '_id']);
|
||||
}
|
||||
|
||||
$this->retriever->loadSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,4 @@
|
||||
|
||||
/* Thelia Admin */
|
||||
@import "thelia/thelia.less";
|
||||
// @import "thelia/responsive.less";
|
||||
|
||||
//mmm
|
||||
// @import "thelia/responsive.less";
|
||||
@@ -1,11 +1,2 @@
|
||||
<h2>ALL ATTRIBUTES</h2>
|
||||
|
||||
<ul>
|
||||
{loop name="attr" type="attribute"}
|
||||
<li>
|
||||
#TITLE - (#LOOP_COUNT / #LOOP_TOTAL)<br />
|
||||
created at {format_date date=$CREATE_DATE} - updated at {format_date date=$UPDATE_DATE}
|
||||
<hr />
|
||||
</li>
|
||||
{/loop}
|
||||
</ul>
|
||||
::{customer attr="firstname"};;
|
||||
::{customer attr="titleId"};;
|
||||
Reference in New Issue
Block a user