diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 5c9399e27..3ed059e7e 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -290,6 +290,18 @@ + + + + Thelia\Controller\Admin\CountryController::indexAction + + + + Thelia\Controller\Admin\CountryController::createAction + + + + diff --git a/core/lib/Thelia/Controller/Admin/CountryController.php b/core/lib/Thelia/Controller/Admin/CountryController.php new file mode 100644 index 000000000..172552893 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/CountryController.php @@ -0,0 +1,39 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +/** + * Class CustomerController + * @package Thelia\Controller\Admin + * @author Manuel Raynaud + */ +class CountryController extends BaseAdminController +{ + public function indexAction() + { + if (null !== $response = $this->checkAuth("admin.country.view")) return $response; + return $this->render("countries", array("display_country" => 20)); + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/CountryCreationForm.php b/core/lib/Thelia/Form/CountryCreationForm.php new file mode 100644 index 000000000..2c56a1b6a --- /dev/null +++ b/core/lib/Thelia/Form/CountryCreationForm.php @@ -0,0 +1,59 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class CountryCreationForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("title", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Category title *"), + "label_attr" => array( + "for" => "title" + ) + )) + ->add("parent", "integer", array( + "constraints" => array( + new NotBlank() + ) + )) + ->add("locale", "text", array( + "constraints" => array( + new NotBlank() + ) + )) + ; + } + + public function getName() + { + return "thelia_country_creation"; + } +} diff --git a/templates/admin/default/countries.html b/templates/admin/default/countries.html new file mode 100644 index 000000000..b3e2254b8 --- /dev/null +++ b/templates/admin/default/countries.html @@ -0,0 +1,168 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Countries'}{/block} + +{block name="check-permissions"}admin.configuration.countries.view{/block} + +{block name="main-content"} + + + + + + {intl l="Home"} + {intl l="Configuration"} + {intl l="Countries"} + + + {module_include location='countries_top'} + + + + + + + + + + + {intl l='Countries'} + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.countries.create"} + + + + {/loop} + + + + ID + Name + Default + Shop + N° ISO + ISO Code + + {module_include location='countries_table_header'} + + {intl l='Actions'} + + + + + {loop name="countries" type="country" backend_context="1" lang=$lang_id order=$order} + + {$ID} + {$TITLE} + + + + + + + + + + + {$ISOCODE} + {$ISOALPHA3} + + {module_include location='countries_table_row'} + + + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.countries.change"} + + + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.countries.delete"} + + + + {/loop} + + + + {/loop} + {elseloop rel="countries"} + + + + {intl l="No country has been created yet. Click the + button to create one."} + + + + {/elseloop} + + + + + + + + + + + + {module_include location='countries_bottom'} + + + + + {* Adding a new Country *} + + {form name="thelia.admin.country.creation"} + + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "country_creation_dialog"} + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} + + {/form_field} + + {form_field form=$form field='parent'} + + {/form_field} + + + + {module_include location='country_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "add_country_dialog" + dialog_title = {intl l="Create a new country"} + dialog_body = {$smarty.capture.country_creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this country"} + dialog_cancel_label = {intl l="Cancel"} + + form_action = {url path='/admin/configuration/countries/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } + {/form} + +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + + + {/javascripts} + +{/block} \ No newline at end of file diff --git a/templates/admin/default/country-edit.html b/templates/admin/default/country-edit.html new file mode 100644 index 000000000..e69de29bb