/**
  * 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(_SEASONS_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 "' . _SEASONS_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 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(_SEASONS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 if (file_exists(_SEASONS_VIEWS_ . '/' . $this->view_name . '.tpl')) {
                     try {
                         require_once _SEASONS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         $id = Tools::getInstance()->getUrl_id($url);
                         $data = \Season\DisplayModel::getInstance()->display_season($id);
                         echo $this->twig->render($this->view_name . '.tpl', array('season' => $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 "' . _SEASONS_VIEWS_ . '"!');
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _SEASONS_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 SeasonController 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_, _SEASONS_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(_SEASONS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 try {
                     require_once _SEASONS_MODELS_ . '/' . $this->model_name . 'Model.php';
                     $id = Tools::getInstance()->getUrl_id($url);
                     switch ($id) {
                         case 'all':
                             \Season\DeleteModel::getInstance()->delete_seasons();
                             break;
                         default:
                             if (\Season\DeleteModel::getInstance()->has_season($id) == 1) {
                                 \Season\DeleteModel::getInstance()->delete_season($id);
                             } else {
                                 header('Location: /Cas-M-Ping/errors/404');
                             }
                             break;
                     }
                     header('Location: /Cas-M-Ping/seasons/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 "' . _SEASONS_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(_SEASONS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 try {
                     require_once _SEASONS_MODELS_ . '/' . $this->model_name . 'Model.php';
                     $id = Tools::getInstance()->getUrl_id($url);
                     $datetime1 = new DateTime($_POST['beginDate']);
                     $datetime2 = new DateTime($_POST['endDate']);
                     $interval = $datetime1->diff($datetime2);
                     Tools::getInstance()->createPost($_POST);
                     if (!empty($_POST['name']) && !empty($_POST['beginDate']) && !empty($_POST['endDate']) && !empty($_POST['coefficient'])) {
                         $_POST['coefficient'] = $_POST['coefficient'] > 1 ? 1 : $_POST['coefficient'];
                         $_POST['coefficient'] = $_POST['coefficient'] <= 0 ? 0.1 : $_POST['coefficient'];
                         \Season\ModifyModel::getInstance()->modify_season($id, $_POST['name'], $_POST['beginDate'], $_POST['endDate'], $_POST['coefficient']);
                         header('Location: /Cas-M-Ping/seasons/show/' . $id);
                     } else {
                         header('Location: /Cas-M-Ping/seasons/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 "' . _SEASONS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }