4 |
david |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/***************************************************************************\
|
|
|
4 |
* SPIP, Systeme de publication pour l'internet *
|
|
|
5 |
* *
|
|
|
6 |
* Copyright (c) 2001-2005 *
|
|
|
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 |
include_once("inc.php3");
|
|
|
15 |
|
|
|
16 |
if (http_last_modified(@filemtime("js_menu_rubriques.php"), time() + 24 * 3600))
|
|
|
17 |
exit;
|
|
|
18 |
|
|
|
19 |
@Header ("Content-Type: text/javascript");
|
|
|
20 |
|
|
|
21 |
function extraire_article($id_p) {
|
|
|
22 |
if (array_key_exists($id_p, $GLOBALS['db_art_cache'])) {
|
|
|
23 |
return $GLOBALS['db_art_cache'][$id_p];
|
|
|
24 |
} else {
|
|
|
25 |
return array();
|
|
|
26 |
}
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
function gen_liste_rubriques() {
|
|
|
30 |
// se restreindre aux rubriques utilisees recemment +secteurs
|
|
|
31 |
$liste="0";
|
|
|
32 |
$s = spip_query("SELECT id_rubrique FROM spip_rubriques
|
|
|
33 |
ORDER BY id_parent=0 DESC, date DESC LIMIT 0,500");
|
|
|
34 |
while ($t = spip_fetch_array($s))
|
|
|
35 |
$liste .=",".$t['id_rubrique'];
|
|
|
36 |
|
|
|
37 |
$q = "SELECT id_rubrique, id_parent, titre
|
|
|
38 |
FROM spip_rubriques
|
|
|
39 |
WHERE id_rubrique IN ($liste)
|
|
|
40 |
ORDER BY id_parent,0+titre,titre";
|
|
|
41 |
|
|
|
42 |
$res = spip_query($q);
|
|
|
43 |
|
|
|
44 |
$GLOBALS['db_art_cache'] = array();
|
|
|
45 |
if (spip_num_rows($res) > 0) {
|
|
|
46 |
while ($row = spip_fetch_array($res)) {
|
|
|
47 |
$parent = $row['id_parent'];
|
|
|
48 |
$id = $row['id_rubrique'];
|
|
|
49 |
$GLOBALS['db_art_cache'][$parent][$id] = $row['titre'];
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
function bandeau_menu() {
|
|
|
56 |
global $spip_ecran;
|
|
|
57 |
|
|
|
58 |
gen_liste_rubriques();
|
|
|
59 |
$arr_low = extraire_article(0);
|
|
|
60 |
|
|
|
61 |
$i = sizeof($arr_low);
|
|
|
62 |
|
|
|
63 |
$total_lignes = $i;
|
|
|
64 |
if ($spip_ecran == "large") $max_lignes = 20;
|
|
|
65 |
else $max_lignes = 15;
|
|
|
66 |
|
|
|
67 |
$nb_col = ceil($total_lignes / $max_lignes);
|
|
|
68 |
if ($nb_col < 1) $nb_col = 1;
|
|
|
69 |
$max_lignes = ceil($total_lignes / $nb_col);
|
|
|
70 |
|
|
|
71 |
$count_lignes = 0;
|
|
|
72 |
|
|
|
73 |
if ($i > 0) {
|
|
|
74 |
$ret = "<div> </div>";
|
|
|
75 |
$ret .= "<div class='bandeau_rubriques' style='z-index: 1;'>";
|
|
|
76 |
foreach( $arr_low as $id_rubrique => $titre_rubrique) {
|
|
|
77 |
|
|
|
78 |
if ($count_lignes == $max_lignes) {
|
|
|
79 |
$count_lignes = 0;
|
|
|
80 |
$ret .= "</div></td><td valign='top' width='200'><div> </div><div class='bandeau_rubriques' style='z-index: 1;'>";
|
|
|
81 |
}
|
|
|
82 |
$count_lignes ++;
|
|
|
83 |
|
|
|
84 |
$titre_rubrique = supprimer_numero(typo($titre_rubrique));
|
|
|
85 |
$ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i);
|
|
|
86 |
$i = $i - 1;
|
|
|
87 |
}
|
|
|
88 |
$ret .= "</div>";
|
|
|
89 |
}
|
|
|
90 |
unset($GLOBALS['db_art_cache']); // On libère la mémoire
|
|
|
91 |
return $ret;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
function bandeau_rubrique($id_rubrique, $titre_rubrique, $z = 1) {
|
|
|
96 |
global $zdecal;
|
|
|
97 |
global $spip_ecran, $spip_display;
|
|
|
98 |
global $spip_lang, $spip_lang_rtl, $spip_lang_left, $spip_lang_right;
|
|
|
99 |
|
|
|
100 |
$titre_rubrique = preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique);
|
|
|
101 |
|
|
|
102 |
// Calcul du nombre max de sous-menus
|
|
|
103 |
$zdecal = $zdecal + 1;
|
|
|
104 |
if ($spip_ecran == "large") $zmax = 8;
|
|
|
105 |
else $zmax= 6;
|
|
|
106 |
|
|
|
107 |
// Limiter volontairement le nombre de sous-menus
|
|
|
108 |
$zmax = 6;
|
|
|
109 |
if ($spip_ecran == "large") $max_lignes = 20;
|
|
|
110 |
else $max_lignes = 15;
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
if ($zindex < 1) $zindex = 1;
|
|
|
115 |
if ($zdecal == 1) $image = "secteur-12.gif";
|
|
|
116 |
//else $image = "rubrique-12.gif";
|
|
|
117 |
else $image = '';
|
|
|
118 |
|
|
|
119 |
if (strlen($image) > 1) $image = " style='background-image:url(" . _DIR_IMG_PACK . $image .");'";
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
$arr_rub = extraire_article($id_rubrique);
|
|
|
123 |
|
|
|
124 |
$i = sizeof($arr_rub);
|
|
|
125 |
if ($i > 0 AND $zdecal < $zmax) {
|
|
|
126 |
$ret .= '<div class=\"pos_r\" style=\"z-index: '.$z.';\" onMouseOver=\"montrer(\'b_'.$id_rubrique.'\');\" onMouseOut=\"cacher(\'b_'.$id_rubrique.'\');\">';
|
|
|
127 |
$ret .= '<div class=\"brt\"><a href=\"naviguer.php3?id_rubrique='.$id_rubrique.'\" class=\"bandeau_rub\"'.$image.'>'.addslashes(supprimer_tags($titre_rubrique)).'</a></div>';
|
|
|
128 |
$ret .= '<div class=\"bandeau_rub\" style=\"z-index: '.($z+1).';\" id=\"b_'.$id_rubrique.'\">';
|
|
|
129 |
|
|
|
130 |
$ret .= '<table cellspacing=\"0\" cellpadding=\"0\"><tr><td valign=\"top\">';
|
|
|
131 |
$ret .= "<div class='bandeau_rubriques' style='width: 170px;'>";
|
|
|
132 |
foreach( $arr_rub as $id_rub => $titre_rub) {
|
|
|
133 |
$count_ligne ++;
|
|
|
134 |
|
|
|
135 |
if ($count_ligne == $max_lignes) {
|
|
|
136 |
$count_ligne = 0;
|
|
|
137 |
$ret .= "</div>";
|
|
|
138 |
$ret .= '</td><td> </td><td valign=\"top\">';
|
|
|
139 |
$ret .= "<div class='bandeau_rubriques' style='width: 170px;'>";
|
|
|
140 |
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
$titre_rub = supprimer_numero(typo($titre_rub));
|
|
|
144 |
$ret .= bandeau_rubrique($id_rub, $titre_rub, ($z+$i));
|
|
|
145 |
$i = $i - 1;
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
$ret .= '</div></td></tr></table>';
|
|
|
149 |
|
|
|
150 |
$ret .= "</div></div>";
|
|
|
151 |
} else {
|
|
|
152 |
$ret .= '<div><a href=\"naviguer.php3?id_rubrique='.$id_rubrique.'\" class=\"bandeau_rub\"'.$image.'>'.addslashes(supprimer_tags($titre_rubrique)).'</a></div>';
|
|
|
153 |
}
|
|
|
154 |
$zdecal = $zdecal - 1;
|
|
|
155 |
return $ret;
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
echo "document.write(\"";
|
|
|
159 |
echo "<table><tr><td valign='top' width='200'>";
|
|
|
160 |
echo bandeau_menu();
|
|
|
161 |
echo "</td></tr></table>";
|
|
|
162 |
echo "\");\n";
|
|
|
163 |
|
|
|
164 |
?>
|