Exemplo n.º 1
0
 /**
  * Méthode de parsing de l'url en cours
  * récupère le controller, l'action, la langue (si multilangue) ainsi que les paramètres $_GET
  * @param $pUrl
  * @return void
  */
 public static function parseURL($pUrl = null)
 {
     Configuration::$server_domain = $_SERVER["SERVER_NAME"];
     $protocol = "http" . (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 's' : '') . "://";
     Configuration::$server_folder = preg_replace('/\\/(index).php$/', "", $_SERVER["SCRIPT_NAME"]);
     Configuration::$server_folder = preg_replace('/^\\//', "", Configuration::$server_folder);
     Configuration::$server_url = $protocol . Configuration::$server_domain . "/";
     if (!empty(Configuration::$server_folder)) {
         Configuration::$server_url .= Configuration::$server_folder . "/";
     }
     /**
      * Définition de l'url + suppression des paramètres GET ?var=value
      */
     $url = isset($pUrl) && !is_null($pUrl) ? $pUrl : $_SERVER["REQUEST_URI"];
     if (preg_match("/([^\\?]*)\\?.*\$/", $url, $matches)) {
         $url = $matches[1];
     }
     $application_name = RoutingHandler::extractApplication($url);
     self::$application = Application::getInstance()->setup($application_name);
     self::$application->setModule(RoutingHandler::extractModule($url, self::$application->getModulesAvailable()));
     self::$module = self::$application->getModule()->name;
     Configuration::$server_url .= self::$application->getUrlPart();
     $access = self::$application->getPathPart();
     self::$path_to_components = Configuration::$server_url . $access . self::$path_to_components;
     self::defineGlobalObjects();
     if (self::$application->multiLanguage) {
         self::$application->currentLanguage = RoutingHandler::extractLanguage($url);
         if (empty(self::$application->currentLanguage)) {
             self::$application->currentLanguage = self::$application->defaultLanguage;
             Header::location(Configuration::$server_url . self::$application->currentLanguage . "/" . $url);
         }
     }
     self::$path_to_application = Autoload::$folder . "/includes/applications/" . $application_name;
     self::setDictionary();
     $parsedURL = RoutingHandler::parse($url);
     self::$url = $url;
     self::$controller = str_replace("-", "_", $parsedURL["controller"]);
     self::$action = str_replace("-", "_", $parsedURL["action"]);
     $_GET = array_merge($parsedURL["parameters"], $_GET);
     self::$path_to_theme = Configuration::$server_url . $access . self::$application->getThemePath();
     self::$path_to_templates = self::$application->getThemePath() . "/views";
 }