1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| function MxUrl($index, $urlArg, $param = '', $noSid = false, $attribut = '') {
if ($this -> adressSystem == 'relative') $index = $this -> relativePath.'.'.$index;
$ok = false;
//Ajout des paramètres de sessions en cas de cache ou non
if ($this -> sessionParameter && ! $noSid) {
if ($this -> mXCacheDelay > 0) $urlArg .= '?<mx:session />';
else $urlArg .= '?'.$this -> sessionParameter;
$ok = true;
}
//Construction du lien
if (is_string($param) && $param) {
$param = explode('&',$param);
for($i = 0; $i < count($param) && $param[$i]; $i++){
$cle = explode('=', $param[$i]);
if (! $this -> mXmodRewrite) $urlArg .= ($i == 0 && !$ok) ? '?'.urlencode($cle[0]).'='.urlencode($cle[1]) : '&'.urlencode($cle[0]).'='.urlencode($cle[1]);
else $urlArg .= '/'.urlencode($cle[0]).'/'.urlencode($cle[1]);
}
}
elseif (is_array($param)){
reset($param);
if ($this->mXmodRewrite) {
while (list($cle, $valeur) = each($param)) {
$urlArg .= '/'.urlencode($cle).'/'.urlencode($valeur);
}
}
else {
while (list($cle, $valeur) = each($param)) {
if (!$ok) {
$urlArg .= '?'.urlencode($cle).'='.urlencode($valeur);
$ok = true;
}
else $urlArg .= '&'.urlencode($cle).'='.urlencode($valeur);
}
}
}
elseif ($param) $this -> ErrorTracker(3, 'The third argument must be a queryString or an array.', 'MxUrl', __FILE__, __LINE__);
//Ajout d'éventuels attributs supplémentaires en dynamique
$lien = ($attribut)? ' href="'.$urlArg.'" '.$attribut : ' href="'.$urlArg.'"';
//Gestion multi-attributs
if (! ((isset($this -> attribut[$index]))? chop($this -> attribut[$index]): false)) $this -> attribut[$index] = ' href="'.$urlArg.'"';
else {
if (empty($this -> attribut[$this -> attribut[$index]])) $this -> attribut[$this -> attribut[$index]] = ' href="'.$urlArg.'"';
else $this -> attribut[$this -> attribut[$index]] .= ' href="'.$urlArg.'"';
}
} |
Partager