X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Finc%2Fchercher_rubrique.php;h=d4beae7803e6dd725ce13a4f0c4c4592ccc25568;hp=3ac235743c2ba815c3548024ad4c3c85203e03d2;hb=e99f0878011913365e49b30d90e496c24c301393;hpb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed diff --git a/www/ecrire/inc/chercher_rubrique.php b/www/ecrire/inc/chercher_rubrique.php index 3ac2357..d4beae7 100644 --- a/www/ecrire/inc/chercher_rubrique.php +++ b/www/ecrire/inc/chercher_rubrique.php @@ -3,7 +3,7 @@ /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2011 * + * Copyright (c) 2001-2014 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * @@ -24,7 +24,8 @@ define('_SPIP_SELECT_RUBRIQUES', 20); /* mettre 100000 pour desactiver ajax */ // $idem : en mode rubrique = la rubrique soi-meme // http://doc.spip.org/@inc_chercher_rubrique_dist function inc_chercher_rubrique_dist ($id_rubrique, $type, $restreint, $idem=0, $do='aff') { - if (sql_countsel('spip_rubriques')<1) + $n = sql_countsel('spip_rubriques'); + if ($n < 1) return ''; // Mode sans Ajax : @@ -32,7 +33,7 @@ function inc_chercher_rubrique_dist ($id_rubrique, $type, $restreint, $idem=0, $ // - soit parce qu'il y a peu de rubriques if (_SPIP_AJAX < 1 OR $type == 'breve' - OR sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES) + OR $n < _SPIP_SELECT_RUBRIQUES) return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); else return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); @@ -44,7 +45,7 @@ $GLOBALS['selecteur_rubrique'] = 'inc_chercher_rubrique_dist'; // http://doc.spip.org/@style_menu_rubriques function style_menu_rubriques($i) { - global $browser_name, $browser_version, $spip_lang_left; + global $browser_name, $spip_lang_left; $espace = ''; if (preg_match(",mozilla,i", $browser_name)) { @@ -126,7 +127,13 @@ function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem=0) { // include_spip('base/abstract_sql'); - $q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", ($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre"); + $where = array(); + if ($type == 'breve') + $where[]= ' id_parent=0 '; + if (is_array($restreint) AND $restreint) + $where[]= sql_in('id_rubrique', $restreint); + + $q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", join(' AND ', $where), '', "0+titre,titre"); while ($r = sql_fetch($q)) { if (autoriser('voir','rubrique',$r['id_rubrique'])){ // titre largeur maxi a 50 @@ -136,7 +143,6 @@ function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem=0) { $titre .= ' ['.traduire_nom_langue($r['lang']).']'; $data[$r['id_rubrique']] = $titre; $enfants[$r['id_parent']][] = $r['id_rubrique']; - if ($id_rubrique == $r['id_rubrique']) $id_parent = $r['id_parent']; } } @@ -159,8 +165,7 @@ function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem=0) { // http://doc.spip.org/@selecteur_rubrique_ajax function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem=0, $do) { - ## $restreint indique qu'il faut limiter les rubriques affichees - ## aux rubriques editables par l'admin restreint... or, ca ne marche pas. + ## $restreint, si c'est un tableau, limite les rubriques selectionnables ## Pour la version HTML c'est bon (cf. ci-dessus), mais pour l'ajax... ## je laisse ca aux specialistes de l'ajax & des admins restreints ## note : toutefois c'est juste un pb d'interface, car question securite @@ -202,7 +207,7 @@ function construire_selecteur($url, $js, $idom, $name, $init='', $id=0) . $url . "', this.parentNode.nextSibling, this.nextSibling,'',event)\"> "._T(