"; foreach($arbo as $id => $section) { echo "
  • "; if ($afficher_ajouter_rubrique) { echo ' $id))).'" class="ajouter">+'; } echo '>'; echo ''.$section["titre"].''; echo afficher_enfants($section["enfants"], $articles, $args, $afficher_ajouter_rubrique, $afficher_ajouter_article); if($afficher_ajouter_article) { echo selec_afficher_article($id, $articles, $args, $afficher_ajouter_rubrique, $afficher_ajouter_article); } echo "
  • "; } echo ""; } function charger_structure(){ //rubriques $arbo = array(); $result = spip_query("SELECT id_rubrique, titre FROM spip_rubriques WHERE id_parent=0"); while ($row = spip_fetch_array($result)) { $arbo[$row['id_rubrique']] = array("titre" => $row['titre']); $arbo[$row['id_rubrique']]["enfants"] = rubriques_enfants($row['id_rubrique']); } //articles $articles = array(); $result = spip_query("SELECT id_article, titre, id_rubrique FROM spip_articles WHERE statut='publie'"); while ($row = spip_fetch_array($result)) { $articles[$row['id_article']] = array("titre" => $row['titre'], "id_rubrique" => $row['id_rubrique']); } return array($arbo, $articles); } function rubriques_enfants($id_parent){ $return = array(); $result = spip_query("SELECT id_rubrique, titre FROM spip_rubriques WHERE id_parent=".$id_parent); while ($rub = spip_fetch_array($result)){ $return[$rub['id_rubrique']]["titre"] = ($rub['titre']); $return[$rub['id_rubrique']]["enfants"] = rubriques_enfants($rub['id_rubrique']); } return $return; } function afficher_enfants($arbo, $articles, $args, $afficher_ajouter_rubrique=true, $afficher_ajouter_article=true) { $html = ""; foreach($arbo as $id => $rub){ $html .= "
  • "; if ($afficher_ajouter_rubrique) { $html .= " $id)))."\" class=\"ajouter\">\"+\""; } $html .= '>'; $html .= "".raccourcir_titre($rub["titre"], 45).""; $html .= afficher_enfants($rub["enfants"], $articles, $args, $afficher_ajouter_rubrique, $afficher_ajouter_article); if ($afficher_ajouter_article) { $html .= selec_afficher_article($id, $articles, $args, $afficher_ajouter_rubrique, $afficher_ajouter_article); } $html .= "
  • "; } if ($html != "") { $html = ""; } return $html; } function selec_afficher_article($id_rubrique, $articles, $args, $afficher_ajouter_rubrique=true, $afficher_ajouter_article=true){ $html = ""; foreach($articles as $id => $article){ if ($article["id_rubrique"] == $id_rubrique) { $html .= "
  • "; if ($afficher_ajouter_article) { $html .= " $id)))."\" class=\"ajouter\">\"+\""; } $html .= "".raccourcir_titre($article["titre"], 45).""; $html .= "
  • "; } } if ($html != "") { $html = ""; } return $html; } function generer_url($args) { $segments = array(); $ancre = ""; $script = ""; foreach ($args as $param => $value) { if ($param == "#") { $ancre = "#".$value; } elseif ($param == "exec") { $script = $value; } else { $segments[] = $param."=".$value; } } $args = implode("&", $segments).$ancre; $url = generer_url_ecrire($script, $args); return $url; } function raccourcir_titre($titre, $max){ if (strlen($titre) > $max) { return substr($titre, 0, $max)."..."; } else { return $titre; } } function afficher_selecteur_mots($args) { $groupes = charger_structure_mots(); echo ""; } function charger_structure_mots(){ //groupes de mots $groupes = array(); $result = spip_query("SELECT id_groupe, titre FROM spip_groupes_mots"); while ($row = spip_fetch_array($result)) { $result2 = spip_query("SELECT id_mot, titre FROM spip_mots WHERE id_groupe=".$row['id_groupe']); $mots = array(); while ($row2 = spip_fetch_array($result2)) { $mots[$row2['id_mot']] = $row2['titre']; } $groupes[$row['id_groupe']] = array( 'titre' => $row['titre'], 'mots' => $mots, ); } return $groupes; } function afficher_mots($mots, $args){ $html = ""; foreach($mots as $id => $mot){ $html .= "
  • "; $html .= " $id)))."\" class=\"ajouter\">\"+\""; $html .= "".raccourcir_titre($mot, 45).""; $html .= "
  • "; } if ($html != "") { $html = ""; } return $html; } ?>