コード例 #1
0
 public function findPerPage($A_limit)
 {
     $I_firstOfPage = $A_limit['firstOfPage'];
     $I_perPage = $A_limit['perPage'];
     $S_sql = 'SELECT id, label, model, reference, description, lifetime, control_cycle, notice,
           `procedure`, image, size, color, category_epi_id
           FROM label_epi LIMIT ' . $I_firstOfPage . ', ' . $I_perPage;
     $O_connection = new Connection();
     if ($A_data = $O_connection->requestDb($S_sql, null, self::CLASS_NAME)) {
         $A_labels = null;
         foreach ($A_data as $O_label) {
             if (!is_null($O_label->getCategoryEpiId())) {
                 try {
                     $O_categoryMapper = new CategoryMapper();
                     $O_category = $O_categoryMapper->findById($O_label->getCategoryEpiId());
                     $O_label->setCategory($O_category);
                 } catch (Exception $e) {
                     //On récupère le message de l'exception
                     echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
                 }
             }
             $A_labels[] = $O_label;
         }
         return $A_labels;
     } else {
         throw new Exception("Une erreur s'est produite");
     }
 }
コード例 #2
0
 public function newAction()
 {
     $this->haveAccess();
     $O_categoryMapper = new CategoryMapper();
     $O_category = $O_categoryMapper->findAll();
     Buffer::flushBuffer('label/new', array('category' => $O_category));
 }
コード例 #3
0
 public function paginateAction($I_pageNumber)
 {
     // On vérifie si l'utilisateur connecté est bien un admin
     $this->haveAccess();
     $O_categoryMapper = new CategoryMapper();
     $O_pagination = new Pagination($O_categoryMapper);
     $A_limit = $O_pagination->paginate($I_pageNumber);
     $I_nbPage = $A_limit['nbPage'];
     $A_categorys = $O_categoryMapper->findPerPage($A_limit);
     Buffer::flushBuffer('category/list', array('categorys' => $A_categorys, 'nbPage' => $I_nbPage, 'pageNumber' => $I_pageNumber));
 }
コード例 #4
0
 public function defaultAction()
 {
     $O_epiMapper = new EpiMapper();
     $I_nbrEpi = $O_epiMapper->countId();
     $I_nbrEpiByUser = $O_epiMapper->countEpiByUser(Session::getSession('user')->getId());
     $I_nbrEpiNextCheckByUser = $O_epiMapper->countEpiNextCheckByUser(Session::getSession('user')->getId());
     $O_labelMapper = new LabelMapper();
     $I_nbrLabel = $O_labelMapper->countId();
     $O_categoryMapper = new CategoryMapper();
     $I_nbrCategory = $O_categoryMapper->countId();
     $O_checkMapper = new CheckMapper();
     $I_nbrCheck = $O_checkMapper->countId();
     $I_nbrCheckedByUser = $O_checkMapper->countEpiCheckedByUser(Session::getSession('user')->getId());
     Buffer::flushBuffer('epi/default', array('nbrEpi' => $I_nbrEpi, 'nbrLabel' => $I_nbrLabel, 'nbrCategory' => $I_nbrCategory, 'nbrCheck' => $I_nbrCheck, 'nbrEpiByUser' => $I_nbrEpiByUser, 'nbrEpiNextCheckByUser' => $I_nbrEpiNextCheckByUser, 'nbrCheckedByUser' => $I_nbrCheckedByUser));
 }
コード例 #5
0
 /**
  * Returns an singleton instance of this class
  * @return
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new CategoryMapper();
     }
     return self::$instance;
 }
コード例 #6
0
 /**
  * Initializes DB mappers
  *
  * @param object $config
  * @param object $args
  * @return
  */
 function __construct($config, $args)
 {
     $this->mapper = CategoryMapper::getInstance();
     $this->config = $config;
     $this->args = $args;
     $this->categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args);
     $this->initCache();
 }
コード例 #7
0
ファイル: FrontController.php プロジェクト: lexdss/shop
 public function route()
 {
     $request = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');
     $request_arr = explode('/', $request);
     if ($request == '') {
         $controller = new IndexController($this->service);
         $controller->indexAction();
     } elseif ($request == 'basket') {
         $controller = new BasketController($this->service);
         $controller->indexAction();
     } elseif ($request == 'auth') {
         $controller = new AuthController($this->service);
         $controller->indexAction();
     } elseif ($request == 'reg') {
         $controller = new RegController($this->service);
         $controller->indexAction();
     } elseif ($request == 'admin') {
         $controller = new AdminController($this->service);
         $controller->indexAction();
     } elseif ($request == 'admin/additem') {
         $controller = new AdminController($this->service);
         $controller->additemAction();
     } elseif ($request == 'admin/category') {
         $controller = new AdminController($this->service);
         $controller->categoryAction();
     } elseif ($request == 'admin/catalog') {
         $controller = new AdminController($this->service);
         $controller->catalogAction();
     } elseif ($request == 'admin/orders') {
         $controller = new AdminController($this->service);
         $controller->ordersAction();
     } elseif ($request = 'cat/' . $request_arr[1]) {
         $category_mapper = new CategoryMapper($this->service->get('db'));
         if (!$category_mapper->getCategoryFromCode($request_arr[1])) {
             $this->get404();
         } else {
             $controller = new CatController($this->service);
             $controller->categoryAction($request_arr[1]);
         }
     } else {
         $this->get404();
     }
 }
コード例 #8
0
 protected function initSearchValues($searchArgs)
 {
     if (!empty($searchArgs['category']) && !empty($searchArgs['property'])) {
         $this->category = array('leisureProperty' => CategoryMapper::getLeisurePropertiesFromSearchCategory($searchArgs['category']), 'value' => $searchArgs['property']);
     } else {
         $this->category = array();
     }
     unset($searchArgs['category']);
     unset($searchArgs['property']);
     $include = array('priceFrom', 'priceTo', 'startDate', 'endDate', 'organization', 'country', 'location', 'description');
     foreach ($searchArgs as $key => $val) {
         if (in_array($key, $include)) {
             $this->{$key} = $val;
         }
     }
 }