[ Index ] |
|
Code source de SPIP Agora 1.4 |
1 <?php 2 /***************************************************** 3 * This file is part of Agora, web based content management system. 4 * 5 * Agora is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * 9 * Agora is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details (file "COPYING"). 13 * 14 * Copyright © Arnaud Martin, Antoine Pitrou et Philippe Rivière. 15 * List of authors detailed in "copyright_fr.html" file. 16 * E-mail : agora@sig.premier-ministre.gouv.fr 17 * Web site : http://www.agora.gouv.fr 18 *****************************************************/ 19 include ("inc.php"); 20 21 include_ecrire ("inc_objet.php"); 22 include_ecrire ("inc_documents.php"); 23 24 //Gestion abstraction 25 require_once (dirname(__FILE__). "/include/bd/inc_type_document_factory.php"); 26 require_once (dirname(__FILE__). "/include/bd/inc_document_factory.php"); 27 require_once (dirname(__FILE__). "/include/bd/inc_rubrique_factory.php"); 28 //HACK TEMPORAIRE A VIRER 29 require_once (dirname(__FILE__). "/include/bd/inc_metier_factory.php"); 30 31 function afficher_un_document ($id_document) { 32 global $connect_id_auteur, $connect_statut; 33 34 $documentMetier = &recuperer_instance_document(); 35 $loadOK = $documentMetier->load($id_document); 36 37 if (PEAR::isError($loadOK)) { 38 die ($loadOK->getMessage()); 39 } 40 41 $id_vignette = $documentMetier->getVignetteId(); 42 ; 43 $id_type = $documentMetier->getTypeId(); 44 $titre = $documentMetier->getTitre(); 45 $descriptif = $documentMetier->getDescriptif(); 46 $fichier = generer_url_document($id_document); 47 $taille = $documentMetier->getTaille(); 48 $mode = $documentMetier->getMode(); 49 50 if ($titre == '') { 51 $titre = ereg_replace("^[^\/]*\/[^\/]*\/", "", $fichier); 52 } 53 54 $typeDocumentMetier = &recuperer_instance_type_document(); 55 $loadOK = $typeDocumentMetier->load($id_type); 56 57 if (!PEAR::isError($loadOK)) { 58 $type_extension = $typeDocumentMetier->getExtension(); 59 $type_inclus = $typeDocumentMetier->getInclus(); 60 $type_titre = $typeDocumentMetier->getTitre(); 61 } 62 63 if ($id_vignette) { 64 $vignetteMetier = &recuperer_instance_document(); 65 $loadOK = $vignetteMetier->load($id_vignette); 66 67 if (PEAR::isError($loadOK)) { 68 die ($loadOK->getMessage()); 69 } 70 71 $fichier_vignette = generer_url_document($id_vignette); 72 $largeur_vignette = $vignetteMetier->getLargeur(); 73 $hauteur_vignette = $vignetteMetier->getHauteur(); 74 } 75 $retour = ''; 76 $bouton = bouton_block_invisible('doc' . $id_document); 77 78 if (test_layer()) { 79 $rest = substr($bouton, 87, 10); 80 $i = 0; 81 82 while (is_numeric($rest[$i])) 83 $i++; 84 85 $idBlock = substr($rest, 0, $i); 86 87 $GLOBALS['blocksDocs'][] = $idBlock; 88 } 89 90 $retour .= '<tr><td valign="top">' . $bouton . '</td>'; 91 $retour .= '<td><img src="img_pack/doc-24.gif" align="absbottom" /> ' . $titre; 92 $retour .= debut_block_invisible('doc' . $id_document); 93 $retour .= '<div style="border: 1px dashed #666666; padding: 5px; background-color: #f0f0f0;">'; 94 $retour .= '<table border="0" cellspacing="3" cellpadding="3"><tr><td rowspan="' 95 .(_GALERIE_MODE ? 5 : 4). '" valign="top">'; 96 97 if ($fichier_vignette) { 98 $retour .= texte_vignette_document($largeur_vignette, $hauteur_vignette, $fichier_vignette, $fichier); 99 } 100 else { 101 list($icone, $largeur_icone, $hauteur_icone) = vignette_par_defaut($type_extension); 102 if ($icone) { 103 $retour .= '<a href="'.$fichier.'" target="_blank">'; 104 $retour .= '<img src="'.$icone.'" border="0" ' . 105 'width="'.$largeur_icone.'" height="'.$hauteur_icone.'" align="top" /></a>'; 106 } 107 } 108 109 $retour .= '</td>'; 110 111 $retour .= '<th align="right" valign="top">Fichier :</th>'; 112 $retour .= '<td valign="top"><a href="' . $fichier . '" target="_blank">' . $fichier . '</a></td></tr>'; 113 114 $retour .= '<tr><th align="right" valign="top">Type :</th>'; 115 $retour .= '<td valign="top">' . ($type_titre ? $type_titre : majuscules($type_extension)). '</td></tr>'; 116 117 $retour .= '<tr><th align="right" valign="top">Taille :</th>'; 118 $retour .= '<td valign="top">' . taille_en_octets($taille). '</td></tr>'; 119 120 $retour .= '<tr><th align="right" valign="top">Descriptif :</th>'; 121 $retour .= '<td valign="top">' . ($descriptif ? propre($descriptif) : 'Aucun'). '</td></tr>'; 122 123 if (_GALERIE_MODE) { 124 $retour .= '<tr><th align="right" valign="top">Ajouter :</th>'; 125 $retour .= '<td valign="top">'; 126 $retour .= '<a href="javascript:addDoc(' . $id_document . ', \'left\');">left</a>'; 127 $retour .= ' | <a href="javascript:addDoc(' . $id_document . ', \'center\');">center</a>'; 128 $retour .= ' | <a href="javascript:addDoc(' . $id_document . ', \'right\');">right</a>'; 129 $retour .= '</td></tr>'; 130 } 131 132 $retour .= '</table></div>'; 133 134 $retour .= fin_block(); 135 $retour .= '</td></tr>'; 136 137 return $retour; 138 } 139 140 function sous_arborescence ($id_rubrique) { 141 $nbDocsTotal = 0; 142 143 $dbMetier = &recuperer_instance_metier(); 144 $db = &$dbMetier->_getDB(); 145 $sousRubriques = $db->query( 146 "SELECT id_rubrique, titre " . 147 "FROM ".$GLOBALS['table_prefix']."_rubriques " . 148 "WHERE id_parent = $id_rubrique " . 149 "ORDER BY titre"); 150 $nbSousRubriques = $sousRubriques->numRows(); 151 152 $documentsRubrique = $db->query( 153 "SELECT id_document " . 154 "FROM ".$GLOBALS['table_prefix']."_documents_rubriques " . 155 "WHERE id_rubrique = $id_rubrique"); 156 $nbDocumentsRubrique = $documentsRubrique->numRows(); 157 158 $nbDocsTotal += $nbDocumentsRubrique; 159 160 $query = "SELECT a.id_article, a.titre, COUNT(d.id_document) AS nb ". 161 "FROM ".$GLOBALS['table_prefix']."_articles a, " 162 .$GLOBALS['table_prefix']."_documents_articles d " . 163 "WHERE a.id_article = d.id_article AND a.id_rubrique = " . $id_rubrique . " " . 164 "GROUP BY a.id_article, a.titre " . 165 "ORDER BY a.titre"; 166 $articles = $db->query($query); 167 $nbArticles = $articles->numRows($articles); 168 169 $nbDocumentsArticles = 0; 170 $listeArticles = array(); 171 172 if ($nbArticles > 0) { 173 while ($row = $articles->fetchRow()) { 174 $listeArticles[] = array('id' => $row['id_article'], 'titre' => $row['titre'], 'nb' => $row['nb']); 175 $nbDocumentsArticles += $row['nb']; 176 $nbDocsTotal += $row['nb']; 177 } 178 } 179 180 $retour = ''; 181 182 if (($nbSousRubriques + $nbDocumentsRubrique + $nbDocumentsArticles) > 0) { 183 $retour .= '<table border="0" cellpadding="3" cellspacing="1">'; 184 185 while ($row = $sousRubriques->fetchRow()) { 186 list($content, $nbDocs) = sous_arborescence($row['id_rubrique']); 187 $nbDocsTotal += $nbDocs; 188 $retour .= '<tr><td valign="top">'; 189 190 if ($content != '') { 191 $bouton = bouton_block_invisible('rub' . $row['id_rubrique']); 192 193 if (test_layer()) { 194 $rest = substr($bouton, 87, 10); 195 $i = 0; 196 197 while (is_numeric($rest[$i])) 198 $i++; 199 200 $idBlock = substr($rest, 0, $i); 201 202 $GLOBALS['blocks'][] = $idBlock; 203 if ($nbDocs > 0) { 204 $GLOBALS['blocksPleins'][] = $idBlock; 205 } 206 } 207 $retour .= $bouton; 208 } 209 else { 210 $retour .= '<img src="img_pack/rien.gif" width="16" height="14" />'; 211 } 212 213 $retour .= '</td><td valign="top"><img src="img_pack/rubrique-24.gif" align="absbottom" /> '; 214 $retour .= $row['titre']. '(' . $nbDocs . ' document' . ($nbDocs > 1 ? 's' : ''). ')'; 215 216 if ($content != '') { 217 $retour .= '<br />'; 218 $retour .= debut_block_invisible('rub' . $row['id_rubrique']); 219 $retour .= $content; 220 $retour .= fin_block(); 221 } 222 $retour .= '</td></tr>'; 223 } 224 225 if ($nbArticles > 0) { 226 reset ($listeArticles); 227 while (list(, $article) = each($listeArticles)) { 228 $documentsArticle = $db->query("SELECT id_document " . 229 "FROM ".$GLOBALS['table_prefix']."_documents_articles " . 230 "WHERE id_article = ".$article['id']); 231 $nbDocumentsArticle = $documentsArticle->numRows(); 232 $retour .= '<tr><td valign="top">'; 233 $bouton = bouton_block_invisible('art' . $article['id']); 234 235 if (test_layer()) { 236 $rest = substr($bouton, 87, 10); 237 $i = 0; 238 239 while (is_numeric($rest[$i])) 240 $i++; 241 242 $idBlock = substr($rest, 0, $i); 243 $GLOBALS['blocks'][] = $idBlock; 244 $GLOBALS['blocksPleins'][] = $idBlock; 245 } 246 247 $retour .= $bouton; 248 $retour .= '</td><td valign="top"><img src="img_pack/article-24.gif" align="absbottom" /> '; 249 $retour .= $article['titre']. '(' . $article['nb']. ' document' . ($article['nb'] > 1 ? 's' : ''). ')'; 250 $retour .= '<br />'; 251 $retour .= debut_block_invisible('art' . $article['id']); 252 $retour .= '<table border="0" cellpadding="3" cellspacing="1">'; 253 254 while ($doc = $documentsArticle->fetchRow()) { 255 $retour .= afficher_un_document($doc['id_document']); 256 } 257 258 $retour .= '</table>'; 259 $retour .= fin_block(); 260 $retour .= '</td></tr>'; 261 } 262 } 263 264 while ($row = $documentsRubrique->fetchRow()) { 265 $retour .= afficher_un_document($row['id_document']); 266 } 267 $retour .= '</table>'; 268 } 269 270 $sousRubriques->free(); 271 $documentsRubrique->free(); 272 273 return array($retour, $nbDocsTotal); 274 } 275 ?> 276 277 <?php 278 $GLOBALS['blocks'] = array(); 279 $GLOBALS['blocksDocks'] = array(); 280 $GLOBALS['blocksPleins'] = array(); 281 282 list($data, $nbDocsTotal) = sous_arborescence(0); 283 284 //var_dump($nbDocsTotal); 285 286 if (isset($GLOBALS['field'])) { 287 define('_GALERIE_MODE', true); 288 } 289 else { 290 define('_GALERIE_MODE', false); 291 } 292 293 if (_GALERIE_MODE) { 294 debut_html ('Galerie'); 295 296 echo '<table border="0" cellpadding="5" cellspacing="0"><tr><td>'; 297 debut_cadre_enfonce(); 298 gros_titre ('Galerie de documents'); 299 } 300 else { 301 debut_page(_T('titre_page_documents_tous'), "asuivre", "tout-site"); 302 debut_gauche(); 303 debut_boite_info(); 304 305 echo 'Liste des documents attachés aux éléments du site'; 306 fin_boite_info(); 307 debut_droite(); 308 gros_titre ('Tous les documents du site'); 309 } 310 311 if (_GALERIE_MODE) { 312 ?> 313 314 <script type = "text/javascript" language = "JavaScript"> 315 316 function insertAfterSelection(toolbarfield, data) 317 { 318 var txtarea = toolbarfield; 319 var clientVer = parseInt(navigator.appVersion); 320 if (clientVer >= 4) { 321 txtarea.focus(); 322 txtarea.value += data; 323 } 324 else 325 if (txtarea.selectionEnd) { 326 mozWrap(txtarea, '', data); 327 } 328 return ; 329 } 330 331 function addDoc(id_doc, alignement) 332 { 333 insertAfterSelection(window.opener.<?php echo $GLOBALS['field']; ?>, '<doc' + id_doc + '|' + alignement + '>'); 334 window.close(); 335 return true; 336 } 337 338 function linkDoc(id_doc, id_objet, type) 339 { 340 alert('document_tous.php?linkDoc='+id_doc+'&id_objet='+id_objet+'&type='+type); 341 document.location='document_tous.php?linkDoc='+id_doc+'&id_objet='+id_objet+'&type='+type; 342 window.opener.reload(); 343 return true; 344 } 345 </script> 346 347 <?php 348 } 349 350 if (test_layer()) { 351 ?> 352 353 <p>Déplier : <a href = "javascript: showAll()">l'arborescence</a>| 354 <a href = "javascript: showNice()"> les éléments non vides</a>| 355 <a href = "javascript: showDocs()"> les docs</a><br/> 356 357 Replier : <a href = "javascript: hideAll()">tout</a>|<a href = "javascript: hideDocs()"> les docs</a> 358 </p> 359 360 <?php 361 } 362 363 if (_GALERIE_MODE) { 364 debut_cadre_relief(); 365 echo $data; 366 fin_cadre_relief(); 367 fin_cadre_enfonce(); 368 echo '</td></tr></table></body></html>'; 369 } 370 else { 371 echo $data; 372 fin_page(); 373 } 374 ?> 375 376 <script type="text/javascript"> 377 <!-- 378 function showAll() { 379 <?php 380 reset($GLOBALS['blocks']); 381 while (list(, $v) = each($GLOBALS['blocks'])) { 382 ?> 383 showOne('<?php echo $v; ?>', '<?php echo $spip_lang_rtl?>'); 384 <?php 385 } 386 ?> 387 } 388 389 function hideAll() { 390 <?php 391 reset($GLOBALS['blocks']); 392 while (list(, $v) = each($GLOBALS['blocks'])) { 393 ?> 394 hideOne('<?php echo $v; ?>', '<?php echo $spip_lang_rtl?>'); 395 <?php 396 } 397 ?> 398 } 399 400 function showNice() 401 { 402 hideAll(); 403 <?php 404 reset($GLOBALS['blocksPleins']); 405 while (list(, $v) = each($GLOBALS['blocksPleins'])) { 406 ?> 407 showOne('<?php echo $v; ?>', '<?php echo $spip_lang_rtl?>'); 408 <?php 409 } 410 ?> 411 } 412 413 function showDocs() 414 { 415 <?php 416 reset($GLOBALS['blocksDocs']); 417 while (list(, $v) = each($GLOBALS['blocksDocs'])) { 418 ?> 419 showOne('<?php echo $v; ?>', '<?php echo $spip_lang_rtl?>'); 420 <?php 421 } 422 ?> 423 } 424 425 function hideDocs() 426 { 427 <?php 428 reset($GLOBALS['blocksDocs']); 429 430 while (list(, $v) = each($GLOBALS['blocksDocs'])) { 431 ?> 432 hideOne('<?php echo $v; ?>', '<?php echo $spip_lang_rtl?>'); 433 <?php 434 } 435 ?> 436 } 437 438 function showOne(couche, rtl) 439 { 440 triangle = MM_findObj('triangle' + couche); 441 if (!(layer = MM_findObj('Layer' + couche))) return; 442 if (triangle) triangle.src = 'img_pack/deplierbas' + rtl + '.gif'; 443 layer.style.display = 'block'; 444 vis[couche] = 'show'; 445 } 446 447 function hideOne(couche, rtl) 448 { 449 triangle = MM_findObj('triangle' + couche); 450 if (!(layer = MM_findObj('Layer' + couche))) return; 451 if (triangle) triangle.src = 'img_pack/deplierhaut' + rtl + '.gif'; 452 layer.style.display = 'none'; 453 vis[couche] = 'hide'; 454 } 455 //--> 456 </script>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |