Merge branch 'master' of github.com:thelia/thelia
Conflicts: core/lib/Thelia/Config/Resources/routing/front.xml
This commit is contained in:
@@ -34,6 +34,8 @@ use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\CurrencyChangeEvent;
|
||||
use Thelia\Core\Event\CurrencyCreateEvent;
|
||||
use Thelia\Core\Event\CurrencyDeleteEvent;
|
||||
use Thelia\Model\Map\CurrencyTableMap;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
class Currency extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
@@ -53,11 +55,12 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
->setName($event->getCurrencyName())
|
||||
->setSymbol($event->getSymbol())
|
||||
->setRate($event->getRate())
|
||||
->setCode($event->getCode())
|
||||
->setCode(strtoupper($event->getCode()))
|
||||
|
||||
->save()
|
||||
;
|
||||
|
||||
|
||||
$event->setCurrency($currency);
|
||||
}
|
||||
|
||||
@@ -79,7 +82,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
->setName($event->getCurrencyName())
|
||||
->setSymbol($event->getSymbol())
|
||||
->setRate($event->getRate())
|
||||
->setCode($event->getCode())
|
||||
->setCode(strtoupper($event->getCode()))
|
||||
|
||||
->save();
|
||||
|
||||
@@ -87,6 +90,32 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default currency
|
||||
*
|
||||
* @param CurrencyChangeEvent $event
|
||||
*/
|
||||
public function setDefault(CurrencyChangeEvent $event)
|
||||
{
|
||||
$search = CurrencyQuery::create();
|
||||
|
||||
if (null !== $currency = CurrencyQuery::create()->findOneById($event->getCurrencyId())) {
|
||||
|
||||
if ($currency->getByDefault() != $event->getIsDefault()) {
|
||||
|
||||
// Reset default status
|
||||
CurrencyQuery::create()->filterByByDefault(true)->update(array('ByDefault' => false));
|
||||
|
||||
$currency
|
||||
->setByDefault($event->getIsDefault())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
|
||||
$event->setCurrency($currency);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a currencyuration entry
|
||||
*
|
||||
@@ -106,15 +135,41 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function updateRates() {
|
||||
|
||||
$rates_url = ConfigQuery::read('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml');
|
||||
|
||||
$rate_data = file_get_contents($rates_url);
|
||||
|
||||
if ($rate_data && $sxe = new \SimpleXMLElement($rate_data)) {
|
||||
|
||||
foreach ($sxe->Cube[0]->Cube[0]->Cube as $last)
|
||||
{
|
||||
$code = strtoupper($last["currency"]);
|
||||
$rate = floatval($last['rate']);
|
||||
|
||||
if (null !== $currency = CurrencyQuery::create()->findOneByCode($code)) {
|
||||
$currency->setRate($rate)->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new \RuntimeException(sprintf("Failed to get currency rates data from URL %s", $url));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::CURRENCY_CREATE => array("create", 128),
|
||||
TheliaEvents::CURRENCY_MODIFY => array("modify", 128),
|
||||
TheliaEvents::CURRENCY_DELETE => array("delete", 128),
|
||||
TheliaEvents::CURRENCY_CREATE => array("create", 128),
|
||||
TheliaEvents::CURRENCY_MODIFY => array("modify", 128),
|
||||
TheliaEvents::CURRENCY_DELETE => array("delete", 128),
|
||||
TheliaEvents::CURRENCY_SET_DEFAULT => array("setDefault", 128),
|
||||
TheliaEvents::CURRENCY_UPDATE_RATES => array("updateRates", 128),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
84
core/lib/Thelia/Action/PageNotFound.php
Executable file
84
core/lib/Thelia/Action/PageNotFound.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?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\Action;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class PageNotFound
|
||||
* @package Thelia\Action
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class PageNotFound extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
public function display404(GetResponseForExceptionEvent $event)
|
||||
{
|
||||
if(is_a($event->getException(), 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException')) {
|
||||
|
||||
$parser = $this->container->get("thelia.parser");
|
||||
|
||||
// Define the template thant shoud be used
|
||||
$parser->setTemplate(ConfigQuery::getActiveTemplate());
|
||||
|
||||
//$event->getRequest()->attributes->set('_view', ConfigQuery::getPageNotFoundView());
|
||||
|
||||
$response = new Response($parser->render(ConfigQuery::getPageNotFoundView()), 404);
|
||||
|
||||
$event->setResponse($response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
*
|
||||
* The array keys are event names and the value can be:
|
||||
*
|
||||
* * The method name to call (priority defaults to 0)
|
||||
* * An array composed of the method name to call and the priority
|
||||
* * An array of arrays composed of the method names to call and respective
|
||||
* priorities, or 0 if unset
|
||||
*
|
||||
* For instance:
|
||||
*
|
||||
* * array('eventName' => 'methodName')
|
||||
* * array('eventName' => array('methodName', $priority))
|
||||
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
|
||||
*
|
||||
* @return array The event names to listen to
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
KernelEvents::EXCEPTION => array("display404", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,11 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.pageNotFound" class="Thelia\Action\PageNotFound">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
</services>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -167,17 +167,23 @@
|
||||
<argument type="service" id="request"/>
|
||||
</service>
|
||||
|
||||
<service id="smarty.plugin.security" class="Thelia\Core\Template\Smarty\Plugins\Security" scope="request">
|
||||
<service id="smarty.plugin.security" class="Thelia\Core\Template\Smarty\Plugins\Security" scope="request">
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
<argument type="service" id="thelia.securityContext" />
|
||||
</service>
|
||||
|
||||
<service id="smarty.plugin.dataAccess" class="Thelia\Core\Template\Smarty\Plugins\DataAccessFunctions" scope="request">
|
||||
<service id="smarty.plugin.dataAccess" class="Thelia\Core\Template\Smarty\Plugins\DataAccessFunctions" scope="request">
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
<argument type="service" id="thelia.securityContext" />
|
||||
<argument type="service" id="thelia.parser.context"/>
|
||||
</service>
|
||||
|
||||
<service id="smarty.plugin.adminUtilities" class="Thelia\Core\Template\Smarty\Plugins\AdminUtilities" scope="request">
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
<argument type="service" id="thelia.securityContext" />
|
||||
</service>
|
||||
|
||||
|
||||
<service id="http_kernel" class="Thelia\Core\TheliaHttpKernel">
|
||||
<argument type="service" id="event_dispatcher" />
|
||||
<argument type="service" id="service_container" />
|
||||
|
||||
@@ -101,6 +101,14 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\CurrencyController::saveChangeAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.currencies.set-default" path="/admin/configuration/currencies/set-default">
|
||||
<default key="_controller">Thelia\Controller\Admin\CurrencyController::setDefaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.currencies.update-rates" path="/admin/configuration/currencies/update-rates">
|
||||
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updateRatesAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.currencies.delete" path="/admin/configuration/currencies/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\CurrencyController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
@@ -49,5 +49,8 @@
|
||||
<default key="_controller">Thelia\Controller\Front\CartController::changeItem</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
<!-- end cart routes -->
|
||||
|
||||
<route id="url-rewriting.check" path="/{rewritten_url}" methods="GET">
|
||||
<default key="_controller">Thelia\Controller\Front\UrlRewritingController::check</default>
|
||||
</route>
|
||||
</routes>
|
||||
|
||||
@@ -150,12 +150,33 @@ class BaseAdminController extends BaseController
|
||||
return $this->container->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the route path defined for the givent route ID
|
||||
*
|
||||
* @param string $routeId a route ID, as defines in Config/Resources/routing/admin.xml
|
||||
*
|
||||
* @see \Thelia\Controller\BaseController::getRouteFromRouter()
|
||||
*/
|
||||
protected function getRoute($routeId) {
|
||||
return $this->getRouteFromRouter('router.admin', $routeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to à route ID related URL
|
||||
*
|
||||
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
|
||||
* @param unknown $urlParameters the URL parametrs, as a var/value pair array
|
||||
*/
|
||||
public function redirectToRoute($routeId, $urlParameters = array()) {
|
||||
$this->redirect(URL::absoluteUrl($this->getRoute($routeId), $urlParameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current edition lang ID, checking if a change was requested in the current request
|
||||
*/
|
||||
protected function getCurrentEditionLangId() {
|
||||
return $this->getRequest()->get(
|
||||
'edition_language',
|
||||
'edit_language_id',
|
||||
$this->getSession()->getAdminEditionLangId()
|
||||
);
|
||||
}
|
||||
@@ -196,29 +217,32 @@ class BaseAdminController extends BaseController
|
||||
|
||||
$session = $this->getSession();
|
||||
|
||||
// Find the current edit language ID
|
||||
$edition_language = $this->getCurrentEditionLangId();
|
||||
|
||||
// Current back-office (not edition) language
|
||||
$current_lang = LangQuery::create()->findOneById($session->getLangId());
|
||||
$current_lang = LangQuery::create()->findOneById($session->getLangId());
|
||||
|
||||
// Find the current edit language ID
|
||||
$edition_language = LangQuery::create()->findOneById($this->getCurrentEditionLangId());
|
||||
|
||||
// Prepare common template variables
|
||||
$args = array_merge($args, array(
|
||||
'locale' => $session->getLocale(),
|
||||
'lang_code' => $session->getLang(),
|
||||
'lang_id' => $session->getLangId(),
|
||||
'locale' => $session->getLocale(),
|
||||
'lang_code' => $session->getLang(),
|
||||
'lang_id' => $session->getLangId(),
|
||||
|
||||
'datetime_format' => $current_lang->getDateTimeFormat(),
|
||||
'date_format' => $current_lang->getDateFormat(),
|
||||
'time_format' => $current_lang->getTimeFormat(),
|
||||
'datetime_format' => $current_lang->getDateTimeFormat(),
|
||||
'date_format' => $current_lang->getDateFormat(),
|
||||
'time_format' => $current_lang->getTimeFormat(),
|
||||
|
||||
'edition_language' => $edition_language,
|
||||
'edit_language_id' => $edition_language->getId(),
|
||||
'edit_language_locale' => $edition_language->getLocale(),
|
||||
|
||||
'current_url' => htmlspecialchars($this->getRequest()->getUri())
|
||||
'current_url' => htmlspecialchars($this->getRequest()->getUri())
|
||||
));
|
||||
|
||||
// Update the current edition language in session
|
||||
$this->getSession()->setAdminEditionLangId($edition_language);
|
||||
$this->getSession()->setAdminEditionLangId($edition_language->getId());
|
||||
|
||||
// Render the template.
|
||||
try {
|
||||
|
||||
@@ -188,7 +188,7 @@ class CategoryController extends BaseAdminController
|
||||
|
||||
// Find the current order
|
||||
$category_order = $this->getRequest()->get(
|
||||
'category_order',
|
||||
'order',
|
||||
$this->getSession()->get('admin.category_order', 'manual')
|
||||
);
|
||||
|
||||
|
||||
@@ -42,6 +42,25 @@ use Thelia\Form\ConfigCreationForm;
|
||||
*/
|
||||
class ConfigController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* Render the currencies list, ensuring the sort order is set.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
protected function renderList() {
|
||||
|
||||
// Find the current order
|
||||
$order = $this->getRequest()->get(
|
||||
'order',
|
||||
$this->getSession()->get('admin.variables_order', 'name')
|
||||
);
|
||||
|
||||
// Store the current sort order in session
|
||||
$this->getSession()->set('admin.variables_order', $order);
|
||||
|
||||
return $this->render('variables', array('order' => $order));
|
||||
}
|
||||
|
||||
/**
|
||||
* The default action is displaying the variables list.
|
||||
*
|
||||
@@ -51,7 +70,7 @@ class ConfigController extends BaseAdminController
|
||||
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.variables.view")) return $response;
|
||||
|
||||
return $this->render('variables');
|
||||
return $this->renderList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +143,7 @@ class ConfigController extends BaseAdminController
|
||||
}
|
||||
|
||||
// At this point, the form has error, and should be redisplayed.
|
||||
return $this->render('variables');
|
||||
return $this->renderList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,10 +239,11 @@ class ConfigController extends BaseAdminController
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl,
|
||||
// just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirect(URL::absoluteUrl(
|
||||
"admin/configuration/variables/change",
|
||||
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.variables.change",
|
||||
array('variable_id' => $variable_id)
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
@@ -276,7 +296,7 @@ class ConfigController extends BaseAdminController
|
||||
$this->dispatch(TheliaEvents::CONFIG_SETVALUE, $event);
|
||||
}
|
||||
|
||||
$this->redirect(URL::adminViewUrl('variables'));
|
||||
$this->redirectToRoute('admin.configuration.variables.default');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,6 +314,6 @@ class ConfigController extends BaseAdminController
|
||||
|
||||
$this->dispatch(TheliaEvents::CONFIG_DELETE, $event);
|
||||
|
||||
$this->redirect(URL::adminViewUrl('variables'));
|
||||
$this->redirectToRoute('admin.configuration.variables.default');
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ class CurrencyController extends BaseAdminController
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.currencies.create")) return $response;
|
||||
|
||||
$currency = false;
|
||||
$error_msg = false;
|
||||
|
||||
// Create the Creation Form
|
||||
$creationForm = new CurrencyCreationForm($this->getRequest());
|
||||
@@ -101,7 +101,9 @@ class CurrencyController extends BaseAdminController
|
||||
->setCurrencyName($data['name'])
|
||||
->setLocale($data["locale"])
|
||||
->setSymbol($data['symbol'])
|
||||
;
|
||||
->setCode($data['code'])
|
||||
->setRate($data['rate'])
|
||||
;
|
||||
|
||||
$this->dispatch(TheliaEvents::CURRENCY_CREATE, $createEvent);
|
||||
|
||||
@@ -118,24 +120,24 @@ class CurrencyController extends BaseAdminController
|
||||
}
|
||||
catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$currency = sprintf("Please check your input: %s", $ex->getCurrency());
|
||||
$error_msg = sprintf("Please check your input: %s", $ex->getMessage());
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$currency = sprintf("Sorry, an error occured: %s", $ex->getCurrency());
|
||||
$error_msg = sprintf("Sorry, an error occured: %s", $ex->getMessage());
|
||||
}
|
||||
|
||||
if ($currency !== false) {
|
||||
if ($error_msg !== false) {
|
||||
// An error has been detected: log it
|
||||
Tlog::getInstance()->error(sprintf("Error during currency creation process : %s. Exception was %s", $currency, $ex->getCurrency()));
|
||||
Tlog::getInstance()->error(sprintf("Error during currency creation process : %s. Exception was %s", $error_msg, $ex->getMessage()));
|
||||
|
||||
// Mark the form as errored
|
||||
$creationForm->setErrorCurrency($currency);
|
||||
$creationForm->setErrorMessage($error_msg);
|
||||
|
||||
// Pass it to the parser, along with the error currency
|
||||
$this->getParserContext()
|
||||
->addForm($creationForm)
|
||||
->setGeneralError($currency)
|
||||
->setGeneralError($error_msg)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -167,7 +169,7 @@ class CurrencyController extends BaseAdminController
|
||||
'locale' => $currency->getLocale(),
|
||||
'code' => $currency->getCode(),
|
||||
'symbol' => $currency->getSymbol(),
|
||||
'rate' => $currency->getSubject()
|
||||
'rate' => $currency->getRate()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
@@ -191,7 +193,7 @@ class CurrencyController extends BaseAdminController
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.currencies.change")) return $response;
|
||||
|
||||
$currency = false;
|
||||
$error_msg = false;
|
||||
|
||||
// Create the form from the request
|
||||
$changeForm = new CurrencyModificationForm($this->getRequest());
|
||||
@@ -228,10 +230,10 @@ class CurrencyController extends BaseAdminController
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl,
|
||||
// just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirect(URL::absoluteUrl(
|
||||
"admin/configuration/currencies/change",
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.currencies.change",
|
||||
array('currency_id' => $currency_id)
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
@@ -239,24 +241,24 @@ class CurrencyController extends BaseAdminController
|
||||
}
|
||||
catch (FormValidationException $ex) {
|
||||
// Invalid data entered
|
||||
$currency = sprintf("Please check your input: %s", $ex->getCurrency());
|
||||
$error_msg = sprintf("Please check your input: %s", $ex->getMessage());
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$currency = sprintf("Sorry, an error occured: %s", $ex->getCurrency());
|
||||
$error_msg = sprintf("Sorry, an error occured: %s", $ex->getMessage());
|
||||
}
|
||||
|
||||
if ($currency !== false) {
|
||||
if ($error_msg !== false) {
|
||||
// Log error currency
|
||||
Tlog::getInstance()->error(sprintf("Error during currency modification process : %s. Exception was %s", $currency, $ex->getCurrency()));
|
||||
Tlog::getInstance()->error(sprintf("Error during currency modification process : %s. Exception was %s", $error_msg, $ex->getMessage()));
|
||||
|
||||
// Mark the form as errored
|
||||
$changeForm->setErrorCurrency($currency);
|
||||
$changeForm->setErrorMessage($error_msg);
|
||||
|
||||
// Pas the form and the error to the parser
|
||||
$this->getParserContext()
|
||||
->addForm($changeForm)
|
||||
->setGeneralError($currency)
|
||||
->setGeneralError($error_msg)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -264,6 +266,47 @@ class CurrencyController extends BaseAdminController
|
||||
return $this->render('currency-edit', array('currency_id' => $currency_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default currency
|
||||
*/
|
||||
public function setDefaultAction() {
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.currencies.change")) return $response;
|
||||
|
||||
$changeEvent = new CurrencyChangeEvent($this->getRequest()->get('currency_id', 0));
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent->setIsDefault(true);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::CURRENCY_SET_DEFAULT, $changeEvent);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage(sprintf("Sorry, an error occured: %s", $ex->getMessage()));
|
||||
}
|
||||
|
||||
$this->redirectToRoute('admin.configuration.currencies.default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update currencies rates
|
||||
*/
|
||||
public function updateRatesAction() {
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.currencies.change")) return $response;
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage(sprintf("Sorry, an error occured: %s", $ex->getMessage()));
|
||||
}
|
||||
|
||||
$this->redirectToRoute('admin.configuration.currencies.default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a currency object
|
||||
*
|
||||
@@ -279,6 +322,6 @@ class CurrencyController extends BaseAdminController
|
||||
|
||||
$this->dispatch(TheliaEvents::CURRENCY_DELETE, $event);
|
||||
|
||||
$this->redirect(URL::adminViewUrl('currencies'));
|
||||
$this->redirectToRoute('admin.configuration.currencies.default');
|
||||
}
|
||||
}
|
||||
@@ -214,10 +214,10 @@ class MessageController extends BaseAdminController
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl,
|
||||
// just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirect(URL::absoluteUrl(
|
||||
"admin/configuration/messages/change",
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.messages.change",
|
||||
array('message_id' => $message_id)
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
|
||||
@@ -46,7 +46,7 @@ class SessionController extends BaseAdminController
|
||||
$this->getSecurityContext()->clearAdminUser();
|
||||
|
||||
// Go back to login page.
|
||||
return Redirect::exec(URL::absoluteUrl('/admin/login')); // FIXME - should be a parameter
|
||||
$this->redirectToRoute('admin.login');
|
||||
}
|
||||
|
||||
public function checkLoginAction()
|
||||
|
||||
@@ -31,11 +31,12 @@ use Thelia\Tools\Redirect;
|
||||
use Thelia\Core\Template\ParserContext;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Thelia\Core\Factory\ActionEventFactory;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Thelia\Core\Event\DefaultActionEvent;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -177,9 +178,9 @@ class BaseController extends ContainerAware
|
||||
*
|
||||
* @param string $url
|
||||
*/
|
||||
public function redirect($url)
|
||||
public function redirect($url, $status = 302)
|
||||
{
|
||||
Redirect::exec($url);
|
||||
Redirect::exec($url, $status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,4 +201,32 @@ class BaseController extends ContainerAware
|
||||
|
||||
if (null !== $url) $this->redirect($url);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a route path from the route id.
|
||||
*
|
||||
* @param $routerName
|
||||
* @param $routeId
|
||||
*
|
||||
* @return mixed
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function getRouteFromRouter($routerName, $routeId) {
|
||||
$route = $this->container->get($routerName)->getRouteCollection()->get($routeId);
|
||||
|
||||
if ($route == null) {
|
||||
throw new InvalidArgumentException(sprintf("Route ID '%s' does not exists.", $routeId));
|
||||
}
|
||||
|
||||
return $route->getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a 404 error
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
protected function pageNotFound()
|
||||
{
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
}
|
||||
@@ -26,4 +26,24 @@ use Thelia\Controller\BaseController;
|
||||
|
||||
class BaseFrontController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Return the route path defined for the givent route ID
|
||||
*
|
||||
* @param string $routeId a route ID, as defines in Config/Resources/routing/front.xml
|
||||
*
|
||||
* @see \Thelia\Controller\BaseController::getRouteFromRouter()
|
||||
*/
|
||||
protected function getRoute($routeId) {
|
||||
return $this->getRouteFromRouter('router.front', $routeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to à route ID related URL
|
||||
*
|
||||
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
|
||||
* @param unknown $urlParameters the URL parametrs, as a var/value pair array
|
||||
*/
|
||||
public function redirectToRoute($routeId, $urlParameters = array()) {
|
||||
$this->redirect(URL::absoluteUrl($this->getRoute($routeId), $urlParameters));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
namespace Thelia\Controller\Front;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\Redirect;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -43,6 +46,16 @@ class DefaultController extends BaseFrontController
|
||||
*/
|
||||
public function noAction(Request $request)
|
||||
{
|
||||
if(ConfigQuery::isRewritingEnable()) {
|
||||
|
||||
/* Does the query GET parameters match a rewritten URL ? */
|
||||
$rewrittenUrl = URL::init()->retrieveCurrent($request);
|
||||
if($rewrittenUrl->rewrittenUrl !== null) {
|
||||
/* 301 redirection to rewritten URL */
|
||||
$this->redirect($rewrittenUrl->rewrittenUrl, 301);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $view = $request->query->get('view')) {
|
||||
$view = "index";
|
||||
if ($request->request->has('view')) {
|
||||
|
||||
81
core/lib/Thelia/Controller/Front/UrlRewritingController.php
Executable file
81
core/lib/Thelia/Controller/Front/UrlRewritingController.php
Executable file
@@ -0,0 +1,81 @@
|
||||
<?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\Front;
|
||||
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Exception\UrlRewritingException;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
class UrlRewritingController extends BaseFrontController
|
||||
{
|
||||
public function check(Request $request, $rewritten_url)
|
||||
{
|
||||
if(ConfigQuery::isRewritingEnable()) {
|
||||
try {
|
||||
$rewrittenUrlData = URL::init()->resolve($rewritten_url);
|
||||
} catch(UrlRewritingException $e) {
|
||||
switch($e->getCode()) {
|
||||
case UrlRewritingException::URL_NOT_FOUND :
|
||||
return $this->pageNotFound();
|
||||
break;
|
||||
default:
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/* is the URL redirected ? */
|
||||
|
||||
if(null !== $rewrittenUrlData->redirectedToUrl) {
|
||||
$this->redirect($rewrittenUrlData->redirectedToUrl, 301);
|
||||
}
|
||||
|
||||
/* define GET arguments in request */
|
||||
|
||||
if(null !== $rewrittenUrlData->view) {
|
||||
$request->query->set('view', $rewrittenUrlData->view);
|
||||
if(null !== $rewrittenUrlData->viewId) {
|
||||
$request->query->set($rewrittenUrlData->view . '_id', $rewrittenUrlData->viewId);
|
||||
}
|
||||
}
|
||||
if(null !== $rewrittenUrlData->locale) {
|
||||
$request->query->set('locale', $rewrittenUrlData->locale);
|
||||
}
|
||||
|
||||
foreach($rewrittenUrlData->otherParameters as $parameter => $value) {
|
||||
$request->query->set($parameter, $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $view = $request->query->get('view')) {
|
||||
$view = "index";
|
||||
if ($request->request->has('view')) {
|
||||
$view = $request->request->get('view');
|
||||
}
|
||||
}
|
||||
|
||||
$request->attributes->set('_view', $view);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ use Thelia\Model\Currency;
|
||||
class CurrencyChangeEvent extends CurrencyCreateEvent
|
||||
{
|
||||
protected $currency_id;
|
||||
protected $is_default;
|
||||
|
||||
public function __construct($currency_id)
|
||||
{
|
||||
@@ -44,4 +45,16 @@ class CurrencyChangeEvent extends CurrencyCreateEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
public function getIsDefault()
|
||||
{
|
||||
return $this->is_default;
|
||||
}
|
||||
|
||||
public function setIsDefault($is_default)
|
||||
{
|
||||
$this->is_default = $is_default;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ class CurrencyCreateEvent extends CurrencyEvent
|
||||
public function setSymbol($symbol)
|
||||
{
|
||||
$this->symbol = $symbol;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCode()
|
||||
|
||||
@@ -215,9 +215,11 @@ final class TheliaEvents
|
||||
|
||||
// -- Currencies management ---------------------------------------------
|
||||
|
||||
const CURRENCY_CREATE = "action.createCurrency";
|
||||
const CURRENCY_MODIFY = "action.changeCurrency";
|
||||
const CURRENCY_DELETE = "action.deleteCurrency";
|
||||
const CURRENCY_CREATE = "action.createCurrency";
|
||||
const CURRENCY_MODIFY = "action.changeCurrency";
|
||||
const CURRENCY_DELETE = "action.deleteCurrency";
|
||||
const CURRENCY_SET_DEFAULT = "action.setDefaultCurrency";
|
||||
const CURRENCY_UPDATE_RATES = "action.updateCurrencyRates";
|
||||
|
||||
const BEFORE_CREATECURRENCY = "action.before_createCurrency";
|
||||
const AFTER_CREATECURRENCY = "action.after_createCurrency";
|
||||
|
||||
@@ -114,22 +114,24 @@ class Address extends BaseLoop
|
||||
|
||||
foreach ($addresses as $address) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ID", $address->getId());
|
||||
$loopResultRow->set("NAME", $address->getName());
|
||||
$loopResultRow->set("CUSTOMER", $address->getCustomerId());
|
||||
$loopResultRow->set("TITLE", $address->getTitleId());
|
||||
$loopResultRow->set("COMPANY", $address->getCompany());
|
||||
$loopResultRow->set("FIRSTNAME", $address->getFirstname());
|
||||
$loopResultRow->set("LASTNAME", $address->getLastname());
|
||||
$loopResultRow->set("ADDRESS1", $address->getAddress1());
|
||||
$loopResultRow->set("ADDRESS2", $address->getAddress2());
|
||||
$loopResultRow->set("ADDRESS3", $address->getAddress3());
|
||||
$loopResultRow->set("ZIPCODE", $address->getZipcode());
|
||||
$loopResultRow->set("CITY", $address->getCity());
|
||||
$loopResultRow->set("COUNTRY", $address->getCountryId());
|
||||
$loopResultRow->set("PHONE", $address->getPhone());
|
||||
$loopResultRow->set("CELLPHONE", $address->getCellphone());
|
||||
$loopResultRow->set("DEFAULT", $address->getIsDefault());
|
||||
$loopResultRow
|
||||
->set("ID", $address->getId())
|
||||
->set("NAME", $address->getName())
|
||||
->set("CUSTOMER", $address->getCustomerId())
|
||||
->set("TITLE", $address->getTitleId())
|
||||
->set("COMPANY", $address->getCompany())
|
||||
->set("FIRSTNAME", $address->getFirstname())
|
||||
->set("LASTNAME", $address->getLastname())
|
||||
->set("ADDRESS1", $address->getAddress1())
|
||||
->set("ADDRESS2", $address->getAddress2())
|
||||
->set("ADDRESS3", $address->getAddress3())
|
||||
->set("ZIPCODE", $address->getZipcode())
|
||||
->set("CITY", $address->getCity())
|
||||
->set("COUNTRY", $address->getCountryId())
|
||||
->set("PHONE", $address->getPhone())
|
||||
->set("CELLPHONE", $address->getCellphone())
|
||||
->set("DEFAULT", $address->getIsDefault())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
@@ -107,8 +107,6 @@ class CategoryTree extends BaseI18nLoop
|
||||
$visible = $this->getVisible();
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
//echo "exclude=".print_r($exclude);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
$this->buildCategoryTree($id, $visible, 0, $depth, $exclude, $loopResult);
|
||||
|
||||
@@ -34,6 +34,8 @@ use Thelia\Model\LangQuery;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type\EnumListType;
|
||||
|
||||
/**
|
||||
* Config loop, to access configuration variables
|
||||
@@ -59,7 +61,21 @@ class Config extends BaseI18nLoop
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
Argument::createAnyTypeArgument('variable'),
|
||||
Argument::createBooleanOrBothTypeArgument('hidden'),
|
||||
Argument::createBooleanOrBothTypeArgument('secured')
|
||||
Argument::createBooleanOrBothTypeArgument('secured'),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new EnumListType(
|
||||
array(
|
||||
'id', 'id_reverse',
|
||||
'name', 'name_reverse',
|
||||
'title', 'title_reverse',
|
||||
'value', 'value_reverse',
|
||||
)
|
||||
)
|
||||
),
|
||||
'name'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,7 +110,39 @@ class Config extends BaseI18nLoop
|
||||
if (! is_null($secured) && $secured != BooleanOrBothType::ANY)
|
||||
$search->filterBySecured($secured ? 1 : 0);
|
||||
|
||||
$search->orderByName(Criteria::ASC);
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case 'id':
|
||||
$search->orderById(Criteria::ASC);
|
||||
break;
|
||||
case 'id_reverse':
|
||||
$search->orderById(Criteria::DESC);
|
||||
break;
|
||||
|
||||
case 'name':
|
||||
$search->orderByName(Criteria::ASC);
|
||||
break;
|
||||
case 'name_reverse':
|
||||
$search->orderByName(Criteria::DESC);
|
||||
break;
|
||||
|
||||
case 'title':
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case 'title_reverse':
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
|
||||
case 'value':
|
||||
$search->orderByValue(Criteria::ASC);
|
||||
break;
|
||||
case 'value_reverse':
|
||||
$search->orderByValue(Criteria::DESC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$results = $this->search($search, $pagination);
|
||||
|
||||
@@ -116,9 +164,13 @@ class Config extends BaseI18nLoop
|
||||
->set("POSTSCRIPTUM" , $result->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("HIDDEN" , $result->getHidden())
|
||||
->set("SECURED" , $result->getSecured())
|
||||
->set("CREATE_DATE" , $result->getCreatedAt())
|
||||
->set("UPDATE_DATE" , $result->getUpdatedAt())
|
||||
;
|
||||
|
||||
->set("CREATE_DATE" , $result->getCreatedAt())
|
||||
->set("UPDATE_DATE" , $result->getUpdatedAt())
|
||||
->set("VERSION" , $result->getVersion())
|
||||
->set("VERSION_DATE" , $result->getVersionCreatedAt())
|
||||
->set("VERSION_AUTHOR" , $result->getVersionCreatedBy())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
@@ -66,8 +66,9 @@ class Currency extends BaseI18nLoop
|
||||
'code', 'code_reverse',
|
||||
'symbol', 'symbol_reverse',
|
||||
'rate', 'rate_reverse',
|
||||
'is_default', 'is_default_reverse',
|
||||
'manual', 'manual_reverse')
|
||||
)
|
||||
)
|
||||
),
|
||||
'manual'
|
||||
)
|
||||
@@ -143,6 +144,13 @@ class Currency extends BaseI18nLoop
|
||||
$search->orderByRate(Criteria::DESC);
|
||||
break;
|
||||
|
||||
case 'is_default':
|
||||
$search->orderByByDefault(Criteria::ASC);
|
||||
break;
|
||||
case 'is_default_reverse':
|
||||
$search->orderByByDefault(Criteria::DESC);
|
||||
break;
|
||||
|
||||
case 'manual':
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
@@ -169,7 +177,11 @@ class Currency extends BaseI18nLoop
|
||||
->set("SYMBOL" , $currency->getSymbol())
|
||||
->set("RATE" , $currency->getRate())
|
||||
->set("POSITION" , $currency->getPosition())
|
||||
->set("IS_DEFAULT" , $currency->getByDefault());
|
||||
->set("IS_DEFAULT" , $currency->getByDefault())
|
||||
|
||||
->set("CREATE_DATE" , $currency->getCreatedAt())
|
||||
->set("UPDATE_DATE" , $currency->getUpdatedAt())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
@@ -519,6 +519,12 @@ class Product extends BaseI18nLoop
|
||||
->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo'))
|
||||
->set("IS_NEW", $product->getVirtualColumn('main_product_is_new'))
|
||||
->set("POSITION", $product->getPosition())
|
||||
|
||||
->set("CREATE_DATE", $category->getCreatedAt())
|
||||
->set("UPDATE_DATE", $category->getUpdatedAt())
|
||||
->set("VERSION", $category->getVersion())
|
||||
->set("VERSION_DATE", $category->getVersionCreatedAt())
|
||||
->set("VERSION_AUTHOR", $category->getVersionCreatedBy())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
144
core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php
Normal file
144
core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?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\Core\Template\Smarty\Plugins;
|
||||
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
|
||||
/**
|
||||
* This class implements variour admin template utilities
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class AdminUtilities extends AbstractSmartyPlugin
|
||||
{
|
||||
private $securityContext;
|
||||
|
||||
public function __construct(SecurityContext $securityContext)
|
||||
{
|
||||
$this->securityContext = $securityContext;
|
||||
}
|
||||
|
||||
public function generatePositionChangeBlock($params, &$smarty) {
|
||||
// The required permissions
|
||||
$permission = $this->getParam($params, 'permission');
|
||||
|
||||
// The base position change path
|
||||
$path = $this->getParam($params, 'path');
|
||||
|
||||
// The URL parameter the object ID is assigned
|
||||
$url_parameter = $this->getParam($params, 'url_parameter');
|
||||
|
||||
// The current object position
|
||||
$position = $this->getParam($params, 'position');
|
||||
|
||||
// The object ID
|
||||
$id = $this->getParam($params, 'id');
|
||||
|
||||
// The in place dition class
|
||||
$in_place_edit_class = $this->getParam($params, 'in_place_edit_class');
|
||||
|
||||
/*
|
||||
<a href="{url path='/admin/configuration/currencies/positionUp' currency_id=$ID}"><i class="icon-arrow-up"></i></a>
|
||||
<span class="currencyPositionChange" data-id="{$ID}">{$POSITION}</span>
|
||||
<a href="{url path='/admin/configuration/currencies/positionDown' currency_id=$ID}"><i class="icon-arrow-down"></i></a>
|
||||
*/
|
||||
|
||||
if ($permissions == null || $this->securityContext->isGranted("ADMIN", array($permission))) {
|
||||
return sprintf(
|
||||
'<a href="%s"><i class="icon-arrow-up"></i></a><span class="%s" data-id="%s">%s</span><a href="%s"><i class="icon-arrow-down"></i></a>',
|
||||
URL::absoluteUrl("$path/positionUp", array($url_parameter => $id)),
|
||||
$in_place_edit_class,
|
||||
$id,
|
||||
$position,
|
||||
URL::absoluteUrl("$path/positionDown", array($url_parameter => $id))
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $position;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the link of a sortable column header
|
||||
*
|
||||
* @param array $params
|
||||
* @param unknown $smarty
|
||||
* @return string no text is returned.
|
||||
*/
|
||||
public function generateSortableColumnHeader($params, &$smarty)
|
||||
{
|
||||
// The current order of the table
|
||||
$current_order = $this->getParam($params, 'current_order');
|
||||
|
||||
// The column ascending order
|
||||
$order = $this->getParam($params, 'order');
|
||||
|
||||
// The column descending order label
|
||||
$reverse_order = $this->getParam($params, 'reverse_order');
|
||||
|
||||
// The order change path
|
||||
$path = $this->getParam($params, 'path');
|
||||
|
||||
// The column label
|
||||
$label = $this->getParam($params, 'label');
|
||||
|
||||
if ($current_order == $order) {
|
||||
$icon = 'up';
|
||||
$order_change = $reverse_order;
|
||||
}
|
||||
else if ($current_order == $reverse_order) {
|
||||
$icon = 'down';
|
||||
$order_change = $order;
|
||||
}
|
||||
else {
|
||||
$order_change = $order;
|
||||
}
|
||||
|
||||
if (! empty($icon))
|
||||
$output = sprintf('<i class="icon icon-chevron-%s"></i> ', $icon);
|
||||
else
|
||||
$output = '';
|
||||
|
||||
return sprintf('%s<a href="%s">%s</a>', $output, URL::absoluteUrl($path, array('order' => $order_change)), $label);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Define the various smarty plugins handled by this class
|
||||
*
|
||||
* @return an array of smarty plugin descriptors
|
||||
*/
|
||||
public function getPluginDescriptors()
|
||||
{
|
||||
return array(
|
||||
new SmartyPluginDescriptor('function', 'admin_sortable_header', $this, 'generateSortableColumnHeader'),
|
||||
new SmartyPluginDescriptor('function', 'admin_position_block' , $this, 'generatePositionChangeBlock'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
{
|
||||
return array(
|
||||
"current" => "getCurrentUrl",
|
||||
"return_to" => "getReturnToUrl",
|
||||
"return_to" => "getReturnToUrl",
|
||||
"index" => "getIndexUrl",
|
||||
);
|
||||
}
|
||||
@@ -169,7 +169,9 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
|
||||
protected function getCurrentUrl()
|
||||
{
|
||||
return URL::retrieveCurrent($this->request);
|
||||
$retriever = URL::init()->retrieveCurrent($this->request);
|
||||
|
||||
return $retriever->rewrittenUrl === null ? $retriever->url : $retriever->rewrittenUrl ;
|
||||
}
|
||||
|
||||
protected function getReturnToUrl()
|
||||
|
||||
@@ -36,6 +36,7 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param EventDispatcherInterface $dispatcher
|
||||
* @param ParserContext $parserContext
|
||||
* @param bool $template
|
||||
* @param string $env
|
||||
* @param bool $debug
|
||||
|
||||
42
core/lib/Thelia/Exception/UrlRewritingException.php
Executable file
42
core/lib/Thelia/Exception/UrlRewritingException.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?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\Exception;
|
||||
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
class UrlRewritingException extends \Exception
|
||||
{
|
||||
const UNKNOWN_EXCEPTION = 0;
|
||||
|
||||
const URL_NOT_FOUND = 404;
|
||||
|
||||
const RESOLVER_NULL_SEARCH = 800;
|
||||
|
||||
public function __construct($message, $code = null, $previous = null) {
|
||||
if($code === null) {
|
||||
$code = self::UNKNOWN_EXCEPTION;
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -31,20 +31,20 @@ class CurrencyCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm($change_mode = false)
|
||||
{
|
||||
$name_constraints = array(new Constraints\NotBlank());
|
||||
$code_constraints = array(new Constraints\NotBlank());
|
||||
|
||||
if (!$change_mode) {
|
||||
$name_constraints[] = new Constraints\Callback(array(
|
||||
"methods" => array(array($this, "checkDuplicateName"))
|
||||
$code_constraints[] = new Constraints\Callback(array(
|
||||
"methods" => array(array($this, "checkDuplicateCode"))
|
||||
));
|
||||
}
|
||||
|
||||
$this->formBuilder
|
||||
->add("name" , "text" , array("constraints" => array($name_constraints)))
|
||||
->add("locale" , "text" , array())
|
||||
->add("name" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("locale" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("symbol" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("rate" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("code" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("code" , "text" , array("constraints" => $code_constraints))
|
||||
;
|
||||
}
|
||||
|
||||
@@ -53,12 +53,12 @@ class CurrencyCreationForm extends BaseForm
|
||||
return "thelia_currency_creation";
|
||||
}
|
||||
|
||||
public function checkDuplicateName($value, ExecutionContextInterface $context)
|
||||
public function checkDuplicateCode($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$currency = CurrencyQuery::create()->findOneByName($value);
|
||||
$currency = CurrencyQuery::create()->findOneByCode($value);
|
||||
|
||||
if ($currency) {
|
||||
$context->addViolation(sprintf("A currency with name \"%s\" already exists.", $value));
|
||||
$context->addViolation(sprintf("A currency with code \"%s\" already exists.", $value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ class CurrencyModificationForm extends CurrencyCreationForm
|
||||
parent::buildForm(true);
|
||||
|
||||
$this->formBuilder
|
||||
->add("id" , "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
;
|
||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
||||
@@ -23,7 +23,7 @@ class Category extends BaseCategory
|
||||
|
||||
public function getUrl($locale)
|
||||
{
|
||||
return URL::retrieve('category', $this->getId(), $locale);
|
||||
return URL::init()->retrieve('category', $this->getId(), $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,4 +32,14 @@ class ConfigQuery extends BaseConfigQuery {
|
||||
{
|
||||
return self::read("rewriting_enable") == 1;
|
||||
}
|
||||
|
||||
public static function getPageNotFoundView()
|
||||
{
|
||||
return self::read("page_not_found_view", '404.html');
|
||||
}
|
||||
|
||||
public static function getActiveTemplate()
|
||||
{
|
||||
return self::read('active-template', 'default');
|
||||
}
|
||||
} // ConfigQuery
|
||||
|
||||
@@ -9,6 +9,6 @@ class Content extends BaseContent
|
||||
{
|
||||
public function getUrl($locale)
|
||||
{
|
||||
return URL::retrieve('content', $this->getId(), $locale);
|
||||
return URL::init()->retrieve('content', $this->getId(), $locale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class Folder extends BaseFolder
|
||||
|
||||
public function getUrl($locale)
|
||||
{
|
||||
return URL::retrieve('folder', $this->getId(), $locale);
|
||||
return URL::init()->retrieve('folder', $this->getId(), $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,6 @@ class Product extends BaseProduct
|
||||
{
|
||||
public function getUrl($locale)
|
||||
{
|
||||
return URL::retrieve('product', $this->getId(), $locale);
|
||||
return URL::init()->retrieve('product', $this->getId(), $locale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Model\Base\RewritingUrlQuery as BaseRewritingUrlQuery;
|
||||
|
||||
use Thelia\Model\Map\RewritingUrlTableMap;
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'rewriting_url' table.
|
||||
@@ -15,6 +17,96 @@ use Thelia\Model\Base\RewritingUrlQuery as BaseRewritingUrlQuery;
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
*/
|
||||
class RewritingUrlQuery extends BaseRewritingUrlQuery {
|
||||
class RewritingUrlQuery extends BaseRewritingUrlQuery
|
||||
{
|
||||
/**
|
||||
* @param $rewrittenUrl
|
||||
*
|
||||
* @return array|mixed|\Propel\Runtime\Collection\ObjectCollection
|
||||
*/
|
||||
public function getResolverSearch($rewrittenUrl)
|
||||
{
|
||||
$redirectedJoin = new Join();
|
||||
$redirectedJoin->addExplicitCondition(RewritingUrlTableMap::TABLE_NAME, 'REDIRECTED', 'ru', RewritingUrlTableMap::TABLE_NAME, 'ID', 'is_redirected');
|
||||
$redirectedJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search = RewritingArgumentQuery::create()
|
||||
->joinRewritingUrl('ru', Criteria::RIGHT_JOIN)
|
||||
->addJoinObject($redirectedJoin)
|
||||
->where('`ru`.URL = ?', $rewrittenUrl, \PDO::PARAM_STR)
|
||||
->withColumn('`ru`.URL', 'ru_url')
|
||||
->withColumn('`ru`.VIEW', 'ru_view')
|
||||
->withColumn('`ru`.VIEW_LOCALE', 'ru_locale')
|
||||
->withColumn('`ru`.VIEW_ID', 'ru_viewId')
|
||||
->withColumn('`is_redirected`.URL', 'ru_redirected_to_url')
|
||||
->find();
|
||||
|
||||
return $search;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $view
|
||||
* @param $viewId
|
||||
* @param $viewLocale
|
||||
*
|
||||
* @return null|RewritingUrl
|
||||
*/
|
||||
public function getViewUrlQuery($view, $viewLocale, $viewId)
|
||||
{
|
||||
return RewritingUrlQuery::create()
|
||||
->joinRewritingArgument('ra', Criteria::LEFT_JOIN)
|
||||
->where('ISNULL(`ra`.REWRITING_URL_ID)')
|
||||
->filterByView($view)
|
||||
->filterByViewLocale($viewLocale)
|
||||
->filterByViewId($viewId)
|
||||
->filterByRedirected(null)
|
||||
->orderByUpdatedAt(Criteria::DESC)
|
||||
->findOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $view
|
||||
* @param $viewLocale
|
||||
* @param $viewId
|
||||
* @param $viewOtherParameters
|
||||
*
|
||||
* @return null|RewritingUrl
|
||||
*/
|
||||
public function getSpecificUrlQuery($view, $viewLocale, $viewId, $viewOtherParameters)
|
||||
{
|
||||
$urlQuery = RewritingUrlQuery::create()
|
||||
->joinRewritingArgument('ra', Criteria::LEFT_JOIN)
|
||||
->withColumn('`ra`.REWRITING_URL_ID', 'ra_REWRITING_URL_ID')
|
||||
->filterByView($view)
|
||||
->filterByViewLocale($viewLocale)
|
||||
->filterByViewId($viewId)
|
||||
->filterByRedirected(null)
|
||||
->orderByUpdatedAt(Criteria::DESC);
|
||||
|
||||
$otherParametersCount = count($viewOtherParameters);
|
||||
if($otherParametersCount > 0) {
|
||||
$parameterConditions = array();
|
||||
|
||||
foreach($viewOtherParameters as $parameter => $value) {
|
||||
$conditionName = 'other_parameter_condition_' . count($parameterConditions);
|
||||
$urlQuery->condition('parameter_condition', '`ra`.PARAMETER= ?', $parameter, \PDO::PARAM_STR)
|
||||
->condition('value_condition', '`ra`.VALUE = ?', $value, \PDO::PARAM_STR)
|
||||
->combine(array('parameter_condition', 'value_condition'), Criteria::LOGICAL_AND, $conditionName);
|
||||
$parameterConditions[] = $conditionName;
|
||||
}
|
||||
|
||||
$urlQuery->where($parameterConditions, Criteria::LOGICAL_OR);
|
||||
|
||||
$urlQuery->groupBy(RewritingUrlTableMap::ID);
|
||||
|
||||
$urlQuery->condition('count_condition_1', 'COUNT(' . RewritingUrlTableMap::ID . ') = ?', $otherParametersCount, \PDO::PARAM_INT) // ensure we got all the asked parameters (provided by the query)
|
||||
->condition('count_condition_2', 'COUNT(' . RewritingUrlTableMap::ID . ') = (SELECT COUNT(*) FROM rewriting_argument WHERE rewriting_argument.REWRITING_URL_ID = ra_REWRITING_URL_ID)'); // ensure we don't miss any parameters (needed to match the rewritten url)
|
||||
|
||||
$urlQuery->having(array('count_condition_1', 'count_condition_2'), Criteria::LOGICAL_AND);
|
||||
} else {
|
||||
$urlQuery->where('ISNULL(`ra`.REWRITING_URL_ID)');
|
||||
}
|
||||
|
||||
return $urlQuery->findOne();
|
||||
}
|
||||
} // RewritingUrlQuery
|
||||
|
||||
@@ -22,6 +22,13 @@
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Rewriting;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Exception\RewritingUrlException;
|
||||
use Thelia\Exception\UrlRewritingException;
|
||||
use Thelia\Model\RewritingUrlQuery;
|
||||
use Thelia\Model\Map\RewritingUrlTableMap;
|
||||
|
||||
/**
|
||||
* Class RewritingResolver
|
||||
* @package Thelia\Rewriting
|
||||
@@ -31,5 +38,58 @@ namespace Thelia\Rewriting;
|
||||
*/
|
||||
class RewritingResolver
|
||||
{
|
||||
protected $search = null;
|
||||
protected $rewritingUrlQuery = null;
|
||||
|
||||
public $view;
|
||||
public $viewId;
|
||||
public $locale;
|
||||
public $otherParameters;
|
||||
public $redirectedToUrl;
|
||||
|
||||
public function __construct($url = null)
|
||||
{
|
||||
$this->rewritingUrlQuery = new RewritingUrlQuery();
|
||||
|
||||
if($url !== null) {
|
||||
$this->load($url);
|
||||
}
|
||||
}
|
||||
|
||||
public function load($rewrittenUrl)
|
||||
{
|
||||
$this->search = $this->rewritingUrlQuery->getResolverSearch($rewrittenUrl);
|
||||
|
||||
if($this->search->count() == 0) {
|
||||
throw new UrlRewritingException('URL NOT FOUND', UrlRewritingException::URL_NOT_FOUND);
|
||||
}
|
||||
|
||||
$this->view = $this->search->getFirst()->getVirtualColumn('ru_view');
|
||||
$this->viewId = $this->search->getFirst()->getVirtualColumn('ru_viewId');
|
||||
$this->locale = $this->search->getFirst()->getVirtualColumn('ru_locale');
|
||||
$this->redirectedToUrl = $this->search->getFirst()->getVirtualColumn('ru_redirected_to_url');
|
||||
|
||||
$this->otherParameters = $this->getOtherParameters();
|
||||
}
|
||||
|
||||
protected function getOtherParameters()
|
||||
{
|
||||
if($this->search === null) {
|
||||
throw new UrlRewritingException('RESOLVER NULL SEARCH', UrlRewritingException::RESOLVER_NULL_SEARCH);
|
||||
}
|
||||
|
||||
$otherParameters = array();
|
||||
foreach($this->search as $result) {
|
||||
$parameter = $result->getParameter();
|
||||
$value = $result->getValue();
|
||||
|
||||
if(null !== $parameter) {
|
||||
$otherParameters[$parameter] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $otherParameters;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,8 +23,9 @@
|
||||
namespace Thelia\Rewriting;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Model\Base\RewritingUrlQuery;
|
||||
use Thelia\Model\RewritingUrlQuery;
|
||||
use Thelia\Model\Map\RewritingUrlTableMap;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class RewritingRetriever
|
||||
@@ -35,38 +36,40 @@ use Thelia\Model\Map\RewritingUrlTableMap;
|
||||
*/
|
||||
class RewritingRetriever
|
||||
{
|
||||
/**
|
||||
* @param $view
|
||||
* @param $viewLocale
|
||||
* @param $viewId
|
||||
*
|
||||
* @return null|$url
|
||||
*/
|
||||
public function getViewUrl($view, $viewLocale, $viewId)
|
||||
{
|
||||
$url = $this->getViewUrlQuery($view, $viewId, $viewLocale);
|
||||
protected $search = null;
|
||||
protected $rewritingUrlQuery = null;
|
||||
|
||||
return $url === null ? null : $url->getUrl();
|
||||
public $url;
|
||||
public $rewrittenUrl;
|
||||
|
||||
public function __construct($view = null, $viewLocale = null, $viewId = null)
|
||||
{
|
||||
$this->rewritingUrlQuery = new RewritingUrlQuery();
|
||||
|
||||
if($view !== null && $viewLocale !== null) {
|
||||
$this->load($view, $viewLocale, $viewId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $view
|
||||
* @param $viewId
|
||||
* @param $viewLocale
|
||||
*
|
||||
* @return null|RewritingUrl
|
||||
* @param $view
|
||||
* @param $viewLocale
|
||||
* @param null $viewId
|
||||
*/
|
||||
protected function getViewUrlQuery($view, $viewId, $viewLocale)
|
||||
public function loadViewUrl($view, $viewLocale, $viewId = null)
|
||||
{
|
||||
return RewritingUrlQuery::create()
|
||||
->joinRewritingArgument('ra', Criteria::LEFT_JOIN)
|
||||
->where('ISNULL(`ra`.REWRITING_URL_ID)')
|
||||
->filterByView($view)
|
||||
->filterByViewLocale($viewLocale)
|
||||
->filterByViewId($viewId)
|
||||
->filterByRedirected(null)
|
||||
->orderByUpdatedAt(Criteria::DESC)
|
||||
->findOne();
|
||||
$this->search = $this->rewritingUrlQuery->getViewUrlQuery($view, $viewLocale, $viewId);
|
||||
|
||||
$allParametersWithoutView = array();
|
||||
$allParametersWithoutView['locale'] = $viewLocale;
|
||||
if(null !== $viewId) {
|
||||
$allParametersWithoutView[$view . '_id'] = $viewId;
|
||||
}
|
||||
|
||||
$this->url = URL::viewUrl($view, $allParametersWithoutView);
|
||||
if($this->search !== null) {
|
||||
$this->rewrittenUrl = $this->search->getUrl();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,46 +77,25 @@ class RewritingRetriever
|
||||
* @param $viewLocale
|
||||
* @param null $viewId
|
||||
* @param array $viewOtherParameters
|
||||
*
|
||||
* @return null|$url
|
||||
*/
|
||||
public function getSpecificUrl($view, $viewLocale, $viewId = null, $viewOtherParameters = array())
|
||||
public function loadSpecificUrl($view, $viewLocale, $viewId = null, $viewOtherParameters = array())
|
||||
{
|
||||
$urlQuery = RewritingUrlQuery::create()
|
||||
->joinRewritingArgument('ra', Criteria::LEFT_JOIN)
|
||||
->withColumn('`ra`.REWRITING_URL_ID', 'ra_REWRITING_URL_ID')
|
||||
->filterByView($view)
|
||||
->filterByViewLocale($viewLocale)
|
||||
->filterByViewId($viewId)
|
||||
->filterByRedirected(null)
|
||||
->orderByUpdatedAt(Criteria::DESC);
|
||||
|
||||
$otherParametersCount = count($viewOtherParameters);
|
||||
if($otherParametersCount > 0) {
|
||||
$parameterConditions = array();
|
||||
|
||||
foreach($viewOtherParameters as $parameter => $value) {
|
||||
$conditionName = 'other_parameter_condition_' . count($parameterConditions);
|
||||
$urlQuery->condition('parameter_condition', '`ra`.PARAMETER= ?', $parameter, \PDO::PARAM_STR)
|
||||
->condition('value_condition', '`ra`.VALUE = ?', $value, \PDO::PARAM_STR)
|
||||
->combine(array('parameter_condition', 'value_condition'), Criteria::LOGICAL_AND, $conditionName);
|
||||
$parameterConditions[] = $conditionName;
|
||||
}
|
||||
|
||||
$urlQuery->where($parameterConditions, Criteria::LOGICAL_OR);
|
||||
|
||||
$urlQuery->groupBy(RewritingUrlTableMap::ID);
|
||||
|
||||
$urlQuery->condition('count_condition_1', 'COUNT(' . RewritingUrlTableMap::ID . ') = ?', $otherParametersCount, \PDO::PARAM_INT) // ensure we got all the asked parameters (provided by the query)
|
||||
->condition('count_condition_2', 'COUNT(' . RewritingUrlTableMap::ID . ') = (SELECT COUNT(*) FROM rewriting_argument WHERE rewriting_argument.REWRITING_URL_ID = ra_REWRITING_URL_ID)'); // ensure we don't miss any parameters (needed to match the rewritten url)
|
||||
|
||||
$urlQuery->having(array('count_condition_1', 'count_condition_2'), Criteria::LOGICAL_AND);
|
||||
} else {
|
||||
$urlQuery->where('ISNULL(`ra`.REWRITING_URL_ID)');
|
||||
if(empty($viewOtherParameters)) {
|
||||
$this->loadViewUrl($view, $viewLocale, $viewId);
|
||||
return;
|
||||
}
|
||||
|
||||
$url = $urlQuery->findOne();
|
||||
$this->search = $this->rewritingUrlQuery->getSpecificUrlQuery($view, $viewLocale, $viewId, $viewOtherParameters);
|
||||
|
||||
return $url === null ? null : $url->getUrl();
|
||||
$allParametersWithoutView = $viewOtherParameters;
|
||||
$allParametersWithoutView['locale'] = $viewLocale;
|
||||
if(null !== $viewId) {
|
||||
$allParametersWithoutView[$view . '_id'] = $viewId;
|
||||
}
|
||||
|
||||
$this->url = URL::viewUrl($view, $allParametersWithoutView);
|
||||
if($this->search !== null) {
|
||||
$this->rewrittenUrl = $this->search->getUrl();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
154
core/lib/Thelia/Tests/Rewriting/RewritingResolverTest.php
Executable file
154
core/lib/Thelia/Tests/Rewriting/RewritingResolverTest.php
Executable file
@@ -0,0 +1,154 @@
|
||||
<?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\Tests\Rewriting;
|
||||
|
||||
use Thelia\Model\RewritingArgument;
|
||||
use Thelia\Rewriting\RewritingResolver;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class RewritingResolverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function getMethod($name)
|
||||
{
|
||||
$class = new \ReflectionClass('\Thelia\Rewriting\RewritingResolver');
|
||||
$method = $class->getMethod($name);
|
||||
$method->setAccessible(true);
|
||||
|
||||
return $method;
|
||||
}
|
||||
|
||||
protected function getProperty($name)
|
||||
{
|
||||
$class = new \ReflectionClass('\Thelia\Rewriting\RewritingResolver');
|
||||
$property = $class->getProperty($name);
|
||||
$property->setAccessible(true);
|
||||
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\Exception\UrlRewritingException
|
||||
* @expectedExceptionCode 800
|
||||
*/
|
||||
public function testGetOtherParametersException()
|
||||
{
|
||||
$resolver = new RewritingResolver();
|
||||
|
||||
$method = $this->getMethod('getOtherParameters');
|
||||
$actual = $method->invoke($resolver);
|
||||
}
|
||||
|
||||
public function testGetOtherParameters()
|
||||
{
|
||||
$rewritingArguments = array(
|
||||
array('Parameter' => 'foo0', 'Value' => 'bar0'),
|
||||
array('Parameter' => 'foo1', 'Value' => 'bar1'),
|
||||
array('Parameter' => 'foo2', 'Value' => 'bar2'),
|
||||
);
|
||||
$searchResult = new ObjectCollection();
|
||||
$searchResult->setModel('\Thelia\Model\RewritingArgument');
|
||||
$searchResult->fromArray($rewritingArguments);
|
||||
|
||||
$resolver = new RewritingResolver();
|
||||
|
||||
$search = $this->getProperty('search');
|
||||
$search->setValue($resolver, $searchResult);
|
||||
|
||||
$method = $this->getMethod('getOtherParameters');
|
||||
$actual = $method->invoke($resolver);
|
||||
|
||||
$expected = array(
|
||||
'foo0' => 'bar0',
|
||||
'foo1' => 'bar1',
|
||||
'foo2' => 'bar2',
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\Exception\UrlRewritingException
|
||||
* @expectedExceptionCode 404
|
||||
*/
|
||||
public function testLoadException()
|
||||
{
|
||||
$collection = new ObjectCollection();
|
||||
$collection->setModel('\Thelia\Model\RewritingArgument');
|
||||
|
||||
$resolverQuery = $this->getMock('\Thelia\Model\RewritingUrlQuery', array('getResolverSearch'));
|
||||
$resolverQuery->expects($this->any())
|
||||
->method('getResolverSearch')
|
||||
->with('foo.html')
|
||||
->will($this->returnValue($collection));
|
||||
|
||||
$resolver = new RewritingResolver();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('rewritingUrlQuery');
|
||||
$rewritingUrlQuery->setValue($resolver, $resolverQuery);
|
||||
|
||||
$resolver->load('foo.html');
|
||||
}
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$collection = new ObjectCollection();
|
||||
$collection->setModel('\Thelia\Model\RewritingArgument');
|
||||
|
||||
for($i=0; $i<3; $i++) {
|
||||
$ra = new RewritingArgument();
|
||||
$ra->setParameter('foo' . $i);
|
||||
$ra->setValue('bar' . $i);
|
||||
$ra->setVirtualColumn('ru_view', 'view');
|
||||
$ra->setVirtualColumn('ru_viewId', 'viewId');
|
||||
$ra->setVirtualColumn('ru_locale', 'locale');
|
||||
$ra->setVirtualColumn('ru_redirected_to_url', null);
|
||||
|
||||
$collection->append($ra);
|
||||
}
|
||||
|
||||
|
||||
$resolverQuery = $this->getMock('\Thelia\Model\RewritingUrlQuery', array('getResolverSearch'));
|
||||
$resolverQuery->expects($this->any())
|
||||
->method('getResolverSearch')
|
||||
->with('foo.html')
|
||||
->will($this->returnValue($collection));
|
||||
|
||||
$resolver = new RewritingResolver();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('rewritingUrlQuery');
|
||||
$rewritingUrlQuery->setValue($resolver, $resolverQuery);
|
||||
|
||||
$resolver->load('foo.html');
|
||||
|
||||
$this->assertEquals('view', $resolver->view);
|
||||
$this->assertEquals('viewId', $resolver->viewId);
|
||||
$this->assertEquals('locale', $resolver->locale);
|
||||
$this->assertEquals(array('foo0' => 'bar0', 'foo1' => 'bar1', 'foo2' => 'bar2'), $resolver->otherParameters);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,9 @@
|
||||
|
||||
namespace Thelia\Tests\Rewriting;
|
||||
|
||||
use Thelia\Model\RewritingUrl;
|
||||
use Thelia\Rewriting\RewritingRetriever;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -32,13 +34,65 @@ use Thelia\Rewriting\RewritingRetriever;
|
||||
*/
|
||||
class RewritingRetrieverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetViewUrl()
|
||||
protected function getMethod($name)
|
||||
{
|
||||
$class = new \ReflectionClass('\Thelia\Rewriting\RewritingRetriever');
|
||||
$method = $class->getMethod($name);
|
||||
$method->setAccessible(true);
|
||||
|
||||
return $method;
|
||||
}
|
||||
|
||||
public function testGetSpecificUrl()
|
||||
protected function getProperty($name)
|
||||
{
|
||||
$class = new \ReflectionClass('\Thelia\Rewriting\RewritingRetriever');
|
||||
$property = $class->getProperty($name);
|
||||
$property->setAccessible(true);
|
||||
|
||||
return $property;
|
||||
}
|
||||
|
||||
public function testLoadViewUrl()
|
||||
{
|
||||
$searchResult = new RewritingUrl();
|
||||
$searchResult->setUrl('foo.html');
|
||||
|
||||
$retrieverQuery = $this->getMock('\Thelia\Model\RewritingUrlQuery', array('getViewUrlQuery'));
|
||||
$retrieverQuery->expects($this->any())
|
||||
->method('getViewUrlQuery')
|
||||
->with('view', 'fr_FR', 1)
|
||||
->will($this->returnValue($searchResult));
|
||||
|
||||
$retriever = new RewritingRetriever();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('rewritingUrlQuery');
|
||||
$rewritingUrlQuery->setValue($retriever, $retrieverQuery);
|
||||
|
||||
$retriever->loadViewUrl('view', 'fr_FR', 1);
|
||||
|
||||
$this->assertEquals('foo.html', $retriever->rewrittenUrl);
|
||||
$this->assertEquals(URL::viewUrl('view', array('locale' => 'fr_FR', 'view_id' => 1)), $retriever->url);
|
||||
}
|
||||
|
||||
public function testLoadSpecificUrl()
|
||||
{
|
||||
$searchResult = new RewritingUrl();
|
||||
$searchResult->setUrl('foo.html');
|
||||
|
||||
$retrieverQuery = $this->getMock('\Thelia\Model\RewritingUrlQuery', array('getSpecificUrlQuery'));
|
||||
$retrieverQuery->expects($this->any())
|
||||
->method('getSpecificUrlQuery')
|
||||
->with('view', 'fr_FR', 1, array('foo0' => 'bar0', 'foo1' => 'bar1'))
|
||||
->will($this->returnValue($searchResult));
|
||||
|
||||
$retriever = new RewritingRetriever();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('rewritingUrlQuery');
|
||||
$rewritingUrlQuery->setValue($retriever, $retrieverQuery);
|
||||
|
||||
$retriever->loadSpecificUrl('view', 'fr_FR', 1, array('foo0' => 'bar0', 'foo1' => 'bar1'));
|
||||
|
||||
$this->assertEquals('foo.html', $retriever->rewrittenUrl);
|
||||
$this->assertEquals(URL::viewUrl('view', array('foo0' => 'bar0', 'foo1' => 'bar1', 'locale' => 'fr_FR', 'view_id' => 1)), $retriever->url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -621,6 +621,7 @@ form .info .input-append .add-on {
|
||||
li.active a {
|
||||
opacity: 1;
|
||||
background-color: #E7E7E7;
|
||||
border: 1px solid #E9720F;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -657,6 +658,7 @@ label {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
|
||||
.form-horizontal input + .help-block,
|
||||
.form-horizontal select + .help-block,
|
||||
.form-horizontal textarea + .help-block,
|
||||
@@ -664,9 +666,10 @@ label {
|
||||
.form-horizontal .input-prepend + .help-block,
|
||||
.form-horizontal .input-append + .help-block
|
||||
.help-block, .form-horizontal .help-block {
|
||||
margin-top: 0px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
|
||||
// Fix for append-fields shorter than others
|
||||
// see http://stackoverflow.com/questions/13306670/bootstrap-prepended-and-appended-input-how-to-max-input-field-width
|
||||
.input-append.input-block-level,
|
||||
@@ -725,6 +728,17 @@ label {
|
||||
|
||||
td, th {
|
||||
text-align: center;
|
||||
|
||||
&.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
&.text-left {
|
||||
text-align: left;
|
||||
}
|
||||
&.text-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
td.object-title, th.object-title {
|
||||
|
||||
@@ -47,54 +47,40 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="object-image"> </th>
|
||||
|
||||
<th class="object-title">
|
||||
{if $category_order == 'alpha'}
|
||||
<i class="icon icon-chevron-up"></i>
|
||||
{$order_change = 'alpha_reverse'}
|
||||
{elseif $category_order == 'alpha_reverse'}
|
||||
<i class="icon icon-chevron-down"></i>
|
||||
{$order_change = 'alpha'}
|
||||
{else}
|
||||
{$order_change = 'alpha'}
|
||||
{/if}
|
||||
<a href="{url path='/admin/catalog/category' id="{$current_category_id}" category_order="$order_change"}">
|
||||
{intl l="Category title"}
|
||||
</a>
|
||||
</th>
|
||||
{admin_sortable_header
|
||||
current_order=$category_order
|
||||
order='alpha'
|
||||
reverse_order='alpha_reverse'
|
||||
path={url path='/admin/catalog/category' id="{$current_category_id}"}
|
||||
label={intl l='Category title'}
|
||||
}
|
||||
</th>
|
||||
|
||||
{module_include location='category_list_header'}
|
||||
|
||||
<th>
|
||||
{if $category_order == 'visible'}
|
||||
<i class="icon icon-chevron-up"></i>
|
||||
{$order_change = 'visible_reverse'}
|
||||
{elseif $category_order == 'visible_reverse'}
|
||||
<i class="icon icon-chevron-down"></i>
|
||||
{$order_change = 'visible'}
|
||||
{else}
|
||||
{$order_change = 'visible'}
|
||||
{/if}
|
||||
|
||||
<a href="{url path='admin/catalog/category' id="{$current_category_id}" category_order="$order_change"}">
|
||||
{intl l="Online"}
|
||||
</a>
|
||||
{admin_sortable_header
|
||||
current_order=$category_order
|
||||
order='visible'
|
||||
reverse_order='visible_reverse'
|
||||
path={url path='/admin/catalog/category' id="{$current_category_id}"}
|
||||
label={intl l='Online'}
|
||||
}
|
||||
</th>
|
||||
|
||||
<th>
|
||||
{if $category_order == 'manual'}
|
||||
<i class="icon icon-chevron-up"></i>
|
||||
{$order_change = 'manual_reverse'}
|
||||
{elseif $category_order == 'manual_reverse'}
|
||||
<i class="icon icon-chevron-down"></i>
|
||||
{$order_change = 'manual'}
|
||||
{else}
|
||||
{$order_change = 'manual'}
|
||||
{/if}
|
||||
|
||||
<a href="{url path='admin/catalog/category' id="{$current_category_id}" category_order="$order_change"}">{intl l="Position"}</a>
|
||||
{admin_sortable_header
|
||||
current_order=$category_order
|
||||
order='manual'
|
||||
reverse_order='manual_reverse'
|
||||
path={url path='/admin/catalog/category' id="{$current_category_id}"}
|
||||
label={intl l='Position'}
|
||||
}
|
||||
</th>
|
||||
|
||||
<th>{intl l="Actions"}</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -126,15 +112,14 @@
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.category.edit"}
|
||||
<a href="{url path='admin/catalog/category' category_id="{$ID}" action='positionUp'}"><i class="icon-arrow-up"></i></a>
|
||||
<span class="categoryPositionChange" data-id="{$ID}">{$POSITION}</span>
|
||||
<a href="{url path='admin/catalog/category' category_id="{$ID}" action='positionDown'}"><i class="icon-arrow-down"></i></a>
|
||||
{/loop}
|
||||
|
||||
{elseloop rel="can_change"}
|
||||
{$POSITION}
|
||||
{/elseloop}
|
||||
{admin_position_block
|
||||
permission="admin.category.edit"
|
||||
path={url path='admin/catalog/category' category_id="{$ID}"}
|
||||
url_parameter="category_id"
|
||||
in_place_edit_class="categoryPositionChange"
|
||||
position="$POSITION"
|
||||
id="$ID"
|
||||
}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@@ -200,13 +185,38 @@
|
||||
<tr>
|
||||
<th> </th>
|
||||
|
||||
<th class="object-title">{intl l="Product title"}</th>
|
||||
<th class="object-title">
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='alpha'
|
||||
reverse_order='alpha_reverse'
|
||||
path={url path='/admin/catalog/product' id="{$current_category_id}"}
|
||||
label={intl l='Product title'}
|
||||
}
|
||||
|
||||
{module_include location='product_list_header'}
|
||||
|
||||
<th>{intl l="Online"}</th>
|
||||
<th>{intl l="Position"}</th>
|
||||
<th>{intl l="Actions"}</th>
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='visible'
|
||||
reverse_order='visible_reverse'
|
||||
path={url path='/admin/catalog/product' id="{$current_category_id}"}
|
||||
label={intl l='Online'}
|
||||
}
|
||||
</th>
|
||||
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$product_order
|
||||
order='manual'
|
||||
reverse_order='manual_reverse'
|
||||
path={url path='/admin/catalog/product' id="{$current_category_id}"}
|
||||
label={intl l='Position'}
|
||||
}
|
||||
</th>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -229,13 +239,18 @@
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<a href="{url path='admin/catalog/product' id="$ID" action='positionUn'}"><i class="icon-arrow-up"></i></a>
|
||||
<span class="object_classement_editable" data-action="changeProductPosition" data-name="product_id" data-id="{$ID}">{$POSITION}</span>
|
||||
<a href="{url path='admin/catalog/product' id="$ID" action='positionDown'}"><i class="icon-arrow-down"></i></a>
|
||||
{admin_position_block
|
||||
permission="admin.product.edit"
|
||||
path={url path='admin/catalog/product' category_id="{$ID}"}
|
||||
url_parameter="product_id"
|
||||
in_place_edit_class="productPositionChange"
|
||||
position="$POSITION"
|
||||
id="$ID"
|
||||
}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<a class="btn btn-mini" title="{intl l='Edit this category'}" href="{url path='admin/catalog/product' id="$ID" action='edit'}"><i class="icon-edit"></i></a>
|
||||
<a class="btn btn-mini" title="{intl l='Edit this product'}" href="{url path='admin/catalog/product' id="$ID" action='edit'}"><i class="icon-edit"></i></a>
|
||||
<a class="btn btn-mini product-delete" title="{intl l='Delete this product'}" href="{url path='admin/catalog/product' id="$ID" action='delete'}"><i class="icon-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span12">
|
||||
<form action="{url path='/admin/configuration/currencies/change-values'}" method="post">
|
||||
<form action="{url path='/admin/configuration/currencies/update-rates'}" method="post">
|
||||
<div class="general-block-decorator">
|
||||
<table class="table table-striped table-condensed table-left-aligned">
|
||||
<caption>
|
||||
@@ -35,99 +35,81 @@
|
||||
<a class="btn btn-primary action-btn" title="{intl l='Add a new currency'}" href="#add_currency_dialog" data-toggle="modal">
|
||||
<i class="icon-plus-sign icon-white"></i>
|
||||
</a>
|
||||
<button class="btn btn-info action-btn" title="{intl l='Update rates'}">{intl l='Update rates'} <i class="icon icon-white icon-globe"></i></button>
|
||||
{/loop}
|
||||
|
||||
</caption>
|
||||
<tr>
|
||||
<th>
|
||||
{if $order == 'id'}
|
||||
<i class="icon icon-chevron-up"></i>
|
||||
{$order_change = 'id_reverse'}
|
||||
{elseif $order == 'id_reverse'}
|
||||
<i class="icon icon-chevron-down"></i>
|
||||
{$order_change = 'id'}
|
||||
{else}
|
||||
{$order_change = 'id'}
|
||||
{/if}
|
||||
<a href="{url path='/admin/configuration/currencies' order=$order_change}">
|
||||
{intl l="ID"}
|
||||
</a>
|
||||
{admin_sortable_header
|
||||
current_order=$order
|
||||
order='id'
|
||||
reverse_order='id_reverse'
|
||||
path='/admin/configuration/currencies'
|
||||
label="{intl l='ID'}"
|
||||
}
|
||||
</th>
|
||||
|
||||
<th>
|
||||
{if $order == 'alpha'}
|
||||
<i class="icon icon-chevron-up"></i>
|
||||
{$order_change = 'alpha_reverse'}
|
||||
{elseif $order == 'alpha_reverse'}
|
||||
<i class="icon icon-chevron-down"></i>
|
||||
{$order_change = 'alpha'}
|
||||
{else}
|
||||
{$order_change = 'alpha'}
|
||||
{/if}
|
||||
<a href="{url path='/admin/configuration/currencies' order=$order_change}">
|
||||
{intl l="Name"}
|
||||
</a>
|
||||
{admin_sortable_header
|
||||
current_order=$order
|
||||
order='alpha'
|
||||
reverse_order='alpha_reverse'
|
||||
path='/admin/configuration/currencies'
|
||||
label="{intl l='Name'}"
|
||||
}
|
||||
</th>
|
||||
|
||||
<th>
|
||||
{if $order == 'code'}
|
||||
<i class="icon icon-chevron-up"></i>
|
||||
{$order_change = 'code_reverse'}
|
||||
{elseif $order == 'code_reverse'}
|
||||
<i class="icon icon-chevron-down"></i>
|
||||
{$order_change = 'code'}
|
||||
{else}
|
||||
{$order_change = 'code'}
|
||||
{/if}
|
||||
<a href="{url path='/admin/configuration/currencies' order=$order_change}">{intl l="ISO 4217 Code"}</a>
|
||||
<th class="text-center">
|
||||
{admin_sortable_header
|
||||
current_order=$order
|
||||
order='code'
|
||||
reverse_order='code_reverse'
|
||||
path='/admin/configuration/currencies'
|
||||
label="{intl l="ISO 4217 Code"}"
|
||||
}
|
||||
<a title="{intl l='More information about ISO 4217'}" href="http://fr.wikipedia.org/wiki/ISO_4217" target="_blank"><i class="icon icon-question-sign"></i></a>
|
||||
</th>
|
||||
|
||||
<th>
|
||||
{if $order == 'symbol'}
|
||||
<i class="icon icon-chevron-up"></i>
|
||||
{$order_change = 'symbol_reverse'}
|
||||
{elseif $order == 'symbol_reverse'}
|
||||
<i class="icon icon-chevron-down"></i>
|
||||
{$order_change = 'symbol'}
|
||||
{else}
|
||||
{$order_change = 'symbol'}
|
||||
{/if}
|
||||
<a href="{url path='/admin/configuration/currencies' order=$order_change}">
|
||||
{intl l="Symbol"}
|
||||
</a>
|
||||
<th class="text-center">
|
||||
{admin_sortable_header
|
||||
current_order=$order
|
||||
order='symbol'
|
||||
reverse_order='symbol_reverse'
|
||||
path='/admin/configuration/currencies'
|
||||
label="{intl l="Symbol"}"
|
||||
}
|
||||
</th>
|
||||
|
||||
<th>
|
||||
{if $order == 'rate'}
|
||||
<i class="icon icon-chevron-up"></i>
|
||||
{$order_change = 'rate_reverse'}
|
||||
{elseif $order == 'rate_reverse'}
|
||||
<i class="icon icon-chevron-down"></i>
|
||||
{$order_change = 'rate'}
|
||||
{else}
|
||||
{$order_change = 'rate'}
|
||||
{/if}
|
||||
<a href="{url path='/admin/configuration/currencies' order=$order_change}">
|
||||
{intl l="Rate in €"}
|
||||
</a>
|
||||
<th class="text-right">
|
||||
{admin_sortable_header
|
||||
current_order=$order
|
||||
order='rate'
|
||||
reverse_order='rate_reverse'
|
||||
path='/admin/configuration/currencies'
|
||||
label="{intl l="Rate in €"}"
|
||||
}
|
||||
</th>
|
||||
|
||||
<th>
|
||||
{if $order == 'manual'}
|
||||
<i class="icon icon-chevron-up"></i>
|
||||
{$order_change = 'manual_reverse'}
|
||||
{elseif $order == 'manual_reverse'}
|
||||
<i class="icon icon-chevron-down"></i>
|
||||
{$order_change = 'manual'}
|
||||
{else}
|
||||
{$order_change = 'manual'}
|
||||
{/if}
|
||||
|
||||
<a href="{url path='/admin/configuration/currencies' order="$order_change"}">{intl l="Position"}</a>
|
||||
<th class="text-center">
|
||||
{admin_sortable_header
|
||||
current_order=$order
|
||||
order='manual'
|
||||
reverse_order='manual_reverse'
|
||||
path='/admin/configuration/currencies'
|
||||
label="{intl l="Position"}"
|
||||
}
|
||||
</th>
|
||||
|
||||
<th>{intl l="Default"}</th>
|
||||
<th class="text-center">
|
||||
{admin_sortable_header
|
||||
current_order=$order
|
||||
order='is_default'
|
||||
reverse_order='is_default_reverse'
|
||||
path='/admin/configuration/currencies'
|
||||
label="{intl l="Default"}"
|
||||
}
|
||||
</th>
|
||||
|
||||
{module_include location='currencies_table_header'}
|
||||
|
||||
@@ -136,37 +118,37 @@
|
||||
|
||||
{loop name="currencies" type="currency" backend_context="1" lang=$lang_id order=$order}
|
||||
<tr>
|
||||
<td>{$ID}</td>
|
||||
|
||||
<td>{$ID}</td>
|
||||
<td>
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.currencies.change"}
|
||||
<a title="{intl l='Change this currency'}" href="{url path='/admin/configuration/currencies/change' currency_id="$ID"}">{$NAME}</a>
|
||||
{/loop}
|
||||
{elseloop rel="can_change"}
|
||||
{$NAME}
|
||||
{/elseloop}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.currencies.change"}
|
||||
<a title="{intl l='Change this currency'}" href="{url path='/admin/configuration/currencies/change' currency_id="$ID"}">{$NAME}</a>
|
||||
{/loop}
|
||||
{elseloop rel="can_change"}
|
||||
{$NAME}
|
||||
{/elseloop}
|
||||
</td>
|
||||
<td class="text-center">{$ISOCODE}</td>
|
||||
|
||||
<td>{$ISOCODE}</td>
|
||||
<td class="text-center">{$SYMBOL}</td>
|
||||
|
||||
<td>{$SYMBOL}</td>
|
||||
<td class="text-right">{format_number number="$RATE" decimals="4"}</td>
|
||||
|
||||
<td>{$RATE|string_format:"%.4f"}</td>
|
||||
<td class="text-center">
|
||||
{admin_position_block
|
||||
permission="admin.currencies.edit"
|
||||
path="/admin/configuration/currencies"
|
||||
url_parameter="currency_id"
|
||||
in_place_edit_class="currencyPositionChange"
|
||||
position="$POSITION"
|
||||
id="$ID"
|
||||
}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.category.edit"}
|
||||
<a href="{url path='/admin/configuration/currencies/positionUp' currency_id=$ID}"><i class="icon-arrow-up"></i></a>
|
||||
<span class="currencyPositionChange" data-id="{$ID}">{$POSITION}</span>
|
||||
<a href="{url path='/admin/configuration/currencies/positionDown' currency_id=$ID}"><i class="icon-arrow-down"></i></a>
|
||||
{/loop}
|
||||
|
||||
{elseloop rel="can_change"}
|
||||
{$POSITION}
|
||||
{/elseloop}
|
||||
</td>
|
||||
|
||||
<td><input type="radio" name="default[{$ID}]" value="1" {if $IS_DEFAULT}checked="checked"{/if}/></td>
|
||||
<td class="text-center">
|
||||
<input class="change-default" type="radio" name="is_default" value="{$ID}" {if $IS_DEFAULT}checked="checked"{/if}/>
|
||||
</td>
|
||||
|
||||
{module_include location='currencies_table_row'}
|
||||
|
||||
@@ -228,7 +210,7 @@
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
{if #form_error}<div class="alert alert-block alert-error" id="add_currency_dialog_error">#form_error_currency</div>{/if}
|
||||
{if $form_error}<div class="alert alert-block alert-error" id="add_currency_dialog_error">{$form_error_message}</div>{/if}
|
||||
|
||||
<div class="control-group">
|
||||
|
||||
@@ -238,6 +220,10 @@
|
||||
|
||||
<div class="controls">
|
||||
{loop type="lang" name="default-lang" default_only="1"}
|
||||
|
||||
{* Switch edition to the current locale *}
|
||||
<input type="hidden" name="edit_language_id" value="{$ID}" />
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$LOCALE}" />
|
||||
{/form_field}
|
||||
@@ -262,7 +248,7 @@
|
||||
</label>
|
||||
|
||||
<div class="controls">
|
||||
{form_field form=$form field='symbol'}
|
||||
{form_field form=$form field='code'}
|
||||
<span {if $error}class="error"{/if}>
|
||||
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='ISO 4217 code'}" placeholder="{intl l='Code'}">
|
||||
</span>
|
||||
@@ -294,11 +280,11 @@
|
||||
</label>
|
||||
|
||||
<div class="controls">
|
||||
{form_field form=$form field='symbol'}
|
||||
{form_field form=$form field='rate'}
|
||||
<span {if $error}class="error"{/if}>
|
||||
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Currency rate'}" placeholder="{intl l='Rate'}">
|
||||
</span>
|
||||
<div class="help-block">{intl l="Currency rate, in Euro"}</div>
|
||||
<div class="help-block">{intl l="The rate from Euro (Price in Euro * rate = Price in this currency)"}</div>
|
||||
{/form_field}
|
||||
</div>
|
||||
</div>
|
||||
@@ -396,6 +382,18 @@
|
||||
}
|
||||
});
|
||||
|
||||
{* Change default status *}
|
||||
|
||||
$('.change-default').click(function(ev) {
|
||||
var url = "{url path='/admin/configuration/currencies/set-default' currency_id='__ID__'}";
|
||||
|
||||
// Perform ID subtitutions
|
||||
url = url.replace('__ID__', $(this).val());
|
||||
|
||||
// Reload the page
|
||||
location.href = url;
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
147
templates/admin/default/currency-edit.html
Normal file
147
templates/admin/default/currency-edit.html
Normal file
@@ -0,0 +1,147 @@
|
||||
{extends file="admin-layout.tpl"}
|
||||
|
||||
{block name="page-title"}{intl l='Edit a currency'}{/block}
|
||||
|
||||
{block name="check-permissions"}admin.configuration.currencies.edit{/block}
|
||||
|
||||
{block name="main-content"}
|
||||
<div class="currencies edit-currency">
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
{loop name="currency_edit" type="currency" id="$currency_id" backend_context="1" lang="$edit_language_id"}
|
||||
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a> <span class="divider">/</span></li>
|
||||
<li><a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a> <span class="divider">/</span></li>
|
||||
<li><a href="{url path='/admin/configuration/currencies'}">{intl l="Currencies"}</a> <span class="divider">/</span></li>
|
||||
<li>{intl l='Editing currency "%name"' name="{$NAME}"}</li>
|
||||
</ul>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12 general-block-decorator">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span12 title title-without-tabs">
|
||||
{intl l="Edit currency $NAME"}
|
||||
</div>
|
||||
|
||||
<div class="form-container">
|
||||
<div class="form-horizontal span12">
|
||||
{form name="thelia.admin.currency.modification"}
|
||||
<form method="POST" action="{url path='/admin/configuration/currencies/save-change'}" {form_enctype form=$form}>
|
||||
<fieldset>
|
||||
{* Be sure to get the currency ID, even if the form could not be validated *}
|
||||
<input type="hidden" name="currency_id" value="{$currency_id}" />
|
||||
|
||||
{include file="includes/inner-form-toolbar.html"}
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/currencies'}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$edit_language_locale}" />
|
||||
{/form_field}
|
||||
|
||||
{if $form_error}<div class="alert alert-block alert-error">{$form_error_message}</div>{/if}
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
{intl l='Name *'}
|
||||
</label>
|
||||
|
||||
<div class="controls">
|
||||
{form_field form=$form field='name'}
|
||||
<span {if $error}class="error"{/if}>
|
||||
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency name'}" placeholder="{intl l='Currency name'}" class="input-medium">
|
||||
</span>
|
||||
{/form_field}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
{intl l='ISO 4217 Code *'}
|
||||
<span class="label-help-block"><a title="{intl l='More information about ISO 4217'}" href="http://fr.wikipedia.org/wiki/ISO_4217" target="_blank">List of ISO 4217 code</a></span>
|
||||
</label>
|
||||
|
||||
<div class="controls">
|
||||
{form_field form=$form field='code'}
|
||||
<span {if $error}class="error"{/if}>
|
||||
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency ISO 4217 Code'}" placeholder="{intl l='Code'}" class="input-mini">
|
||||
</span>
|
||||
{/form_field}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="span6">
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
{intl l='Symbol *'}
|
||||
<span class="label-help-block">The symbol, sur as $, £, €...</span>
|
||||
</label>
|
||||
|
||||
<div class="controls">
|
||||
{form_field form=$form field='symbol'}
|
||||
<span {if $error}class="error"{/if}>
|
||||
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency symbol'}" placeholder="{intl l='Symbol'}" class="input-mini">
|
||||
</span>
|
||||
{/form_field}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
{intl l='Rate from € *'}
|
||||
<span class="label-help-block">The rate from Euro</span>
|
||||
</label>
|
||||
|
||||
<div class="controls">
|
||||
{form_field form=$form field='rate'}
|
||||
<span {if $error}class="error"{/if}>
|
||||
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Rate from Euro'}" placeholder="{intl l='Rate'}" class="input-mini">
|
||||
</span>
|
||||
{/form_field}
|
||||
<span class="help-block">Price in Euro x rate = Price in this currency</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<p>{intl l='Currency created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
{/form}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{/loop}
|
||||
|
||||
{elseloop rel="currency_edit"}
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="alert alert-error">
|
||||
{intl l="Sorry, currency ID=$currency_id was not found."}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/elseloop}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
@@ -12,7 +12,7 @@
|
||||
</ul>
|
||||
|
||||
<div class="row-fluid">
|
||||
{loop name="category_edit" type="category" visible="*" id="{$current_category_id}" backend_context="1" lang="$edition_language"}
|
||||
{loop name="category_edit" type="category" visible="*" id="{$current_category_id}" backend_context="1" lang="$edit_language_id"}
|
||||
<div class="span12 general-block-decorator">
|
||||
<div class="row-fluid">
|
||||
<div class="span7 title">
|
||||
@@ -123,7 +123,7 @@
|
||||
<div class="control-group">
|
||||
<lablel> </lablel>
|
||||
<div class="controls">
|
||||
<p>{intl l='Category created on %date_create. Last modification: %date_change' date_create=$CREATE_DATE->format($datetime_format) date_change=$UPDATE_DATE->format($datetime_format)}</p>
|
||||
<p>{intl l='Category created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
<ul class="nav nav-pills">
|
||||
{loop name="lang_list" type="lang" default_only={$default_only}}
|
||||
<li {if $ID == $edition_language}class="active"{/if}>
|
||||
<a href="{$current_url}&edition_language={$ID}" title="{intl l="Edit information in %lng" lng=$TITLE}">
|
||||
<li {if $ID == $edit_language_id}class="active"{/if}>
|
||||
<a href="{$current_url}&edit_language_id={$ID}" title="{intl l="Edit information in %lng" lng=$TITLE}">
|
||||
<img src="{image file="../assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" />
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
{loop name="message_edit" type="message" secured="*" id="$message_id" backend_context="1" lang="$edition_language"}
|
||||
{loop name="message_edit" type="message" secured="*" id="$message_id" backend_context="1" lang="$edit_language_id"}
|
||||
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a> <span class="divider">/</span></li>
|
||||
@@ -47,7 +47,7 @@
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$value|htmlspecialchars}" />
|
||||
<input type="hidden" name="{$name}" value="{{$edit_language_locale}}" />
|
||||
{/form_field}
|
||||
|
||||
{if #form_error}<div class="alert alert-block alert-error">#form_error_message</div>{/if}
|
||||
@@ -144,7 +144,7 @@
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<p>{intl l='Message created on %date_create. Last modification: %date_change' df=$datetime_format date_create=$CREATE_DATE->format($datetime_format) date_change=$UPDATE_DATE->format($datetime_format)}</p>
|
||||
<p>{intl l='Message created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -151,6 +151,10 @@
|
||||
|
||||
<div class="controls">
|
||||
{loop type="lang" name="default-lang" default_only="1"}
|
||||
|
||||
{* Switch edition to the current locale *}
|
||||
<input type="hidden" name="edit_language_id" value="{$ID}" />
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$LOCALE}" />
|
||||
{/form_field}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
{loop name="config_edit" type="config" hidden="*" id="$variable_id" backend_context="1" lang="$edition_language"}
|
||||
{loop name="config_edit" type="config" hidden="*" id="$variable_id" backend_context="1" lang="$edit_language_id"}
|
||||
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a> <span class="divider">/</span></li>
|
||||
@@ -53,7 +53,7 @@
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$value|htmlspecialchars}" />
|
||||
<input type="hidden" name="{$name}" value="{$edit_language_locale}" />
|
||||
{/form_field}
|
||||
|
||||
{if #form_error}<div class="alert alert-block alert-error">#form_error_message</div>{/if}
|
||||
@@ -108,7 +108,7 @@
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<p>{intl l='Variable created on %date_create. Last modification: %date_change' df=$datetime_format date_create=$CREATE_DATE->format($datetime_format) date_change=$UPDATE_DATE->format($datetime_format)}</p>
|
||||
<p>{intl l='Variable created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -34,16 +34,42 @@
|
||||
|
||||
</caption>
|
||||
<tr>
|
||||
<th>{intl l="Purpose"}</th>
|
||||
<th>{intl l="Name"}</th>
|
||||
<th>{intl l="Value"}</th>
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$order
|
||||
order='title'
|
||||
reverse_order='title_reverse'
|
||||
path={url path='/admin/configuration/variables'}
|
||||
label={intl l='Purpose'}
|
||||
}
|
||||
</th>
|
||||
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$order
|
||||
order='name'
|
||||
reverse_order='name_reverse'
|
||||
path={url path='/admin/configuration/variables'}
|
||||
label={intl l='Name'}
|
||||
}
|
||||
</th>
|
||||
|
||||
<th>
|
||||
{admin_sortable_header
|
||||
current_order=$order
|
||||
order='value'
|
||||
reverse_order='value_reverse'
|
||||
path={url path='/admin/configuration/variables'}
|
||||
label={intl l='Value'}
|
||||
}
|
||||
</th>
|
||||
|
||||
{module_include location='variables_table_header'}
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
{loop name="config" type="config" hidden="0" secured="*" backend_context="1" lang="$lang_id"}
|
||||
{loop name="config" type="config" hidden="0" secured="*" backend_context="1" lang="$lang_id" order="$order"}
|
||||
<tr>
|
||||
|
||||
<td>{$TITLE}</td>
|
||||
@@ -172,6 +198,10 @@
|
||||
|
||||
<div class="controls">
|
||||
{loop type="lang" name="default-lang" default_only="1"}
|
||||
|
||||
{* Switch edition to the current locale *}
|
||||
<input type="hidden" name="edit_language_id" value="{$ID}" />
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$LOCALE}" />
|
||||
{/form_field}
|
||||
|
||||
3
templates/default/404.html
Normal file
3
templates/default/404.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<h1>PAGE NOT FOUND</h1>
|
||||
|
||||
<a href="{navigate to="index"}">Back Home</a>
|
||||
Reference in New Issue
Block a user