From eb2bbe036cfd1a5669a80c4f030fbd89f2d5536b Mon Sep 17 00:00:00 2001 From: Fil <fil@rezo.net> Date: Mon, 25 Aug 2008 12:20:41 +0000 Subject: [PATCH] revision de la possibilite de faire une transition entre une mode d'url et un autre ; a noter les rubriques en arbo ne transitionnent pas vers les autres modes (juste pour ca, il faudrait tout revoir : on surseoit) --- ecrire/urls/html.php | 12 +++++++----- ecrire/urls/page.php | 11 +++++++---- ecrire/urls/standard.php | 9 ++++++--- htaccess.txt | 20 ++------------------ 4 files changed, 22 insertions(+), 30 deletions(-) diff --git a/ecrire/urls/html.php b/ecrire/urls/html.php index e70e534737..ffa45e360a 100644 --- a/ecrire/urls/html.php +++ b/ecrire/urls/html.php @@ -75,7 +75,7 @@ function generer_url_document($id_document, $args='', $ancre='') { // retrouver les parametres d'une URL dite "html" // http://doc.spip.org/@urls_html_dist -function urls_html_dist($fond, $url) { +function urls_html_dist(&$fond, $url) { global $contexte; @@ -92,12 +92,14 @@ function urls_html_dist($fond, $url) { (isset($_ENV['url_propre']) ? $_ENV['url_propre'] : ''); - if ($url_propre AND preg_match(',^(article|breve|rubrique|mot|auteur|site)$,', $fond)) { + if ($url_propre AND preg_match(',^(article|breve|rubrique|mot|auteur|site|type_urls)$,', $fond)) { $url_propre = (preg_replace('/^[_+-]{0,2}(.*?)[_+-]{0,2}(\.html)?$/', '$1', $url_propre)); - - $r = sql_fetsel("id_objet", "spip_urls", "url=" . _q($url_propre)); - if ($r) $contexte[id_table_objet($fond)] = $r['id_objet']; + $r = sql_fetsel("id_objet,type", "spip_urls", "url=" . _q($url_propre)); + if ($r) { + $fond = ($r['type'] == 'syndic') ? 'site' : $r['type']; + $contexte[id_table_objet($fond)] = $r['id_objet']; + } } /* Fin du bloc compatibilite url-propres */ } diff --git a/ecrire/urls/page.php b/ecrire/urls/page.php index 6d34738203..35e770eb3e 100644 --- a/ecrire/urls/page.php +++ b/ecrire/urls/page.php @@ -118,11 +118,14 @@ function urls_page_dist(&$fond, $url) { if ( (isset($_SERVER['REDIRECT_url_propre']) AND $url_propre = $_SERVER['REDIRECT_url_propre']) OR (isset($_ENV['url_propre']) AND $url_propre = $_ENV['url_propre']) - AND preg_match(',^(article|breve|rubrique|mot|auteur|site)$,', $fond)) { - $url_propre = (preg_replace('/^[_+-]{0,2}(.*?)[_+-]{0,2}(\.html)?$/', + AND preg_match(',^(article|breve|rubrique|mot|auteur|site|type_urls)$,', $fond)) { + $url_propre = (preg_replace('/^[_+-]{0,2}(.*?)[_+-]{0,2}(\.html)?$/', '$1', $url_propre)); - $r = sql_fetsel("id_objet", "spip_urls", "url=" . _q($url_propre)); - if ($r) $contexte[id_table_objet($fond)] = $r['id_objet']; + $r = sql_fetsel("id_objet,type", "spip_urls", "url=" . _q($url_propre)); + if ($r) { + $fond = ($r['type'] == 'syndic') ? 'site' : $r['type']; + $contexte[id_table_objet($fond)] = $r['id_objet']; + } } /* Fin du bloc compatibilite url-propres */ diff --git a/ecrire/urls/standard.php b/ecrire/urls/standard.php index ae09272df7..9cf0e32fc6 100644 --- a/ecrire/urls/standard.php +++ b/ecrire/urls/standard.php @@ -70,11 +70,14 @@ function recuperer_parametres_url(&$fond, $url) { (isset($_ENV['url_propre']) ? $_ENV['url_propre'] : ''); - if ($url_propre AND preg_match(',^(article|breve|rubrique|mot|auteur|site)$,', $fond)) { + if ($url_propre AND preg_match(',^(article|breve|rubrique|mot|auteur|site|type_urls)$,', $fond)) { $url_propre = (preg_replace('/^[_+-]{0,2}(.*?)[_+-]{0,2}(\.html)?$/', '$1', $url_propre)); - $r = sql_fetsel("id_objet", "spip_urls", "url=" . _q($url_propre)); - if ($r) $contexte[id_table_objet($fond)] = $r['id_objet']; + $r = sql_fetsel("id_objet,type", "spip_urls", "url=" . _q($url_propre)); + if ($r) { + $fond = ($r['type'] == 'syndic') ? 'site' : $r['type']; + $contexte[id_table_objet($fond)] = $r['id_objet']; + } } /* Fin du bloc compatibilite url-propres */ diff --git a/htaccess.txt b/htaccess.txt index 2a62fcd1d8..91276f0c79 100644 --- a/htaccess.txt +++ b/htaccess.txt @@ -74,29 +74,13 @@ RewriteRule ^spip_rss\.php3?$ spip.php?action=rss [QSA,L] ### ### -# URLs "propres" et "propres2" -# pensez a regler $type_urls='propres' ou 'propres2' -# dans ecrire/mes_options.php -# (fichier associe : ecrire/urls/propres.php) +# URLs "propres", "propres2", "libres", "arbo" -RewriteRule ^[^/\.]+(\.html)?$ spip.php?page=type_urls [QSA,E=url_propre:$0,L] +RewriteRule ^[^\.]+(\.html)?$ spip.php?page=type_urls [QSA,E=url_propre:$0,L] # Fin URLs "propres" et "propres2" ### -### -# URLs "arbo" -# pensez a ajouter -# $type_urls='arbo' -# define('_SET_HTML_BASE',1); // si vos squelette sont en url relatives -# dans ecrire/mes_options.php -# (fichier associe : ecrire/urls/arbo.php) - -RewriteRule ^[^\.]+(\.html)?$ spip.php?page=type_urls [QSA,E=url_propre:$0,L] - -# Fin URLs "arbo" -### - ### # Divers -- GitLab