/**
  * Initialize the ModifyController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'ModifyController') {
             if (file_exists(_SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 if (file_exists(_SECTORS_VIEWS_ . '/' . $this->view_name . '.tpl')) {
                     try {
                         require_once _SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         $id = Tools::getInstance()->getUrl_id($url);
                         $data = \Sector\DisplayModel::getInstance()->display_sector($id);
                         echo $this->twig->render($this->view_name . '.tpl', array('sector' => $data[0], 'bootstrapPath' => _BOOTSTRAP_FILE_));
                     } catch (Exception $e) {
                         throw new Exception('Une erreur est survenue durant la récupération des données: ' . $e->getMessage());
                     }
                 } else {
                     throw new Exception('Le template "' . $this->view_name . '" n\'existe pas dans "' . _SECTORS_VIEWS_ . '"!');
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _SECTORS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }
 /**
  * Initialize the ConfirmModifyController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'ConfirmModifyController') {
             if (file_exists(_SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 try {
                     require_once _SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php';
                     $id = Tools::getInstance()->getUrl_id($url);
                     Tools::getInstance()->createPost($_POST);
                     if (!empty($_POST['sec_name'])) {
                         \Sector\ModifyModel::getInstance()->modify_sector($id, $_POST['sec_name']);
                         header('Location: /Cas-M-Ping/sectors/show/' . $id);
                     } else {
                         header('Location: /Cas-M-Ping/sectors/modify/' . $id);
                     }
                 } catch (Exception $e) {
                     throw new Exception('Une erreur est survenue durant la modification des données: ' . $e->getMessage());
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _SECTORS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }
 /**
  * Initialize the AddController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $url .= '&id=ukn';
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'AddController') {
             if (file_exists(_SECTORS_VIEWS_ . '/' . $this->view_name . '.tpl')) {
                 try {
                     echo $this->twig->render($this->view_name . '.tpl', array('bootstrapPath' => _BOOTSTRAP_FILE_));
                 } catch (Exception $e) {
                     throw new Exception('Une erreur est survenue durant l\'affichage des données: ' . $e->getMessage());
                 }
             } else {
                 throw new Exception('Le template "' . $this->view_name . '" n\'existe pas dans "' . _SECTORS_VIEWS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }
 /**
  * Initialize the DisplayController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'DisplayController') {
             if (file_exists(_SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php') && file_exists(_LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 if (file_exists(_SECTORS_VIEWS_ . '/' . $this->view_name . '.tpl')) {
                     try {
                         require_once _SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         require_once _LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         $id = Tools::getInstance()->getUrl_id($url);
                         switch ($id) {
                             case 'all':
                                 $sectors = \Sector\DisplayModel::getInstance()->display_sectors();
                                 $locations = \Location\DisplayModel::getInstance()->display_locationAll();
                                 break;
                             default:
                                 if (\Sector\DisplayModel::getInstance()->has_sector($id) == 1) {
                                     $data = \Sector\DisplayModel::getInstance()->display_sector($id);
                                     $sectors = \Sector\DisplayModel::getInstance()->display_sector($id);
                                     $locations = \Location\DisplayModel::getInstance()->display_locationAll();
                                 } else {
                                     header('Location: /Cas-M-Ping/errors/404');
                                 }
                                 break;
                         }
                         echo $this->twig->render($this->view_name . '.tpl', array('sectors' => $sectors, 'locations' => $locations, 'bootstrapPath' => _BOOTSTRAP_FILE_));
                     } catch (Exception $e) {
                         throw new Exception('Une erreur est survenue durant la récupération des données: ' . $e->getMessage());
                     }
                 } else {
                     throw new Exception('Le template "' . $this->view_name . '" n\'existe pas dans "' . _SECTORS_VIEWS_ . '"!');
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _SECTORS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }
 /**
  * Initialize the SectorController class
  */
 public function init()
 {
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     if (file_exists(_TWIG_AUTOLOADER_)) {
         try {
             require_once _TWIG_AUTOLOADER_;
             Twig_Autoloader::register();
             $loader = new Twig_Loader_Filesystem(array(_DEPENDENCIES_DIR_, _SECTORS_VIEWS_));
             $this->twig = new Twig_Environment($loader, array('cache' => _TWIG_CACHE_));
         } catch (Exception $e) {
             throw new Exception('Le fichier de démarrage Twig ne peut pas s\'executer!');
         }
     } else {
         throw new Exception('Il n\'existe pas le fichier de démarrage Twig à cet emplacement "' . _TWIG_AUTOLOADER_ . '"!');
     }
 }
 /**
  * Initialize the DeleteController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'DeleteController') {
             if (file_exists(_SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 try {
                     require_once _SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php';
                     $id = Tools::getInstance()->getUrl_id($url);
                     switch ($id) {
                         case 'all':
                             \Sector\DeleteModel::getInstance()->delete_sectors();
                             break;
                         default:
                             if (\Sector\DeleteModel::getInstance()->has_sector($id) == 1) {
                                 \Sector\DeleteModel::getInstance()->delete_sector($id);
                             } else {
                                 header('Location: /Cas-M-Ping/errors/404');
                             }
                             break;
                     }
                     header('Location: /Cas-M-Ping/sectors/show/all');
                 } catch (Exception $e) {
                     throw new Exception('Une erreur est survenue durant la suppression des données: ' . $e->getMessage());
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _SECTORS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }