[ 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 // Base class for Syndic List Data abstraction. 20 // 21 22 /** 23 * BD_syndicListData is a base class for syndic lists data database abstraction implementations, and must be 24 * inherited by all such. 25 */ 26 if (defined("_BD_SYNDICLISTDATA")) 27 return; 28 29 define("_BD_SYNDICLISTDATA", "1"); 30 31 require_once("PEAR.php"); 32 require_once("DB.php"); 33 require_once dirname(__FILE__). "/objectlistdata.php"; 34 require_once (dirname(__FILE__). "/inc_rubrique_factory.php"); 35 require_once (dirname(__FILE__). "/inc_syndic_articles_factory.php"); 36 require_once dirname(__FILE__). "/inc_listdata_querytypes_constants.php"; 37 38 /** 39 * This class implements data lists for Syndic business data type 40 * @package BD 41 * @author Antoine Angénieux <aangenieux@clever-age.com> 42 * @author Erwan Le Bescond <elebescond@clever-age.com> 43 * @access public 44 */ 45 class BD_syndicListData extends BD_objectListData { 46 47 /** 48 * Create a new syndic list data object for the specified database parameters 49 * passed 50 * 51 * @param BD_parameters $dbParameters database configuration object 52 * 53 * @return mixed a newly created SyndicListData object, or a PEAR error code on 54 * error 55 * 56 * access public 57 */ 58 59 function &factory ($dbParameters = null) { 60 if (file_exists( 61 dirname( 62 __FILE__). "/" . $dbParameters->_dbEngine . "/syndiclistdata_" . $dbParameters->_dbEngine . ".php") 63 == false) { 64 include_once (dirname(__FILE__). "/common/syndiclistdata_common.php"); 65 $classname = "BD_syndiclistdata_common"; 66 } 67 else { 68 include_once (dirname( 69 __FILE__). "/" . $dbParameters->_dbEngine . "/syndiclistdata_" . $dbParameters->_dbEngine . ".php"); 70 $classname = "BD_syndicListData_" . $dbParameters->_dbEngine; 71 } 72 73 if (!class_exists($classname)) { 74 return PEAR::raiseError("Cannot instanciate class $classname", null, null, null, null, null, false); 75 } 76 77 $obj = &new $classname; 78 $result = $obj->setDbParameters($dbParameters); 79 80 if (PEAR::isError($result)) { 81 return $result; 82 } 83 else { 84 return $obj; 85 } 86 } 87 88 // {{{ constructor 89 90 /** 91 * Constructor. 92 * 93 * @access public 94 */ 95 96 function BD_syndicListData () { 97 $par = get_parent_class(get_parent_class($this)); 98 $this->$par(); 99 } 100 101 // }}} 102 103 // {{{ displayHTMLList($titre_table, $requete) 104 105 /** 106 * returns the HTML List for the various syndic data lists implementations 107 * This method should <b>NEVER<b> be overloaded, otherwise EXTRA-EXTRA-CARE is required 108 * while overloading this method. 109 * 110 * @return String reprensenting the generated HTML list navigation 111 * @param $queryType int representing the desired query type (refer to inc_listdata_query_types_contants.php) 112 * @param $params array containing the query parameters 113 * @param $countQuery boolean : if set to true, the returned query is a count result query for the specified query type. 114 * @access public 115 */ 116 117 function displayHTMLList ($titre_table, $queryType, $params = array(), $firstElement = 0, $lastElement = 0) { 118 global $couleur_claire; 119 global $connect_id_auteur; 120 121 $activer_messagerie = lire_meta("activer_messagerie"); 122 $activer_statistiques = lire_meta("activer_statistiques"); 123 124 $copyParams = $params; 125 126 $tranches = $this->_getHTMLNavigation($queryType, $params, 3); 127 128 $requete = $this->_getQuery($queryType, false, $copyParams); 129 130 if ($tranches) { 131 debut_cadre_relief ("site-24.gif"); 132 133 echo "<TABLE WIDTH=100% CELLPADDING=3 CELLSPACING=0 BORDER=0>"; 134 bandeau_titre_boite($titre_table, true); 135 136 echo $tranches; 137 138 $ifond = 0; 139 $premier = true; 140 141 $compteur_liste = 0; 142 143 $db = &$this->_getDB(); 144 145 if (DB::isError($db)) { 146 die ("Impossible d'obternir une connexion à la base de données! " . $db->getMessage()); 147 } 148 149 if ($this->_getQueryIsLimited()) { 150 $limitStart = $this->_getLimitStart(); 151 $limitCount = $this->_getLimitCount(); 152 $result = $db->limitQuery($requete, $limitStart, $limitCount, $copyParams); 153 } 154 else { 155 if ($lastElement > 0) { 156 $result = $db->limitQuery($requete, $firstElement, $lastElement, $copyParams); 157 } 158 else { 159 $result = $db->query($requete, $copyParams); 160 } 161 } 162 163 if (DB::isError($result)) { 164 die ("la requete a échouée! " . $result->getMessage()); 165 } 166 167 $table = ''; 168 169 while ($row = $result->fetchRow()) { 170 $id_rubrique = $row["id_rubrique"]; 171 $authorization = &recuperer_instance_authorization( 172 'isManagedRubriqueByAuteurId', $GLOBALS['connect_id_auteur'], 173 array('rubriqueId' => $id_rubrique)); 174 if ($authorization->isAuthorizedAction()) { 175 $ifond = $ifond ^ 1; 176 $couleur = ($ifond) ? '#FFFFFF' : $couleur_claire; 177 178 $id_syndic = $row["id_syndic"]; 179 $nom_site = typo($row["nom_site"]); 180 $url_site = $row["url_site"]; 181 $url_syndic = $row["url_syndic"]; 182 $description = propre($row["description"]); 183 $syndication = $row["syndication"]; 184 $statut = $row["statut"]; 185 $date = $row["date"]; 186 $moderation = $row['moderation']; 187 188 $tous_id[] = $id_syndic; 189 190 echo "<tr bgcolor='$couleur'>"; 191 192 echo "<td class='arial2'>"; 193 $link = new Link("sites.php?id_syndic=$id_syndic"); 194 $redirect = new Link; 195 $link->addVar('redirect', $redirect->getUrl()); 196 197 switch ($statut) { 198 case 'publie': 199 $authorization = &recuperer_instance_authorization( 200 'isManagedRubriqueByAuteurId', $GLOBALS['connect_id_auteur'], 201 array('rubriqueId' => $id_rubrique)); 202 if (!$authorization->isAuthorizedAction()) 203 //if (acces_restreint_rubrique($id_rubrique)) 204 $puce = 'puce-verte-anim.gif'; 205 else 206 $puce = 'puce-verte.gif'; 207 $title = _T('info_site_reference'); 208 break; 209 210 case 'prop': 211 $authorization = &recuperer_instance_authorization( 212 'isManagedRubriqueByAuteurId', $GLOBALS['connect_id_auteur'], 213 array('rubriqueId' => $id_rubrique)); 214 if (!$authorization->isAuthorizedAction()) 215 //if (acces_restreint_rubrique($id_rubrique)) 216 $puce = 'puce-blanche-anim.gif'; 217 else 218 $puce = 'puce-blanche.gif'; 219 $title = _T('info_site_attente'); 220 break; 221 222 case 'refuse': 223 $authorization = &recuperer_instance_authorization( 224 'isManagedRubriqueByAuteurId', $GLOBALS['connect_id_auteur'], 225 array('rubriqueId' => $id_rubrique)); 226 if (!$authorization->isAuthorizedAction()) 227 //if (acces_restreint_rubrique($id_rubrique)) 228 $puce = 'puce-rouge-anim.gif'; 229 else 230 $puce = 'puce-rouge.gif'; 231 $title = _T('info_site_refuse'); 232 break; 233 234 case 'poubelle': 235 $authorization = &recuperer_instance_authorization( 236 'isManagedRubriqueByAuteurId', $GLOBALS['connect_id_auteur'], 237 array('rubriqueId' => $id_rubrique)); 238 if (!$authorization->isAuthorizedAction()) 239 //if (acces_restreint_rubrique($id_rubrique)) 240 $puce = 'puce-poubelle-anim.gif'; 241 else 242 $puce = 'puce-poubelle.gif'; 243 $title = _T('info_site_refuse'); 244 break; 245 } 246 247 if ($syndication == "off") { 248 $puce = 'puce-orange-anim.gif'; 249 $title = _T('info_panne_site_syndique'); 250 } 251 252 echo "<a href=\"" . $link->getUrl(). "\" title=\"$title\">"; 253 echo "<img src='img_pack/$puce' width='7' height='7' border='0'> "; 254 255 if ($moderation == 'oui') 256 echo "<i>" . typo($nom_site). "</i>"; 257 else 258 echo typo($nom_site); 259 260 echo "</a> <font size='1'>[<a href='$url_site'>" . _T( 261 'lien_visite_site'). "</a>]</font>"; 262 echo "</td>"; 263 264 echo "<td class='arial1' align='right'> "; 265 266 if ($syndication == "off") { 267 echo "<font color='red'>" . _T('info_probleme_grave'). " </font>"; 268 } 269 270 if ($syndication == "oui" or $syndication == "off") { 271 echo "<font color='red'>" . _T('info_syndication'). "</font>"; 272 } 273 274 echo "</td>"; 275 echo "<td class='arial1'>"; 276 277 if ($syndication == "oui" OR $syndication == "off") { 278 $syndicArticleMetier = &recuperer_instance_syndic_articles(); 279 $resultat_art = $syndicArticleMetier->howManySyndicArticleIdForSyndicId($id_syndic); 280 281 if (PEAR::isError($resultat_art)) { 282 die ($resultat_art->getMessage()); 283 } 284 //list($total_art) = each($result_art); 285 //echo " $total_art article(s)"; 286 echo " $resultat_art article(s)"; 287 } 288 else { 289 echo " "; 290 } 291 292 echo "</td>"; 293 echo "</tr></n>"; 294 } 295 } 296 297 echo "</TABLE>"; 298 fin_cadre_relief(); 299 } 300 301 return $tous_id; 302 } 303 304 // }}} 305 306 // {{{ displaySyndicArticleHTMLList($titre_table, $queryType, $afficher_site = false) 307 308 /** 309 * returns the HTML List for the various syndic article data lists implementations 310 * This method should <b>NEVER<b> be overloaded, otherwise EXTRA-EXTRA-CARE is required 311 * while overloading this method. 312 * 313 * @return String reprensenting the generated HTML list navigation 314 * @param $queryType int representing the desired query type (refer to inc_listdata_query_types_contants.php) 315 * @param $params array containing the query parameters 316 * @param $countQuery boolean : if set to true, the returned query is a count result query for the specified query type. 317 * @access public 318 */ 319 function displaySyndicArticleHTMLList ($titre_table, $queryType, $params = array(), $afficher_site = false, 320 $firstElement = 0, $lastElement = 0) { 321 global $couleur_claire; 322 global $connect_statut; 323 global $REQUEST_URI; 324 global $debut_liste_sites; 325 global $flag_editable; 326 327 static $n_liste_sites; 328 329 $n_liste_sites++; 330 331 if (!$debut_liste_sites[$n_liste_sites]) 332 $debut_liste_sites[$n_liste_sites] = 0; 333 334 $adresse_page = substr($REQUEST_URI, strpos($REQUEST_URI, "/ecrire") + 8, strlen($REQUEST_URI)); 335 $adresse_page = ereg_replace("\&?debut\_liste\_sites\[$n_liste_sites\]\=[0-9]+", "", $adresse_page); 336 $adresse_page = ereg_replace("\&?(ajouter\_lien|supprimer_lien)\=[0-9]+", "", $adresse_page); 337 338 if (ereg("\?", $adresse_page)) 339 $lien_url = "&"; 340 else 341 $lien_url = "?"; 342 343 $lien_url .= "debut_liste_sites[" . $n_liste_sites . "]=" . $debut_liste_sites[$n_liste_sites]. "&"; 344 345 $nombre_aff = 10; 346 347 $activer_messagerie = lire_meta("activer_messagerie"); 348 $activer_statistiques = lire_meta("activer_statistiques"); 349 350 $db = &$this->_getDB(); 351 352 if (DB::isError($db)) { 353 die ("Impossible d'obtenir une connexion à la base de données! " . $db->getMessage()); 354 } 355 356 $requete = $this->_getQuery($queryType, false, $params); 357 358 if ($lastElement > 0) { 359 $queryResult = $db->limitQuery($requete, $firstElement, $lastElement, $params); 360 } 361 else { 362 $queryResult = $db->query($requete, $params); 363 } 364 365 if (DB::isError($queryResult)) { 366 return $queryResult; 367 } 368 369 $num_rows = $queryResult->numRows(); 370 371 // Ne pas couper pour trop peu 372 if ($num_rows <= 1.5 * $nombre_aff) 373 $nombre_aff = $num_rows; 374 375 if ($num_rows > 0) { 376 echo "<P><TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0 BORDER=0><TR><TD WIDTH=100% BACKGROUND=''>"; 377 echo "<TABLE WIDTH=100% CELLPADDING=3 CELLSPACING=0 BORDER=0>"; 378 379 bandeau_titre_boite($titre_table, true); 380 381 if ($num_rows > $nombre_aff) { 382 echo "<tr><td background='' class='arial2' colspan=4>"; 383 384 for ($i = 0; $i < $num_rows; $i = $i + $nombre_aff) { 385 $deb = $i + 1; 386 $fin = $i + $nombre_aff; 387 388 if ($fin > $num_rows) 389 $fin = $num_rows; 390 if ($debut_liste_sites[$n_liste_sites] == $i) { 391 echo "[<B>$deb-$fin</B>] "; 392 } 393 else { 394 echo "[<A HREF='" . $adresse_page . $lien_url . "debut_liste_sites[$n_liste_sites]=$i'>$deb-$fin</A>] "; 395 } 396 } 397 echo "</td></tr>"; 398 } 399 400 $ifond = 0; 401 $premier = true; 402 403 $compteur_liste = 0; 404 405 while ($row = $queryResult->fetchRow()) { 406 if ($compteur_liste >= $debut_liste_sites[$n_liste_sites]AND $compteur_liste 407 < $debut_liste_sites[$n_liste_sites] + $nombre_aff) { 408 $ifond = $ifond ^ 1; 409 $couleur = ($ifond) ? '#FFFFFF' : $couleur_claire; 410 411 $id_syndic_article = $row["id_syndic_article"]; 412 $id_syndic = $row["id_syndic"]; 413 $titre = typo($row["titre"]); 414 $url = $row["url"]; 415 $date = $row["date"]; 416 $lesauteurs = propre($row["lesauteurs"]); 417 $statut = $row["statut"]; 418 $descriptif = $row["descriptif"]; 419 420 echo "<tr bgcolor='$couleur'>"; 421 422 echo "<td class='arial1'>"; 423 echo "<A HREF='$url'>"; 424 425 if ($statut == 'publie') { 426 if (acces_restreint_rubrique($id_rubrique)) 427 $puce = 'puce-verte-anim.gif'; 428 else 429 $puce = 'puce-verte.gif'; 430 } 431 else if ($statut == "refuse") { 432 $puce = 'puce-poubelle.gif'; 433 } 434 else if ($statut == "dispo") { // moderation : a valider 435 $puce = 'puce-rouge.gif'; 436 } 437 else if ($statut == "off") { // vieillerie 438 $puce = 'puce-rouge-anim.gif'; 439 } 440 441 echo "<img src='img_pack/$puce' width='7' height='7' border='0'>"; 442 443 if ($statut == "refuse") 444 echo "<font color='black'> " . $titre . "</font>"; 445 else 446 echo " " . $titre; 447 448 echo "</A>"; 449 450 if (strlen($lesauteurs) > 0) 451 echo "<br>" . _T('info_auteurs_nombre'). " <font color='#336666'>$lesauteurs</font>"; 452 453 if (strlen($descriptif) > 0) 454 echo "<br>" . _T('info_descriptif_nombre'). " <font color='#336666'>$descriptif</font>"; 455 456 echo "</td>"; 457 458 // $my_sites cache les resultats des requetes sur les sites 459 if ($afficher_site) { 460 $syndicMetier = &recuperer_instance_syndic(); 461 $loadOK = $syndicMetier->load($id_syndic); 462 if (PEAR::isError($loadOK)) { 463 die ($loadOK->getMessage()); 464 } 465 else { 466 echo "<td class='arial1' align='left'>"; 467 $aff = $syndicMetier->getNomSite(); 468 469 if ($syndicMetier->getModeration() == 'oui') 470 echo "<i>$aff</i>"; 471 else 472 echo $aff; 473 echo "</td>"; 474 } 475 } 476 else 477 echo "<td></td>"; 478 479 echo "<td class='arial1' align='right'>"; 480 481 //-----------MODIFICATION CLEVER AGE elebescond@clever-age.com---------- 482 $authorization = &recuperer_instance_authorization( 483 'supprimerSite', $GLOBALS['connect_id_auteur'], $params); 484 485 if ($authorization->isAuthorizedAction()) { 486 /* 487 if ($connect_statut == 'minirezo'){ 488 */ 489 //-----------FIN MODIFICATION CLEVER AGE elebescond@clever-age.com---------- 490 491 if ($statut == "publie") { 492 echo 493 "[<a href='" . $adresse_page . $lien_url . "id_syndic=$id_syndic&supprimer_lien=$id_syndic_article'><font color='black'>" . _T('info_bloquer_lien'). "</font></a>]"; 494 } 495 else if ($statut == "refuse") { 496 echo 497 "[<a href='" . $adresse_page . $lien_url . "id_syndic=$id_syndic&ajouter_lien=$id_syndic_article'>" . _T('info_retablir_lien'). "</a>]"; 498 } 499 else if ($statut == "dispo") { 500 echo 501 "[<a href='" . $adresse_page . $lien_url . "id_syndic=$id_syndic&ajouter_lien=$id_syndic_article'>" . _T('info_valider_lien'). "</a>]"; 502 } 503 } 504 else { 505 echo " "; 506 } 507 508 echo "</td>"; 509 echo "</tr></n>"; 510 } 511 $compteur_liste++; 512 } 513 echo "</TABLE></TD></TR></TABLE>"; 514 } 515 } 516 517 // }}} 518 519 // {{{ _fillQueries() 520 521 /** 522 * This methods fill the query associative arrays with SQL 92 compliant 523 * queries. Each driver that requires specific SQL querying must implement 524 * the _adaptQueriesToDriver() method. 525 * @access private 526 * @see _adaptQueriesToDriver() 527 */ 528 function _fillQueries () { 529 $this->_queries[SYNDICS_BY_STATE] 530 = "SELECT * FROM " . $GLOBALS['table_prefix']. "_syndic WHERE statut=? ORDER BY nom_site"; 531 $this->_queriesCount[SYNDICS_BY_STATE] 532 = "SELECT COUNT(*) FROM " . $GLOBALS['table_prefix']. "_syndic WHERE statut=?"; 533 534 $this->_queries[SYNDICS_BY_SYNDICATION_AND_STATE] 535 = "SELECT * FROM " . $GLOBALS['table_prefix']. "_syndic WHERE syndication=? AND statut=? ORDER BY nom_site"; 536 $this->_queriesCount[SYNDICS_BY_SYNDICATION_AND_STATE] 537 = "SELECT COUNT(*) FROM " . $GLOBALS['table_prefix']. "_syndic WHERE syndication=? AND statut=?"; 538 539 $this->_queries[SYNDICS_MOT_BY_MOT_ID] 540 = "SELECT syndic.* FROM " . $GLOBALS['table_prefix']. "_syndic syndic, " . $GLOBALS['table_prefix']. "_mots_syndic lien WHERE lien.id_mot=? AND lien.id_syndic=syndic.id_syndic ORDER BY syndic.nom_site DESC"; 541 $this->_queriesCount[SYNDICS_MOT_BY_MOT_ID] 542 = "SELECT COUNT(*) FROM " . $GLOBALS['table_prefix']. "_syndic syndic, " . $GLOBALS['table_prefix']. "_mots_syndic lien WHERE lien.id_mot=? AND lien.id_syndic=syndic.id_syndic"; 543 544 $this->_queries[SYNDICS_MOT_BY_RUBRIQUE_ID_AND_NOT_STATE] 545 = "SELECT * FROM " . $GLOBALS['table_prefix']. "_syndic WHERE id_rubrique=? AND statut<>? ORDER BY nom_site"; 546 $this->_queriesCount[SYNDICS_MOT_BY_RUBRIQUE_ID_AND_NOT_STATE] 547 = "SELECT COUNT(*) FROM " . $GLOBALS['table_prefix']. "_syndic WHERE id_rubrique=? AND statut<>?"; 548 549 $this->_queries[SYNDICS_BY_SYNDICATIONS_AND_STATE] 550 = "SELECT * FROM " . $GLOBALS['table_prefix']. "_syndic WHERE (syndication=? OR syndication=?) AND statut=? ORDER BY nom_site"; 551 $this->_queriesCount[SYNDICS_BY_SYNDICATIONS_AND_STATE] 552 = "SELECT COUNT(*) FROM " . $GLOBALS['table_prefix']. "_syndic WHERE (syndication=? OR syndication=?) AND statut=?"; 553 554 $this->_queries[SYNDICS_ARTICLES_BY_SYNDICID] 555 = "SELECT * FROM " . $GLOBALS['table_prefix']. "_syndic_articles WHERE id_syndic=? ORDER BY date_heure DESC"; 556 $this->_queriesCount[SYNDICS_ARTICLES_BY_SYNDICID] 557 = "SELECT COUNT(*) FROM " . $GLOBALS['table_prefix']. "_syndic_articles WHERE id_syndic=?"; 558 559 $this->_queries[SYNDICS_LAST_ARTICLES] 560 = "SELECT * FROM " . $GLOBALS['table_prefix']. "_syndic_articles ORDER BY date_heure DESC"; 561 $this->_queriesCount[SYNDICS_LAST_ARTICLES] 562 = "SELECT COUNT(*) FROM " . $GLOBALS['table_prefix']. "_syndic_articles"; 563 564 $this->_queries[SYNDICS_RECHERCHE] 565 = "SELECT * " . "FROM " . $GLOBALS['table_prefix']. "_syndic WHERE <!spipSYNDIC_CONSTRUCTION_RECHERCHEspip!> ORDER BY maj DESC"; 566 $this->_queriesCount[SYNDICS_RECHERCHE] 567 = "SELECT count(id_syndic) " . "FROM " . $GLOBALS['table_prefix']. "_syndic WHERE <!spipSYNDIC_CONSTRUCTION_RECHERCHEspip!>"; 568 569 $this->_queries[SYNDICS_RECHERCHE_INT] 570 = "SELECT objet.id_syndic, objet.nom_site, objet.url_site, objet.date_heure, objet.statut, SUM(idx.points) AS points " . "FROM " . $GLOBALS['table_prefix']. "_syndic objet, " . $GLOBALS['table_prefix']. "_index_syndic idx " . "WHERE objet.id_syndic = idx.id_syndic AND idx.hash IN (!) AND objet.id_syndic NOT IN (!) GROUP BY objet.id_syndic, objet.nom_site, objet.url_site, objet.date_heure, objet.statut ORDER BY points DESC"; 571 $this->_queriesCount[SYNDICS_RECHERCHE_INT] 572 = "SELECT COUNT(*) " . "FROM " . $GLOBALS['table_prefix']. "_syndic objet, " . $GLOBALS['table_prefix']. "_index_syndic idx " . "WHERE objet.id_syndic = idx.id_syndic AND idx.hash IN (!) AND objet.id_syndic NOT IN (!)"; 573 } 574 575 // }}} 576 } 577 ?>
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 |