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

# By Manuel Raynaud (22) and others
# Via Manuel Raynaud (7) and others
* 'master' of https://github.com/thelia/thelia: (32 commits)
  refactor name for updating actions
  choose UPDATE word for name actions
  add update address action and create tests
  404 not found management
  Working Fix unset namespace
  modify travis script
  test rewriting exception
  Fixed minor bug in Currencies
  Finished currency edition
  Added route methods
  address action implementation
  hot fix
  rewriting
  add address create controller and event
  Added AdminUtilities Smarty plugin, optimized templates
  update customer model createOrUpdate method
  update address model
  fix redirect process in viewListener
  refactor reset_install script
  refactor install process, database management in dedicated class
  ...

Conflicts:
	local/config/schema.xml
	reset_install.sh
This commit is contained in:
gmorel
2013-09-04 15:42:38 +02:00
103 changed files with 4436 additions and 1827 deletions

View File

@@ -0,0 +1,16 @@
<?php
/**
* Created by JetBrains PhpStorm.
* Date: 9/4/13
* Time: 2:55 PM
*
* @author Guillaume MOREL <gmorel@openstudio.fr>
*/
namespace Thelia\Tools;
class I18n
{
}

View File

@@ -25,18 +25,33 @@ namespace Thelia\Tools;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Model\ConfigQuery;
use Thelia\Rewriting\RewritingResolver;
use Thelia\Rewriting\RewritingRetriever;
class URL
{
protected $resolver = null;
protected $retriever = null;
const PATH_TO_FILE = true;
const WITH_INDEX_PAGE = false;
public function __construct()
{
$this->retriever = new RewritingRetriever();
$this->resolver = new RewritingResolver();
}
public static function getIndexPage()
{
return ConfigQuery::read('base_url', '/') . "index_dev.php"; // FIXME !
}
public static function init()
{
return new URL();
}
/**
* Returns the Absolute URL for a given path relative to web root. By default,
* the index.php (or index_dev.php) script name is added to the URL, use
@@ -103,7 +118,7 @@ class URL
*/
public static function viewUrl($viewName, array $parameters = array())
{
$path = sprintf("%s?view=%s", self::getIndexPage(), $viewName);
$path = sprintf("?view=%s", $viewName);
return self::absoluteUrl($path, $parameters);
}
@@ -115,18 +130,17 @@ class URL
*
* @return null|string
*/
public static function retrieve($view, $viewId, $viewLocale)
public function retrieve($view, $viewId, $viewLocale)
{
$rewrittenUrl = null;
if(ConfigQuery::isRewritingEnable()) {
$retriever = new RewritingRetriever();
$rewrittenUrl = $retriever->getViewUrl($view, $viewLocale, $viewId);
$rewrittenUrl = $this->retriever->loadViewUrl($view, $viewLocale, $viewId);
}
return $rewrittenUrl === null ? self::viewUrl($view, array($view . '_id' => $viewId, 'locale' => $viewLocale)) : $rewrittenUrl;
}
public static function retrieveCurrent(Request $request)
public function retrieveCurrent(Request $request)
{
$rewrittenUrl = null;
if(ConfigQuery::isRewritingEnable()) {
@@ -134,12 +148,10 @@ class URL
$viewLocale = $request->query->get('locale', null);
$viewId = $view === null ? null : $request->query->get($view . '_id', null);
$allParameters = $request->query->all();
$allParametersWithoutView = $allParameters;
$allOtherParameters = $request->query->all();
if($view !== null) {
unset($allParametersWithoutView['view']);
unset($allOtherParameters['view']);
}
$allOtherParameters = $allParametersWithoutView;
if($viewLocale !== null) {
unset($allOtherParameters['locale']);
}
@@ -147,10 +159,15 @@ class URL
unset($allOtherParameters[$view . '_id']);
}
$retriever = new RewritingRetriever();
$rewrittenUrl = $retriever->getSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
$this->retriever->loadSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
}
return $rewrittenUrl === null ? self::viewUrl($view, $allParametersWithoutView) : $rewrittenUrl;
return $this->retriever;
}
public function resolve($url)
{
$this->resolver->load($url);
return $this->resolver;
}
}