diff --git a/core/lib/Thelia/Action/Currency.php b/core/lib/Thelia/Action/Currency.php
index 4e3bb45d4..5ed2fb875 100644
--- a/core/lib/Thelia/Action/Currency.php
+++ b/core/lib/Thelia/Action/Currency.php
@@ -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),
+
);
}
}
diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml
index 627fa9bf3..58645d531 100755
--- a/core/lib/Thelia/Config/Resources/routing/admin.xml
+++ b/core/lib/Thelia/Config/Resources/routing/admin.xml
@@ -101,6 +101,14 @@
Thelia\Controller\Admin\CurrencyController::saveChangeAction
+
+ Thelia\Controller\Admin\CurrencyController::setDefaultAction
+
+
+
+ Thelia\Controller\Admin\CurrencyController::updateRatesAction
+
+
Thelia\Controller\Admin\CurrencyController::deleteAction
diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php
index b4b10e9be..949344685 100755
--- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php
+++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php
@@ -150,6 +150,27 @@ 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
*/
diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/ConfigController.php
index c6fab6b1b..f7e62ff19 100644
--- a/core/lib/Thelia/Controller/Admin/ConfigController.php
+++ b/core/lib/Thelia/Controller/Admin/ConfigController.php
@@ -239,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
@@ -295,7 +296,7 @@ class ConfigController extends BaseAdminController
$this->dispatch(TheliaEvents::CONFIG_SETVALUE, $event);
}
- $this->redirect(URL::absoluteUrl('/admin/configuration/variables'));
+ $this->redirectToRoute('admin.configuration.variables.default');
}
/**
@@ -313,6 +314,6 @@ class ConfigController extends BaseAdminController
$this->dispatch(TheliaEvents::CONFIG_DELETE, $event);
- $this->redirect(URL::absoluteUrl('/admin/configuration/variables'));
+ $this->redirectToRoute('admin.configuration.variables.default');
}
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Controller/Admin/CurrencyController.php b/core/lib/Thelia/Controller/Admin/CurrencyController.php
index b9ca98083..2fae3315b 100644
--- a/core/lib/Thelia/Controller/Admin/CurrencyController.php
+++ b/core/lib/Thelia/Controller/Admin/CurrencyController.php
@@ -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());
@@ -120,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)
;
}
@@ -169,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
@@ -193,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());
@@ -230,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
@@ -241,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)
;
}
@@ -266,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
*
@@ -281,6 +322,6 @@ class CurrencyController extends BaseAdminController
$this->dispatch(TheliaEvents::CURRENCY_DELETE, $event);
- $this->redirect(URL::adminViewUrl('currencies'));
+ $this->redirectToRoute('admin.configuration.currencies.default');
}
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Controller/Admin/MessageController.php b/core/lib/Thelia/Controller/Admin/MessageController.php
index 5a53fd28a..29ee83df4 100644
--- a/core/lib/Thelia/Controller/Admin/MessageController.php
+++ b/core/lib/Thelia/Controller/Admin/MessageController.php
@@ -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
diff --git a/core/lib/Thelia/Controller/Admin/SessionController.php b/core/lib/Thelia/Controller/Admin/SessionController.php
index 552fea8eb..a377df208 100755
--- a/core/lib/Thelia/Controller/Admin/SessionController.php
+++ b/core/lib/Thelia/Controller/Admin/SessionController.php
@@ -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()
diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php
index a15226e83..853776214 100755
--- a/core/lib/Thelia/Controller/BaseController.php
+++ b/core/lib/Thelia/Controller/BaseController.php
@@ -31,14 +31,13 @@ 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;
-
/**
*
* The defaut administration controller. Basically, display the login form if
@@ -203,6 +202,25 @@ 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
@@ -211,4 +229,4 @@ class BaseController extends ContainerAware
{
throw new NotFoundHttpException();
}
-}
+}
\ No newline at end of file
diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php
index c466ab0c6..b6d4a6f93 100755
--- a/core/lib/Thelia/Controller/Front/BaseFrontController.php
+++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php
@@ -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));
+ }
}
diff --git a/core/lib/Thelia/Core/Event/CurrencyChangeEvent.php b/core/lib/Thelia/Core/Event/CurrencyChangeEvent.php
index f94d71b88..1e7677fee 100644
--- a/core/lib/Thelia/Core/Event/CurrencyChangeEvent.php
+++ b/core/lib/Thelia/Core/Event/CurrencyChangeEvent.php
@@ -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;
}
-}
\ No newline at end of file
+
+ public function getIsDefault()
+ {
+ return $this->is_default;
+ }
+
+ public function setIsDefault($is_default)
+ {
+ $this->is_default = $is_default;
+
+ return $this;
+ }
+}
diff --git a/core/lib/Thelia/Core/Event/CurrencyCreateEvent.php b/core/lib/Thelia/Core/Event/CurrencyCreateEvent.php
index fba23a09b..d9d345ddd 100644
--- a/core/lib/Thelia/Core/Event/CurrencyCreateEvent.php
+++ b/core/lib/Thelia/Core/Event/CurrencyCreateEvent.php
@@ -65,6 +65,8 @@ class CurrencyCreateEvent extends CurrencyEvent
public function setSymbol($symbol)
{
$this->symbol = $symbol;
+
+ return $this;
}
public function getCode()
diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php
index 8bca60bb4..ba7f46b8e 100755
--- a/core/lib/Thelia/Core/Event/TheliaEvents.php
+++ b/core/lib/Thelia/Core/Event/TheliaEvents.php
@@ -211,9 +211,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";
diff --git a/core/lib/Thelia/Core/Template/Loop/Address.php b/core/lib/Thelia/Core/Template/Loop/Address.php
index eb837eb4b..43bbbaefb 100755
--- a/core/lib/Thelia/Core/Template/Loop/Address.php
+++ b/core/lib/Thelia/Core/Template/Loop/Address.php
@@ -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);
}
diff --git a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php
index 63f1e9cfb..afcd0410e 100755
--- a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php
+++ b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php
@@ -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);
diff --git a/core/lib/Thelia/Core/Template/Loop/Config.php b/core/lib/Thelia/Core/Template/Loop/Config.php
index 684803385..f8819afef 100644
--- a/core/lib/Thelia/Core/Template/Loop/Config.php
+++ b/core/lib/Thelia/Core/Template/Loop/Config.php
@@ -164,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);
}
diff --git a/core/lib/Thelia/Core/Template/Loop/Currency.php b/core/lib/Thelia/Core/Template/Loop/Currency.php
index b6756fbe6..6db6c6223 100755
--- a/core/lib/Thelia/Core/Template/Loop/Currency.php
+++ b/core/lib/Thelia/Core/Template/Loop/Currency.php
@@ -177,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);
}
diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php
index a35ff90b3..17ecd3212 100755
--- a/core/lib/Thelia/Core/Template/Loop/Product.php
+++ b/core/lib/Thelia/Core/Template/Loop/Product.php
@@ -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);
diff --git a/core/lib/Thelia/Form/CurrencyCreationForm.php b/core/lib/Thelia/Form/CurrencyCreationForm.php
index 11a496582..a4d858ed6 100644
--- a/core/lib/Thelia/Form/CurrencyCreationForm.php
+++ b/core/lib/Thelia/Form/CurrencyCreationForm.php
@@ -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));
}
}
diff --git a/core/lib/Thelia/Form/CurrencyModificationForm.php b/core/lib/Thelia/Form/CurrencyModificationForm.php
index 6a4279d1b..3f0b1f152 100644
--- a/core/lib/Thelia/Form/CurrencyModificationForm.php
+++ b/core/lib/Thelia/Form/CurrencyModificationForm.php
@@ -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()
diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php
index 26343142e..a3ad2ce77 100755
--- a/core/lib/Thelia/Model/Category.php
+++ b/core/lib/Thelia/Model/Category.php
@@ -2,6 +2,7 @@
namespace Thelia\Model;
+use Thelia\Core\Event\CategoryEvent;
use Thelia\Model\Base\Category as BaseCategory;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Tools\URL;
diff --git a/install/insert.sql b/install/insert.sql
index 780be7ae4..a4b7d3c1b 100755
--- a/install/insert.sql
+++ b/install/insert.sql
@@ -6,14 +6,15 @@ INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`by_default`,`created_at`,
INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES
('session_config.default', '1', 1, 1, NOW(), NOW()),
-('verifyStock', '1', 1, 0, NOW(), NOW()),
-('default_lang_without_translation', '1', 1, 0, NOW(), NOW()),
-('rewriting_enable', '0', 1, 0, NOW(), NOW()),
-('imagine_graphic_driver', 'gd', 1, 0, NOW(), NOW()),
-('default_images_quality_percent', '75', 1, 0, NOW(), NOW()),
-('original_image_delivery_mode', 'symlink', 1, 0, NOW(), NOW()),
-('images_library_path', 'local/media/images', 1, 0, NOW(), NOW()),
-('image_cache_dir_from_web_root', 'cache/images', 1, 0, NOW(), NOW());
+('verifyStock', '1', 0, 0, NOW(), NOW()),
+('default_lang_without_translation', '1', 0, 0, NOW(), NOW()),
+('rewriting_enable', '0', 0, 0, NOW(), NOW()),
+('imagine_graphic_driver', 'gd', 0, 0, NOW(), NOW()),
+('default_images_quality_percent', '75', 0, 0, NOW(), NOW()),
+('original_image_delivery_mode', 'symlink', 0, 0, NOW(), NOW()),
+('images_library_path', 'local/media/images', 0, 0, NOW(), NOW()),
+('image_cache_dir_from_web_root', 'cache/images', 0, 0, NOW(), NOW()),
+('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()),
('page_not_found_view', '404.html', 0, 0, NOW(), NOW());
INSERT INTO `module` (`code`, `type`, `activate`, `position`, `created_at`, `updated_at`) VALUES ('test', '1', '1', '1', NOW(), NOW());
@@ -39,12 +40,12 @@ VALUES
INSERT INTO `currency_i18n` (`id` ,`locale` ,`name`)
VALUES
-(1, 'fr_FR', 'euro'),
-(1, 'en_UK', 'euro'),
-(2, 'fr_FR', 'dollar'),
-(2, 'en_UK', 'dollar'),
-(3, 'fr_FR', 'livre'),
-(3, 'en_UK', 'pound');
+(1, 'fr_FR', 'Euro'),
+(1, 'en_UK', 'Euro'),
+(2, 'fr_FR', 'Dollar Américain'),
+(2, 'en_UK', 'United States Dollar'),
+(3, 'fr_FR', 'Livre anglaise'),
+(3, 'en_UK', 'UK Pound');
INSERT INTO `country` (`id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `created_at`, `updated_at`) VALUES
diff --git a/templates/admin/default/assets/css/admin.less b/templates/admin/default/assets/css/admin.less
index 9a01cfb67..0bc9fc274 100755
--- a/templates/admin/default/assets/css/admin.less
+++ b/templates/admin/default/assets/css/admin.less
@@ -658,6 +658,7 @@ label {
font-weight: normal;
}
+
.form-horizontal input + .help-block,
.form-horizontal select + .help-block,
.form-horizontal textarea + .help-block,
@@ -665,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,
diff --git a/templates/admin/default/currencies.html b/templates/admin/default/currencies.html
index 6671c131f..a693214d7 100644
--- a/templates/admin/default/currencies.html
+++ b/templates/admin/default/currencies.html
@@ -26,7 +26,7 @@