From 61bf8b8d5526ef8314cfe997b7dc9382a9ed58bb Mon Sep 17 00:00:00 2001 From: Fil <fil@rezo.net> Date: Fri, 22 Mar 2002 22:51:46 +0000 Subject: [PATCH] Ne passe plus les titres des forums dans l'URL (future compatibilite autres charsets + URLs moins charges) --- inc-calcul-squel.php3 | 50 ++++++++++++++----------------------------- inc-forum.php3 | 21 ++++++++++++++---- 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/inc-calcul-squel.php3 b/inc-calcul-squel.php3 index cd1cc37f78..fb13cee3b1 100644 --- a/inc-calcul-squel.php3 +++ b/inc-calcul-squel.php3 @@ -1380,38 +1380,27 @@ function calculer_champ($id_champ, $id_boucle, $nom_var) $milieu = ' switch ($pile_boucles[$id_instance]->type_requete) { case "articles": - $titre = "> ".$pile_boucles[$id_instance]->row["titre"]; - $'.$nom_var.' = retour_forum(0, 0, $contexte["id_article"], 0, 0, $titre); + $'.$nom_var.' = retour_forum(0, 0, $contexte["id_article"], 0, 0); break; case "breves": - $titre = "> ".$pile_boucles[$id_instance]->row["titre"]; - $'.$nom_var.' = retour_forum(0, 0, 0, $contexte["id_breve"], 0, $titre); + $'.$nom_var.' = retour_forum(0, 0, 0, $contexte["id_breve"], 0); break; case "forums": - $titre = "> ".$pile_boucles[$id_instance]->row["titre"]; - $'.$nom_var.' = retour_forum($contexte["id_rubrique"], $contexte["id_forum"], $contexte["id_article"], $contexte["id_breve"], $contexte["id_syndic"], $titre); + $'.$nom_var.' = retour_forum($contexte["id_rubrique"], $contexte["id_forum"], $contexte["id_article"], $contexte["id_breve"], $contexte["id_syndic"]); break; case "rubriques": - $titre = "> ".$pile_boucles[$id_instance]->row["titre"]; - $'.$nom_var.' = retour_forum($contexte["id_rubrique"], 0, 0, 0, 0, $titre); + $'.$nom_var.' = retour_forum($contexte["id_rubrique"], 0, 0, 0, 0); break; case "syndication": - $titre = "> ".$pile_boucles[$id_instance]->row["nom_site"]; - $'.$nom_var.' = retour_forum(0, 0, 0, 0, $contexte["id_syndic"], $titre); + $'.$nom_var.' = retour_forum(0, 0, 0, 0, $contexte["id_syndic"]); break; default: - if ($http_get_vars["titre"]) { - $titre = "> ".rawurldecode($http_get_vars["titre"]); - } - else { - $titre = ""; - } - $'.$nom_var.' = retour_forum($contexte["id_rubrique"], $contexte["id_forum"], $contexte["id_article"], $contexte["id_breve"], $contexte["id_syndic"], $titre); + $'.$nom_var.' = retour_forum($contexte["id_rubrique"], $contexte["id_forum"], $contexte["id_article"], $contexte["id_breve"], $contexte["id_syndic"]); break; } '; @@ -1429,44 +1418,37 @@ function calculer_champ($id_champ, $id_boucle, $nom_var) if ($forums_publics != "non" AND $contexte["accepter_forum"] != "non") { $lien = substr($request_uri, strrpos($request_uri, "/") + 1); if (!$lien_retour = $http_get_vars["retour"]) - $lien_retour = rawurlencode($lien); + $lien_retour = $lien; + $lien_retour = rawurlencode($lien_retour); switch ($pile_boucles[$id_instance]->type_requete) { case "articles": - $titre = $pile_boucles[$id_instance]->row["titre"]; $'.$nom_var.' = "id_article=$contexte[id_article]"; break; case "breves": - $titre = $pile_boucles[$id_instance]->row["titre"]; $'.$nom_var.' = "id_breve=$contexte[id_breve]"; break; - case "forums": - $titre = $pile_boucles[$id_instance]->row["titre"]; - $'.$nom_var.' = "id_article=$contexte[id_article]&id_breve=$contexte[id_breve]&id_rubrique=$contexte[id_rubrique]&id_syndic=$contexte[id_syndic]&id_forum=$contexte[id_forum]"; - break; - case "rubriques": - $titre = $pile_boucles[$id_instance]->row["titre"]; $'.$nom_var.' = "id_rubrique=$contexte[id_rubrique]"; break; case "syndication": - $titre = $pile_boucles[$id_instance]->row["nom_site"]; $'.$nom_var.' = "id_syndic=$contexte[id_syndic]"; break; - + case "forums": default: - $titre = ""; - $'.$nom_var.' = "id_article=$contexte[id_article]&id_breve=$contexte[id_breve]&id_rubrique=$contexte[id_rubrique]&id_syndic=$contexte[id_syndic]&id_forum=$contexte[id_forum]"; + $liste_champs = array ("id_article","id_breve","id_rubrique","id_syndic","id_forum"); + while (list(,$champ) = each ($liste_champs)) { + if ($contexte[$champ]) $element[] = "$champ=$contexte[$champ]"; + } + $'.$nom_var.' = join("&",$element); break; + } - if ($http_get_vars["titre"]) { - $titre = "> ".rawurldecode($http_get_vars["titre"]); - } - $'.$nom_var.' .= "&titre=".rawurlencode(substr($titre, 0, 25))."&retour=$lien_retour"; + $'.$nom_var.' .= "&retour=$lien_retour"; } else { $'.$nom_var.' = ""; diff --git a/inc-forum.php3 b/inc-forum.php3 index 267e4c8ade..c1d7d80b46 100644 --- a/inc-forum.php3 +++ b/inc-forum.php3 @@ -86,7 +86,7 @@ function forum_abonnement() { } -function retour_forum($id_rubrique, $id_parent, $id_article, $id_breve, $id_syndic, $titre) { +function retour_forum($id_rubrique, $id_parent, $id_article, $id_breve, $id_syndic) { global $REQUEST_URI, $HTTP_GET_VARS, $PATH_TRANSLATED; $forums_publics = lire_meta("forums_publics"); @@ -96,7 +96,7 @@ function retour_forum($id_rubrique, $id_parent, $id_article, $id_breve, $id_synd $retour = $HTTP_GET_VARS['retour']; if ($retour) - $retour = $retour; + $retour = rawurlencode($retour); else $retour = rawurlencode($lien); @@ -118,8 +118,21 @@ function retour_forum($id_rubrique, $id_parent, $id_article, $id_breve, $id_synd $ret .= "\n"; - if ($HTTP_GET_VARS['titre']){ - $titre = "> ".rawurldecode($HTTP_GET_VARS['titre']); + // recuperer le titre + if (! $titre) { + if ($id_parent) + $titre_select = "SELECT titre FROM spip_forum WHERE id_forum = $id_parent"; + else if ($id_rubrique) + $titre_select = "SELECT titre FROM spip_rubriques WHERE id_rubrique = $id_rubrique"; + else if ($id_article) + $titre_select = "SELECT titre FROM spip_articles WHERE id_article = $id_article"; + else if ($id_breve) + $titre_select = "SELECT titre FROM spip_breves WHERE id_breve = $id_breve"; + else if ($id_syndic) + $titre_select = "SELECT nom_site FROM spip_syndic WHERE id_syndic = $id_syndic"; + + $res = mysql_fetch_object(mysql_query($titre_select)); + $titre = '> ' . ereg_replace ('^[>[:space:]]*', '', $res->titre); } $seed = (double) (microtime() + 1) * time() * 1000000; -- GitLab