diff --git a/.gitattributes b/.gitattributes index 2b6ae7ef552c3a030086440d305c168deb42d53f..5f744b02627d5099652220e7d75acb704969b981 100644 --- a/.gitattributes +++ b/.gitattributes @@ -319,6 +319,7 @@ ecrire/inc/petitionner.php -text ecrire/inc/plonger.php -text ecrire/inc/plugin.php -text ecrire/inc/prepare_recherche.php -text +ecrire/inc/presenter_enfants.php -text ecrire/inc/presenter_liste.php -text ecrire/inc/puce_statut.php -text ecrire/inc/rechercher.php -text diff --git a/ecrire/exec/accueil.php b/ecrire/exec/accueil.php index 0f2d32873e58df66af587ec94f6ee50bd1dc7ec0..f01f85fe86bfda47e1249d19a9c5dbb00e70871a 100644 --- a/ecrire/exec/accueil.php +++ b/ecrire/exec/accueil.php @@ -472,6 +472,7 @@ function exec_accueil_dist() echo encours_accueil(); } + include_spip('inc/presenter_enfants'); if (!$connect_id_rubrique) echo afficher_enfant_rub(0, false, true) . "<div class='nettoyeur'></div>"; diff --git a/ecrire/exec/naviguer.php b/ecrire/exec/naviguer.php index d2e68e012eebd27bad7da4607311426bda011cd4..88a5ce86d7b7874dcc22da165506fcdbbaf3d4c8 100644 --- a/ecrire/exec/naviguer.php +++ b/ecrire/exec/naviguer.php @@ -129,6 +129,7 @@ function naviguer_droite($row, $id_rubrique, $id_parent, $id_secteur, $haut, $n_ $onglet_contenu = "<div id='wysiwyg'>$fond</div>" . (_INTERFACE_ONGLETS? $boucles:""); + include_spip('inc/presenter_enfants'); $onglet_enfants = afficher_enfant_rub($id_rubrique, false, true) .(_INTERFACE_ONGLETS?"": diff --git a/ecrire/inc/presentation.php b/ecrire/inc/presentation.php index 3fa9ee6a3b749821070f7bb0dd239ff8fbfed6eb..3461a0c56236ef2af49ab91ab28c92825cf45310 100644 --- a/ecrire/inc/presentation.php +++ b/ecrire/inc/presentation.php @@ -1071,139 +1071,6 @@ function afficher_hierarchie($id_parent, $message='',$id_objet=0,$type='',$id_se return $out; } -// http://doc.spip.org/@enfant_rub -function enfant_rub($collection){ - global $spip_display, $spip_lang_left, $spip_lang_right, $spip_lang; - - $voir_logo = ($spip_display != 1 AND $spip_display != 4 AND isset($GLOBALS['meta']['image_process']) AND $GLOBALS['meta']['image_process'] != "non"); - - if ($voir_logo) { - $voir_logo = "float: $spip_lang_right; margin-$spip_lang_right: 0px; margin-top: 0px;"; - $chercher_logo = charger_fonction('chercher_logo', 'inc'); - } else $logo =''; - - $res = ""; - - $result = sql_select("id_rubrique, id_parent, titre, descriptif, lang ", "spip_rubriques", "id_parent=$collection",'', '0+titre,titre'); - - while($row=sql_fetch($result)){ - $id_rubrique=$row['id_rubrique']; - $id_parent=$row['id_parent']; - $titre=$row['titre']; - - 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']); - - if ($voir_logo) { - if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) { - list($fid, $dir, $nom, $format) = $logo; - include_spip('inc/filtres_images'); - $logo = image_reduire("<img src='$fid' alt='' />", 48, 36); - if ($logo) - $logo = "\n<div style='$voir_logo'>$logo</div>"; - } - } - - $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? "" : - http_img_pack("admin-12.gif", '', " width='12' height='12'", _T('image_administrer_rubrique'))) . - " <span dir='$lang_dir'><a href='" . - generer_url_ecrire("naviguer","id_rubrique=$id_rubrique") . - "'>". - typo($titre) . - "</a></span>"; - - $titre = (is_string($logo) ? $logo : '') . - bouton_block_depliable($lib_bouton,$les_sous_enfants ?false:-1,"enfants$id_rubrique"); - - $les_enfants = "\n<div class='enfants'>" . - debut_cadre_sous_rub(($id_parent ? "rubrique-24.gif" : "secteur-24.gif"), true, "", $titre) . - (!$descriptif ? '' : "\n<div class='verdana1'>$descriptif</div>") . - (($spip_display == 4) ? '' : $les_sous_enfants) . - "\n<div style='clear:both;'></div>" . - fin_cadre_sous_rub(true) . - "</div>"; - - $res .= ($spip_display != 4) - ? $les_enfants - : "\n<li>$les_enfants</li>"; - } - } - - changer_typo($spip_lang); # remettre la typo de l'interface pour la suite - return (($spip_display == 4) ? "\n<ul>$res</ul>\n" : $res); - -} - -// http://doc.spip.org/@sous_enfant_rub -function sous_enfant_rub($collection2){ - global $spip_lang_left; - - $result3 = sql_select("id_rubrique, id_parent, titre, lang", "spip_rubriques", "id_parent=$collection2",'', '0+titre,titre'); - - $retour = ''; - while($row=sql_fetch($result3)){ - $id_rubrique2=$row['id_rubrique']; - $id_parent2=$row['id_parent']; - $titre2=$row['titre']; - changer_typo($row['lang']); - $lang_dir = lang_dir($row['lang']); - if (autoriser('voir','rubrique',$id_rubrique2)) - $retour.="\n<li class='arial11 rubrique_12' dir='$lang_dir'><a href='" . generer_url_ecrire("naviguer","id_rubrique=$id_rubrique2") . "'>".typo($titre2)."</a></li>\n"; - } - - if (!$retour) return ''; - - return debut_block_depliable(false,"enfants$collection2") - ."\n<ul style='margin: 0px; padding: 0px; padding-top: 3px;'>\n" - . $retour - . "</ul>\n\n".fin_block()."\n\n"; -} - -// http://doc.spip.org/@afficher_enfant_rub -function afficher_enfant_rub($id_rubrique, $bouton=false, $return=false) { - global $spip_lang_left,$spip_lang_right, $spip_display; - - $les_enfants = enfant_rub($id_rubrique); - $n = strlen(trim($les_enfants)); - - if (!$n && !$bouton) return ""; - - if (!($x = strpos($les_enfants,"\n<div class='enfants'>",round($n/2)))) { - $les_enfants2=""; - }else{ - $les_enfants2 = substr($les_enfants, $x); - $les_enfants = substr($les_enfants,0,$x); - if ($spip_display == 4) { - $les_enfants .= '</li></ul>'; - $les_enfants2 = '<ul><li>' . $les_enfants2; - } - } - - $res = - "<div class='gauche'>" - . $les_enfants - . "</div>" - . "<div class='droite'>" - . $les_enfants2 - . "</div>" - . " " - . "<div style='float:" - . $spip_lang_right - . ";position:relative;'>" - . (!$bouton ? '' - : (!$id_rubrique - ? icone(_T('icone_creer_rubrique'), generer_url_ecrire("rubriques_edit","new=oui&retour=nav"), "secteur-24.gif", "creer.gif",$spip_lang_right, false) - : icone(_T('icone_creer_sous_rubrique'), generer_url_ecrire("rubriques_edit","new=oui&retour=nav&id_parent=$id_rubrique"), "rubrique-24.gif", "creer.gif",$spip_lang_right,false))) - . "</div>"; - - if ($return) return $res; else echo_log('afficher_enfant_rub',$res); -} - // Pour construire des menu avec SELECTED // http://doc.spip.org/@mySel function mySel($varaut,$variable, $option = NULL) { diff --git a/ecrire/inc/presenter_enfants.php b/ecrire/inc/presenter_enfants.php new file mode 100644 index 0000000000000000000000000000000000000000..178e6ccfa980a6131c2468f65ce1d02ea56221a3 --- /dev/null +++ b/ecrire/inc/presenter_enfants.php @@ -0,0 +1,149 @@ +<?php + +/***************************************************************************\ + * SPIP, Systeme de publication pour l'internet * + * * + * Copyright (c) 2001-2008 * + * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * + * * + * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * + * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * +\***************************************************************************/ + +include_spip('inc/autoriser'); +include_spip('inc/presentation'); + +// http://doc.spip.org/@enfant_rub +function enfant_rub($collection){ + global $spip_display, $spip_lang_left, $spip_lang_right, $spip_lang; + + $voir_logo = ($spip_display != 1 AND $spip_display != 4 AND isset($GLOBALS['meta']['image_process']) AND $GLOBALS['meta']['image_process'] != "non"); + + if ($voir_logo) { + $voir_logo = "float: $spip_lang_right; margin-$spip_lang_right: 0px; margin-top: 0px;"; + $chercher_logo = charger_fonction('chercher_logo', 'inc'); + } else $logo =''; + + $res = ""; + + $result = sql_select("id_rubrique, id_parent, titre, descriptif, lang ", "spip_rubriques", "id_parent=$collection",'', '0+titre,titre'); + + while($row=sql_fetch($result)){ + $id_rubrique=$row['id_rubrique']; + $id_parent=$row['id_parent']; + $titre=$row['titre']; + + 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']); + + if ($voir_logo) { + if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) { + list($fid, $dir, $nom, $format) = $logo; + include_spip('inc/filtres_images'); + $logo = image_reduire("<img src='$fid' alt='' />", 48, 36); + if ($logo) + $logo = "\n<div style='$voir_logo'>$logo</div>"; + } + } + + $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? "" : + http_img_pack("admin-12.gif", '', " width='12' height='12'", _T('image_administrer_rubrique'))) . + " <span dir='$lang_dir'><a href='" . + generer_url_ecrire("naviguer","id_rubrique=$id_rubrique") . + "'>". + typo($titre) . + "</a></span>"; + + $titre = (is_string($logo) ? $logo : '') . + bouton_block_depliable($lib_bouton,$les_sous_enfants ?false:-1,"enfants$id_rubrique"); + + $les_enfants = "\n<div class='enfants'>" . + debut_cadre_sous_rub(($id_parent ? "rubrique-24.gif" : "secteur-24.gif"), true, "", $titre) . + (!$descriptif ? '' : "\n<div class='verdana1'>$descriptif</div>") . + (($spip_display == 4) ? '' : $les_sous_enfants) . + "\n<div style='clear:both;'></div>" . + fin_cadre_sous_rub(true) . + "</div>"; + + $res .= ($spip_display != 4) + ? $les_enfants + : "\n<li>$les_enfants</li>"; + } + } + + changer_typo($spip_lang); # remettre la typo de l'interface pour la suite + return (($spip_display == 4) ? "\n<ul>$res</ul>\n" : $res); + +} + +// http://doc.spip.org/@sous_enfant_rub +function sous_enfant_rub($collection2){ + global $spip_lang_left; + + $result3 = sql_select("id_rubrique, id_parent, titre, lang", "spip_rubriques", "id_parent=$collection2",'', '0+titre,titre'); + + $retour = ''; + while($row=sql_fetch($result3)){ + $id_rubrique2=$row['id_rubrique']; + $id_parent2=$row['id_parent']; + $titre2=$row['titre']; + changer_typo($row['lang']); + $lang_dir = lang_dir($row['lang']); + if (autoriser('voir','rubrique',$id_rubrique2)) + $retour.="\n<li class='arial11 rubrique_12' dir='$lang_dir'><a href='" . generer_url_ecrire("naviguer","id_rubrique=$id_rubrique2") . "'>".typo($titre2)."</a></li>\n"; + } + + if (!$retour) return ''; + + return debut_block_depliable(false,"enfants$collection2") + ."\n<ul style='margin: 0px; padding: 0px; padding-top: 3px;'>\n" + . $retour + . "</ul>\n\n".fin_block()."\n\n"; +} + +// http://doc.spip.org/@afficher_enfant_rub +function afficher_enfant_rub($id_rubrique, $bouton=false, $return=false) { + global $spip_lang_left,$spip_lang_right, $spip_display; + + $les_enfants = enfant_rub($id_rubrique); + $n = strlen(trim($les_enfants)); + + if (!$n && !$bouton) return ""; + + if (!($x = strpos($les_enfants,"\n<div class='enfants'>",round($n/2)))) { + $les_enfants2=""; + }else{ + $les_enfants2 = substr($les_enfants, $x); + $les_enfants = substr($les_enfants,0,$x); + if ($spip_display == 4) { + $les_enfants .= '</li></ul>'; + $les_enfants2 = '<ul><li>' . $les_enfants2; + } + } + + $res = + "<div class='gauche'>" + . $les_enfants + . "</div>" + . "<div class='droite'>" + . $les_enfants2 + . "</div>" + . " " + . "<div style='float:" + . $spip_lang_right + . ";position:relative;'>" + . (!$bouton ? '' + : (!$id_rubrique + ? icone(_T('icone_creer_rubrique'), generer_url_ecrire("rubriques_edit","new=oui&retour=nav"), "secteur-24.gif", "creer.gif",$spip_lang_right, false) + : icone(_T('icone_creer_sous_rubrique'), generer_url_ecrire("rubriques_edit","new=oui&retour=nav&id_parent=$id_rubrique"), "rubrique-24.gif", "creer.gif",$spip_lang_right,false))) + . "</div>"; + + if ($return) return $res; else echo_log('afficher_enfant_rub',$res); +} + +?> \ No newline at end of file