1 | <?php |
---|
2 | |
---|
3 | // détermination du chemin de base par rapport à la racine du serveur |
---|
4 | $dir_relatif_array = explode('/', $_SERVER["PHP_SELF"]); |
---|
5 | $i = 0; |
---|
6 | $dir_relatif=""; |
---|
7 | while($dir_relatif_array[$i] != 'plugins') { |
---|
8 | $dir_relatif .= $dir_relatif_array[$i]; |
---|
9 | $i++; |
---|
10 | } |
---|
11 | define('_DIR_ECRIRE',$dir_relatif.'/ecrire/'); |
---|
12 | |
---|
13 | $chemin = "../../../../../../"; |
---|
14 | $cheminEcrire = $chemin."ecrire/"; |
---|
15 | if (defined("_ECRIRE_INC_VERSION")) return; |
---|
16 | define("_ECRIRE_INC_VERSION", "1"); |
---|
17 | function spip_connect_db($host, $port, $login, $pass, $db) { |
---|
18 | global $fck_mysql_link; // pour connexions multiples |
---|
19 | $fck_mysql_link = @mysql_connect($host, $login, $pass); |
---|
20 | mysql_select_db($db); |
---|
21 | } |
---|
22 | include ($cheminEcrire.'inc_connect.php'); |
---|
23 | ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
---|
24 | <html> |
---|
25 | <head> |
---|
26 | <link rel="stylesheet" type="text/css" href="<?php echo $chemin; ?>spip.php?page=style_prive&couleur_claire=C0CAD4&couleur_foncee=85909A&ltr=left" > |
---|
27 | <script type='text/javascript'><!-- |
---|
28 | var admin = 0; |
---|
29 | var stat = 1; |
---|
30 | var largeur_icone = 110; |
---|
31 | var bug_offsetwidth = 0 ; |
---|
32 | |
---|
33 | var confirm_changer_statut = 'confirm_changer_statut'; |
---|
34 | //--></script> |
---|
35 | <script type="text/javascript" language="JavaScript"> |
---|
36 | |
---|
37 | function addDoc( fileUrl ) |
---|
38 | { |
---|
39 | window.top.opener.GetE('cmbLinkProtocol').value = '' ; |
---|
40 | window.top.opener.SetUrl( fileUrl ) ; |
---|
41 | window.top.close() ; |
---|
42 | window.top.opener.focus() ; |
---|
43 | } |
---|
44 | function show(id) { |
---|
45 | layer = document.getElementById(id); |
---|
46 | if(layer.style.display == 'none' || layer.style.display == '') layer.style.display = 'block'; |
---|
47 | else layer.style.display = 'none'; |
---|
48 | } |
---|
49 | |
---|
50 | </script> |
---|
51 | <style type="text/css"> |
---|
52 | body { |
---|
53 | font-size: 11px; |
---|
54 | margin-left: 15px; |
---|
55 | margin-top: 15px; |
---|
56 | } |
---|
57 | td { |
---|
58 | font-size: 11px; |
---|
59 | } |
---|
60 | .fleche { |
---|
61 | padding-top: 8px; |
---|
62 | } |
---|
63 | a:link, a:visited { |
---|
64 | text-decoration: none; |
---|
65 | color: #000000; |
---|
66 | } |
---|
67 | a:hover, a:active { |
---|
68 | text-decoration: underline; |
---|
69 | } |
---|
70 | .indent { |
---|
71 | padding-left: 30px; |
---|
72 | } |
---|
73 | .invisible { |
---|
74 | display: none; |
---|
75 | } |
---|
76 | .puce { |
---|
77 | margin-right: 5px; |
---|
78 | border: 1px solid #000; |
---|
79 | } |
---|
80 | </style> |
---|
81 | </head> |
---|
82 | |
---|
83 | <body> |
---|
84 | <?php |
---|
85 | |
---|
86 | |
---|
87 | list($data, $nbDocsTotal) = sous_arborescence(0); |
---|
88 | |
---|
89 | echo $data; |
---|
90 | |
---|
91 | function sous_arborescence($id_rubrique) { |
---|
92 | global $cheminEcrire; |
---|
93 | |
---|
94 | $image_article = array('prepa'=>'blanche', 'prop'=>'orange', 'publie'=>'verte', 'poubelle'=>'poubelle', 'refuse'=>'rouge'); |
---|
95 | $nbDocsTotal = 0; |
---|
96 | |
---|
97 | $sousRubriques = mysql_query("SELECT id_rubrique, titre FROM spip_rubriques WHERE id_parent = $id_rubrique ORDER BY titre"); |
---|
98 | $nbSousRubriques = mysql_num_rows($sousRubriques); |
---|
99 | |
---|
100 | $documentsRubrique = mysql_query("SELECT id_document FROM spip_documents_rubriques WHERE id_rubrique = $id_rubrique"); |
---|
101 | $nbDocumentsRubrique = mysql_num_rows($documentsRubrique); |
---|
102 | $nbDocsTotal += $nbDocumentsRubrique; |
---|
103 | |
---|
104 | $articles = mysql_query("SELECT id_article AS nb, titre, id_article, statut FROM spip_articles WHERE id_rubrique = ".$id_rubrique." GROUP BY id_article ORDER BY titre"); |
---|
105 | $nbArticles = mysql_num_rows($articles); |
---|
106 | |
---|
107 | $sites = mysql_query("SELECT id_syndic, nom_site, statut FROM spip_syndic WHERE id_rubrique = ".$id_rubrique.""); |
---|
108 | $nbSites = mysql_num_rows($sites); |
---|
109 | |
---|
110 | $listeSites = array(); |
---|
111 | if ($nbSites > 0) { |
---|
112 | while ($row = mysql_fetch_array($sites)) { |
---|
113 | $listeSites[] = array('id' => $row['id_syndic'], 'titre' => $row['nom_site'], 'statut' => $row['statut']); |
---|
114 | } |
---|
115 | } |
---|
116 | |
---|
117 | $nbDocumentsArticles = 0; |
---|
118 | $listeArticles = array(); |
---|
119 | if ($nbArticles > 0) { |
---|
120 | while ($row = mysql_fetch_array($articles)) { |
---|
121 | $listeArticles[] = array('id' => $row['id_article'], 'titre' => $row['titre'], 'statut' => $row['statut'], 'nb' => $row['nb']); |
---|
122 | $nbDocumentsArticles += $row['nb']; |
---|
123 | $nbDocsTotal += $row['nb']; |
---|
124 | } |
---|
125 | } |
---|
126 | |
---|
127 | $retour = ''; |
---|
128 | if (($nbSousRubriques + $nbDocumentsRubrique + $nbDocumentsArticles + $nbSites) > 0) { |
---|
129 | $retour .= '<div>'; |
---|
130 | |
---|
131 | while ($row = mysql_fetch_array($sousRubriques)) { |
---|
132 | |
---|
133 | list($content, $nbDocs) = sous_arborescence($row['id_rubrique']); |
---|
134 | |
---|
135 | $nbDocsTotal += $nbDocs; |
---|
136 | $retour .= '<div class="indent">'; |
---|
137 | if ($content != '') { |
---|
138 | $retour .= '<a href="#" onclick="show(\'rub'.$row['id_rubrique'].'\');"><img src="'.$cheminEcrire.'img_pack/triangle-droite.gif" width="8" height="8" class="puce"></a>'; |
---|
139 | } else { |
---|
140 | $retour .= '<img src="'.$cheminEcrire.'img_pack/rien.gif" width="16" height="14" />'; |
---|
141 | } |
---|
142 | $retour .= '<img src="'.$cheminEcrire.'img_pack/rubrique-24.gif" align="absbottom" /> '; |
---|
143 | $retour .= '<a href="javascript:addDoc(\'spip.php?rubrique'.$row['id_rubrique'].'\');" title="Lier la rubrique">' . $row['titre'].' <img src="'.$cheminEcrire.'img_pack/plus.gif" align="bottom" border="0" /> <img src="'.$cheminEcrire.'img_pack/rubrique-12.gif" align="absbottom" border="0" /></a>'; |
---|
144 | if ($content != '') { |
---|
145 | $retour .= '<div id="rub'.$row['id_rubrique'].'" class="invisible">'; |
---|
146 | $retour .= $content; |
---|
147 | $retour .= '</div>'; |
---|
148 | } |
---|
149 | $retour .= '</div>'; |
---|
150 | } |
---|
151 | if ($nbArticles > 0) { |
---|
152 | reset($listeArticles); |
---|
153 | while (list(, $article) = each($listeArticles)) { |
---|
154 | |
---|
155 | $retour .= '<div class="indent">'; |
---|
156 | $retour .= '<img src="'.$cheminEcrire.'img_pack/article-24.gif" align="absbottom" /> '; |
---|
157 | $retour .= '<a href="javascript:addDoc(\'spip.php?article'.$article['id'].'\');" title="Lier l\'article">' . $article['titre'] . ' <img src="'.$cheminEcrire.'img_pack/plus.gif" align="bottom" border="0" /> <img src="'.$cheminEcrire.'img_pack/puce-'.$image_article[$article['statut']].'.gif" align="bottom" border="0" /></a>'; |
---|
158 | $retour .= '</div>'; |
---|
159 | } |
---|
160 | } |
---|
161 | if($nbSites > 0) { |
---|
162 | reset($listeSites); |
---|
163 | while (list(, $site) = each($listeSites)) { |
---|
164 | $retour .= '<div class="indent">'; |
---|
165 | $retour .= '<img src="'.$cheminEcrire.'img_pack/site-24.gif" align="absbottom" /><a href="javascript:addDoc(\'spip.php?site'.$site['id'].'\');" title="Lier l\'outil">'; |
---|
166 | $retour .= $site['titre'].' '; |
---|
167 | $retour .= '<img src="'.$cheminEcrire.'img_pack/plus.gif" align="bottom" border="0" /> <img src="'.$cheminEcrire.'img_pack/puce-'.$image_article[$site['statut']].'.gif" align="bottom" border="0" /></a>'; |
---|
168 | $retour .= '</div>'; |
---|
169 | } |
---|
170 | } |
---|
171 | $retour .= '</div>'; |
---|
172 | } |
---|
173 | mysql_free_result($sousRubriques); |
---|
174 | mysql_free_result($documentsRubrique); |
---|
175 | |
---|
176 | return array($retour, $nbDocsTotal); |
---|
177 | } |
---|
178 | ?> |
---|
179 | |
---|
180 | |
---|
181 | </body> |
---|
182 | </html> |
---|