Skip to content
Extraits de code Groupes Projets
Valider c12ddc0f rédigé par Fil's avatar Fil
Parcourir les fichiers

la recherche de squelette conforme au F3C

parent 6d49af07
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -342,18 +342,18 @@ function sql_chapo($id_article)
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 @@ function sql_rubrique_fond($contexte, $lang) {
}
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'];
......
......@@ -119,17 +119,28 @@ function charger_squelette ($squelette) {
# 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_contexte() {
}
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 @@ function calculer_page_globale($cache, $contexte_local, $fond) {
$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 @@ function calculer_page($chemin_cache, $elements, $delais, $inclusion=false) {
if ($inclusion) {
$contexte_inclus = $elements['contexte'];
$page = cherche_page($chemin_cache,
$contexte_inclus,
$elements['fond'],
$contexte_inclus['id_rubrique']
);
$contexte_inclus, $elements['fond']);
}
else {
......
......@@ -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;
}
?>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter