aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-15 11:20:55 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-15 11:20:55 +0100
commitd202a648f9eb45aa479a86ebb8db326eae944b4c (patch)
tree21714a73195c8d62268d00c94e0d0c0821a99876 /lib
parent71f6eef0eb17ba4992ad941d8e2d8f1ee5516297 (diff)
Delete Url.php
Diffstat (limited to 'lib')
-rwxr-xr-xlib/minz/Url.php129
1 files changed, 0 insertions, 129 deletions
diff --git a/lib/minz/Url.php b/lib/minz/Url.php
deleted file mode 100755
index 30f7f6231..000000000
--- a/lib/minz/Url.php
+++ /dev/null
@@ -1,129 +0,0 @@
-<?php
-
-/**
- * La classe Url permet de gérer les URL à travers MINZ
- */
-class Minz_Url {
- /**
- * 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 &amp; pour html)
- * @return l'url formatée
- */
- public static function display ($url = array (), $encodage = 'html', $absolute = false) {
- $url = self::checkUrl ($url);
-
- $url_string = '';
-
- if ($absolute) {
- if (is_array ($url) && 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 = '.';
- }
-
- if (is_array ($url)) {
- $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;
- }
-
- /**
- * Construit l'URI d'une URL sans url rewriting
- * @param l'url sous forme de tableau
- * @param $encodage pour indiquer comment encoder les & (& ou &amp; pour html)
- * @return l'uri sous la forme ?key=value&key2=value2
- */
- private static function printUri ($url, $encodage) {
- $uri = '';
- $separator = '/?';
-
- if($encodage == 'html') {
- $and = '&amp;';
- } else {
- $and = '&';
- }
-
- if (isset ($url['c'])
- && $url['c'] != Minz_Request::defaultControllerName ()) {
- $uri .= $separator . 'c=' . $url['c'];
- $separator = $and;
- }
-
- if (isset ($url['a'])
- && $url['a'] != Minz_Request::defaultActionName ()) {
- $uri .= $separator . 'a=' . $url['a'];
- $separator = $and;
- }
-
- if (isset ($url['params'])) {
- foreach ($url['params'] as $key => $param) {
- $uri .= $separator . $key . '=' . $param;
- $separator = $and;
- }
- }
-
- return $uri;
- }
-
- /**
- * Vérifie que les éléments du tableau représentant une url soit ok
- * @param l'url sous forme de tableau (sinon renverra directement $url)
- * @return l'url vérifié
- */
- public static function checkUrl ($url) {
- $url_checked = $url;
-
- if (is_array ($url)) {
- if (!isset ($url['c'])) {
- $url_checked['c'] = Minz_Request::defaultControllerName ();
- }
- if (!isset ($url['a'])) {
- $url_checked['a'] = Minz_Request::defaultActionName ();
- }
- if (!isset ($url['params'])) {
- $url_checked['params'] = array ();
- }
- }
-
- return $url_checked;
- }
-}
-
-function _url ($controller, $action) {
- $nb_args = func_num_args ();
-
- if($nb_args < 2 || $nb_args % 2 != 0) {
- return false;
- }
-
- $args = func_get_args ();
- $params = array ();
- for($i = 2; $i < $nb_args; $i = $i + 2) {
- $params[$args[$i]] = $args[$i + 1];
- }
-
- return Minz_Url::display (array ('c' => $controller, 'a' => $action, 'params' => $params));
-}