|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Created on: <02-Dec-2002 14:39:39 bf> 00004 // 00005 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00006 // SOFTWARE NAME: eZ Publish 00007 // SOFTWARE RELEASE: 4.0.x 00008 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00009 // SOFTWARE LICENSE: GNU General Public License v2.0 00010 // NOTICE: > 00011 // This program is free software; you can redistribute it and/or 00012 // modify it under the terms of version 2.0 of the GNU General 00013 // Public License as published by the Free Software Foundation. 00014 // 00015 // This program is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU General Public License for more details. 00019 // 00020 // You should have received a copy of version 2.0 of the GNU General 00021 // Public License along with this program; if not, write to the Free 00022 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00023 // MA 02110-1301, USA. 00024 // 00025 // 00026 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00027 // 00028 00029 /*! 00030 \class eZInformationCollectionAttribute ezinformationcollectionattribute.php 00031 \ingroup eZKernel 00032 \brief The class eZInformationCollectionAttribute handles collected attribute information 00033 00034 */ 00035 00036 //include_once( 'kernel/classes/ezpersistentobject.php' ); 00037 00038 class eZInformationCollectionAttribute extends eZPersistentObject 00039 { 00040 function eZInformationCollectionAttribute( $row ) 00041 { 00042 $this->Content = null; 00043 $this->eZPersistentObject( $row ); 00044 } 00045 00046 /*! 00047 \return the persistent object definition for the eZInformationCollectionAttribute class. 00048 */ 00049 static function definition() 00050 { 00051 return array( 'fields' => array( 'id' => array( 'name' => 'ID', 00052 'datatype' => 'integer', 00053 'default' => 0, 00054 'required' => true ), 00055 'informationcollection_id' => array( 'name' => 'InformationCollectionID', 00056 'datatype' => 'integer', 00057 'default' => 0, 00058 'required' => true, 00059 'foreign_class' => 'eZInformationCollection', 00060 'foreign_attribute' => 'id', 00061 'multiplicity' => '1..*' ), 00062 'contentclass_attribute_id' => array( 'name' => 'ContentClassAttributeID', 00063 'datatype' => 'integer', 00064 'default' => 0, 00065 'required' => true, 00066 'foreign_class' => 'eZContentClassAttribute', 00067 'foreign_attribute' => 'id', 00068 'multiplicity' => '1..*' ), 00069 'contentobject_attribute_id' => array( 'name' => 'ContentObjectAttributeID', 00070 'datatype' => 'integer', 00071 'default' => 0, 00072 'required' => true, 00073 'foreign_class' => 'eZContentObjectAttribute', 00074 'foreign_attribute' => 'id', 00075 'multiplicity' => '1..*' ), 00076 'contentobject_id' => array( 'name' => 'ContentObjectID', 00077 'datatype' => 'integer', 00078 'default' => 0, 00079 'required' => true, 00080 'foreign_class' => 'eZContentObject', 00081 'foreign_attribute' => 'id', 00082 'multiplicity' => '1..*' ), 00083 'data_text' => array( 'name' => 'DataText', 00084 'datatype' => 'text', 00085 'default' => '', 00086 'required' => true ), 00087 'data_int' => array( 'name' => 'DataInt', 00088 'datatype' => 'integer', 00089 'default' => 0, 00090 'required' => true ), 00091 'data_float' => array( 'name' => 'DataFloat', 00092 'datatype' => 'float', 00093 'default' => 0, 00094 'required' => true ) ), 00095 'keys' => array( 'id' ), 00096 'function_attributes' => array( 'contentclass_attribute_name' => 'contentClassAttributeName', 00097 'contentclass_attribute' => 'contentClassAttribute', 00098 'contentobject_attribute' => 'contentObjectAttribute', 00099 'contentobject' => 'contentObject', 00100 'result_template' => 'resultTemplateName', 00101 'has_content' => 'hasContent', 00102 'content' => 'content', 00103 'class_content' => 'classContent' ), 00104 'increment_key' => 'id', 00105 'class_name' => 'eZInformationCollectionAttribute', 00106 'name' => 'ezinfocollection_attribute' ); 00107 } 00108 00109 /*! 00110 \return the content for the contentclass attribute which defines this information collection attribute. 00111 */ 00112 function classContent() 00113 { 00114 $classAttribute = $this->contentClassAttribute(); 00115 if ( is_object( $classAttribute ) ) 00116 { 00117 return $classAttribute->content(); 00118 } 00119 return null; 00120 } 00121 00122 /*! 00123 \return the content for this attribute. 00124 */ 00125 function content() 00126 { 00127 if ( $this->Content === null ) 00128 { 00129 $dataType = $this->dataType(); 00130 if ( is_object( $dataType ) ) 00131 { 00132 $this->Content = $dataType->objectAttributeContent( $this ); 00133 } 00134 } 00135 return $this->Content; 00136 } 00137 00138 /*! 00139 \return \c true if the attribute is considered to have any content at all (ie. non-empty). 00140 00141 It will call the hasObjectAttributeContent() for the current datatype to figure this out. 00142 */ 00143 function hasContent() 00144 { 00145 $dataType = $this->dataType(); 00146 if ( is_object( $dataType ) ) 00147 { 00148 return $dataType->hasObjectAttributeContent( $this ); 00149 } 00150 return false; 00151 } 00152 00153 /*! 00154 \return the template name to use for viewing the attribute 00155 \note The returned template name does not include the .tpl extension. 00156 \sa informationTemplate 00157 */ 00158 function resultTemplateName() 00159 { 00160 $dataType = $this->dataType(); 00161 if ( $dataType ) 00162 { 00163 return $dataType->resultTemplate( $this ); 00164 } 00165 return null; 00166 } 00167 00168 /*! 00169 */ 00170 function contentObject() 00171 { 00172 return eZContentObject::fetch( $this->attribute( 'contentobject_id' ) ); 00173 } 00174 00175 /*! 00176 */ 00177 function contentObjectAttribute() 00178 { 00179 $contentObject = $this->contentObject(); 00180 return eZContentObjectAttribute::fetch( $this->attribute( 'contentobject_attribute_id' ), $contentObject->attribute( 'current_version' ) ); 00181 } 00182 00183 /*! 00184 */ 00185 function contentClassAttribute() 00186 { 00187 return eZContentClassAttribute::fetch( $this->attribute( 'contentclass_attribute_id' ) ); 00188 } 00189 00190 /*! 00191 */ 00192 function dataType() 00193 { 00194 $contentClassAttribute = $this->contentClassAttribute(); 00195 if ( $contentClassAttribute ) 00196 return $contentClassAttribute->dataType(); 00197 return null; 00198 } 00199 00200 /*! 00201 */ 00202 function contentClassAttributeName() 00203 { 00204 $db = eZDB::instance(); 00205 $nameArray = $db->arrayQuery( "SELECT serialized_name_list FROM ezcontentclass_attribute WHERE id='$this->ContentClassAttributeID'" ); 00206 00207 return eZContentClassAttributeNameList::nameFromSerializedString( $nameArray[0]['serialized_name_list'] ); 00208 } 00209 00210 /*! 00211 Creates a new eZInformationCollectionAttribute instance. 00212 */ 00213 static function create( $informationCollectionID ) 00214 { 00215 $row = array( 'informationcollection_id' => $informationCollectionID ); 00216 return new eZInformationCollectionAttribute( $row ); 00217 } 00218 00219 /*! 00220 \static 00221 Fetches the information collection by object attribute ID. 00222 */ 00223 static function fetchByObjectAttributeID( $id, $contentobjectAttributeID, $asObject = true ) 00224 { 00225 return eZPersistentObject::fetchObject( eZInformationCollectionAttribute::definition(), 00226 null, 00227 array( 'informationcollection_id' => $id, 00228 'contentobject_attribute_id' => $contentobjectAttributeID ), 00229 $asObject ); 00230 } 00231 00232 /*! 00233 \static 00234 Removes all attributes for collected information. 00235 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 00236 the calls within a db transaction; thus within db->begin and db->commit. 00237 */ 00238 static function cleanup() 00239 { 00240 $db = eZDB::instance(); 00241 $db->query( "DELETE FROM ezinfocollection_attribute" ); 00242 } 00243 00244 // Contains the content for this attribute 00245 public $Content; 00246 } 00247 00248 ?>