diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 2f85b57bc..2e83bd7fb 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -405,6 +405,21 @@ Thelia\Controller\Admin\FolderController::updatePositionAction + + + + Thelia\Controller\Admin\CountryController::defaultAction + + + + Thelia\Controller\Admin\CountryController::createAction + + + + Thelia\Controller\Admin\CountryController::updateAction + \d+ + + Thelia\Controller\Admin\ContentController::createAction @@ -668,20 +683,7 @@ - - - Thelia\Controller\Admin\CountryController::indexAction - - - - Thelia\Controller\Admin\CountryController::createAction - - - - Thelia\Controller\Admin\CountryController::updateAction - \d+ - diff --git a/core/lib/Thelia/Controller/Admin/CountryController.php b/core/lib/Thelia/Controller/Admin/CountryController.php index 404c062a4..6efe1f898 100644 --- a/core/lib/Thelia/Controller/Admin/CountryController.php +++ b/core/lib/Thelia/Controller/Admin/CountryController.php @@ -22,31 +22,185 @@ /*************************************************************************************/ namespace Thelia\Controller\Admin; +use Thelia\Core\Event\TheliaEvents; /** * Class CustomerController * @package Thelia\Controller\Admin * @author Manuel Raynaud */ -class CountryController extends BaseAdminController +class CountryController extends AbstractCrudController { - public function indexAction() + + /** + * @param string $objectName the lower case object name. Example. "message" + * + * @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual + * @param string $orderRequestParameterName Name of the request parameter that set the list order (null if list is not sortable) + * + * @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view" + * @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create" + * @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update" + * @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete" + * + * @param string $createEventIdentifier the dispatched create TheliaEvent identifier. Example: TheliaEvents::MESSAGE_CREATE + * @param string $updateEventIdentifier the dispatched update TheliaEvent identifier. Example: TheliaEvents::MESSAGE_UPDATE + * @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE + * + * @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY + * @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION + */ + public function __construct() + { + parent::__construct( + 'country', + 'manual', + 'country_order', + + 'admin.country.default', + 'admin.country.create', + 'admin.country.update', + 'admin.country.delete', + + TheliaEvents::COUNTRY_CREATE, + TheliaEvents::COUNTRY_UPDATE, + TheliaEvents::COUNTRY_DELETE + ); + } + + /** + * Return the creation form for this object + */ + protected function getCreationForm() + { + // TODO: Implement getCreationForm() method. + } + + /** + * Return the update form for this object + */ + protected function getUpdateForm() + { + // TODO: Implement getUpdateForm() method. + } + + /** + * Hydrate the update form for this object, before passing it to the update template + * + * @param unknown $object + */ + protected function hydrateObjectForm($object) + { + // TODO: Implement hydrateObjectForm() method. + } + + /** + * Creates the creation event with the provided form data + * + * @param unknown $formData + */ + protected function getCreationEvent($formData) + { + // TODO: Implement getCreationEvent() method. + } + + /** + * Creates the update event with the provided form data + * + * @param unknown $formData + */ + protected function getUpdateEvent($formData) + { + // TODO: Implement getUpdateEvent() method. + } + + /** + * Creates the delete event with the provided form data + */ + protected function getDeleteEvent() + { + // TODO: Implement getDeleteEvent() method. + } + + /** + * Return true if the event contains the object, e.g. the action has updated the object in the event. + * + * @param unknown $event + */ + protected function eventContainsObject($event) + { + // TODO: Implement eventContainsObject() method. + } + + /** + * Get the created object from an event. + * + * @param unknown $createEvent + */ + protected function getObjectFromEvent($event) + { + // TODO: Implement getObjectFromEvent() method. + } + + /** + * Load an existing object from the database + */ + protected function getExistingObject() + { + // TODO: Implement getExistingObject() method. + } + + /** + * Returns the object label form the object event (name, title, etc.) + * + * @param unknown $object + */ + protected function getObjectLabel($object) + { + // TODO: Implement getObjectLabel() method. + } + + /** + * Returns the object ID from the object + * + * @param unknown $object + */ + protected function getObjectId($object) + { + // TODO: Implement getObjectId() method. + } + + /** + * Render the main list template + * + * @param unknown $currentOrder, if any, null otherwise. + */ + protected function renderListTemplate($currentOrder) { - if (null !== $response = $this->checkAuth("admin.country.view")) return $response; return $this->render("countries", array("display_country" => 20)); } /** - * update country action - * - * @param $country_id - * @return mixed|\Symfony\Component\HttpFoundation\Response + * Render the edition template */ - public function updateAction($country_id) + protected function renderEditionTemplate() { - return $this->render("country-edit", array( - "country_id" => $country_id - )); + // TODO: Implement renderEditionTemplate() method. } + /** + * Redirect to the edition template + */ + protected function redirectToEditionTemplate() + { + // TODO: Implement redirectToEditionTemplate() method. + } + + /** + * Redirect to the list template + */ + protected function redirectToListTemplate() + { + // TODO: Implement redirectToListTemplate() method. + } } diff --git a/core/lib/Thelia/Core/Event/Country/CountryCreateEvent.php b/core/lib/Thelia/Core/Event/Country/CountryCreateEvent.php new file mode 100644 index 000000000..48e8469a4 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Country/CountryCreateEvent.php @@ -0,0 +1,154 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Country; + + +/** + * Class CountryCreateEvent + * @package Thelia\Core\Event\Country + * @author Manuel Raynaud + */ +class CountryCreateEvent extends CountryEvent +{ + protected $locale; + protected $title; + protected $isocode; + protected $isoAlpha2; + protected $isoAlpha3; + + /** + * @var int area zone + */ + protected $area; + + /** + * @param mixed $isoAlpha2 + */ + public function setIsoAlpha2($isoAlpha2) + { + $this->isoAlpha2 = $isoAlpha2; + + return $this; + } + + /** + * @return mixed + */ + public function getIsoAlpha2() + { + return $this->isoAlpha2; + } + + /** + * @param mixed $isoAlpha3 + */ + public function setIsoAlpha3($isoAlpha3) + { + $this->isoAlpha3 = $isoAlpha3; + + return $this; + } + + /** + * @return mixed + */ + public function getIsoAlpha3() + { + return $this->isoAlpha3; + } + + /** + * @param mixed $isocode + */ + public function setIsocode($isocode) + { + $this->isocode = $isocode; + + return $this; + } + + /** + * @return mixed + */ + public function getIsocode() + { + return $this->isocode; + } + + /** + * @param mixed $locale + */ + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + /** + * @return mixed + */ + public function getLocale() + { + return $this->locale; + } + + /** + * @param mixed $title + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * @return mixed + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param int $area + */ + public function setArea($area) + { + $this->area = $area; + + return $this; + } + + /** + * @return int + */ + public function getArea() + { + return $this->area; + } + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Country/CountryDeleteEvent.php b/core/lib/Thelia/Core/Event/Country/CountryDeleteEvent.php new file mode 100644 index 000000000..4a7d9c400 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Country/CountryDeleteEvent.php @@ -0,0 +1,60 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Country; + + +/** + * Class CountryDeleteEvent + * @package Thelia\Core\Event\Country + * @author Manuel Raynaud + */ +class CountryDeleteEvent extends CountryEvent +{ + /** + * @var int country id + */ + protected $country_id; + + function __construct($country_id) + { + $this->country_id = $country_id; + } + + /** + * @param int $country_id + */ + public function setCountryId($country_id) + { + $this->country_id = $country_id; + } + + /** + * @return int + */ + public function getCountryId() + { + return $this->country_id; + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Country/CountryEvent.php b/core/lib/Thelia/Core/Event/Country/CountryEvent.php new file mode 100644 index 000000000..91f7bafa1 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Country/CountryEvent.php @@ -0,0 +1,73 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Country; +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\Country; + + +/** + * Class CountryEvent + * @package Thelia\Core\Event\Country + * @author Manuel Raynaud + */ +class CountryEvent extends ActionEvent +{ + /* + * @var \Thelia\Model\Country + */ + protected $country; + + function __construct(Country $country) + { + $this->country = $country; + } + + /** + * @param mixed $country + */ + public function setCountry(Country $country) + { + $this->country = $country; + + return $this; + } + + /** + * @return null|\Thelia\Model\Country + */ + public function getCountry() + { + return $this->country; + } + + /** + * @return bool + */ + public function hasCountry() + { + return null !== $this->country; + } + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Country/CountryUpdateEvent.php b/core/lib/Thelia/Core/Event/Country/CountryUpdateEvent.php new file mode 100644 index 000000000..5c4ad1cf3 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Country/CountryUpdateEvent.php @@ -0,0 +1,35 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Country; + + +/** + * Class CountryUpdateEvent + * @package Thelia\Core\Event\Country + * @author Manuel Raynaud + */ +class CountryUpdateEvent extends CountryCreateEvent +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index f0dc68702..daf647085 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -183,8 +183,6 @@ final class TheliaEvents const FOLDER_TOGGLE_VISIBILITY = "action.toggleFolderVisibility"; const FOLDER_UPDATE_POSITION = "action.updateFolderPosition"; -// const FOLDER_ADD_CONTENT = "action.categoryAddContent"; -// const FOLDER_REMOVE_CONTENT = "action.categoryRemoveContent"; const BEFORE_CREATEFOLDER = "action.before_createFolder"; const AFTER_CREATEFOLDER = "action.after_createFolder"; @@ -216,6 +214,24 @@ final class TheliaEvents const BEFORE_UPDATECONTENT = "action.before_updateContent"; const AFTER_UPDATECONTENT = "action.after_updateContent"; + // -- country management ----------------------------------------------- + + const COUNTRY_CREATE = "action.createCountry"; + const COUNTRY_UPDATE = "action.updateCountry"; + const COUNTRY_DELETE = "action.deleteCountry"; + const COUNTRY_TOGGLE_VISIBILITY = "action.toggleCountryVisibility"; + //const COUNTRY_UPDATE_POSITION = "action.updateFolderPosition"; + + + const BEFORE_CREATECOUNTRY = "action.before_createCountry"; + const AFTER_CREATECOUNTRY = "action.after_createCountry"; + + const BEFORE_DELETECOUNTRY = "action.before_deleteCountry"; + const AFTER_DELETECOUNTRY = "action.after_deleteCountry"; + + const BEFORE_UPDATECOUNTRY = "action.before_updateCountry"; + const AFTER_UPDATECOUNTRY = "action.after_updateCountry"; + // -- Categories Associated Content ---------------------------------------- const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent"; diff --git a/core/lib/Thelia/Model/Country.php b/core/lib/Thelia/Model/Country.php index a7a6c23b9..56a7667cf 100755 --- a/core/lib/Thelia/Model/Country.php +++ b/core/lib/Thelia/Model/Country.php @@ -6,4 +6,7 @@ use Thelia\Model\Base\Country as BaseCountry; class Country extends BaseCountry { + + + } diff --git a/templates/admin/default/countries.html b/templates/admin/default/countries.html index fe1b614a1..bf68db361 100644 --- a/templates/admin/default/countries.html +++ b/templates/admin/default/countries.html @@ -35,12 +35,12 @@ - ID - Name - Default - Shop - N° ISO - ISO Code + {intl l="ID"} + {intl l="Name"} + {intl l="Default"} + {intl l="Shop"} + {intl l="N° ISO"} + {intl l="ISO Code"} {module_include location='countries_table_header'}