Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

field_set.php
Go to the documentation of this file.
1 <?php
18 class ezpContentFieldSet implements ArrayAccess, Iterator
19 {
25 public function __construct()
26 {
27 }
28
34 public static function fromContentObject( eZContentObject $contentObject )
35 {
36 $set = new ezpContentFieldSet();
37 $languages = $contentObject->availableLanguages();
38 foreach( $languages as $language )
39 {
40 $set->childrenFieldSets[$language] =
41 ezpContentFieldSet::fromDataMap( $contentObject->fetchDataMap( false, $language ) );
42 }
43
44 // this sequence is REALLY ugly
45 reset( $languages );
46 $set->setActiveLanguage( current( $languages ) );
47
48 return $set;
49 }
50
56 public static function fromDataMap( $dataMap )
57 {
58 $set = new ezpContentFieldSet();
59 foreach( $dataMap as $attribute )
60 {
61 $identifier = $attribute->attribute( 'contentclass_attribute_identifier' );
62 $set->fields[$identifier] = ezpContentField::fromContentObjectAttribute( $attribute );
63 }
64 $set->initIterator();
65 return $set;
66 }
67
73 public function offsetExists( $offset )
74 {
75 }
76
86 public function offsetSet( $offset, $value )
87 {
88 }
89
96 public function offsetGet( $offset )
97 {
98 // This needs to check if this language can be instanciated (e.g. is active on the installation)
99 if ( !isset( $this->childrenFieldSets[$offset] ) )
100 {
101 throw new Exception( "Language $offset could not be found on this ezpContent" );
102 }
103
104 return $this->childrenFieldSets[$offset];
105 }
106
114 public function offsetUnset( $offset )
115 {
116 }
117
121 public function __set( $name, eZContentObjectAttribute $value )
122 {
123 $this->contentObjectAttributes[$name] = $value;
124 // Check if the attribute is a valid one
125 if ( isset( $this->contentObjectAttributes[$name] ) )
126 {
127 // needs to adapt itself to the given parameter (state object, string, etc)
128 // fromString will do for now
129 $this->contentObjectAttributes[$name]->fromString( $value );
130 }
131 }
132
137 public function __get( $name )
138 {
139 // Request on a level 2 ezpFieldSet, that holds fields (attributes)
140 if ( isset( $this->fields[$name] ) )
141 {
142 return $this->fields[$name];
143 }
144 // direct request on a level 1 ezpFieldSet, that holds sub ezpFieldSet, but has a default language
145 else
146 {
147 if ( $this->activeLanguage === null )
148 throw new Exception( "You need to set an active language in order to query fields directly" );
149 else
150 {
151 return $this[$this->activeLanguage]->$name;
152 }
153 }
154 }
155
164 public function __isset( $name )
165 {
166 if ( $this->fields == null )
167 {
168 if ( $this->activeLanguage === null )
169 {
170 throw new Exception( "You need to define ezpFieldSet::activeLanguage to query fields directly" );
171 return false;
172 }
173 else
174 {
175 return isset( $this->childrenFieldSets[$this->activeLanguage]->{$name} );
176 }
177 }
178 else
179 {
180 return isset( $this->fields[$name] );
181 }
182 }
183
187 public function key()
188 {
189 return current( $this->iteratorPointer );
190 }
191
195 public function current()
196 {
197 return $this->iteratorData[current( $this->iteratorPointer )];
198 }
199
203 public function next()
204 {
205 next( $this->iteratorPointer );
206 }
207
211 public function rewind ()
212 {
213 reset( $this->iteratorPointer );
214 }
215
219 public function valid()
220 {
221 return isset( $this->iteratorData[current( $this->iteratorPointer )] );
222 }
223
227 protected function initIterator()
228 {
229 // level 1 ezpFieldSet
230 if ( $this->childrenFieldSets !== null )
231 {
232 $this->iteratorData = $this->childrenFieldSets[$this->activeLanguage]->fields;
233 $this->iteratorPointer = array_keys( $this->iteratorData );
234 }
235 else
236 {
237 $this->iteratorData = $this->fields;
238 $this->iteratorPointer = array_keys( $this->iteratorData );
239 }
240 }
241
247 public function setActiveLanguage( $language )
248 {
249 $this->activeLanguage = $language;
250 $this->initIterator();
251 }
252
257 protected $parentFieldSet;
258
264 protected $childrenFieldSets;
265
270 protected $fields;
271
276 protected $iteratorPointer = null;
277
283 protected $iteratorData = null;
284
289 protected $activeLanguage = false;
290 }
291 ?>
ezpContentFieldSet
Definition: field_set.php:19
ezpContentFieldSet\$iteratorData
$iteratorData
Definition: field_set.php:283
ezpContentFieldSet\current
current()
Definition: field_set.php:195
ezpContentFieldSet\initIterator
initIterator()
Definition: field_set.php:227
ezpContentFieldSet\$iteratorPointer
$iteratorPointer
Definition: field_set.php:276
ezpContentFieldSet\__set
__set( $name, eZContentObjectAttribute $value)
Definition: field_set.php:121
ezpContentFieldSet\$childrenFieldSets
$childrenFieldSets
Definition: field_set.php:264
ezpContentFieldSet\offsetUnset
offsetUnset( $offset)
Definition: field_set.php:114
ezpContentFieldSet\key
key()
Definition: field_set.php:187
ezpContentFieldSet\__get
__get( $name)
Definition: field_set.php:137
ezpContentFieldSet\offsetExists
offsetExists( $offset)
Definition: field_set.php:73
ezpContentFieldSet\next
next()
Definition: field_set.php:203
ezpContentFieldSet\__isset
__isset( $name)
Definition: field_set.php:164
ezpContentFieldSet\rewind
rewind()
Definition: field_set.php:211
ezpContentFieldSet\$fields
$fields
Definition: field_set.php:270
ezpContentFieldSet\fromDataMap
static fromDataMap( $dataMap)
Definition: field_set.php:56
ezpContentFieldSet\$activeLanguage
$activeLanguage
Definition: field_set.php:289
ezpContentFieldSet\offsetGet
offsetGet( $offset)
Definition: field_set.php:96
ezpContentFieldSet\setActiveLanguage
setActiveLanguage( $language)
Definition: field_set.php:247
ezpContentFieldSet\valid
valid()
Definition: field_set.php:219
ezpContentFieldSet\__construct
__construct()
Definition: field_set.php:25
ezpContentFieldSet\fromContentObject
static fromContentObject(eZContentObject $contentObject)
Definition: field_set.php:34
ezpContentFieldSet\offsetSet
offsetSet( $offset, $value)
Definition: field_set.php:86
ezpContentFieldSet\$parentFieldSet
$parentFieldSet
Definition: field_set.php:257
ezpContentField\fromContentObjectAttribute
static fromContentObjectAttribute(eZContentObjectAttribute $attribute)
Definition: field.php:29
$name
$name
Definition: companytypelist.php:194
$offset
$offset
Definition: ezstats/admin/cron.php:51
$language
$language
Definition: messageform.php:32
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.