[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

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

   1  <?php
   2  //
   3  // Created on: <02-Dec-2002 14:39:39 bf>
   4  //
   5  // SOFTWARE NAME: eZ publish
   6  // SOFTWARE RELEASE: 3.9.0
   7  // BUILD VERSION: 17785
   8  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   9  // SOFTWARE LICENSE: GNU General Public License v2.0
  10  // NOTICE: >
  11  //   This program is free software; you can redistribute it and/or
  12  //   modify it under the terms of version 2.0  of the GNU General
  13  //   Public License as published by the Free Software Foundation.
  14  //
  15  //   This program is distributed in the hope that it will be useful,
  16  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18  //   GNU General Public License for more details.
  19  //
  20  //   You should have received a copy of version 2.0 of the GNU General
  21  //   Public License along with this program; if not, write to the Free
  22  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  23  //   MA 02110-1301, USA.
  24  //
  25  //
  26  
  27  /*!
  28    \class eZInformationCollectionAttribute ezinformationcollectionattribute.php
  29    \ingroup eZKernel
  30    \brief The class eZInformationCollectionAttribute handles collected attribute information
  31  
  32  */
  33  
  34  include_once ( 'kernel/classes/ezpersistentobject.php' );
  35  
  36  class eZInformationCollectionAttribute extends eZPersistentObject
  37  {
  38      function eZInformationCollectionAttribute( $row )
  39      {
  40          $this->Content = null;
  41          $this->eZPersistentObject( $row );
  42      }
  43  
  44      /*!
  45       \return the persistent object definition for the eZInformationCollectionAttribute class.
  46      */
  47      function definition()
  48      {
  49          return array( 'fields' => array( 'id' => array( 'name' => 'ID',
  50                                                          'datatype' => 'integer',
  51                                                          'default' => 0,
  52                                                          'required' => true ),
  53                                           'informationcollection_id' => array( 'name' => 'InformationCollectionID',
  54                                                                                'datatype' => 'integer',
  55                                                                                'default' => 0,
  56                                                                                'required' => true,
  57                                                                                'foreign_class' => 'eZInformationCollection',
  58                                                                                'foreign_attribute' => 'id',
  59                                                                                'multiplicity' => '1..*' ),
  60                                           'contentclass_attribute_id' => array( 'name' => 'ContentClassAttributeID',
  61                                                                                 'datatype' => 'integer',
  62                                                                                 'default' => 0,
  63                                                                                 'required' => true,
  64                                                                                 'foreign_class' => 'eZContentClassAttribute',
  65                                                                                 'foreign_attribute' => 'id',
  66                                                                                 'multiplicity' => '1..*' ),
  67                                           'contentobject_attribute_id' => array( 'name' => 'ContentObjectAttributeID',
  68                                                                                  'datatype' => 'integer',
  69                                                                                  'default' => 0,
  70                                                                                  'required' => true,
  71                                                                                  'foreign_class' => 'eZContentObjectAttribute',
  72                                                                                  'foreign_attribute' => 'id',
  73                                                                                  'multiplicity' => '1..*' ),
  74                                           'contentobject_id' => array( 'name' => 'ContentObjectID',
  75                                                                        'datatype' => 'integer',
  76                                                                        'default' => 0,
  77                                                                        'required' => true,
  78                                                                        'foreign_class' => 'eZContentObject',
  79                                                                        'foreign_attribute' => 'id',
  80                                                                        'multiplicity' => '1..*' ),
  81                                           'data_text' => array( 'name' => 'DataText',
  82                                                                 'datatype' => 'text',
  83                                                                 'default' => '',
  84                                                                 'required' => true ),
  85                                           'data_int' => array( 'name' => 'DataInt',
  86                                                                'datatype' => 'integer',
  87                                                                'default' => 0,
  88                                                                'required' => true ),
  89                                           'data_float' => array( 'name' => 'DataFloat',
  90                                                                  'datatype' => 'float',
  91                                                                  'default' => 0,
  92                                                                  'required' => true ) ),
  93                        'keys' => array( 'id' ),
  94                        'function_attributes' => array( 'contentclass_attribute_name' => 'contentClassAttributeName',
  95                                                        'contentclass_attribute' => 'contentClassAttribute',
  96                                                        'contentobject_attribute' => 'contentObjectAttribute',
  97                                                        'contentobject' => 'contentObject',
  98                                                        'result_template' => 'resultTemplateName',
  99                                                        'has_content' => 'hasContent',
 100                                                        'content' => 'content',
 101                                                        'class_content' => 'classContent' ),
 102                        'increment_key' => 'id',
 103                        'class_name' => 'eZInformationCollectionAttribute',
 104                        'name' => 'ezinfocollection_attribute' );
 105      }
 106  
 107      /*!
 108       \return the content for the contentclass attribute which defines this information collection attribute.
 109      */
 110      function &classContent()
 111      {
 112          $classAttribute =& $this->contentClassAttribute();
 113          if ( is_object( $classAttribute ) )
 114              $content =& $classAttribute->content();
 115          else
 116              $content = null;
 117          return $content;
 118      }
 119  
 120      /*!
 121       \return the content for this attribute.
 122      */
 123      function &content()
 124      {
 125          if ( $this->Content === null )
 126          {
 127              $dataType = $this->dataType();
 128              if ( is_object( $dataType ) )
 129              {
 130                  $this->Content =& $dataType->objectAttributeContent( $this );
 131              }
 132          }
 133          return $this->Content;
 134      }
 135  
 136      /*!
 137       \return \c true if the attribute is considered to have any content at all (ie. non-empty).
 138  
 139       It will call the hasObjectAttributeContent() for the current datatype to figure this out.
 140      */
 141      function &hasContent()
 142      {
 143          $hasContent = false;
 144          $dataType = $this->dataType();
 145          if ( is_object( $dataType ) )
 146          {
 147              $hasContent = $dataType->hasObjectAttributeContent( $this );
 148          }
 149          return $hasContent;
 150      }
 151  
 152      /*!
 153       \return the template name to use for viewing the attribute
 154       \note The returned template name does not include the .tpl extension.
 155       \sa informationTemplate
 156      */
 157      function &resultTemplateName()
 158      {
 159          $dataType = $this->dataType();
 160          if ( $dataType )
 161              $retValue =& $dataType->resultTemplate( $this );
 162          else
 163              $retValue = null;
 164          return $retValue;
 165      }
 166  
 167      /*!
 168      */
 169      function &contentObject()
 170      {
 171          $contentObject =& eZContentObject::fetch( $this->attribute( 'contentobject_id' ) );
 172          return $contentObject;
 173      }
 174  
 175      /*!
 176      */
 177      function &contentObjectAttribute()
 178      {
 179          $contentObject =& $this->contentObject();
 180          $contentObjectAttribute = eZContentObjectAttribute::fetch( $this->attribute( 'contentobject_attribute_id' ), $contentObject->attribute( 'current_version' ) );
 181          return $contentObjectAttribute;
 182      }
 183  
 184      /*!
 185      */
 186      function &contentClassAttribute()
 187      {
 188          $contentClassAttribute =& eZContentClassAttribute::fetch( $this->attribute( 'contentclass_attribute_id' ) );
 189          return $contentClassAttribute;
 190      }
 191  
 192      /*!
 193      */
 194      function dataType()
 195      {
 196          $contentClassAttribute =& $this->contentClassAttribute();
 197          if ( $contentClassAttribute )
 198              return  $contentClassAttribute->dataType();
 199          return null;
 200      }
 201  
 202      /*!
 203      */
 204      function &contentClassAttributeName()
 205      {
 206          $db =& eZDB::instance();
 207          $nameArray = $db->arrayQuery( "SELECT serialized_name_list FROM ezcontentclass_attribute WHERE id='$this->ContentClassAttributeID'" );
 208  
 209          return eZContentClassAttributeNameList::nameFromSerializedString( $nameArray[0]['serialized_name_list'] );
 210      }
 211  
 212      /*!
 213       Creates a new eZInformationCollectionAttribute instance.
 214      */
 215      function create( $informationCollectionID )
 216      {
 217          $row = array( 'informationcollection_id' => $informationCollectionID );
 218          return new eZInformationCollectionAttribute( $row );
 219      }
 220  
 221      /*!
 222       \static
 223        Fetches the information collection by object attribute ID.
 224      */
 225      function fetchByObjectAttributeID( $id, $contentobjectAttributeID, $asObject = true )
 226      {
 227          return eZPersistentObject::fetchObject( eZInformationCollectionAttribute::definition(),
 228                                                  null,
 229                                                  array( 'informationcollection_id' => $id,
 230                                                         'contentobject_attribute_id' => $contentobjectAttributeID ),
 231                                                  $asObject );
 232      }
 233  
 234      /*!
 235       \static
 236       Removes all attributes for collected information.
 237       \note Transaction unsafe. If you call several transaction unsafe methods you must enclose
 238       the calls within a db transaction; thus within db->begin and db->commit.
 239      */
 240      function cleanup()
 241      {
 242          $db =& eZDB::instance();
 243          $db->query( "DELETE FROM ezinfocollection_attribute" );
 244      }
 245  
 246      // Contains the content for this attribute
 247      var $Content;
 248  }
 249  
 250  ?>


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