";
+ }
+ $count_lignes ++;
+ if (autoriser('voir','rubrique',$id_rubrique)){
+ $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i, $largeur, $image);
+ $i--;
+ }
+ }
+
+ $ret = "
\n";
+ }
+
+ include_spip('inc/actions');
+ ajax_retour("
" . $ret);
+ }
+}
+
+
+// http://doc.spip.org/@bandeau_rubrique
+function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $largeur, $image='') {
+
+ global $spip_lang_left;
+
+ static $zmax = 6;
+
+ $nav = "
\n "
+ . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique))
+ . "\n";
+
+ // Limiter volontairement le nombre de sous-menus
+ if (!(--$zmax)) {
+ $zmax++;
+ return "\n
$nav
";
+ }
+
+ $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']);
+ $i = sizeof($arr_rub);
+ if (!$i) {
+ $zmax++;
+ return "\n
$nav
";
+ }
+
+ $pxdecal = max(15, ceil($largeur/5)) . 'px';
+
+ $ret = http_script("// http://doc.spip.org/@bandeauHover
+// http://doc.spip.org/@bandeauHover
+ function bandeauHover(r) {
+ if (!$(r).is('.hovered'))
+ $(r)
+ .addClass('hovered')
+ .children('.bandeau_rub')
+ .css('visibility', 'visible') // bizarre
+ .show()
+ .end()
+ .hover(
+ function(){\$(this).children('.bandeau_rub').show();},
+ function(){\$(this).children('.bandeau_rub').hide();}
+ );
+ };");
+
+ $ret .= "
"
+ . '
'
+ . $nav
+ . "
\n
";
+
+ if ($nb_rub = count($arr_rub)) {
+ $nb_col = min(10,max(1,ceil($nb_rub / 10)));
+ $ret_ligne = max(4,ceil($nb_rub / $nb_col));
+ }
+ $count_ligne = 0;
+ foreach( $arr_rub as $id_rub => $titre_rub) {
+ $count_ligne ++;
+
+ if ($count_ligne > $ret_ligne) {
+ $count_ligne = 0;
+ $ret .= " | ";
+ $ret .= '';
+
+ }
+ if (autoriser('voir','rubrique',$id_rub)){
+ $titre = supprimer_numero(typo($titre_rub));
+ $ret .= bandeau_rubrique($id_rub, $titre, $zdecal+$i, $largeur);
+ $i--;
+ }
+ }
+ $ret .= " |
\n";
+ $ret .= "
\n";
+
+ $zmax++;
+ return $ret;
+}
+
+
+// http://doc.spip.org/@extraire_article
+function extraire_article($id_p, $t) {
+ return array_key_exists($id_p, $t) ? $t[$id_p]: array();
+}
+
+// http://doc.spip.org/@gen_liste_rubriques
+function gen_liste_rubriques() {
+
+ // ici, un petit fichier cache ne fait pas de mal
+ $last = $GLOBALS['meta']["date_calcul_rubriques"];
+ if (lire_fichier(_CACHE_RUBRIQUES, $cache)) {
+ list($date,$GLOBALS['db_art_cache']) = @unserialize($cache);
+ if ($date == $last) return false; // c'etait en cache :-)
+ }
+ // se restreindre aux rubriques utilisees recemment +secteurs
+
+ $where = sql_in_select("id_rubrique", "id_rubrique", "spip_rubriques", "", "", "id_parent=0 DESC, date DESC", _CACHE_RUBRIQUES_MAX);
+
+ // puis refaire la requete pour avoir l'ordre alphabetique
+
+ $res = sql_select("id_rubrique, titre, id_parent", "spip_rubriques", $where, '', 'id_parent, 0+titre, titre');
+
+ // il ne faut pas filtrer le autoriser voir ici
+ // car on met le resultat en cache, commun a tout le monde
+ $GLOBALS['db_art_cache'] = array();
+ while ($r = sql_fetch($res)) {
+ $t = sinon($r['titre'], _T('ecrire:info_sans_titre'));
+ $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t));
+ }
+
+ $t = array($last ? $last : time(), $GLOBALS['db_art_cache']);
+ ecrire_fichier(_CACHE_RUBRIQUES, serialize($t));
+ return true;
+}
+?>