[ Index ]
 

Code source de SPIP Agora 1.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Agora1-4/ecrire/include/bd/ -> rubriquelistdata.php (source)

   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 Rubrique List Data abstraction.
  20  //
  21  
  22  /**
  23   * BD_rubriqueListData is a base class for rubrique lists data database abstraction implementations, and must be
  24   * inherited by all such.
  25   */
  26  if (defined("_BD_RUBRIQUELISTDATA"))
  27      return;
  28  
  29  define("_BD_RUBRIQUELISTDATA", "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_listdata_querytypes_constants.php";
  36  
  37  /**
  38   * This class implements data lists for Rubique business data type
  39   * @package    BD
  40   * @author  Antoine Angénieux <aangenieux@clever-age.com>
  41   * @author     Erwan Le Bescond <elebescond@clever-age.com>
  42   * @access    public
  43   */
  44  class BD_rubriqueListData extends BD_objectListData {
  45  
  46      /**
  47       * Create a new rubrique list data object for the specified database parameters
  48       * passed
  49       *
  50       * @param BD_parameters $dbParameters database configuration object
  51       *
  52       * @return mixed a newly created RubriqueListData object, or a PEAR error code on
  53       * error
  54       *
  55       * access public
  56       */
  57  
  58      function &factory ($dbParameters = null) {
  59          if (file_exists(dirname(
  60                              __FILE__). "/" . $dbParameters->_dbEngine . "/rubriquelistdata_" . $dbParameters->_dbEngine . ".php") == false)
  61              {
  62              include_once (dirname(__FILE__). "/common/rubriquelistdata_common.php");
  63              $classname = "BD_rubriquelistdata_common";
  64          }
  65          else {
  66              include_once (dirname(
  67                                __FILE__). "/" . $dbParameters->_dbEngine . "/rubriquelistdata_" . $dbParameters->_dbEngine . ".php");
  68              $classname = "BD_rubriqueListData_" . $dbParameters->_dbEngine;
  69          }
  70  
  71          if (!class_exists($classname)) {
  72              return PEAR::raiseError("Cannot instanciate class $classname", null, null, null, null, null, false);
  73          }
  74  
  75          $obj = &new $classname;
  76          $result = $obj->setDbParameters($dbParameters);
  77  
  78          if (PEAR::isError($result)) {
  79              return $result;
  80          }
  81          else {
  82              return $obj;
  83          }
  84      }
  85  
  86      // {{{ constructor
  87  
  88      /**
  89       * Constructor.
  90       *
  91       * @access public
  92       */
  93  
  94  	function BD_rubriqueListData () {
  95          $par = get_parent_class(get_parent_class($this));
  96          $this->$par();
  97      }
  98  
  99      // }}}
 100  
 101      // {{{ getHTMLList($titre_table, $requete, $affrub=false)
 102  
 103      /**
 104       * returns the HTML List for the various rubrique data lists implementations
 105       * This method should <b>NEVER<b> be overloaded, otherwise EXTRA-EXTRA-CARE is required
 106       * while overloading this method.
 107       *
 108       * @return String reprensenting the generated HTML list navigation
 109       * @param $queryType int representing the desired query type (refer to inc_listdata_query_types_contants.php)
 110       * @param $params array containing the query parameters
 111       * @param $countQuery boolean : if set to true, the returned query is a count result query for the specified query type.
 112       * @access public
 113       */
 114  
 115  	function displayHTMLList ($titre_table, $queryType, $params = array(), $firstElement = 0, $lastElement = 0) {
 116          global $connect_id_auteur;
 117          global $spip_lang_rtl;
 118  
 119          $copyParams = $params;
 120  
 121          $tranches = $this->_getHTMLNavigation($queryType, $params, 2);
 122  
 123          $requete = $this->_getQuery($queryType, false, $copyParams);
 124  
 125          if (strlen($tranches)) {
 126              debut_cadre_relief ("rubrique-24.gif");
 127  
 128              if ($titre_table) {
 129                  echo "<p><table width=100% cellpadding=0 cellspacing=0 border=0 background=''>";
 130                  echo "<tr><td width=100% background=''>";
 131                  echo "<table width=100% cellpadding=3 cellspacing=0 border=0>";
 132                  echo "<tr bgcolor='#333333'><td width=100% colspan=2><font face='Verdana,Arial,Helvetica,sans-serif' size=3 color='#FFFFFF'>";
 133                  echo "<b>$titre_table</b></font></td></tr>";
 134              }
 135              else {
 136                  echo "<p><table width=100% cellpadding=3 cellspacing=0 border=0 background=''>";
 137              }
 138  
 139              echo $tranches;
 140  
 141              $db = &$this->_getDB();
 142  
 143              if (DB::isError($db)) {
 144                  die ("Impossible d'obternir une connexion à la base de données! " . $db->getMessage());
 145              }
 146  
 147              if ($this->_getQueryIsLimited()) {
 148                  $limitStart = $this->_getLimitStart();
 149                  $limitCount = $this->_getLimitCount();
 150                  $result = $db->limitQuery($requete, $limitStart, $limitCount, $copyParams);
 151              }
 152              else {
 153                  if ($lastElement > 0) {
 154                      $result = $db->limitQuery($requete, $firstElement, $lastElement, $copyParams);
 155                  }
 156                  else {
 157                      $result = $db->query($requete, $copyParams);
 158                  }
 159              }
 160  
 161              if (DB::isError($result)) {
 162                  die ("la requete a échouée! " . $result->getMessage());
 163              }
 164  
 165              $table = '';
 166  
 167              while ($row = $result->fetchRow()) {
 168                  $vals = '';
 169                  if ($queryType == RUBRIQUES_FORUM_MESSAGE) {
 170                      $id_rubrique = $row['id_rubrique'];
 171                      $forumMetier = &recuperer_instance_forum();
 172                      $nbMessageTotal = $forumMetier->howManyForumForRubriqueId($id_rubrique). ' message(s)';
 173  
 174                      $tous_id[] = $id_rubrique;
 175                      $titre = $row['titre'];
 176  
 177                      $authorization = &recuperer_instance_authorization(
 178                                            'controlerForum', $GLOBALS['connect_id_auteur'],
 179                                            array('id_rubrique' => $id_rubrique));
 180                      if ($authorization->isAuthorizedAction()) {
 181                          $s = "<b><a href=\"naviguer.php?coll=$id_rubrique\">";
 182                          $puce = "puce$spip_lang_rtl.gif";
 183                          $s .= "<img src=\"$puce\" alt=\"- \" border=\"0\"> ";
 184                          $s .= typo($titre);
 185                          $forumMetier = &recuperer_instance_forum();
 186                          $nbMessProp = $forumMetier->howManyForumForRubriqueIdAndStatuts($id_rubrique, "'prop'");
 187  
 188                          $s
 189                              .= "<td align='right' colspan=1><img src=\"img_pack/puce-orange.gif\" alt='" . _T('message_attente_validation'). "' width=\"13\" height=\"14\" border=\"0\">&nbsp;<a href='controle_forum_suite.php?affType=discussion&affMessage[]=publie,prop&vierge=1&id_current_forum=$id_rubrique&type_forum=rubrique'>$nbMessProp message(s) en attente</a></td>";
 190                          $s .= "<tr><td align=center colspan=3>";
 191  
 192                          $nbMessPublie = $forumMetier->howManyForumForRubriqueIdAndStatuts($id_rubrique, "'publie'");
 193                          $s .= "<img src=\"img_pack/puce-verte.gif\" alt='" . _T(
 194                                                                                   'message_publie'). "' width=\"13\" height=\"14\" border=\"0\">&nbsp;<a href='controle_forum_suite.php?affType=discussion&affMessage[]=publie&vierge=1&id_current_forum=$id_rubrique&type_forum=rubrique'>$nbMessPublie mess</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
 195                          $nbMessOff = $forumMetier->howManyForumForRubriqueIdAndStatuts($id_rubrique, "'off'");
 196                          $s .= "<img src=\"img_pack/puce-rouge.gif\" alt='" . _T(
 197                                                                                   'message_off'). "' width=\"13\" height=\"14\" border=\"0\">&nbsp;<a href='controle_forum_suite.php?affType=discussion&affMessage[]=publie,off&vierge=1&id_current_forum=$id_rubrique&type_forum=rubrique'>$nbMessOff mess</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
 198                          $nbMessPoubelle = $forumMetier->howManyForumForRubriqueIdAndStatuts($id_rubrique, "'poubelle'");
 199                          $s .= "<img src=\"img_pack/puce-poubelle.gif\" alt='" . _T(
 200                                                                                      'message_poubelle'). "' width=\"13\" height=\"14\" border=\"0\">&nbsp;<a href='controle_forum_suite.php?affType=discussion&affMessage[]=publie,poubelle&vierge=1&id_current_forum=$id_rubrique&type_forum=rubrique'>$nbMessPoubelle mess</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
 201  
 202                          $s .= "</td></tr>";
 203                          $vals[] = $s;
 204  
 205                          $s = "<div align=\"right\">";
 206                          $s .= "</div>";
 207                          $vals[] = $s;
 208                          $table[] = $vals;
 209                      }
 210                  }
 211                  else {
 212                      $id_rubrique = $row['id_rubrique'];
 213                      $tous_id[] = $id_rubrique;
 214                      $titre = $row['titre'];
 215  
 216                      $s = "<b><a href=\"naviguer.php?coll=$id_rubrique\">";
 217                      $puce = "puce$spip_lang_rtl.gif";
 218                      $s .= "<img src=\"$puce\" alt=\"- \" border=\"0\"> ";
 219                      $s .= typo($titre);
 220                      $s .= "</A></b>";
 221                      $vals[] = $s;
 222  
 223                      $s = "<div align=\"right\">";
 224                      $s .= "</div>";
 225                      $vals[] = $s;
 226                      $table[] = $vals;
 227                  }
 228              }
 229  
 230              $result->free();
 231  
 232              $largeurs = array('', '');
 233              $styles = array('arial2', 'arial2');
 234              afficher_liste($largeurs, $table, $styles);
 235  
 236              if ($titre_table)
 237                  echo "</TABLE></TD></TR>";
 238  
 239              echo "</TABLE>";
 240              fin_cadre_relief();
 241          }
 242  
 243          return $tous_id;
 244      }
 245  
 246      // }}}
 247  
 248      // {{{ _fillQueries()
 249  
 250      /**
 251       * This methods fill the query associative arrays with SQL 92 compliant
 252       * queries. Each driver that requires specific SQL querying must implement
 253       * the _adaptQueriesToDriver() method.
 254       * @access  private
 255       * @see     _adaptQueriesToDriver()
 256       */
 257  	function _fillQueries () {
 258          $this->_queries[RUBRIQUES_BY_LINK]
 259              = "SELECT rubrique.* FROM " . $GLOBALS['table_prefix']. "_rubriques rubrique, " . $GLOBALS['table_prefix']. "_mots_rubriques lien WHERE lien.id_mot=? " . "AND lien.id_rubrique=rubrique.id_rubrique ORDER BY rubrique.titre";
 260          $this->_queriesCount[RUBRIQUES_BY_LINK]
 261              = "SELECT COUNT(*) FROM " . $GLOBALS['table_prefix']. "_rubriques rubrique, " . $GLOBALS['table_prefix']. "_mots_rubriques lien WHERE lien.id_mot=? " . "AND lien.id_rubrique=rubrique.id_rubrique";
 262  
 263          $this->_queries[RUBRIQUES_RECHERCHE]
 264              = "SELECT * " . "FROM " . $GLOBALS['table_prefix']. "_rubriques WHERE <!spipRUBRIQUE_CONSTRUCTION_RECHERCHEspip!> ORDER BY maj DESC";
 265          $this->_queriesCount[RUBRIQUES_RECHERCHE]
 266              = "SELECT count(id_rubrique) " . "FROM " . $GLOBALS['table_prefix']. "_rubriques WHERE  <!spipRUBRIQUE_CONSTRUCTION_RECHERCHEspip!>";
 267  
 268          $this->_queries[RUBRIQUES_RECHERCHE_INT]
 269              = "SELECT objet.id_rubrique, objet.titre, objet.date_heure, objet.statut, SUM(idx.points) AS points " . "FROM " . $GLOBALS['table_prefix']. "_rubriques objet, " . $GLOBALS['table_prefix']. "_index_rubriques idx " . "WHERE objet.id_rubrique = idx.id_rubrique AND idx.hash IN (!) AND objet.id_rubrique NOT IN (!) GROUP BY objet.id_rubrique, objet.titre, objet.date_heure, objet.statut ORDER BY points DESC";
 270          $this->_queriesCount[RUBRIQUES_RECHERCHE_INT]
 271              = "SELECT COUNT(*) " . "FROM " . $GLOBALS['table_prefix']. "_rubriques objet, " . $GLOBALS['table_prefix']. "_index_rubriques idx " . "WHERE objet.id_rubrique = idx.id_rubrique AND idx.hash IN (!) AND objet.id_rubrique NOT IN (!)";
 272  
 273          $this->_queries[RUBRIQUES_FORUM_MESSAGE]
 274              = "SELECT " . $GLOBALS['table_prefix']. "_rubriques.* FROM " . $GLOBALS['table_prefix']. "_rubriques, " . $GLOBALS['table_prefix']. "_forum WHERE " . $GLOBALS['table_prefix']. "_forum.id_rubrique=" . $GLOBALS['table_prefix']. "_rubriques.id_rubrique ORDER BY " . $GLOBALS['table_prefix']. "_forum.date_heure DESC";
 275          // A VERIFIER, BIZARRERIE!
 276          //$this->_queries[RUBRIQUES_FORUM_MESSAGE] = "SELECT DISTINCT(".$GLOBALS['table_prefix']."_rubriques.id_rubrique), ".$GLOBALS['table_prefix']."_rubriques.titre, ".$GLOBALS['table_prefix']."_rubriques.date_heure, ".$GLOBALS['table_prefix']."_rubriques.statut FROM ".$GLOBALS['table_prefix']."_rubriques, ".$GLOBALS['table_prefix']."_forum WHERE ( (".$GLOBALS['table_prefix']."_rubriques.id_rubrique = ".$GLOBALS['table_prefix']."_forum.id_rubrique) ) ORDER BY ".$GLOBALS['table_prefix']."_rubriques.date_heure";
 277          $this->_queriesCount[RUBRIQUES_FORUM_MESSAGE]
 278              = "SELECT count(id_forum) FROM " . $GLOBALS['table_prefix']. "_rubriques, " . $GLOBALS['table_prefix']. "_forum WHERE " . $GLOBALS['table_prefix']. "_forum.id_rubrique=" . $GLOBALS['table_prefix']. "_rubriques.id_rubrique GROUP BY " . $GLOBALS['table_prefix']. "_forum.id_rubrique";
 279  
 280      /*
 281      $this->_queries[RUBRIQUES_FORUM_MESSAGE_PROP] = "SELECT count(id_forum) AS count, ".$GLOBALS['table_prefix']."_rubriques.* FROM ".$GLOBALS['table_prefix']."_rubriques, ".$GLOBALS['table_prefix']."_forum WHERE ".$GLOBALS['table_prefix']."_forum.id_rubrique=".$GLOBALS['table_prefix']."_rubriques.id_rubrique AND ".$GLOBALS['table_prefix']."_forum.statut IN ('prop') GROUP BY ".$GLOBALS['table_prefix']."_forum.id_rubrique ORDER BY ".$GLOBALS['table_prefix']."_forum.date_heure DESC";
 282      $this->_queriesCount[RUBRIQUES_FORUM_MESSAGE_PROP] = "SELECT count(id_forum) AS count FROM ".$GLOBALS['table_prefix']."_rubriques, ".$GLOBALS['table_prefix']."_forum WHERE ".$GLOBALS['table_prefix']."_forum.id_rubrique=".$GLOBALS['table_prefix']."_rubriques.id_rubrique AND ".$GLOBALS['table_prefix']."_forum.statut IN ('prop') GROUP BY ".$GLOBALS['table_prefix']."_forum.id_rubrique";
 283      */
 284      /******* Ajout EXTRANET guillaume.grason@diplomatie.gouv.fr *******/
 285      $this->_queries[RUBRIQUES_BY_EXTRANAUTE] = "SELECT rubrique.* FROM ".$GLOBALS['table_prefix']."_rubriques rubrique, ".$GLOBALS['table_prefix']."_extranautes_rubriques lien WHERE lien.id_extranaute=? "
 286          . "AND lien.id_rubrique=rubrique.id_rubrique ORDER BY rubrique.titre";
 287      $this->_queriesCount[RUBRIQUES_BY_EXTRANAUTE] = "SELECT COUNT(*) FROM ".$GLOBALS['table_prefix']."_rubriques rubrique, ".$GLOBALS['table_prefix']."_extranautes_rubriques lien WHERE lien.id_extranaute=? "
 288          . "AND lien.id_rubrique=rubrique.id_rubrique";
 289      /******* Fin Ajout EXTRANET guillaume.grason@diplomatie.gouv.fr *******/
 290      }
 291  
 292  // }}}
 293  }
 294  ?>


Généré le : Sat Feb 24 14:40:03 2007 par Balluche grâce à PHPXref 0.7