4,14 → 4,13 |
* classe Url, gérant le découpage des paramètres, leurs modification etc... |
* Traduction et conversion d'une classe (NET_Url2) issue de Pear |
* |
* PHP Version 5 |
* |
* @category Class |
* @category Php5 |
* @package Framework |
// auteur principal |
// Auteur principal |
* @author Christian Schmidt <schmidt@php.net> |
// autre auteurs |
* @author aurelien <aurelien@tela-botanica.org> |
// Autre auteurs |
* @author Aurélien PERONNET <aurelien@tela-botanica.org> |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright 2009 Tela-Botanica |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL |
59,8 → 58,7 |
self::OPTION_UTILISER_CROCHETS => true, |
self::OPTION_ENCODER_CLES => true, |
self::OPTION_SEPARATEUR_ENTREE => 'x&', |
self::OPTION_SEPARATEUR_SORTIE => 'x&', |
); |
self::OPTION_SEPARATEUR_SORTIE => 'x&'); |
|
/** |
* @var string|bool |
101,8 → 99,7 |
* @param string $url une URL relative ou absolue |
* @param array $options |
*/ |
public function __construct($url, $options = null) |
{ |
public function __construct($url, $options = null) { |
$this->setOption(self::OPTION_SEPARATEUR_ENTREE, |
ini_get('arg_separator.input')); |
$this->setOption(self::OPTION_SEPARATEUR_SORTIE, |
143,8 → 140,7 |
* |
* @return string|bool |
*/ |
public function getSchema() |
{ |
public function getSchema() { |
return $this->schema; |
} |
|
154,8 → 150,7 |
* @return void |
* @see getSchema() |
*/ |
public function setSchema($schema) |
{ |
public function setSchema($schema) { |
$this->schema = $schema; |
} |
|
165,8 → 160,7 |
* |
* @return string|bool |
*/ |
public function getUtilisateur() |
{ |
public function getUtilisateur() { |
return $this->infoUtilisateur !== false ? preg_replace('@:.*$@', '', $this->infoUtilisateur) : false; |
} |
|
177,8 → 171,7 |
* |
* @return string|bool |
*/ |
public function getMotDePasse() |
{ |
public function getMotDePasse() { |
return $this->infoUtilisateur !== false ? substr(strstr($this->infoUtilisateur, ':'), 1) : false; |
} |
|
188,8 → 181,7 |
* |
* @return string|bool |
*/ |
public function getInfoUtilisateur() |
{ |
public function getInfoUtilisateur() { |
return $this->infoUtilisateur; |
} |
|
202,8 → 194,7 |
* |
* @return void |
*/ |
public function setInfoUtilisateur($infoUtilisateur, $motDePasse = false) |
{ |
public function setInfoUtilisateur($infoUtilisateur, $motDePasse = false) { |
$this->infoUtilisateur = $infoUtilisateur; |
if ($motDePasse !== false) { |
$this->infoUtilisateur .= ':' . $motDePasse; |
216,8 → 207,7 |
* |
* @return string|bool |
*/ |
public function getHote() |
{ |
public function getHote() { |
return $this->hote; |
} |
|
226,8 → 216,7 |
* |
* @return void |
*/ |
public function setHote($hote) |
{ |
public function setHote($hote) { |
$this->hote = $hote; |
} |
|
237,8 → 226,7 |
* |
* @return int|bool |
*/ |
public function getPort() |
{ |
public function getPort() { |
return $this->port; |
} |
|
247,8 → 235,7 |
* |
* @return void |
*/ |
public function setPort($port) |
{ |
public function setPort($port) { |
$this->port = intval($port); |
} |
|
258,8 → 245,7 |
* |
* @return string|bool |
*/ |
public function getAutorite() |
{ |
public function getAutorite() { |
if (!$this->hote) { |
return false; |
} |
284,8 → 270,7 |
* |
* @return void |
*/ |
public function setAutorite($autorite) |
{ |
public function setAutorite($autorite) { |
$this->user = false; |
$this->pass = false; |
$this->hote = false; |
307,8 → 292,7 |
* |
* @return string |
*/ |
public function getChemin() |
{ |
public function getChemin() { |
return $this->chemin; |
} |
|
317,8 → 301,7 |
* |
* @return void |
*/ |
public function setChemin($chemin) |
{ |
public function setChemin($chemin) { |
$this->chemin = $chemin; |
} |
|
329,8 → 312,7 |
* @return string|bool |
* @see self::getVariablesRequete() |
*/ |
public function getRequete() |
{ |
public function getRequete() { |
return $this->requete; |
} |
|
340,8 → 322,7 |
* @return void |
* @see self::setVariablesRequete() |
*/ |
public function setRequete($requete) |
{ |
public function setRequete($requete) { |
$this->requete = $requete; |
} |
|
350,8 → 331,7 |
* |
* @return string|bool |
*/ |
public function getFragment() |
{ |
public function getFragment() { |
return $this->fragment; |
} |
|
360,8 → 340,7 |
* |
* @return void |
*/ |
public function setFragment($fragment) |
{ |
public function setFragment($fragment) { |
$this->fragment = $fragment; |
} |
|
371,8 → 350,7 |
* |
* @return array |
*/ |
public function getVariablesRequete() |
{ |
public function getVariablesRequete() { |
$pattern = '/[' . |
preg_quote($this->getOption(self::OPTION_SEPARATEUR_ENTREE), '/') . |
']/'; |
427,8 → 405,7 |
* |
* @return void |
*/ |
public function setVariablesRequete(array $tableau) |
{ |
public function setVariablesRequete(array $tableau) { |
if (!$tableau) { |
$this->requete = false; |
} else { |
460,8 → 437,7 |
* |
* @return array |
*/ |
public function setVariableRequete($nom, $valeur) |
{ |
public function setVariableRequete($nom, $valeur) { |
$tableau = $this->getVariablesRequete(); |
$tableau[$nom] = $valeur; |
$this->setVariablesRequete($tableau); |
472,8 → 448,7 |
* |
* @return void |
*/ |
public function unsetVariableRequete($nom) |
{ |
public function unsetVariableRequete($nom) { |
$tableau = $this->getVariablesRequete(); |
unset($tableau[$nom]); |
$this->setVariablesRequete($tableau); |
484,8 → 459,7 |
* |
* @return string |
*/ |
public function getURL() |
{ |
public function getURL() { |
// Voir RFC 3986, section 5.3 |
$url = ""; |
|
516,8 → 490,7 |
* |
* @return string |
*/ |
public function getURLNormalisee() |
{ |
public function getURLNormalisee() { |
$url = clone $this; |
$url->normaliser(); |
return $url->getUrl(); |
528,8 → 501,7 |
* |
* @return Url |
*/ |
public function normaliser() |
{ |
public function normaliser() { |
// See RFC 3886, section 6 |
|
// les cchémas sont insesibles à la casse |
571,8 → 543,7 |
* |
* @return bool |
*/ |
public function etreAbsolue() |
{ |
public function etreAbsolue() { |
return (bool) $this->schema; |
} |
|
584,8 → 555,7 |
* |
* @return Url |
*/ |
public function resoudre($reference) |
{ |
public function resoudre($reference) { |
if (is_string($reference)) { |
$reference = new self($reference); |
} |
655,8 → 625,7 |
* |
* @return string un chemin |
*/ |
private static function supprimerSegmentsAPoints($chemin) |
{ |
private static function supprimerSegmentsAPoints($chemin) { |
$sortie = ''; |
|
// Assurons de ne pas nous retrouver piégés dans une boucle infinie due à un bug de |
706,8 → 675,7 |
* |
* @return string |
*/ |
public static function getCanonique() |
{ |
public static function getCanonique() { |
if (!isset($_SERVER['REQUEST_METHOD'])) { |
// ALERT - pas d'URL en cours |
throw new Exception('Le script n\'a pas été appellé à travers un serveur web'); |
731,8 → 699,7 |
* |
* @return string |
*/ |
public static function getURLDemande() |
{ |
public static function getURLDemande() { |
return self::getDemande()->getUrl(); |
} |
|
742,8 → 709,7 |
* |
* @return Url |
*/ |
public static function getDemande() |
{ |
public static function getDemande() { |
if (!isset($_SERVER['REQUEST_METHOD'])) { |
// ALERTE - pas d'URL en cours |
throw new Exception('Le script n\'a pas été appellé à travers un serveur web'); |
768,8 → 734,7 |
* @see self::OPTION_UTILISER_CROCHETS |
* @see self::OPTION_ENCODER_CLES |
*/ |
function setOption($nomOption, $valeur) |
{ |
function setOption($nomOption, $valeur) { |
if (!array_key_exists($nomOption, $this->options)) { |
return false; |
} |
783,8 → 748,7 |
* |
* @return mixed |
*/ |
function getOption($nomOption) |
{ |
function getOption($nomOption) { |
return isset($this->options[$nomOption]) |
? $this->options[$nomOption] : false; |
} |