Commit | Line | Data |
---|---|---|
c495c100 P |
1 | <?php |
2 | ||
3 | /***************************************************************************\ | |
4 | * SPIP, Systeme de publication pour l'internet * | |
5 | * * | |
6 | * Copyright (c) 2001-2007 * | |
7 | * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * | |
8 | * * | |
9 | * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * | |
10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * | |
11 | \***************************************************************************/ | |
12 | ||
13 | ||
14 | if (!defined("_ECRIRE_INC_VERSION")) return; | |
15 | ||
16 | // Ce fichier doit imperativement definir la fonction ci-dessous: | |
17 | ||
18 | // http://doc.spip.org/@public_styliser_dist | |
19 | function public_styliser_dist($fond, $id_rubrique, $lang) { | |
20 | ||
21 | // Actuellement tous les squelettes se terminent par .html | |
22 | // pour des raisons historiques, ce qui est trompeur | |
23 | $ext = 'html'; | |
24 | // Accrocher un squelette de base dans le chemin, sinon erreur | |
25 | if (!$base = find_in_path("$fond.$ext")) { | |
26 | include_spip('public/debug'); | |
27 | erreur_squelette(_T('info_erreur_squelette2', | |
28 | array('fichier'=>"'$fond'")), | |
29 | $GLOBALS['dossier_squelettes']); | |
30 | $f = find_in_path("404.$ext"); | |
31 | return array(substr($f, 0, -strlen(".$ext")), | |
32 | $ext, | |
33 | $ext, | |
34 | $f); | |
35 | } | |
36 | ||
37 | // supprimer le ".html" pour pouvoir affiner par id_rubrique ou par langue | |
38 | $squelette = substr($base, 0, - strlen(".$ext")); | |
39 | ||
40 | // On selectionne, dans l'ordre : | |
41 | // fond=10 | |
42 | $f = "$fond=$id_rubrique"; | |
43 | if (($id_rubrique > 0) AND ($squel=find_in_path("$f.$ext"))) | |
44 | $squelette = substr($squel, 0, - strlen(".$ext")); | |
45 | else { | |
46 | // fond-10 fond-<rubriques parentes> | |
47 | while ($id_rubrique > 0) { | |
48 | $f = "$fond-$id_rubrique"; | |
49 | if ($squel=find_in_path("$f.$ext")) { | |
50 | $squelette = substr($squel, 0, - strlen(".$ext")); | |
51 | break; | |
52 | } | |
53 | else | |
54 | $id_rubrique = sql_parent($id_rubrique); | |
55 | } | |
56 | } | |
57 | ||
58 | // Affiner par lang | |
59 | if ($lang) { | |
60 | lang_select($lang); | |
61 | $f = "$squelette.".$GLOBALS['spip_lang']; | |
62 | lang_dselect(); | |
63 | if (@file_exists("$f.$ext")) | |
64 | $squelette = $f; | |
65 | } | |
66 | ||
67 | return array($squelette, $ext, $ext, "$squelette.$ext"); | |
68 | } | |
69 | ?> |