[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/kernel/classes/ -> ezsection.php (source)

   1  <?php
   2  //
   3  // Definition of eZSection class
   4  //
   5  // Created on: <27-Aug-2002 15:55:18 bf>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*!
  30    \class eZSection ezsection.php
  31    \brief eZSection handles grouping of content in eZ publish
  32  
  33  */
  34  
  35  include_once ( "kernel/classes/ezpersistentobject.php" );
  36  
  37  class eZSection extends eZPersistentObject
  38  {
  39      /*!
  40      */
  41      function eZSection( $row )
  42      {
  43          $this->eZPersistentObject( $row );
  44      }
  45  
  46      /*!
  47       \return the persistent object definition for the eZCard class.
  48      */
  49      function definition()
  50      {
  51          return array( "fields" => array( "id" => array( 'name' => 'ID',
  52                                                          'datatype' => 'integer',
  53                                                          'default' => 0,
  54                                                          'required' => true ),
  55                                           "name" => array( 'name' => "Name",
  56                                                            'datatype' => 'string',
  57                                                            'default' => 0,
  58                                                            'required' => true ),
  59                                           "navigation_part_identifier" => array( 'name' => "NavigationPartIdentifier",
  60                                                                                  'datatype' => 'string',
  61                                                                                  'default' => 'ezcontentnavigationpart',
  62                                                                                  'required' => true ),
  63                                           "locale" => array( 'name' => "Locale",
  64                                                              'datatype' => 'string',
  65                                                              'default' => '',
  66                                                              'required' => true ) ),
  67                        "keys" => array( "id" ),
  68                        "increment_key" => "id",
  69                        "class_name" => "eZSection",
  70                        "name" => "ezsection" );
  71      }
  72  
  73      /*!
  74       \return the section object with the given id.
  75      */
  76      function fetch( $sectionID, $asObject = true )
  77      {
  78          return eZPersistentObject::fetchObject( eZSection::definition(),
  79                                                  null,
  80                                                  array( "id" => $sectionID ),
  81                                                  $asObject );
  82      }
  83  
  84      function fetchFilteredList( $conditions = null, $offset = false, $limit = false, $asObject = true )
  85      {
  86          $limits = null;
  87          if ( $offset or $limit )
  88              $limits = array( 'offset' => $offset,
  89                               'length' => $limit );
  90          return eZPersistentObject::fetchObjectList( eZSection::definition(),
  91                                                      null,
  92                                                      $conditions, null, $limits,
  93                                                      $asObject );
  94      }
  95  
  96      function fetchList( $asObject = true )
  97      {
  98          return eZPersistentObject::fetchObjectList( eZSection::definition(),
  99                                                      null, null, null, null,
 100                                                      $asObject );
 101      }
 102  
 103      function &fetchByOffset( $offset, $limit, $asObject = true )
 104      {
 105          $sectionList = eZPersistentObject::fetchObjectList( eZSection::definition(),
 106                                                               null,
 107                                                               null,
 108                                                               array( 'name' => 'ASC' ),
 109                                                               array( 'offset' => $offset, 'length' => $limit ),
 110                                                               $asObject );
 111          return $sectionList;
 112      }
 113  
 114       /*!
 115       \return the number of active orders
 116      */
 117      function sectionCount()
 118      {
 119          $db =& eZDB::instance();
 120  
 121          $countArray = $db->arrayQuery(  "SELECT count( * ) AS count FROM ezsection" );
 122          return $countArray[0]['count'];
 123      }
 124  
 125      /*!
 126       Makes sure the global section ID is propagated to the template override key.
 127      */
 128      function initGlobalID()
 129      {
 130          global $eZSiteBasics;
 131          $sessionRequired = $eZSiteBasics['session-required'];
 132          $sectionID = false;
 133          if ( $sessionRequired )
 134          {
 135              include_once ( 'lib/ezutils/classes/ezhttptool.php' );
 136              $sectionArray = array();
 137              if ( eZHTTPTool::hasSessionVariable( 'eZGlobalSection' ) )
 138                  $sectionArray = eZHTTPTool::sessionVariable( 'eZGlobalSection' );
 139              if ( !isset( $sectionArray['id'] ) )
 140              {
 141                  return false;
 142              }
 143              $sectionID = $sectionArray['id'];
 144          }
 145  
 146          if ( $sectionID )
 147          {
 148              // eZTemplateDesignResource will read this global variable
 149              $GLOBALS['eZDesignKeys']['section'] = $sectionID;
 150              return true;
 151          }
 152          return false;
 153      }
 154  
 155      /*!
 156       Sets the current global section ID to \a $sectionID in the session and
 157       the template override key.
 158      */
 159      function setGlobalID( $sectionID )
 160      {
 161          include_once ( 'lib/ezutils/classes/ezhttptool.php' );
 162          $sectionArray = array();
 163          if ( eZHTTPTool::hasSessionVariable( 'eZGlobalSection' ) )
 164              $sectionArray = eZHTTPTool::sessionVariable( 'eZGlobalSection' );
 165          $sectionArray['id'] = $sectionID;
 166          eZHTTPTool::setSessionVariable( 'eZGlobalSection', $sectionArray );
 167  
 168          // eZTemplateDesignResource will read this global variable
 169          $GLOBALS['eZDesignKeys']['section'] = $sectionID;
 170      }
 171  
 172      /*!
 173       \return the global section ID or \c null if it is not set yet.
 174      */
 175      function globalID()
 176      {
 177          include_once ( 'lib/ezutils/classes/ezhttptool.php' );
 178          if ( eZHTTPTool::hasSessionVariable( 'eZGlobalSection' ) )
 179          {
 180              $sectionArray = eZHTTPTool::sessionVariable( 'eZGlobalSection' );
 181              if ( isset( $sectionArray['id'] ) )
 182                  return $sectionArray['id'];
 183          }
 184          return null;
 185      }
 186  
 187      /*!
 188       Will remove the current section from the database.
 189       \note Transaction unsafe. If you call several transaction unsafe methods you must enclose
 190       the calls within a db transaction; thus within db->begin and db->commit.
 191      */
 192      function remove( )
 193      {
 194          $def = $this->definition();
 195          eZPersistentObject::removeObject( $def, array( "id" => $this->ID ) );
 196      }
 197  
 198  }
 199  
 200  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7