Exemplo n.º 1
0
 /**
  * Affiche une Url formatée selon que l'on utilise l'url_rewriting ou non
  * si oui, on cherche dans la table de routage la correspondance pour formater
  * @param $url l'url à formater définie comme un tableau :
  *                    $url['c'] = controller
  *                    $url['a'] = action
  *                    $url['params'] = tableau des paramètres supplémentaires
  *                    $url['protocol'] = protocole à utiliser (http par défaut)
  *             ou comme une chaîne de caractère
  * @param $encodage pour indiquer comment encoder les & (& ou & pour html)
  * @return l'url formatée
  */
 public static function display($url = array(), $encodage = 'html', $absolute = false)
 {
     $isArray = is_array($url);
     if ($isArray) {
         $url = self::checkUrl($url);
     }
     $url_string = '';
     if ($absolute) {
         if ($isArray && isset($url['protocol'])) {
             $protocol = $url['protocol'];
         } elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
             $protocol = 'https:';
         } else {
             $protocol = 'http:';
         }
         $url_string = $protocol . '//' . Minz_Request::getDomainName() . Minz_Request::getBaseUrl();
     } else {
         $url_string = $isArray ? '.' : PUBLIC_RELATIVE;
     }
     if ($isArray) {
         $router = new Minz_Router();
         if (Minz_Configuration::useUrlRewriting()) {
             $url_string .= $router->printUriRewrited($url);
         } else {
             $url_string .= self::printUri($url, $encodage);
         }
     } else {
         $url_string .= $url;
     }
     return $url_string;
 }
Exemplo n.º 2
0
 /**
  * Initialise le Router en déterminant le couple Controller / Action
  * Mets à jour la Request
  * @exception RouteNotFoundException si l'uri n'est pas présente dans
  *          > la table de routage
  */
 public function init()
 {
     $url = array();
     if (Minz_Configuration::useUrlRewriting()) {
         try {
             $url = $this->buildWithRewriting();
         } catch (Minz_RouteNotFoundException $e) {
             throw $e;
         }
     } else {
         $url = $this->buildWithoutRewriting();
     }
     $url['params'] = array_merge($url['params'], Minz_Request::fetchPOST());
     Minz_Request::forward($url);
 }