[ 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 Forum List Data abstraction. 20 // 21 22 /** 23 * BD_forumListData is a base class for forum lists data database abstraction implementations, and must be 24 * inherited by all such. 25 */ 26 27 if (defined("_BD_FORUMLISTDATA")) 28 return; 29 30 define("_BD_FORUMLISTDATA", "1"); 31 32 /* Ajout Clever Age / Erwan LE BESCOND */ 33 require_once("PEAR.php"); 34 require_once (dirname(__FILE__). "/inc_forum_factory.php"); 35 /* fin zone de modification Clever Age */ 36 37 require_once("PEAR.php"); 38 require_once("DB.php"); 39 require_once dirname(__FILE__). "/objectlistdata.php"; 40 require_once dirname(__FILE__). "/inc_listdata_querytypes_constants.php"; 41 42 /** 43 * This class implements data lists for Forum business data type 44 * @package BD 45 * @author Antoine Angénieux <aangenieux@clever-age.com> 46 * @author Erwan Le Bescond <elebescond@clever-age.com> 47 * @access public 48 */ 49 class BD_forumListData extends BD_objectListData { 50 51 /** 52 * Create a new forum list data object for the specified database parameters 53 * passed 54 * 55 * @param BD_parameters $dbParameters database configuration object 56 * @return mixed a newly created ForumListData object, or a PEAR error code on 57 * error 58 * @access public 59 */ 60 function &factory ($dbParameters = null) { 61 if (file_exists( 62 dirname( 63 __FILE__). "/" . $dbParameters->_dbEngine . "/forumlistdata_" . $dbParameters->_dbEngine . ".php") 64 == false) { 65 include_once (dirname(__FILE__). "/common/forumlistdata_common.php"); 66 $classname = "BD_forumlistdata_common"; 67 } 68 else { 69 include_once 70 (dirname( 71 __FILE__). "/" . $dbParameters->_dbEngine . "/forumlistdata_" . $dbParameters->_dbEngine . ".php"); 72 $classname = "BD_forumListData_" . $dbParameters->_dbEngine; 73 } 74 75 if (!class_exists($classname)) { 76 return PEAR::raiseError("Cannot instanciate class $classname", null, null, null, null, null, false); 77 } 78 79 $obj = &new $classname; 80 $result = $obj->setDbParameters($dbParameters); 81 82 if (PEAR::isError($result)) { 83 return $result; 84 } 85 else { 86 return $obj; 87 } 88 } 89 90 // {{{ constructor 91 92 /** 93 * Abstract Constructor. 94 * 95 * @access public 96 */ 97 98 function BD_forumListData () { 99 $par = get_parent_class(get_parent_class($this)); 100 $this->$par(); 101 } 102 103 // }}} 104 105 // {{{ displayHTMLList($titre_table, $queryType, $afficher_visites = false, $afficher_auteurs = true, $toujours_afficher = false, $afficher_cadre = true) 106 107 /** 108 * returns the HTML List for the various forum data lists implementations 109 * This method should <b>NEVER<b> be overloaded, otherwise EXTRA-EXTRA-CARE is required 110 * while overloading this method. 111 * 112 * @return String reprensenting the generated HTML list navigation 113 * @param $queryType int representing the desired query type (refer to inc_listdata_query_types_contants.php) 114 * @param $params array containing the query parameters 115 * @param $countQuery boolean : if set to true, the returned query is a count result query for the specified query type. 116 * @access public 117 */ 118 function displayHTMLList ($queryType, $params = array(), $adresse_retour, $controle = "non", $recurrence = "oui", 119 $firstElement = 0, $lastElement = 0) { 120 global $debut; 121 static $compteur_forum; 122 static $nb_forum; 123 static $i; 124 global $couleur_foncee; 125 global $connect_id_auteur, $connect_activer_messagerie; 126 global $mots_cles_forums; 127 global $spip_lang_rtl; 128 129 $db = &$this->_getDB(); 130 131 if (DB::isError($db)) { 132 die ("Impossible d'obternir une connexion à la base de données! " . $db->getMessage()); 133 } 134 135 $activer_messagerie = lire_meta("activer_messagerie"); 136 137 $requete = $this->_getQuery($queryType, false, $params); 138 139 $compteur_forum++; 140 141 if ($lastElement > 0) { 142 $queryResult = $db->limitQuery($requete, $firstElement, $lastElement, $params); 143 } 144 else { 145 $queryResult = $db->query($requete, $params); 146 } 147 148 if (DB::isError($queryResult)) { 149 return $queryResult; 150 } 151 152 $nb_forum[$compteur_forum] = $queryResult->numRows(); 153 154 $i[$compteur_forum] = 1; 155 156 while ($row = $queryResult->fetchRow()) { 157 $id_forum = $row['id_forum']; 158 $id_parent = $row['id_parent']; 159 $id_rubrique = $row['id_rubrique']; 160 $id_article = $row['id_article']; 161 $id_breve = $row['id_breve']; 162 $id_message = $row['id_message']; 163 $id_syndic = $row['id_syndic']; 164 $date_heure = $row['date_heure']; 165 $titre = $row['titre']; 166 $texte = $row['texte']; 167 $auteur = $row['auteur']; 168 $email_auteur = $row['email_auteur']; 169 $nom_site = $row['nom_site']; 170 $url_site = $row['url_site']; 171 $statut = $row['statut']; 172 $ip = $row["ip"]; 173 $id_auteur = $row["id_auteur"]; 174 175 if ($compteur_forum == 1) { 176 echo "<BR><BR>\n"; 177 } 178 179 $afficher = ($controle == "oui") ? ($statut != "perso") 180 : (($statut == "prive" OR $statut == "privrac" OR $statut == "privadm" OR $statut 181 == "perso")OR ($statut == "publie" AND $id_parent > 0)); 182 183 if ($afficher) { 184 echo "<table width=100% cellpadding=0 cellspacing=0 border=0><tr>"; 185 186 for ($count = 2; $count <= $compteur_forum AND $count < 20; $count++) { 187 $fond[$count] = 'img_pack/rien.gif'; 188 189 if ($i[$count] != $nb_forum[$count]) { 190 $fond[$count] = 'img_pack/forum-vert.gif'; 191 } 192 193 $fleche = 'img_pack/rien.gif'; 194 195 if ($count == $compteur_forum) { 196 $fleche = "img_pack/forum-droite$spip_lang_rtl.gif"; 197 } 198 echo "<td width=10 valign='top' background=$fond[$count]><img src='$fleche' alt='' width=10 height=13 border=0></td>\n"; 199 } 200 201 echo "\n<td width=100% valign='top'>"; 202 203 // Si refuse, cadre rouge 204 if ($statut == "off") { 205 echo "<table width=100% cellpadding=2 cellspacing=0 border=0><tr><td>"; 206 } 207 // Si propose, cadre jaune 208 else if ($statut == "prop") { 209 echo "<table width=100% cellpadding=2 cellspacing=0 border=0><tr><td>"; 210 } 211 212 if ($compteur_forum == 1) 213 echo debut_cadre_relief("forum-interne-24.gif"); 214 215 echo "<table width=100% cellpadding=3 cellspacing=0><tr><td bgcolor='$couleur_foncee'><font face='Verdana,Arial,Helvetica,sans-serif' size=2 color='#FFFFFF'><b>" . typo($titre). "</b></font></td></tr>"; 216 echo "<tr><td bgcolor='#EEEEEE'>"; 217 echo "<font size=2 face='Georgia,Garamond,Times,serif'>"; 218 echo "<font face='arial,helvetica'>$date_heure</font>"; 219 220 if ($email_auteur) { 221 echo " <a href=\"mailto:$email_auteur?subject=" . rawurlencode($titre). "\">$auteur</a>"; 222 } 223 else { 224 echo " $auteur"; 225 } 226 227 if ($id_auteur AND $activer_messagerie != "non" AND $connect_activer_messagerie != "non") { 228 $bouton = bouton_imessage($id_auteur, $row_auteur); 229 if ($bouton) 230 echo " " . $bouton; 231 } 232 233 if ($controle == "oui") { 234 switch ($statut) { 235 case 'publie': 236 icone(_T('icone_supprimer_message'), 237 "articles_forum.php?id_article=$id_article&poub_forum=$id_forum&debut=$debut", 238 "forum-interne-24.gif", 239 "supprimer.gif", 240 "right"); 241 icone(_T('icone_desactiver_message'), 242 "articles_forum.php?id_article=$id_article&off_forum=$id_forum&debut=$debut", 243 "forum-interne-24.gif", 244 "supprimer_agora.gif", 245 "right"); 246 break; 247 248 case 'prop': 249 icone(_T('icone_supprimer_message'), 250 "articles_forum.php?id_article=$id_article&poub_forum=$id_forum&debut=$debut", 251 "forum-interne-24.gif", 252 "supprimer.gif", 253 "right"); 254 icone(_T('icone_desactiver_message'), 255 "articles_forum.php?id_article=$id_article&off_forum=$id_forum&debut=$debut", 256 "forum-interne-24.gif", 257 "supprimer_agora.gif", 258 "right"); 259 icone(_T('icone_valider_message'), 260 "articles_forum.php?id_article=$id_article&valid_forum=$id_forum&debut=$debut", 261 "forum-interne-24.gif", 262 "creer.gif", 263 "right", 264 'non'); 265 break; 266 267 case 'off': 268 icone(_T('icone_supprimer_message'), 269 "articles_forum.php?id_article=$id_article&poub_forum=$id_forum&debut=$debut", 270 "forum-interne-24.gif", 271 "supprimer.gif", 272 "right"); 273 icone(_T('icone_valider_message'), 274 "articles_forum.php?id_article=$id_article&valid_forum=$id_forum&debut=$debut", 275 "forum-interne-24.gif", 276 "creer.gif", 277 "right"); 278 break; 279 } 280 /* 281 if ($statut != "off") { 282 icone (_T('icone_supprimer_message'), "articles_forum.php?id_article=$id_article&supp_forum=$id_forum&debut=$debut", "forum-interne-24.gif", "supprimer.gif", "right"); 283 } 284 else { 285 echo "<br><font color='red'><b>"._T('info_message_supprime')." $ip</b></font>"; 286 if ($id_auteur) { 287 echo " - <a href='auteurs_edit.php?id_auteur=$id_auteur'>"._T('lien_voir_auteur')."</A>"; 288 } 289 } 290 if ($statut == "prop" OR $statut == "off") { 291 icone (_T('icone_valider_message'), "articles_forum.php?id_article=$id_article&valid_forum=$id_forum&debut=$debut", "forum-interne-24.gif", "creer.gif", "right"); 292 } 293 */ 294 } 295 296 echo justifier(propre($texte)); 297 298 if (strlen($url_site) > 10 AND $nom_site) { 299 echo "<p align='left'><font face='Verdana,Arial,Helvetica,sans-serif'><b><a href='$url_site'>$nom_site</a></b></font>"; 300 } 301 302 if ($controle != "oui") { 303 echo "<p align='right'><font face='Verdana,Arial,Helvetica,sans-serif' size=1>"; 304 $url = "forum_envoi.php?id_parent=$id_forum&adresse_retour=" . rawurlencode( 305 $adresse_retour). "&titre_message=" . rawurlencode( 306 $titre); 307 echo "<b><a href=\"$url\">" . _T('lien_repondre_message'). "</a></b></font>"; 308 } 309 310 if ($mots_cles_forums == "oui") { 311 $motMetier = &recuperer_instance_mot(); 312 $allMots = $motMetier->getAllFromMotsAndAnotherTable("forum", "id_forum", $id_forum, true); 313 while (list(, $motMetier) = each($allMots)) { 314 $id_mot = $motMetier->getMotId(); 315 $titre_mot = propre($motMetier->getTitre()); 316 $type_mot = propre($motMetier->getType()); 317 echo "<li> <b>$type_mot :</b> $titre_mot"; 318 } 319 } 320 321 echo "</font>"; 322 echo "</td></tr></table>"; 323 324 if ($compteur_forum == 1) 325 echo fin_cadre_relief(); 326 327 if ($statut == "off" OR $statut == "prop") { 328 echo "</td></tr></table>"; 329 } 330 331 echo "</td></tr></table>\n"; 332 if ($recurrence == "oui") 333 forum($id_forum, $adresse_retour, $controle); 334 } 335 $i[$compteur_forum]++; 336 } 337 338 $compteur_forum--; 339 } 340 341 // }}} 342 343 // {{{ _fillQueries() 344 345 /** 346 * This methods fill the query associative arrays with SQL 92 compliant 347 * queries. Each driver that requires specific SQL querying must implement 348 * the _adaptQueriesToDriver() method. 349 * @access private 350 * @see _adaptQueriesToDriver() 351 */ 352 function _fillQueries () { 353 $this->_queries[FORUM_BY_STATE_AND_ARTICLEID] 354 = "SELECT * FROM " . $GLOBALS['table_prefix']. "_forum WHERE statut=? AND id_article=? AND id_parent=0 ORDER BY date_heure DESC"; 355 $this->_queriesCount[FORUM_BY_STATE_AND_ARTICLEID] 356 = "SELECT COUNT(*) FROM " . $GLOBALS['table_prefix']. "_forum WHERE statut=? AND id_article=? AND id_parent=0"; 357 /* 358 $this->_queries[FORUM_BY_STATE_AND_ARTICLEID] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_article=? AND id_parent=0 ORDER BY date_heure DESC LIMIT ?,?"; 359 $this->_queriesCount[FORUM_BY_STATE_AND_ARTICLEID] = "SELECT COUNT(*) FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_article=? AND id_parent=0 ORDER BY date_heure DESC LIMIT ?,?"; 360 */ 361 $this->_queries[FORUM_BY_ARTICLEID] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE id_article=? AND id_parent=0 AND statut IN ('publie', 'off', 'prop') ORDER BY date_heure DESC"; 362 $this->_queriesCount[FORUM_BY_ARTICLEID] = "SELECT COUNT(*) FROM ".$GLOBALS['table_prefix']."_forum WHERE id_article=? AND id_parent=0 AND statut IN ('publie', 'off', 'prop')"; 363 364 $this->_queries[FORUM_BY_STATE_AND_BREVEID] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_breve=? AND id_parent=0 ORDER BY date_heure DESC"; 365 $this->_queriesCount[FORUM_BY_STATE_AND_BREVEID] = "SELECT COUNT(*) FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_breve=? AND id_parent=0"; 366 /* 367 $this->_queries[FORUM_BY_STATE_AND_BREVEID] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_breve=? AND id_parent=0 ORDER BY date_heure DESC LIMIT 0,20"; 368 $this->_queriesCount[FORUM_BY_STATE_AND_BREVEID] = "SELECT COUNT(*) FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_breve=? AND id_parent=0 ORDER BY date_heure DESC LIMIT 0,20"; 369 */ 370 371 $this->_queries[FORUM_BY_STATE] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_parent=0 ORDER BY date_heure DESC"; 372 $this->_queriesCount[FORUM_BY_STATE] = "SELECT COUNT(*) FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_parent=0"; 373 /* 374 $this->_queries[FORUM_BY_STATE] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_parent=0 ORDER BY date_heure DESC LIMIT ?,10"; 375 $this->_queriesCount[FORUM_BY_STATE] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_parent=0 ORDER BY date_heure DESC LIMIT ?,10"; 376 */ 377 378 $this->_queries[FORUM_BY_PARENT_ID] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE id_parent=? ORDER BY date_heure"; 379 $this->_queriesCount[FORUM_BY_PARENT_ID] = "SELECT COUNT(*) FROM ".$GLOBALS['table_prefix']."_forum WHERE id_parent=?"; 380 381 $this->_queries[FORUM_BY_PARENT_ID_AND_STATUT] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE id_parent=? AND statut<>'off' ORDER BY date_heure"; 382 $this->_queriesCount[FORUM_BY_PARENT_ID_AND_STATUT] = "SELECT COUNT(*) FROM ".$GLOBALS['table_prefix']."_forum WHERE id_parent=? AND statut<>'off'"; 383 384 $this->_queries[FORUM_BY_STATE_AND_MESSAGEID] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_message=? AND id_parent=0 ORDER BY date_heure DESC"; 385 $this->_queriesCount[FORUM_BY_STATE_AND_MESSAGEID] = "SELECT COUNT(*) FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_message=? AND id_parent=0"; 386 /* 387 $this->_queries[FORUM_BY_STATE_AND_MESSAGEID] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_message=? AND id_parent=0 ORDER BY date_heure DESC LIMIT 0,20"; 388 $this->_queriesCount[FORUM_BY_STATE_AND_MESSAGEID] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_message=? AND id_parent=0 ORDER BY date_heure DESC LIMIT 0,20"; 389 */ 390 391 $this->_queries[FORUM_BY_STATE_AND_SYNDICID] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_message=? AND id_syndic=0 ORDER BY date_heure DESC"; 392 $this->_queriesCount[FORUM_BY_STATE_AND_SYNDICID] = "SELECT COUNT(*) FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_message=? AND id_syndic=0"; 393 /* 394 $this->_queries[FORUM_BY_STATE_AND_SYNDICID] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_message=? AND id_syndic=0 ORDER BY date_heure DESC LIMIT 0,20"; 395 $this->_queriesCount[FORUM_BY_STATE_AND_SYNDICID] = "SELECT * FROM ".$GLOBALS['table_prefix']."_forum WHERE statut=? AND id_message=? AND id_syndic=0 ORDER BY date_heure DESC LIMIT 0,20"; 396 */ 397 398 } 399 400 // }}} 401 402 } 403 ?>
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 |