diff --git a/.gitattributes b/.gitattributes index c2afb17d5a3b81067b72ae22b1993bebf7c21bfe..8ada7183b1f0fa80047d54607b5426f05e80738f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -89,6 +89,7 @@ ecrire/action/petitionner.php -text ecrire/action/poster_forum_prive.php -text ecrire/action/preferer.php -text ecrire/action/purger.php -text +ecrire/action/redirect.php -text ecrire/action/referencer_traduction.php -text ecrire/action/regler_moderation.php -text ecrire/action/reorganiser.php -text diff --git a/ecrire/action/redirect.php b/ecrire/action/redirect.php new file mode 100644 index 0000000000000000000000000000000000000000..0d961566bf81bad33bd6a9a7fd4932d2cc91a968 --- /dev/null +++ b/ecrire/action/redirect.php @@ -0,0 +1,29 @@ +<?php + +/***************************************************************************\ + * SPIP, Systeme de publication pour l'internet * + * * + * Copyright (c) 2001-2008 * + * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * + * * + * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * + * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * +\***************************************************************************/ + +if (!defined("_ECRIRE_INC_VERSION")) return; + +// Un script utile pour recalculer une URLs symbolique des son changement + +function action_redirect_dist() +{ + $type = _request('type'); + if (!preg_match('/^\w+$/', $type)) return; + $h = generer_url_entite_absolue(intval(_request('id')), + $type, + "var_mode=" . _request('var_mode'), + '', + true); + redirige_par_entete(str_replace('&', '&', $h)); +} + +?> \ No newline at end of file diff --git a/ecrire/inc/presentation.php b/ecrire/inc/presentation.php index aa590524a127d947a0c7350c758c2778d7610d6a..40e2877bdd141c660f0971a3256ecf49e164e354 100644 --- a/ecrire/inc/presentation.php +++ b/ecrire/inc/presentation.php @@ -1095,7 +1095,7 @@ function voir_en_ligne ($type, $id, $statut=false, $image='racine-24.gif', $af = $en_ligne = $message = ''; switch ($type) { - case 'article': + case 'article': if ($statut == "publie" AND $GLOBALS['meta']["post_dates"] == 'non') { $n = sql_fetsel("id_article", "spip_articles", "id_article=$id AND date<=NOW()"); if (!$n) $statut = 'prop'; @@ -1105,28 +1105,29 @@ function voir_en_ligne ($type, $id, $statut=false, $image='racine-24.gif', $af = else if ($statut == 'prop') $en_ligne = 'preview'; break; - case 'rubrique': + case 'rubrique': if ($id > 0) if ($statut == 'publie') $en_ligne = 'calcul'; else $en_ligne = 'preview'; break; - case 'breve': - case 'site': + case 'breve': + case 'site': if ($statut == 'publie') $en_ligne = 'calcul'; else if ($statut == 'prop') $en_ligne = 'preview'; break; - case 'mot': + case 'mot': $en_ligne = 'calcul'; break; - case 'auteur': + case 'auteur': $n = sql_countsel('spip_auteurs_articles AS lien, spip_articles AS articles', "lien.id_auteur=".sql_quote($id)." AND lien.id_article=articles.id_article AND articles.statut='publie'"); if ($n) $en_ligne = 'calcul'; else $en_ligne = 'preview'; break; + default: return ''; } if ($en_ligne == 'calcul') @@ -1137,9 +1138,7 @@ function voir_en_ligne ($type, $id, $statut=false, $image='racine-24.gif', $af = else return ''; - $h = generer_url_entite_absolue($id, $type, "var_mode=$en_ligne", '', true); - - $h = str_replace('&', '&', $h); + $h = generer_url_action('redirect', "type=$type&id=$id&var_mode=$en_ligne"); return $inline ? icone_inline($message, $h, $image, "rien.gif", $GLOBALS['spip_lang_left'])