[ 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 Author List Data abstraction. 20 // 21 22 if (defined("_BD_AUTEURLISTDATA")) 23 return; 24 25 define("_BD_AUTEURLISTDATA", "1"); 26 27 require_once("PEAR.php"); 28 require_once("DB.php"); 29 require_once dirname(__FILE__). "/objectlistdata.php"; 30 require_once dirname(__FILE__). "/inc_listdata_querytypes_constants.php"; 31 32 /** 33 * This class implements data lists for Author business data type 34 * @package BD 35 * @author Antoine Angénieux <aangenieux@clever-age.com> 36 * @author Erwan Le Bescond <elebescond@clever-age.com> 37 * @access public 38 */ 39 class BD_auteurListData extends BD_objectListData { 40 41 /** 42 * Create a new author list data object for the specified database parameters 43 * passed 44 * 45 * @param BD_parameters $dbParameters database configuration object 46 * 47 * @return mixed a newly created BreveListData object, or a PEAR error code on 48 * error 49 * 50 * access public 51 */ 52 53 function &factory ($dbParameters = null) { 54 if (file_exists(dirname(__FILE__). "/" . $dbParameters->_dbEngine . "/auteurlistdata_" . $dbParameters->_dbEngine . ".php") == false) { 55 include_once(dirname(__FILE__). "/common/auteurlistdata_common.php"); 56 $classname = "BD_auteurlistdata_common"; 57 } 58 else { 59 include_once(dirname(__FILE__). "/" . $dbParameters->_dbEngine . "/auteurlistdata_" . $dbParameters->_dbEngine . ".php"); 60 $classname = "BD_auteurListData_" . $dbParameters->_dbEngine; 61 } 62 63 if (!class_exists($classname)) { 64 return PEAR::raiseError("Cannot instanciate class $classname", null, null, null, null, null, false); 65 } 66 67 $obj = &new $classname; 68 $result = $obj->setDbParameters($dbParameters); 69 70 if (PEAR::isError($result)) { 71 return $result; 72 } 73 else { 74 return $obj; 75 } 76 } 77 78 // {{{ constructor 79 80 /** 81 * Constructor. 82 * 83 * @access public 84 */ 85 86 function BD_auteurListData () { 87 $par = get_parent_class(get_parent_class($this)); 88 $this->$par(); 89 } 90 91 // }}} 92 93 // {{{ getHTMLList($titre_table, $requete) 94 95 /** 96 * returns the HTML List for the various author data lists implementations 97 * This method should <b>NEVER<b> be overloaded, otherwise EXTRA-EXTRA-CARE is required 98 * while overloading this method. 99 * 100 * @return String reprensenting the generated HTML list navigation 101 * @param $queryType int representing the desired query type (refer to inc_listdata_query_types_contants.php) 102 * @param $params array containing the query parameters 103 * @param $countQuery boolean : if set to true, the returned query is a count result query for the specified query type. 104 * @access public 105 */ 106 107 function displayHTMLList ($titre_table, $queryType, $params = array(), $firstElement = 0, $lastElement = 0) { 108 $paramsCountQuery = $params; 109 110 $copyParams = $params; 111 112 $tranches = $this->_getHTMLNavigation($queryType, $params, 2); 113 114 $requete = $this->_getQuery($queryType, false, $copyParams); 115 116 if (strlen($tranches)) { 117 debut_cadre_relief("redacteurs-24.gif"); 118 119 if ($titre_table) { 120 echo "<p><table width=100% cellpadding=0 cellspacing=0 border=0 background=''>"; 121 echo "<tr><td width=100% background=''>"; 122 echo "<table width=100% cellpadding=3 cellspacing=0 border=0>"; 123 echo "<tr bgcolor='#333333'><td width=100% colspan=2><font face='Verdana,Arial,Helvetica,sans-serif' size=3 color='#FFFFFF'>"; 124 echo "<b>$titre_table</b></font></td></tr>"; 125 } 126 else { 127 echo "<p><table width=100% cellpadding=3 cellspacing=0 border=0 background=''>"; 128 } 129 130 echo $tranches; 131 132 $db = &$this->_getDB(); 133 134 if (DB::isError($db)) { 135 die("Impossible d'obternir une connexion à la base de données! " . $db->getMessage()); 136 } 137 138 if ($this->_getQueryIsLimited()) { 139 $limitStart = $this->_getLimitStart(); 140 $limitCount = $this->_getLimitCount(); 141 $result = $db->limitQuery($requete, $limitStart, $limitCount, $params); 142 } 143 else { 144 if ($lastElement > 0) { 145 $result = $db->limitQuery($requete, $firstElement, $lastElement, $params); 146 } 147 else { 148 $result = $db->query($requete, $params); 149 } 150 } 151 152 if (DB::isError($result)) { 153 die("la requete a échouée! " . $result->getMessage()); 154 } 155 156 $table = ''; 157 158 while ($row = $result->fetchRow()) { 159 $vals = ''; 160 161 $id_auteur = $row['id_auteur']; 162 $tous_id[] = $id_auteur; 163 $nom = $row['nom']; 164 165 $s = bonhomme_statut($row); 166 $s .= "<a href=\"auteurs_edit.php?id_auteur=$id_auteur\">"; 167 $s .= typo($nom); 168 $s .= "</a>"; 169 $vals[] = $s; 170 $table[] = $vals; 171 } 172 173 $result->free(); 174 175 $largeurs = array(''); 176 $styles = array('arial2'); 177 afficher_liste($largeurs, $table, $styles); 178 179 if ($titre_table) 180 echo "</TABLE></TD></TR>"; 181 182 echo "</TABLE>"; 183 fin_cadre_relief(); 184 } 185 186 return $tous_id; 187 } 188 189 // }}} 190 191 // {{{ _fillQueries() 192 193 /** 194 * This methods fill the query associative arrays with SQL 92 compliant 195 * queries. Each driver that requires specific SQL querying must implement 196 * the _adaptQueriesToDriver() method. 197 * @access private 198 * @see _adaptQueriesToDriver() 199 */ 200 function _fillQueries () { 201 $this->_queries[AUTEURS_RECHERCHE_INT] = "SELECT objet.*, SUM(idx.points) AS points FROM " . $GLOBALS['table_prefix']. "_auteurs objet, " . $GLOBALS['table_prefix']. "_index_auteurs idx WHERE objet.id_auteur = idx.id_auteur AND idx.hash IN (!) GROUP BY objet.id_auteur ORDER BY points DESC"; 202 $this->_queriesCount[AUTEURS_RECHERCHE_INT] = "SELECT COUNT(*) AS points FROM " . $GLOBALS['table_prefix']. "_auteurs objet, " . $GLOBALS['table_prefix']. "_index_auteurs idx WHERE objet.id_auteur = idx.id_auteur AND idx.hash IN (!)"; 203 } 204 205 // }}} 206 } 207 ?>
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 |