function _generer_url_propre($type, $id, $args = '', $ancre = '') { if ($generer_url_externe = charger_fonction("generer_url_{$type}", 'urls', true)) { $url = $generer_url_externe($id, $args, $ancre); if (null != $url) { return $url; } } // Mode compatibilite pour conserver la distinction -Rubrique- if (_MARQUEUR_URL) { $marqueur = unserialize(_MARQUEUR_URL); $marqueur1 = isset($marqueur[$type . '1']) ? $marqueur[$type . '1'] : ''; // debut '+-' $marqueur2 = isset($marqueur[$type . '2']) ? $marqueur[$type . '2'] : ''; // fin '-+' } else { $marqueur1 = $marqueur2 = ''; } // fin // Mode propre $propre = declarer_url_propre($type, $id); if ($propre === false) { return ''; } // objet inconnu. raccourci ? if ($propre) { $url = _debut_urls_propres . $marqueur1 . $propre . $marqueur2 . _terminaison_urls_propres; // les urls de type /1234 sont interpretees comme urls courte vers article 1234 // on les encadre d'un - : /-1234- if (is_numeric($url)) { $url = "-" . $url . "-"; } if (!defined('_SET_HTML_BASE') or !_SET_HTML_BASE) { $url = str_repeat('../', $GLOBALS['profondeur_url']) . $url; } else { $url = _DIR_RACINE . $url; } } else { // objet connu mais sans possibilite d'URL lisible, revenir au defaut include_spip('base/connect_sql'); $id_type = id_table_objet($type); $url = _DIR_RACINE . get_spip_script('./') . "?" . _SPIP_PAGE . "={$type}&{$id_type}={$id}"; } // Ajouter les args if ($args) { $url .= (strpos($url, '?') === false ? '?' : '&') . $args; } // Ajouter l'ancre if ($ancre) { $url .= "#{$ancre}"; } return $url; }
function _generer_url_propre($type, $id, $args='', $ancre='') { if ($generer_url_externe = charger_fonction("generer_url_$type",'urls',true)) { $url = $generer_url_externe($id, $args, $ancre); if (NULL != $url) return $url; } if ($type == 'document') { include_spip('inc/documents'); return generer_url_document_dist($id, $args, $ancre); } // Mode compatibilite pour conserver la distinction -Rubrique- if (_MARQUEUR_URL) { $marqueur = unserialize(_MARQUEUR_URL); $marqueur1 = $marqueur[$type.'1']; // debut '+-' $marqueur2 = $marqueur[$type.'2']; // fin '-+' } else $marqueur1 = $marqueur2 = ''; // fin // Mode propre $propre = declarer_url_propre($type, $id); if ($propre === false) return ''; // objet inconnu. raccourci ? if ($propre) { $url = _debut_urls_propres . $marqueur1 . $propre . $marqueur2 . _terminaison_urls_propres; // Repositionne l'URL par rapport a la racine du site (#GLOBALS) $url = str_repeat('../', $GLOBALS['profondeur_url']).$url; } else { // objet connu mais sans possibilite d'URL lisible, revenir au defaut include_spip('base/connect_sql'); $id_type = id_table_objet($type); $url = _DIR_RACINE . get_spip_script('./')."?"._SPIP_PAGE."=$type&$id_type=$id"; } // Ajouter les args if ($args) $url .= ((strpos($url, '?')===false) ? '?' : '&') . $args; // Ajouter l'ancre if ($ancre) $url .= "#$ancre"; return $url; }