/** * Initialize the ConfirmAddController 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 == 'ConfirmAddController') { if (file_exists(_LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php')) { try { require_once _LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php'; Tools::getInstance()->createPost($_POST); if (!empty($_POST['sector']) && !empty($_POST['location'])) { \Location\CreateModel::getInstance()->add_location($_POST['sector'], $_POST['location']); header('Location: /Cas-M-Ping/locations/show/all'); } else { header('Location: /Cas-M-Ping/locations/add'); } } catch (Exception $e) { throw new Exception('Une erreur est survenue durant l\'ajout des données: ' . $e->getMessage()); } } else { throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _LOCATIONS_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 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(_LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php')) { if (file_exists(_LOCATIONS_VIEWS_ . '/' . $this->view_name . '.tpl')) { try { require_once _LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php'; $id = Tools::getInstance()->getUrl_id($url); switch ($id) { case 'all': $data = \Location\DisplayModel::getInstance()->display_locations(); break; default: if (\Location\DisplayModel::getInstance()->has_location($id) == 1) { $data = \Location\DisplayModel::getInstance()->display_location($id); } else { header('Location: /Cas-M-Ping/errors/404'); } break; } echo $this->twig->render($this->view_name . '.tpl', array('locations' => $data, '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 "' . _LOCATIONS_VIEWS_ . '"!'); } } else { throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _LOCATIONS_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 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(_LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php')) { try { require_once _LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php'; $id = Tools::getInstance()->getUrl_id($url); switch ($id) { case 'all': \Location\DeleteModel::getInstance()->delete_locations(); break; default: if (\Location\DeleteModel::getInstance()->has_location($id) == 1) { \Location\DeleteModel::getInstance()->delete_location($id); } else { header('Location: /Cas-M-Ping/errors/404'); } break; } header('Location: /Cas-M-Ping/locations/show/all'); } 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 "' . _LOCATIONS_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 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(_LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php') && file_exists(_SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php')) { if (file_exists(_LOCATIONS_VIEWS_ . '/' . $this->view_name . '.tpl')) { try { require_once _LOCATIONS_MODELS_ . '/' . $this->model_name . 'Model.php'; require_once _SECTORS_MODELS_ . '/' . $this->model_name . 'Model.php'; $id = Tools::getInstance()->getUrl_id($url); $sectors = \Sector\DisplayModel::getInstance()->display_sectors(); $type_locations = \Location\DisplayModel::getInstance()->display_TypeLocationModels(); $data = \Location\DisplayModel::getInstance()->display_location($id); echo $this->twig->render($this->view_name . '.tpl', array('sectors' => $sectors, 'typeLocations' => $type_locations, 'id' => $data[0], '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 "' . _LOCATIONS_VIEWS_ . '"!'); } } else { throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _LOCATIONS_MODELS_ . '" ou "' . _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(_LOCATIONS_MODELS_ . '/' . $this->model_nameModify . 'Model.php') && file_exists(_LOCATIONS_MODELS_ . '/' . $this->model_nameDisplay . 'Model.php')) { try { require_once _LOCATIONS_MODELS_ . '/' . $this->model_nameModify . 'Model.php'; require_once _LOCATIONS_MODELS_ . '/' . $this->model_nameDisplay . 'Model.php'; $id = Tools::getInstance()->getUrl_id($url); Tools::getInstance()->createPost($_POST); if (!empty($_POST['sector']) && !empty($_POST['location'])) { $data = \Location\DisplayModel::getInstance()->display_location($id); \Location\ModifyModel::getInstance()->modify_location($data[0]['loc_sec_id'], $data[0]['loc_type_id'], $_POST['sector'], $_POST['location']); header('Location: /Cas-M-Ping/locations/show/' . $id); } else { header('Location: /Cas-M-Ping/locations/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_nameModify . '" ou "' . $this->model_nameDisplay . '" n\'existe pas dans "' . _LOCATIONS_MODELS_ . '"!'); } } else { throw new Exception('Une erreur est survenue durant la phase de routage!'); } } else { throw new Exception('L\'URL n\'est pas évaluable!'); } }