Update of /home/spip-cvs/spip
In directory alan:/tmp/cvs-serv4033
Modified Files:
inc-calcul-outils.php3 inc-calcul.php3 inc-chercher.php3
Log Message:
la recherche de squelette conforme au F3C
Index: inc-calcul.php3
RCS file: /home/spip-cvs/spip/inc-calcul.php3,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- inc-calcul.php3 24 Sep 2004 21:18:00 -0000 1.115
+++ inc-calcul.php3 25 Sep 2004 16:52:37 -0000 1.116
@@ -119,17 +119,28 @@
# definie dans inc-chercher, fichier non charge si elle est deja definie
# (typiquement dans mes_fonctions.php3)
-function cherche_page ($cache, $contexte, $fond, $id_rubrique, $lang='') {
+function cherche_page ($cache, $contexte, $fond) {
global $dossier_squelettes, $delais;
if (!function_exists('chercher_squelette'))
include_local("inc-chercher.php3"); # a renommer ?
// Choisir entre $fond-dist.html, $fond=7.html, etc?
+ $id_rubrique_fond = 0;
+ // Si inc-urls veut fixer la langue, on la recupere ici
+ $lang = $contexte['lang'];
+ // Chercher le fond qui va servir de squelette
+ if ($r = sql_rubrique_fond($contexte,
+ $lang ? $lang : lire_meta('langue_site')))
+ list($id_rubrique_fond, $lang) = $r;
+
+ if (!$GLOBALS['forcer_lang'])
+ lang_select($lang);
+
$skel = chercher_squelette($fond,
- $id_rubrique,
+ $id_rubrique_fond,
$dossier_squelettes ? "$dossier_squelettes/" :'',
- $lang);
+ $GLOBALS['spip_lang']);
// Charger le squelette et recuperer sa fonction principale
// (compilation automatique au besoin) et calculer
@@ -181,7 +192,6 @@
}
function calculer_page_globale($cache, $contexte_local, $fond) {
- global $spip_lang;
// Gestion des URLs personnalises - sale mais historique
if (function_exists("recuperer_parametres_url")) {
@@ -197,21 +207,8 @@
$contexte_local = $contexte;
}
- $id_rubrique_fond = 0;
-
- // Si inc-urls veut fixer la langue, se baser ici
- $lang = $contexte_local['lang'];
-
- // Chercher le fond qui va servir de squelette
- if ($r = sql_rubrique_fond($contexte_local,
- $lang ? $lang : lire_meta('langue_site')))
- list($id_rubrique_fond, $lang) = $r;
-
- if (!$GLOBALS['forcer_lang'])
- lang_select($lang);
-
// Go to work !
- $page = cherche_page($cache, $contexte_local, $fond, $id_rubrique_fond, $spip_lang);
+ $page = cherche_page($cache, $contexte_local, $fond);
$signal = array();
foreach(array('id_parent', 'id_rubrique', 'id_article', 'id_auteur',
@@ -234,10 +231,7 @@
if ($inclusion) {
$contexte_inclus = $elements['contexte'];
$page = cherche_page($chemin_cache,
- $contexte_inclus,
- $elements['fond'],
- $contexte_inclus['id_rubrique']
- );
+ $contexte_inclus, $elements['fond']);
}
else {
Index: inc-calcul-outils.php3
RCS file: /home/spip-cvs/spip/inc-calcul-outils.php3,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- inc-calcul-outils.php3 19 Sep 2004 13:12:29 -0000 1.8
+++ inc-calcul-outils.php3 25 Sep 2004 16:52:37 -0000 1.9
@@ -342,18 +342,18 @@
function sql_rubrique_fond($contexte, $lang) {
if ($id = intval($contexte['id_rubrique'])) {
- $row = spip_abstract_fetsel(array('lang'),
- array('rubriques'),
- array("id_rubrique='$id'"));
+ $row = spip_abstract_fetsel(array('lang'),
+ array('rubriques'),
+ array("id_rubrique='$id'"));
if ($row['lang'])
$lang = $row['lang'];
return array ($id, $lang);
}
if ($id = intval($contexte['id_breve'])) {
- $row = spip_abstract_fetsel(array('id_rubrique', 'lang'),
- array('breves'),
- array("id_breve='$id'"));
+ $row = spip_abstract_fetsel(array('id_rubrique', 'lang'),
+ array('breves'),
+ array("id_breve='$id'"));
$id_rubrique_fond = $row['id_rubrique'];
if ($row['lang'])
$lang = $row['lang'];
@@ -361,22 +361,22 @@
}
if ($id = intval($contexte['id_syndic'])) {
- $row = spip_abstract_fetsel(array('id_rubrique'),
- array('syndic'),
- array("id_syndic='$id'"));
+ $row = spip_abstract_fetsel(array('id_rubrique'),
+ array('syndic'),
+ array("id_syndic='$id'"));
$id_rubrique_fond = $row['id_rubrique'];
$row = spip_abstract_fetsel(array('lang'),
- array('rubriques'),
- array("id_rubrique='$id_rubrique_fond'"));
+ array('rubriques'),
+ array("id_rubrique='$id_rubrique_fond'"));
if ($row['lang'])
$lang = $row['lang'];
return array($id_rubrique_fond, $lang);
}
if ($id = intval($contexte['id_article'])) {
- $row = spip_abstract_fetsel(array('id_rubrique', 'lang'),
- array('articles'),
- array("id_article='$id'"));
+ $row = spip_abstract_fetsel(array('id_rubrique', 'lang'),
+ array('articles'),
+ array("id_article='$id'"));
$id_rubrique_fond = $row['id_rubrique'];
if ($row['lang'])
$lang = $row['lang'];
Index: inc-chercher.php3
RCS file: /home/spip-cvs/spip/inc-chercher.php3,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- inc-chercher.php3 22 Sep 2004 21:04:19 -0000 1.6
+++ inc-chercher.php3 25 Sep 2004 16:52:37 -0000 1.7
@@ -4,44 +4,59 @@
if (defined("_INC_CHERCHE")) return;
define("_INC_CHERCHE", "1");
-// Ce fichier doit IMPERATIVEMENT contenir la fonction chercher-squelette
+// Ce fichier doit imperativement contenir la fonction chercher-squelette
// (cf commentaires dans inc-calcul)
function chercher_squelette($fond, $id_rubrique, $dossier, $lang) {
$ext = $GLOBALS['extension_squelette'];
- if ($lang) {
- lang_select($lang);
- $f = "$fond.$lang";
- if (@file_exists("$f.$ext"))
- $fond = $f;
- }
+
$d ="$dossier$fond";
+
// On selectionne, dans l'ordre :
- // fond=10, fond-10 fond-<rubriques parentes> fond fond-dist
+ // fond=10
+
$f = "$d=$id_rubrique";
if (($id_rubrique > 0) AND (@file_exists("$f.$ext")))
- return $f;
+ $squelette = $f;
- while ($id_rubrique) {
- if (@file_exists("$d-$id_rubrique.$ext"))
- return "$d-$id_rubrique";
- else
- $id_rubrique = sql_parent($id_rubrique);
- }
+ // fond-10 fond-<rubriques parentes>
+ if (!$squelette)
+ while ($id_rubrique > 0) {
+ if (@file_exists("$d-$id_rubrique.$ext")) {
+ $squelette = "$d-$id_rubrique";
+ break;
+ }
+ else
+ $id_rubrique = sql_parent($id_rubrique);
+ }
- if (@file_exists("$d.$ext")) {
- return $d;
- } else if (@file_exists("$fond.$ext")) {
- return $fond;
- } else if (@file_exists("$fond-dist.$ext")) {
- return "$fond-dist";
- } else {
- // erreur webmaster : $fond ne correspond a rien
- erreur_squelette(_T('info_erreur_squelette2',
- array('fichier'=>$fond)),
+ if (!$squelette) {
+ // fond
+ if (@file_exists("$d.$ext"))
+ $squelette = $d;
+ // fond, a la racine
+ else if (@file_exists("$fond.$ext"))
+ $squelette = $fond;
+ else if (@file_exists("$fond-dist.$ext"))
+ $squelette = "$fond-dist";
+ else {
+ // erreur webmaster : $fond ne correspond a rien
+ erreur_squelette(_T('info_erreur_squelette2',
+ array('fichier'=>$fond)),
$dossier);
- return '';
+ return '';
+ }
+ }
+
+ // Affiner par lang
+ if ($lang) {
+ lang_select($lang);
+ $f = "$squelette.$lang";
+ if (@file_exists("$f.$ext"))
+ $squelette = $f;
}
+
+ return $squelette;
}
?>