diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 09a1e60e8..67c856a05 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -153,6 +153,8 @@
+ + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 654478642..bea1428ed 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -926,6 +926,11 @@ Thelia\Controller\Admin\LangController::defaultAction + + Thelia\Controller\Admin\LangController::updateAction + \d+ + + diff --git a/core/lib/Thelia/Controller/Admin/LangController.php b/core/lib/Thelia/Controller/Admin/LangController.php index 637cea161..aec455b4a 100644 --- a/core/lib/Thelia/Controller/Admin/LangController.php +++ b/core/lib/Thelia/Controller/Admin/LangController.php @@ -22,8 +22,11 @@ /*************************************************************************************/ namespace Thelia\Controller\Admin; + use Thelia\Core\Security\AccessManager; use Thelia\Core\Security\Resource\AdminResources; +use Thelia\Form\Lang\LangUpdateForm; +use Thelia\Model\LangQuery; /** @@ -38,6 +41,30 @@ class LangController extends BaseAdminController { if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::VIEW)) return $response; - return $this->render('lang'); + return $this->render('languages'); + } + + public function updateAction($lang_id) + { + if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::UPDATE)) return $response; + + $this->checkXmlHttpRequest(); + + $lang = LangQuery::create()->findPk($lang_id); + + $langForm = new LangUpdateForm($this->getRequest(), 'form', array( + 'id' => $lang->getId(), + 'title' => $lang->getTitle(), + 'code' => $lang->getCode(), + 'locale' => $lang->getLocale(), + 'date_format' => $lang->getDateFormat(), + 'time_format' => $lang->getTimeFormat() + )); + + $this->getParserContext()->addForm($langForm); + + return $this->render('ajax/language-update-modal', array( + 'lang_id' => $lang_id + )); } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Loop/Lang.php b/core/lib/Thelia/Core/Template/Loop/Lang.php index 487acb565..52a866d30 100755 --- a/core/lib/Thelia/Core/Template/Loop/Lang.php +++ b/core/lib/Thelia/Core/Template/Loop/Lang.php @@ -99,7 +99,8 @@ class Lang extends BaseLoop ->set("LOCALE", $result->getLocale()) ->set("URL", $result->getUrl()) ->set("IS_DEFAULT", $result->getByDefault()) - ->set("URL", $result->getUrl()) + ->set("DATE_FORMAT", $result->getDateFormat()) + ->set("TIME_FORMAT", $result->getTimeFormat()) ->set("POSITION", $result->getPosition()) ; diff --git a/core/lib/Thelia/Form/Lang/LangCreateForm.php b/core/lib/Thelia/Form/Lang/LangCreateForm.php new file mode 100644 index 000000000..deef71802 --- /dev/null +++ b/core/lib/Thelia/Form/Lang/LangCreateForm.php @@ -0,0 +1,116 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form\Lang; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Form\BaseForm; +use Thelia\Core\Translation\Translator; + + +/** + * Class LangCreateForm + * @package Thelia\Form\Lang + * @author Manuel Raynaud + */ +class LangCreateForm extends BaseForm +{ + + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->formBuilder attribute : + * + * $this->formBuilder->add("name", "text") + * ->add("email", "email", array( + * "attr" => array( + * "class" => "field" + * ), + * "label" => "email", + * "constraints" => array( + * new \Symfony\Component\Validator\Constraints\NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ + protected function buildForm() + { + $this->formBuilder + ->add('title', 'text', array( + 'constraints' => array( + new NotBlank() + ), + 'label' => Translator::getInstance()->trans('Language name'), + 'label_attr' => array( + 'for' => 'title_lang' + ) + )) + ->add('code', 'text', array( + 'constraints' => array( + new NotBlank() + ), + 'label' => Translator::getInstance()->trans('ISO 639 Code'), + 'label_attr' => array( + 'for' => 'code_lang' + ) + )) + ->add('locale', 'text', array( + 'constraints' => array( + new NotBlank() + ), + 'label' => Translator::getInstance()->trans('language locale'), + 'label_attr' => array( + 'for' => 'locale_lang' + ) + )) + ->add('date_format', 'text', array( + 'constraints' => array( + new NotBlank() + ), + 'label' => Translator::getInstance()->trans('date format'), + 'label_attr' => array( + 'for' => 'date_lang' + ) + )) + ->add('time_format', 'text', array( + 'constraints' => array( + new NotBlank() + ), + 'label' => Translator::getInstance()->trans('time format'), + 'label_attr' => array( + 'for' => 'time_lang' + ) + )) + ; + } + + /** + * @return string the name of you form. This name must be unique + */ + public function getName() + { + return 'thelia_language_create'; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/Lang/LangUpdateForm.php b/core/lib/Thelia/Form/Lang/LangUpdateForm.php new file mode 100644 index 000000000..0463335f7 --- /dev/null +++ b/core/lib/Thelia/Form/Lang/LangUpdateForm.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form\Lang; +use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\NotBlank; + + +/** + * Class LangUpdateForm + * @package Thelia\Form\Lang + * @author Manuel Raynaud + */ +class LangUpdateForm extends LangCreateForm +{ + + public function buildForm() + { + parent::buildForm(); + + $this->formBuilder + ->add('id', 'hidden', array( + 'constraints' => array( + new NotBlank(), + new GreaterThan(array('value' => 0)) + ) + )); + } + + public function getName() + { + return 'thelia_lang_update'; + } +} \ No newline at end of file diff --git a/templates/admin/default/ajax/language-update-modal.html b/templates/admin/default/ajax/language-update-modal.html new file mode 100644 index 000000000..909b351b0 --- /dev/null +++ b/templates/admin/default/ajax/language-update-modal.html @@ -0,0 +1,64 @@ +{* Update an Address *} + +{form name="thelia.lang.update"} + +{* Capture the dialog body, to pass it to the generic dialog *} +{capture "edit_lang_dialog"} + + {form_hidden_fields form=$form} + + {form_field form=$form field='title'} +
+ + +
+ {/form_field} + + {form_field form=$form field='code'} +
+ + +
+ {/form_field} + + {form_field form=$form field='locale'} +
+ + +
+ {/form_field} + + {form_field form=$form field='date_format'} +
+ + +
+ {/form_field} + + {form_field form=$form field='time_format'} +
+ + +
+ {/form_field} + + + +{/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "edit_lang_dialog" + dialog_title = {intl l="Edit a language"} + dialog_body = {$smarty.capture.edit_lang_dialog nofilter} + +dialog_ok_label = {intl l="Edit this language"} +dialog_cancel_label = {intl l="Cancel"} + +form_action = {url path="/admin/configuration/languages/save/{$lang_id}"} +form_enctype = {form_enctype form=$form} +form_error_message = $form_error_message +} + +{/form} \ No newline at end of file diff --git a/templates/admin/default/lang.html b/templates/admin/default/lang.html deleted file mode 100644 index 9711c21f1..000000000 --- a/templates/admin/default/lang.html +++ /dev/null @@ -1,46 +0,0 @@ -{extends file="admin-layout.tpl"} - -{block name="page-title"}{intl l='Languages an URLs'}{/block} - -{block name="check-resource"}admin.configuration.languages{/block} -{block name="check-access"}view{/block} - -{block name="main-content"} -
- -
- - -
-
-
- - - - - - - - - - {module_include location='modules_table_header'} - - - - - -
- {intl l="Languages management"} -
{intl l="Title"}{intl l="code ISO 639"}{intl l="locale"}{intl l="locale"}{intl l="Actions"}
-
-
-
-
-
- -{/block} \ No newline at end of file diff --git a/templates/admin/default/languages.html b/templates/admin/default/languages.html index 868d911be..76249b74a 100644 --- a/templates/admin/default/languages.html +++ b/templates/admin/default/languages.html @@ -19,7 +19,7 @@ {module_include location='languages_top'}
-
+
@@ -38,61 +38,43 @@ {intl l="Language name"} {intl l="ISO 639 Code"} + {intl l="Locale"} + {intl l="date form"} + {intl l="time form"} {intl l="Default"} {intl l="Actions"} + {loop type="lang" name="lang.list" backend_context="1"} - - + {$TITLE} + {$CODE} + {$LOCALE} + {$DATE_FORMAT} + {$TIME_FORMAT}
- +
- +
- -
- - - - - - -
- -
- - -
- -
- - - - - - -
- -
- - -
- + {loop type="auth" name="can_change" role="ADMIN" resource="admin.configuration.language" access="UPDATE"} + + + + {/loop} + {loop type="auth" name="can_change" role="ADMIN" resource="admin.configuration.language" access="DELETE"} + + + + {/loop}
+ {/loop} - - - - - - - @@ -100,13 +82,18 @@
+ + +
+ +
- +
{intl l="Parameters"}
- +
@@ -124,24 +111,19 @@
- -
- -
-
+
{intl l="Association language/URL"}
-
+
-
+ -
@@ -169,7 +151,6 @@ -
@@ -249,6 +230,7 @@ form_content = {$smarty.capture.delete_dialog nofilter} } +
{/block} {block name="javascript-initialization"} @@ -270,4 +252,23 @@ {javascripts file='assets/js/bootstrap-select/bootstrap-select.js'} {/javascripts} + + {/block} \ No newline at end of file