Merge branch 'master' of https://github.com/thelia/thelia into coupon

# By franck (9) and others
# Via franck (3) and Etienne Roudeix (1)
* 'master' of https://github.com/thelia/thelia:
  Added get/setLangId() method in session
  Refactored VariableXxxxx.php as ConfigXxxx.php
  Added name duplication check when creating a variable
  Completed the backoffice variable management
  update propel version and dependencies
  add some phpdoc
  Fixed getUrl()
  Typo :(
  Intriducec BaseI18nLoop, started variable config management
  Fixed URL::absoluteUrl()
  Fixed customer front controller, events, addec admion config.
  rewriting
  specific rewrittend url retrievement
  product page
  url global substitution
  sid : rewriting
  rewriting tables
  start rewriting

Conflicts:
	core/lib/Thelia/Config/Resources/routing/admin.xml
	core/lib/Thelia/Core/Event/TheliaEvents.php
This commit is contained in:
gmorel
2013-09-02 09:19:24 +02:00
129 changed files with 3787 additions and 814 deletions

View File

@@ -23,7 +23,9 @@
namespace Thelia\Tools;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Model\ConfigQuery;
use Thelia\Rewriting\RewritingRetriever;
class URL
{
@@ -51,13 +53,17 @@ class URL
// Already absolute ?
if (substr($path, 0, 4) != 'http') {
/**
* @etienne : can't be done here for it's already done in ::viewUrl / ::adminViewUrl
* @franck : should be done, as absoluteUrl() is sometimes called directly (see UrlGenerator::generateUrlFunction())
*/
$root = $path_only == self::PATH_TO_FILE ? ConfigQuery::read('base_url', '/') : self::getIndexPage();
//$root = $path_only == self::PATH_TO_FILE ? ConfigQuery::read('base_url', '/') : '';
$base = rtrim($root, '/') . '/' . ltrim($path, '/');
} else
$base = $path;
$queryString = '';
if (! is_null($parameters)) {
@@ -101,4 +107,50 @@ class URL
return self::absoluteUrl($path, $parameters);
}
/**
* @param $view
* @param $viewId
* @param $viewLocale
*
* @return null|string
*/
public static function retrieve($view, $viewId, $viewLocale)
{
$rewrittenUrl = null;
if(ConfigQuery::isRewritingEnable()) {
$retriever = new RewritingRetriever();
$rewrittenUrl = $retriever->getViewUrl($view, $viewLocale, $viewId);
}
return $rewrittenUrl === null ? self::viewUrl($view, array($view . '_id' => $viewId, 'locale' => $viewLocale)) : $rewrittenUrl;
}
public static function retrieveCurrent(Request $request)
{
$rewrittenUrl = null;
if(ConfigQuery::isRewritingEnable()) {
$view = $request->query->get('view', null);
$viewLocale = $request->query->get('locale', null);
$viewId = $view === null ? null : $request->query->get($view . '_id', null);
$allParameters = $request->query->all();
$allParametersWithoutView = $allParameters;
if($view !== null) {
unset($allParametersWithoutView['view']);
}
$allOtherParameters = $allParametersWithoutView;
if($viewLocale !== null) {
unset($allOtherParameters['locale']);
}
if($viewId !== null) {
unset($allOtherParameters[$view . '_id']);
}
$retriever = new RewritingRetriever();
$rewrittenUrl = $retriever->getSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
}
return $rewrittenUrl === null ? self::viewUrl($view, $allParametersWithoutView) : $rewrittenUrl;
}
}