[ 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/NestedSetHelper/ -> NestedSet.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  //require_once dirname(__FILE__).'/../../NestedSet/NestedSet/DB.php';
  20  require_once("DB/NestedSet.php");
  21  
  22  require_once("DB/NestedSet/DB.php");
  23  
  24  // {{{ NestedSetHelper_NestedSet:: class
  25  
  26  /**
  27   * Wrapper class for DB_NestedSet_DB class
  28   *
  29   * @author       Antoine Angénieux <aangenieux@clever-age.com>
  30   * @package      NestedSetHelper
  31   * @version      $Revision$
  32   * @access       public
  33   */
  34  
  35  // }}}
  36  class NestedSetHelper_NestedSet extends DB_NestedSet_DB {
  37      function &NestedSetHelper_NestedSet ($db, $params) {
  38          $this->_debugMessage('DB_NestedSet_DB($db)');
  39          $this->DB_NestedSet($params);
  40          $this->db = $db;
  41          $this->db->setFetchMode(DB_FETCHMODE_ASSOC);
  42      }
  43  
  44      // {{{ getBranch()
  45  
  46      /**
  47       * Fetch the whole branch where a given node id is in
  48       *
  49       * @param int  $id The node ID
  50       * @param bool $keepAsArray (optional) Keep the result as an array or transform it into
  51       *             a set of NestedSet_Node objects?
  52       * @param bool $aliasFields (optional) Should we alias the fields so they are the names
  53       *             of the parameter keys, or leave them as is?
  54       *
  55       * @access public
  56       * @return mixed False on error, or an array of nodes
  57       */
  58  	function getBranch ($id, $keepAsArray = false, $aliasFields = true) {
  59          $this->_debugMessage('getBranch($id)');
  60  
  61          if (!($thisnode = $this->_getNodeObject($id))) {
  62              return false;
  63          }
  64  
  65          $sql = sprintf('SELECT %s FROM %s WHERE %s=%s ORDER BY %s, %s ASC', $this->_getSelectFields($aliasFields),
  66                         $this->node_table, $this->flparams['rootid'],
  67                         $this->db->quote($thisnode->rootid), $this->flparams['l'],
  68                         $this->secondarySort);
  69          // modifs Olivier Mansour 
  70          // mais qui m'a changé mon API ???? :-(
  71          //return $this->_processResultSet($this->db->getAll($sql), $keepAsArray, $aliasFields);
  72          return $this->_processResultSet($sql, $keepAsArray, $aliasFields);
  73      // fin modifs 
  74      }
  75  
  76      // }}}
  77  
  78      // {{{ _getNodeObject()
  79  
  80      /**
  81       * Gets the node to work on based upon an id
  82       *
  83       * @param mixed $id The id which can be an object or integer
  84       *
  85       * @access private
  86       * @return mixed The node object for an id or false on error
  87       */
  88  	function _getNodeObject ($id) {
  89          if (!is_object($id) || !$id->id) {
  90              return $this->pickNode($id);
  91          }
  92          else {
  93              return $id;
  94          }
  95      }
  96  
  97  // }}}
  98  
  99  }
 100  ?>


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