From da7fcc4274ca15bf9116559a81eee77972c45697 Mon Sep 17 00:00:00 2001 From: franck Date: Tue, 3 Sep 2013 18:58:51 +0200 Subject: [PATCH 1/4] Added route methods --- core/lib/Thelia/Controller/BaseController.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index c7c9f6f14..49d65f22f 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -36,6 +36,7 @@ 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; /** * @@ -200,4 +201,20 @@ class BaseController extends ContainerAware if (null !== $url) $this->redirect($url); } + + /** + * Get a route path from the route id. + * + * @param unknown $routerName either admin.router or front.router + * @param unknown $routeName the route ID + */ + 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(); + } } From 7128739da537a039a3d1781c83ab7fcd8ab0521f Mon Sep 17 00:00:00 2001 From: franck Date: Tue, 3 Sep 2013 19:03:54 +0200 Subject: [PATCH 2/4] Finished currency edition --- templates/admin/default/currency-edit.html | 147 +++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 templates/admin/default/currency-edit.html diff --git a/templates/admin/default/currency-edit.html b/templates/admin/default/currency-edit.html new file mode 100644 index 000000000..a6c6b5500 --- /dev/null +++ b/templates/admin/default/currency-edit.html @@ -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"} +
+ +
+ + {loop name="currency_edit" type="currency" id="$currency_id" backend_context="1" lang="$edit_language_id"} + + + +
+
+
+ +
+ {intl l="Edit currency $NAME"} +
+ +
+
+ {form name="thelia.admin.currency.modification"} +
+
+ {* Be sure to get the currency ID, even if the form could not be validated *} + + + {include file="includes/inner-form-toolbar.html"} + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {form_field form=$form field='locale'} + + {/form_field} + + {if $form_error}
{$form_error_message}
{/if} + +
+
+
+ + +
+ {form_field form=$form field='name'} + + + + {/form_field} +
+
+ +
+ + +
+ {form_field form=$form field='code'} + + + + {/form_field} +
+
+
+ +
+
+ + +
+ {form_field form=$form field='symbol'} + + + + {/form_field} +
+
+ +
+ + +
+ {form_field form=$form field='rate'} + + + + {/form_field} + Price in Euro * rate = Price in this currency +
+
+
+
+ +
+
+

{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}"}

+
+
+ +
+
+ {/form} +
+
+
+
+ +
+ + {/loop} + + {elseloop rel="currency_edit"} +
+
+
+ {intl l="Sorry, currency ID=$currency_id was not found."} +
+
+
+ {/elseloop} + +
+
+{/block} \ No newline at end of file From 26da884daeefe4d778cef50f3a2cddde8c87d810 Mon Sep 17 00:00:00 2001 From: franck Date: Tue, 3 Sep 2013 19:32:57 +0200 Subject: [PATCH 3/4] Fixed minor bug in Currencies --- core/lib/Thelia/Action/Currency.php | 1 + .../Controller/Admin/CurrencyController.php | 4 ---- core/lib/Thelia/Form/CurrencyCreationForm.php | 16 ++++++++-------- install/insert.sql | 12 ++++++------ templates/admin/default/assets/css/admin.less | 4 +++- templates/admin/default/currency-edit.html | 2 +- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/core/lib/Thelia/Action/Currency.php b/core/lib/Thelia/Action/Currency.php index 58257c012..5ed2fb875 100644 --- a/core/lib/Thelia/Action/Currency.php +++ b/core/lib/Thelia/Action/Currency.php @@ -60,6 +60,7 @@ class Currency extends BaseAction implements EventSubscriberInterface ->save() ; + $event->setCurrency($currency); } diff --git a/core/lib/Thelia/Controller/Admin/CurrencyController.php b/core/lib/Thelia/Controller/Admin/CurrencyController.php index 654a92bcf..2fae3315b 100644 --- a/core/lib/Thelia/Controller/Admin/CurrencyController.php +++ b/core/lib/Thelia/Controller/Admin/CurrencyController.php @@ -125,10 +125,6 @@ class CurrencyController extends BaseAdminController catch (\Exception $ex) { // Any other error $error_msg = sprintf("Sorry, an error occured: %s", $ex->getMessage()); - - var_dump($ex); - - exit; } if ($error_msg !== false) { diff --git a/core/lib/Thelia/Form/CurrencyCreationForm.php b/core/lib/Thelia/Form/CurrencyCreationForm.php index 6150947b8..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" => $name_constraints)) + ->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/install/insert.sql b/install/insert.sql index 761704362..5bf2538a1 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -39,12 +39,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/currency-edit.html b/templates/admin/default/currency-edit.html index a6c6b5500..86b6fbf25 100644 --- a/templates/admin/default/currency-edit.html +++ b/templates/admin/default/currency-edit.html @@ -108,7 +108,7 @@ {/form_field} - Price in Euro * rate = Price in this currency + Price in Euro x rate = Price in this currency From 1b7a36addfff7609536f68b423220bb9cb487dab Mon Sep 17 00:00:00 2001 From: mespeche Date: Wed, 4 Sep 2013 09:58:59 +0200 Subject: [PATCH 4/4] Working Fix unset namespace --- core/lib/Thelia/Model/Category.php | 1 + 1 file changed, 1 insertion(+) 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;