From 84a23141087eefcf8ad5985a5c3d2f119370053a Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 28 Aug 2013 18:06:22 +0200 Subject: [PATCH] WIP - Add Coupon BackOffice controller - Add Coupon BackOffice template skeleton - Add Coupon BackOffice routes --- .../Thelia/Config/Resources/routing/admin.xml | 11 +- .../Controller/Admin/CouponController.php | 202 ++++++++++++------ templates/admin/default/coupon/edit.html | 30 +++ templates/admin/default/coupon/list.html | 29 +++ templates/admin/default/coupon/read.html | 29 +++ .../default/includes/coupon_breadcrumb.html | 8 + templates/default/coupon.html | 5 - 7 files changed, 246 insertions(+), 68 deletions(-) create mode 100755 templates/admin/default/coupon/edit.html create mode 100755 templates/admin/default/coupon/list.html create mode 100755 templates/admin/default/coupon/read.html create mode 100755 templates/admin/default/includes/coupon_breadcrumb.html delete mode 100755 templates/default/coupon.html diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index df1495953..2561dcc99 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -36,9 +36,18 @@ - + Thelia\Controller\Admin\CouponController::indexAction + + Thelia\Controller\Admin\CouponController::createAction + + + Thelia\Controller\Admin\CouponController::editAction + + + Thelia\Controller\Admin\CouponController::readAction + diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index 67d1e451e..e6159c9ac 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -1,92 +1,170 @@ . */ -/* */ -/*************************************************************************************/ +/**********************************************************************************/ +/* */ +/* Thelia */ +/* */ +/* Copyright (c) OpenStudio */ +/* email : info@thelia.net */ +/* web : http://www.thelia.net */ +/* */ +/* This program is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation; either version 3 of the License */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program. If not, see . */ +/* */ +/**********************************************************************************/ namespace Thelia\Controller\Admin; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthorizationException; +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Control View and Action (Model) via Events + * + * @package Coupon + * @author Guillaume MOREL + * + */ class CouponController extends BaseAdminController { - - protected function browseCoupon($args) - { - $this->checkAuth("ADMIN", "admin.coupon.view"); - - return $this->render('coupons', $args); - } - + /** + * List all Coupons Action + * + * @return \Symfony\Component\HttpFoundation\Response + */ public function indexAction() { return $this->processAction(); } - public function processAction() + /** + * Create a Coupon Action + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function createAction() + { + return $this->processAction('create'); + } + + /** + * Edit a Coupon Action + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function editAction() + { + return $this->processAction('edit'); + } + + /** + * Read a Coupon Action + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function readAction() + { + return $this->processAction('read'); + } + + /** + * Manage Coupons list display + * + * @param array $args GET arguments + * + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function browseCoupons($args) + { + $this->checkAuth("ADMIN", "admin.coupon.view"); + + return $this->render('coupon/list', $args); + } + + /** + * Manage Coupons creation display + * + * @param array $args GET arguments + * + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function createCoupon($args) + { + $this->checkAuth("ADMIN", "admin.coupon.view"); + + return $this->render('coupon/edit', $args); + } + + /** + * Manage Coupons edition display + * + * @param array $args GET arguments + * + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function editCoupon($args) + { + $this->checkAuth("ADMIN", "admin.coupon.view"); + + return $this->render('coupon/edit', $args); + } + + /** + * Manage Coupons read display + * + * @param array $args GET arguments + * + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function readCoupon($args) + { + $this->checkAuth("ADMIN", "admin.coupon.view"); + + return $this->render('coupon/read', $args); + } + + /** + * Process all Actions + * + * @param string $action Action to process + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function processAction($action = 'browse') { // Get the current action - $action = $this->getRequest()->get('action', 'browse'); +// $action = $this->getRequest()->get('action', 'browse'); // Get the category ID - $id = $this->getRequest()->get('id', 0); +// $id = $this->getRequest()->get('id', 0); $args = array( 'action' => $action, - 'current_coupon_id' => $id +// 'current_coupon_id' => $id ); try { switch ($action) { case 'browse' : // Browse coupon - return $this->browseCoupons($args); - - case 'create' : // Create a new category - -// return $this->createNewCategory($args); - - case 'edit' : // Edit an existing category - -// return $this->editCategory($args); - - case 'delete' : // Delete an existing category - -// return $this->deleteCategory($args); - - case 'visibilityToggle' : // Toggle visibility - -// return $this->visibilityToggle($id); - - case 'changePosition' : // Change position - -// return $this->changePosition($args); - - case 'positionUp' : // Move up category - -// return $this->positionUp($args); - - case 'positionDown' : // Move down category - -// return $this->positionDown($args); + case 'create' : // Create a new coupon + return $this->createCoupon($args); + case 'edit' : // Edit an existing coupon + return $this->editCoupon($args); + case 'read' : // Read an existing coupon + return $this->readCoupon($args); } } catch (AuthorizationException $ex) { return $this->errorPage($ex->getMessage()); diff --git a/templates/admin/default/coupon/edit.html b/templates/admin/default/coupon/edit.html new file mode 100755 index 000000000..017414ec4 --- /dev/null +++ b/templates/admin/default/coupon/edit.html @@ -0,0 +1,30 @@ +{check_auth context="admin" roles="ADMIN" permissions="admin.coupon.view" login_tpl="/admin/login"} + +{$page_title={intl l='Coupon'}} + +{$thelia_page_css_file = "assets/bootstrap-editable/css/bootstrap-editable.css"} + +{include file='includes/header.inc.html'} + +
+
+ + + +

EDIT

+
+
+ + +{include file='includes/js.inc.html'} + +{javascripts file='../assets/bootstrap-editable/js/bootstrap-editable.js'} + +{/javascripts} + + + +{include file='includes/footer.inc.html'} diff --git a/templates/admin/default/coupon/list.html b/templates/admin/default/coupon/list.html new file mode 100755 index 000000000..95b2da098 --- /dev/null +++ b/templates/admin/default/coupon/list.html @@ -0,0 +1,29 @@ +{check_auth context="admin" roles="ADMIN" permissions="admin.coupon.view" login_tpl="/admin/login"} + +{$page_title={intl l='Coupon'}} + +{$thelia_page_css_file = "assets/bootstrap-editable/css/bootstrap-editable.css"} + +{include file='includes/header.inc.html'} + +
+
+ + +

List

+
+
+ + +{include file='includes/js.inc.html'} + +{javascripts file='../assets/bootstrap-editable/js/bootstrap-editable.js'} + +{/javascripts} + + + +{include file='includes/footer.inc.html'} diff --git a/templates/admin/default/coupon/read.html b/templates/admin/default/coupon/read.html new file mode 100755 index 000000000..d29c7d927 --- /dev/null +++ b/templates/admin/default/coupon/read.html @@ -0,0 +1,29 @@ +{check_auth context="admin" roles="ADMIN" permissions="admin.coupon.view" login_tpl="/admin/login"} + +{$page_title={intl l='Coupon'}} + +{$thelia_page_css_file = "assets/bootstrap-editable/css/bootstrap-editable.css"} + +{include file='includes/header.inc.html'} + +
+
+ + +

Read

+
+
+ + +{include file='includes/js.inc.html'} + +{javascripts file='../assets/bootstrap-editable/js/bootstrap-editable.js'} + +{/javascripts} + + + +{include file='includes/footer.inc.html'} diff --git a/templates/admin/default/includes/coupon_breadcrumb.html b/templates/admin/default/includes/coupon_breadcrumb.html new file mode 100755 index 000000000..bcec6d0d3 --- /dev/null +++ b/templates/admin/default/includes/coupon_breadcrumb.html @@ -0,0 +1,8 @@ +{* Breadcrumb for coupon browsing and editing *} + +
  • Home /
  • +
  • Coupon
  • + +
  • /
  • +
  • Browse /
  • + diff --git a/templates/default/coupon.html b/templates/default/coupon.html deleted file mode 100755 index 3fd478575..000000000 --- a/templates/default/coupon.html +++ /dev/null @@ -1,5 +0,0 @@ -

    Coupon page

    - -
    - -

    COUPON