X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fecrire%2Finc%2Fpresenter_enfants.php;fp=www%2Fecrire%2Finc%2Fpresenter_enfants.php;h=b8991a8153eafed970aa1d94d81d0b99c32b81c2;hb=4f443dce95ff6f8221c189880a70c74ce1c1f238;hp=91df554c2d86d7bfb653d7b8555e24c0e969348b;hpb=4a628e9b277d3617535f99d663ca79fa2e891177;p=lhc%2Fweb%2Fwww.git diff --git a/www/ecrire/inc/presenter_enfants.php b/www/ecrire/inc/presenter_enfants.php index 91df554c..b8991a81 100644 --- a/www/ecrire/inc/presenter_enfants.php +++ b/www/ecrire/inc/presenter_enfants.php @@ -3,7 +3,7 @@ /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2016 * + * Copyright (c) 2001-2017 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * @@ -11,26 +11,28 @@ \***************************************************************************/ -if (!defined('_ECRIRE_INC_VERSION')) return; +if (!defined('_ECRIRE_INC_VERSION')) { + return; +} include_spip('inc/autoriser'); include_spip('inc/presentation'); /** * Crée l'affichage des listes de rubriques dans le privé - * + * * @param int $collection * L'identifiant numérique de la rubrique à lister * @param int $debut - * Le numéro de la pagination si paginé (> 500) + * Le numéro de la pagination si paginé (> 500) * @param int $limite - * Le pas de pagination si paginé (> 500) + * Le pas de pagination si paginé (> 500) * @return array $res - * Un tableau des sous rubriques + * Un tableau des sous rubriques */ -function enfant_rub($collection,$debut=0,$limite=500){ - $voir_logo = (isset($GLOBALS['meta']['image_process']) AND $GLOBALS['meta']['image_process'] != "non"); - $logo = ""; +function enfant_rub($collection, $debut = 0, $limite = 500) { + $voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non'); + $logo = ''; if ($voir_logo) { $chercher_logo = charger_fonction('chercher_logo', 'inc'); @@ -38,48 +40,64 @@ function enfant_rub($collection,$debut=0,$limite=500){ } $res = array(); - - $result = sql_select("id_rubrique, id_parent, titre, descriptif, lang ", "spip_rubriques", "id_parent=$collection",'', '0+titre,titre',"$debut,$limite"); - while($row=sql_fetch($result)){ - $id_rubrique=$row['id_rubrique']; - $id_parent=$row['id_parent']; - $titre=generer_info_entite($id_rubrique,'rubrique','titre'); // pour etre sur de passer par tous les traitements - if ('' !== ($rang = recuperer_numero($row['titre']))) - $rang = "$rang. "; - if (autoriser('voir','rubrique',$id_rubrique)){ + $result = sql_select( + 'id_rubrique, id_parent, titre, descriptif, lang', + 'spip_rubriques', + 'id_parent='.intval($collection), + '', + '0+titre,titre', + "$debut,$limite" + ); + while ($row = sql_fetch($result)) { + $id_rubrique = $row['id_rubrique']; + $id_parent = $row['id_parent']; + // pour etre sur de passer par tous les traitements + $titre = generer_info_entite($id_rubrique, 'rubrique', 'titre'); + if ('' !== ($rang = recuperer_numero($row['titre']))) { + $rang = "$rang. "; + } + if (autoriser('voir', 'rubrique', $id_rubrique)) { $les_sous_enfants = sous_enfant_rub($id_rubrique); changer_typo($row['lang']); $lang_dir = lang_dir($row['lang']); - $descriptif=propre($row['descriptif']); + $descriptif = propre($row['descriptif']); if ($voir_logo) { if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) { list($fid, $dir, $nom, $format) = $logo; $logo = image_reduire("", 48, 36); - if ($logo) - $logo = inserer_attribut($logo,'class','logo'); + if ($logo) { + $logo = inserer_attribut($logo, 'class', 'logo'); + } } } - $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? "" : - http_img_pack('auteur-0minirezo-16.png', '', " width='16' height='16'", _T('image_administrer_rubrique'))) . - " ". + $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : + http_img_pack( + 'auteur-0minirezo-16.png', + '', + " width='16' height='16'", + _T('image_administrer_rubrique') + )) . + " " . $rang . $titre . - ""; + ''; $titre = (is_string($logo) ? $logo : '') . - bouton_block_depliable($lib_bouton,$les_sous_enfants ?false:-1,"enfants$id_rubrique"); + bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique"); $res[] = - debut_cadre_sous_rub(($id_parent ? "rubrique-24.png" : "secteur-24.png"), true, "", $titre) . - (!$descriptif ? '' : "\n
'.$pagination($nb, '_rubrique'.$collection2, $debut, $limite, true, 'prive').'
'; + $pagination = '' . $pagination($nb, '_rubrique' . $collection2, $debut, $limite, true, + 'prive') . '
'; $limite = $debut + $limite; } - - $result = sql_select("id_rubrique, id_parent, titre, lang", "spip_rubriques", "id_parent=$collection2",'', '0+titre,titre',"$debut,$limite"); - - while($row=sql_fetch($result)){ - $id_rubrique2=$row['id_rubrique']; - $id_parent2=$row['id_parent']; - $titre2=generer_info_entite($id_rubrique2,'rubrique','titre'); // pour etre sur de passer par tous les traitements - if ('' !== ($rang2 = recuperer_numero($row['titre']))) + + $result = sql_select( + 'id_rubrique, id_parent, titre, lang', + 'spip_rubriques', + 'id_parent='.intval($collection2), + '', + '0+titre,titre', + "$debut,$limite" + ); + + while ($row = sql_fetch($result)) { + $id_rubrique2 = $row['id_rubrique']; + $titre2 = generer_info_entite( + $id_rubrique2, + 'rubrique', + 'titre' + ); // pour etre sur de passer par tous les traitements + if ('' !== ($rang2 = recuperer_numero($row['titre']))) { $rang2 = "$rang2. "; + } changer_typo($row['lang']); $lang_dir = lang_dir($row['lang']); - if (autoriser('voir','rubrique',$id_rubrique2)) - $retour.="\n'.$pagination($nb, '_rubrique'.$collection2, $debut, $limite, true, 'prive').'
'; + $pagination = '' . + $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . + '
'; } - $les_enfants = enfant_rub($id_rubrique,$debut,$limite); + $les_enfants = enfant_rub($id_rubrique, $debut, $limite); - if (!$n = count($les_enfants)) return ""; - - if ($n==1) { - $les_enfants=reset($les_enfants); - $les_enfants2=""; + if (!$n = count($les_enfants)) { + return ''; } - else{ - $n = ceil($n/2); - $les_enfants2 = implode('',array_slice($les_enfants,$n)); - $les_enfants = implode('',array_slice($les_enfants,0,$n)); + + if ($n == 1) { + $les_enfants = reset($les_enfants); + $les_enfants2 = ''; + } else { + $n = ceil($n / 2); + $les_enfants2 = implode('', array_slice($les_enfants, $n)); + $les_enfants = implode('', array_slice($les_enfants, 0, $n)); } - + $res = - $pagination - . "