Merge branch 'master' of https://github.com/thelia/thelia
Conflicts: templates/default/login.html
This commit is contained in:
@@ -219,10 +219,10 @@ abstract class BaseLoop
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ModelCriteria $search
|
||||
* @param $pagination
|
||||
* @param ModelCriteria $search
|
||||
* @param $pagination
|
||||
*
|
||||
* @return array|\PropelModelPager
|
||||
* @return array|\Propel\Runtime\Util\PropelModelPager
|
||||
*/
|
||||
protected function searchWithPagination(ModelCriteria $search, &$pagination)
|
||||
{
|
||||
@@ -242,18 +242,21 @@ abstract class BaseLoop
|
||||
* @param array $columns the i18n columns
|
||||
* @param string $foreignTable the specified table (default to criteria table)
|
||||
* @param string $foreignKey the foreign key in this table (default to criteria table)
|
||||
*
|
||||
* @return mixed the locale
|
||||
*/
|
||||
protected function configureI18nProcessing(ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') {
|
||||
protected function configureI18nProcessing(ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID', $forceReturn = false) {
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n(
|
||||
return ModelCriteriaTools::getI18n(
|
||||
$this->getBackend_context(),
|
||||
$this->getLang(),
|
||||
$search,
|
||||
$this->request->getSession()->getLocale(),
|
||||
$columns,
|
||||
$foreignTable,
|
||||
$foreignKey
|
||||
$foreignKey,
|
||||
$forceReturn
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ class Category extends BaseLoop
|
||||
$search = CategoryQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$this->configureI18nProcessing($search);
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -184,7 +184,7 @@ class Category extends BaseLoop
|
||||
->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $category->getParent())
|
||||
->set("URL", $category->getUrl())
|
||||
->set("URL", $category->getUrl($locale))
|
||||
->set("PRODUCT_COUNT", $category->countChild())
|
||||
->set("VISIBLE", $category->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $category->getPosition())
|
||||
|
||||
@@ -87,7 +87,7 @@ class Content extends BaseLoop
|
||||
$search = ContentQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$this->configureI18nProcessing($search);
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -220,7 +220,7 @@ class Content extends BaseLoop
|
||||
->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $content->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("POSITION", $content->getPosition())
|
||||
->set("URL", $content->getUrl())
|
||||
->set("URL", $content->getUrl($locale))
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -87,7 +87,8 @@ class FeatureValue extends BaseLoop
|
||||
$search,
|
||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||
FeatureAvTableMap::TABLE_NAME,
|
||||
'FEATURE_AV_ID'
|
||||
'FEATURE_AV_ID',
|
||||
true
|
||||
);
|
||||
|
||||
$feature = $this->getFeature();
|
||||
|
||||
@@ -79,7 +79,7 @@ class Folder extends BaseLoop
|
||||
$search = FolderQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$this->configureI18nProcessing($search);
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -162,7 +162,7 @@ class Folder extends BaseLoop
|
||||
->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $folder->getParent())
|
||||
->set("URL", $folder->getUrl())
|
||||
->set("URL", $folder->getUrl($locale))
|
||||
->set("CONTENT_COUNT", $folder->countChild())
|
||||
->set("VISIBLE", $folder->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $folder->getPosition())
|
||||
|
||||
@@ -137,7 +137,7 @@ class Product extends BaseLoop
|
||||
$search = ProductQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$this->configureI18nProcessing($search);
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$attributeNonStrictMatch = $this->getAttribute_non_strict_match();
|
||||
$isPSELeftJoinList = array();
|
||||
@@ -514,7 +514,7 @@ class Product extends BaseLoop
|
||||
->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("URL", $product->getUrl())
|
||||
->set("URL", $product->getUrl($locale))
|
||||
->set("BEST_PRICE", $product->getVirtualColumn('real_lowest_price'))
|
||||
->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo'))
|
||||
->set("IS_NEW", $product->getVirtualColumn('main_product_is_new'))
|
||||
|
||||
@@ -40,11 +40,7 @@ class ParserContext implements \IteratorAggregate
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
// Setup basic variables
|
||||
$this
|
||||
->set('BASE_URL' , ConfigQuery::read('base_url', '/'))
|
||||
->set('INDEX_PAGE' , URL::getIndexPage())
|
||||
->set('RETURN_TO_URL' , URL::absoluteUrl($request->getSession()->getReturnToUrl()))
|
||||
->set('THELIA_VERSION' , ConfigQuery::read('thelia_version', 'undefined'))
|
||||
$this->set('THELIA_VERSION' , ConfigQuery::read('thelia_version', 'undefined'))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,14 +47,15 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
public function generateUrlFunction($params, &$smarty)
|
||||
{
|
||||
// the path to process
|
||||
$path = $this->getParam($params, 'path');
|
||||
$path = $this->getParam($params, 'path');
|
||||
|
||||
$target = $this->getParam($params, 'target', null);
|
||||
$target = $this->getParam($params, 'target', null);
|
||||
|
||||
$url = URL::absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target')));
|
||||
$url = URL::absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target')));
|
||||
|
||||
if ($target != null) $url .= '#'.$target;
|
||||
return $url;
|
||||
if ($target != null) $url .= '#'.$target;
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,6 +82,15 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
return $this->generateViewUrlFunction($params, true);
|
||||
}
|
||||
|
||||
public function navigateToUrlFunction($params, &$smarty)
|
||||
{
|
||||
$to = $this->getParam($params, 'to', null);
|
||||
|
||||
$toMethod = $this->getNavigateToMethod($to);
|
||||
|
||||
return $this->$toMethod();
|
||||
}
|
||||
|
||||
protected function generateViewUrlFunction($params, $forAdmin)
|
||||
{
|
||||
// the view name (without .html)
|
||||
@@ -125,7 +135,50 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
return array(
|
||||
new SmartyPluginDescriptor('function', 'url', $this, 'generateUrlFunction'),
|
||||
new SmartyPluginDescriptor('function', 'viewurl', $this, 'generateFrontViewUrlFunction'),
|
||||
new SmartyPluginDescriptor('function', 'admin_viewurl', $this, 'generateAdminViewUrlFunction')
|
||||
new SmartyPluginDescriptor('function', 'admin_viewurl', $this, 'generateAdminViewUrlFunction'),
|
||||
new SmartyPluginDescriptor('function', 'navigate', $this, 'navigateToUrlFunction'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array sur le format "to_value" => "method_name"
|
||||
*/
|
||||
protected function getNavigateToValues()
|
||||
{
|
||||
return array(
|
||||
"current" => "getCurrentUrl",
|
||||
"return_to" => "getReturnToUrl",
|
||||
"index" => "getIndexUrl",
|
||||
);
|
||||
}
|
||||
|
||||
protected function getNavigateToMethod($to)
|
||||
{
|
||||
if($to === null) {
|
||||
throw new \InvalidArgumentException("Missing 'to' parameter in `navigate` substitution.");
|
||||
}
|
||||
|
||||
$navigateToValues = $this->getNavigateToValues();
|
||||
|
||||
if(!array_key_exists($to, $navigateToValues)) {
|
||||
throw new \InvalidArgumentException("Incorrect value for parameter `to` in `navigate` substitution.");
|
||||
}
|
||||
|
||||
return $navigateToValues[$to];
|
||||
}
|
||||
|
||||
protected function getCurrentUrl()
|
||||
{
|
||||
return URL::retrieveCurrent($this->request);
|
||||
}
|
||||
|
||||
protected function getReturnToUrl()
|
||||
{
|
||||
return URL::absoluteUrl($this->request->getSession()->getReturnToUrl());
|
||||
}
|
||||
|
||||
protected function getIndexUrl()
|
||||
{
|
||||
return Url::getIndexPage();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user