From aeba842acce49158b87673dad99e7f1a0293c292 Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Thu, 10 Nov 2005 20:59:25 +0000 Subject: [PATCH] Rationnalisation des includes dans les fichiers de l'espace public --- inc-balises.php3 | 4 +--- inc-boucles.php3 | 4 +--- inc-cache.php3 | 4 +--- inc-calcul-outils.php3 | 6 ++---- inc-calcul.php3 | 4 +--- inc-chercher-squelette.php3 | 4 +--- inc-compilo-api.php3 | 4 +--- inc-compilo-index.php3 | 4 +--- inc-compilo.php3 | 4 +--- inc-criteres.php3 | 4 +--- inc-html-squel.php3 | 4 +--- inc-messforum.php3 | 1 + inc-public-global.php3 | 8 +++----- inc-stats.php3 | 4 +--- inc-urls-html.php3 | 3 +-- inc-urls-propres.php3 | 3 +-- inc-urls-propres2.php3 | 2 +- inc-urls-standard.php3 | 3 +-- spip_cal.php3 | 4 ++-- spip_image.php3 | 4 ++-- 20 files changed, 25 insertions(+), 53 deletions(-) diff --git a/inc-balises.php3 b/inc-balises.php3 index b4a41ac785..59f4f30cad 100644 --- a/inc-balises.php3 +++ b/inc-balises.php3 @@ -20,9 +20,7 @@ // Cette classe est definie dans inc-compilo-index.php3 // -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_BALISES")) return; -define("_INC_BALISES", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; // diff --git a/inc-boucles.php3 b/inc-boucles.php3 index 3f32d5ea66..455f8c57fe 100644 --- a/inc-boucles.php3 +++ b/inc-boucles.php3 @@ -15,9 +15,7 @@ // Ce fichier definit les boucles standard de SPIP // -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_BOUCLES")) return; -define("_INC_BOUCLES", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; // // Boucle standard, sans condition rajoutee diff --git a/inc-cache.php3 b/inc-cache.php3 index fbfe552bf3..d8509d8130 100644 --- a/inc-cache.php3 +++ b/inc-cache.php3 @@ -12,9 +12,7 @@ // -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_CACHE")) return; -define("_INC_CACHE", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; // diff --git a/inc-calcul-outils.php3 b/inc-calcul-outils.php3 index ddc574954d..e6226ab7d1 100644 --- a/inc-calcul-outils.php3 +++ b/inc-calcul-outils.php3 @@ -22,9 +22,7 @@ // ON TROUVERA EN QUEUE DE FICHIER LES FONCTIONS FAISANT DES APPELS SQL -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_CALCUL_OUTILS")) return; -define("_INC_CALCUL_OUTILS", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; include_ecrire('inc_rubriques.php3'); # pour calcul_branche() @@ -527,4 +525,4 @@ function lang_parametres_forum($s) { return $s; } -?> \ No newline at end of file +?> diff --git a/inc-calcul.php3 b/inc-calcul.php3 index 42d706e9d6..f056018a68 100644 --- a/inc-calcul.php3 +++ b/inc-calcul.php3 @@ -12,9 +12,7 @@ -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_CALCUL")) return; -define("_INC_CALCUL", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; // // Ce fichier calcule une page en executant un squelette. diff --git a/inc-chercher-squelette.php3 b/inc-chercher-squelette.php3 index 0e29bdf04d..96291ed11d 100644 --- a/inc-chercher-squelette.php3 +++ b/inc-chercher-squelette.php3 @@ -11,9 +11,7 @@ \***************************************************************************/ -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_CHERCHER")) return; -define("_INC_CHERCHER", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; // Ce fichier doit imperativement contenir la fonction chercher-squelette // (cf commentaires dans inc-calcul) diff --git a/inc-compilo-api.php3 b/inc-compilo-api.php3 index 1e184f17ad..208557f067 100644 --- a/inc-compilo-api.php3 +++ b/inc-compilo-api.php3 @@ -11,9 +11,7 @@ \***************************************************************************/ -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_COMPILO_API")) return; -define("_INC_COMPILO_API", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; // Definition des noeuds de l'arbre de syntaxe abstraite diff --git a/inc-compilo-index.php3 b/inc-compilo-index.php3 index 1d0277e086..ba8ad28dbc 100644 --- a/inc-compilo-index.php3 +++ b/inc-compilo-index.php3 @@ -15,9 +15,7 @@ // fonctions de recherche et de reservation // dans l'arborescence des boucles -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_COMPILO_INDEX")) return; -define("_INC_COMPILO_INDEX", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; // index_pile retourne la position dans la pile du champ SQL $nom_champ // en prenant la boucle la plus proche du sommet de pile (indique par $idb). diff --git a/inc-compilo.php3 b/inc-compilo.php3 index 46e94f4ff9..830d4e0217 100644 --- a/inc-compilo.php3 +++ b/inc-compilo.php3 @@ -15,9 +15,7 @@ // Fichier principal du compilateur de squelettes // -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_COMPILO")) return; -define("_INC_COMPILO", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; // reperer un code ne calculant rien, meme avec commentaire define('CODE_MONOTONE', "^(\n//[^\n]*\n)?\(?'([^'])*'\)?$"); diff --git a/inc-criteres.php3 b/inc-criteres.php3 index 0996a45171..d7d8987ad6 100644 --- a/inc-criteres.php3 +++ b/inc-criteres.php3 @@ -15,9 +15,7 @@ // Definition des {criteres} d'une boucle // -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_CRITERES")) return; -define("_INC_CRITERES", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; // {racine} diff --git a/inc-html-squel.php3 b/inc-html-squel.php3 index 93124e93c7..9be575fd2b 100644 --- a/inc-html-squel.php3 +++ b/inc-html-squel.php3 @@ -11,9 +11,7 @@ \***************************************************************************/ -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_HTML_SQUEL")) return; -define("_INC_HTML_SQUEL", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; # Ce fichier doit IMPERATIVEMENT contenir la fonction "phraser" # qui transforme un squelette en un tableau d'objets de classe Boucle diff --git a/inc-messforum.php3 b/inc-messforum.php3 index b02f6f8eaa..ef76b39e24 100644 --- a/inc-messforum.php3 +++ b/inc-messforum.php3 @@ -10,6 +10,7 @@ * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * \***************************************************************************/ +if (!defined("_ECRIRE_INC_VERSION")) return; include_ecrire('inc_meta.php3'); include_ecrire('inc_forum.php3'); diff --git a/inc-public-global.php3 b/inc-public-global.php3 index 7742c6071c..d14a18362d 100644 --- a/inc-public-global.php3 +++ b/inc-public-global.php3 @@ -11,9 +11,7 @@ \***************************************************************************/ -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_PUBLIC_GLOBAL")) return; -define("_INC_PUBLIC_GLOBAL", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; // fonction principale declenchant tout le service function calcule_header_et_page ($fond, $delais) { @@ -48,8 +46,8 @@ function calcule_header_et_page ($fond, $delais) { // Si envoi pour un forum, enregistrer puis rediriger if (strlen($_POST['confirmer_forum']) > 0 - OR ($GLOBALS['afficher_texte']=='non' AND $_POST['ajouter_mot'])) { - include('inc-messforum.php3'); + OR ($GLOBALS['afficher_texte']=='non' AND $_POST['ajouter_mot'])) { + include_local('inc-messforum.php3'); redirige_par_entete(enregistre_forum()); } diff --git a/inc-stats.php3 b/inc-stats.php3 index cd90ccd77d..5a3b43b5d6 100644 --- a/inc-stats.php3 +++ b/inc-stats.php3 @@ -12,9 +12,7 @@ // -// Ce fichier ne sera execute qu'une fois -if (defined("_INC_STATS")) return; -define("_INC_STATS", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; function ecrire_stats() { global $id_article, $id_breve, $id_rubrique; diff --git a/inc-urls-html.php3 b/inc-urls-html.php3 index 54cab2b1ab..f8c439fd23 100644 --- a/inc-urls-html.php3 +++ b/inc-urls-html.php3 @@ -34,8 +34,7 @@ pouvez l'editer pour ne conserver que la partie concernant les URLS 'html'. */ // executer une seule fois -if (defined("_INC_URLS2")) return; -define("_INC_URLS2", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; function generer_url_article($id_article) { return "article$id_article.html"; diff --git a/inc-urls-propres.php3 b/inc-urls-propres.php3 index 61e601beec..22b325a61a 100644 --- a/inc-urls-propres.php3 +++ b/inc-urls-propres.php3 @@ -12,8 +12,7 @@ // executer une seule fois -if (defined("_INC_URLS2")) return; -define("_INC_URLS2", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; /* diff --git a/inc-urls-propres2.php3 b/inc-urls-propres2.php3 index e56e960fea..828257a2be 100644 --- a/inc-urls-propres2.php3 +++ b/inc-urls-propres2.php3 @@ -24,4 +24,4 @@ if (!defined('_terminaison_urls_propres')) include('inc-urls-propres.php3'); -?> \ No newline at end of file +?> diff --git a/inc-urls-standard.php3 b/inc-urls-standard.php3 index 76ff357ab0..3b67a07572 100644 --- a/inc-urls-standard.php3 +++ b/inc-urls-standard.php3 @@ -12,8 +12,7 @@ // executer une seule fois -if (defined("_INC_URLS2")) return; -define("_INC_URLS2", "1"); +if (!defined("_ECRIRE_INC_VERSION")) return; function generer_url_article($id_article) { return "article.php3?id_article=$id_article"; diff --git a/spip_cal.php3 b/spip_cal.php3 index 407c4f2d19..050db2eed0 100644 --- a/spip_cal.php3 +++ b/spip_cal.php3 @@ -20,8 +20,8 @@ $var_f = find_in_path('inc_' . $var_nom . '.php'); if ($var_f) include($var_f); -elseif (file_exists($var_f = (_DIR_INCLUDE . 'inc_' . $var_nom . '.php'))) - include($var_f); +else + include_ecrire('inc_' . $var_nom . '.php'); if (function_exists($var_nom)) $var_nom($id, $cle); diff --git a/spip_image.php3 b/spip_image.php3 index b9f8ab2bae..a42bb3658d 100644 --- a/spip_image.php3 +++ b/spip_image.php3 @@ -20,8 +20,8 @@ $var_f = find_in_path('inc_' . $var_nom . '.php'); if ($var_f) include($var_f); -elseif (file_exists($var_f = (_DIR_INCLUDE . 'inc_' . $var_nom . '.php'))) - include($var_f); + else include_ecrire('inc_' . $var_nom . '.php'); + $var_nom .= '_' . $action; -- GitLab