* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
-if (!defined('_ECRIRE_INC_VERSION')) return;
+if (!defined('_ECRIRE_INC_VERSION')) {
+ return;
+}
# donner un exemple d'url pour le formulaire de choix
define('URLS_SIMPLE_EXEMPLE', 'spip.php?page=article&id_article=12');
####### modifications possibles dans ecrire/mes_options
# on peut indiquer '.html' pour faire joli
-define ('_terminaison_urls_simple', '');
-define ('_debut_urls_simple', get_spip_script('./').'?'._SPIP_PAGE.'=');
+define('_terminaison_urls_simple', '');
+define('_debut_urls_simple', get_spip_script('./') . '?' . _SPIP_PAGE . '=');
#######
-function _generer_url_simple($type,$id, $args='', $ancre='') {
+function _generer_url_simple($type, $id, $args = '', $ancre = '') {
- if ($generer_url_externe = charger_fonction("generer_url_$type",'urls',true)) {
+ if ($generer_url_externe = charger_fonction("generer_url_$type", 'urls', true)) {
$url = $generer_url_externe($id, $args, $ancre);
- if (NULL != $url) return $url;
+ if (null != $url) {
+ return $url;
+ }
}
$url = _debut_urls_simple . $type
- . "&" . id_table_objet($type) . "="
- . $id . _terminaison_urls_simple;
+ . '&' . id_table_objet($type) . '='
+ . $id . _terminaison_urls_page;
+
+ if ($args) {
+ $args = strpos($url, '?') ? "&$args" : "?$args";
+ }
- if ($args) $args = strpos($url,'?') ? "&$args" : "?$args";
return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : '');
}
// retrouve le fond et les parametres d'une URL abregee
// le contexte deja existant est fourni dans args sous forme de tableau ou query string
// https://code.spip.net/@urls_page_dist
-function urls_simple_dist($i, &$entite, $args='', $ancre='')
-{
- if (is_numeric($i)){
+function urls_simple_dist($i, &$entite, $args = '', $ancre = '') {
+ if (is_numeric($i)) {
include_spip('urls/page');
+
return _generer_url_simple($entite, $i, $args, $ancre);
}
// traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23
- if ($GLOBALS['profondeur_url']>0 AND $entite=='sommaire'){
- return array(array(),'404');
+ if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') {
+ return array(array(), '404');
}
// voir s'il faut recuperer le id_* implicite et les &debut_xx;
- if (is_array($args))
+ if (is_array($args)) {
$contexte = $args;
- else
- parse_str($args,$contexte);
+ } else {
+ parse_str($args, $contexte);
+ }
include_spip('inc/urls');
$r = nettoyer_url_page($i, $contexte);
if ($r) {
}
if ($type = _request(_SPIP_PAGE)
- AND $_id = id_table_objet($type)
- AND $id = _request($_id)){
+ and $_id = id_table_objet($type)
+ and $id = _request($_id)
+ ) {
$contexte[$_id] = $id;
+
return array($contexte, $type, null, $type);
}
*/
// Si on est revenu en mode html, mais c'est une ancienne url_propre
// on ne redirige pas, on assume le nouveau contexte (si possible)
- $url = $i;
- $url_propre = isset($url)
- ? $url
- : (isset($_SERVER['REDIRECT_url_propre'])
- ? $_SERVER['REDIRECT_url_propre']
- : (isset($_ENV['url_propre'])
- ? $_ENV['url_propre']
- : ''
- ));
+ $url_propre = $i;
if ($url_propre) {
- if ($GLOBALS['profondeur_url']<=0)
- $urls_anciennes = charger_fonction('propres','urls',true);
- else
- $urls_anciennes = charger_fonction('arbo','urls',true);
- return $urls_anciennes?$urls_anciennes($url_propre, $entite, $contexte):'';
+ if ($GLOBALS['profondeur_url'] <= 0) {
+ $urls_anciennes = charger_fonction('propres', 'urls', true);
+ } else {
+ $urls_anciennes = charger_fonction('arbo', 'urls', true);
+ }
+
+ return $urls_anciennes ? $urls_anciennes($url_propre, $entite, $contexte) : '';
}
/* Fin du bloc compatibilite url-propres */
}
-
-?>