00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 class eZTemplateSectionIterator
00051 {
00052
00053
00054
00055 function eZTemplateSectionIterator()
00056 {
00057 $this->InternalAttributes = array( 'item' => false,
00058 'key' => false,
00059 'index' => false,
00060 'number' => false,
00061 'sequence' => false,
00062 'last' => false );
00063 $this->InternalAttributeNames = array_keys( $this->InternalAttributes );
00064 }
00065
00066
00067
00068
00069 function templateValue()
00070 {
00071 $value = $this->InternalAttributes['item'];
00072 return $value;
00073 }
00074
00075
00076
00077
00078 function attributes()
00079 {
00080 $attributes = array();
00081 $item =& $this->InternalAttributes['item'];
00082 if ( is_array( $item ) )
00083 {
00084 $attributes = array_keys( $item );
00085 }
00086 else if ( is_object( $item ) and
00087 method_exists( $item, 'attributes' ) )
00088 {
00089 $attributes = $item->attributes();
00090 }
00091 $attributes = array_merge( $this->InternalAttributes, $attributes );
00092 $attributes = array_unique( $attributes );
00093 return $attributes;
00094 }
00095
00096
00097
00098
00099
00100 function hasAttribute( $name )
00101 {
00102 if ( in_array( $name, $this->InternalAttributeNames ) )
00103 return true;
00104 $item =& $this->InternalAttributes['item'];
00105 if ( is_array( $item ) )
00106 {
00107 return in_array( $name, array_keys( $item ) );
00108 }
00109 else if ( is_object( $item ) and
00110 method_exists( $item, 'hasAttribute' ) )
00111 {
00112 return $item->hasAttribute( $name );
00113 }
00114 return false;
00115 }
00116
00117
00118
00119
00120
00121 function &attribute( $name )
00122 {
00123 if ( in_array( $name, $this->InternalAttributeNames ) )
00124 {
00125 unset( $tempValue );
00126 $tempValue =& $this->InternalAttributes[$name];
00127 return $tempValue;
00128 }
00129 $item =& $this->InternalAttributes['item'];
00130 if ( is_array( $item ) )
00131 {
00132 $arrayItem = $item[$name];
00133 return $arrayItem;
00134 }
00135 else if ( is_object( $item ) and
00136 method_exists( $item, 'attribute' ) )
00137 {
00138 unset( $tempValue );
00139 $tempValue =& $item->attribute( $name );
00140 return $tempValue;
00141 }
00142 eZDebug::writeError( "Attribute '$name' does not exist", 'eZTemplateSectionIterator::attribute' );
00143 $tempValue = null;
00144 return $tempValue;
00145 }
00146
00147
00148
00149
00150 function setIteratorValues( &$item, $key, $index, $number, $sequence, &$last )
00151 {
00152 $this->InternalAttributes['item'] =& $item;
00153 $this->InternalAttributes['key'] = $key;
00154 $this->InternalAttributes['index'] = $index;
00155 $this->InternalAttributes['number'] = $number;
00156 $this->InternalAttributes['sequence'] = $sequence;
00157 $this->InternalAttributes['last'] =& $last;
00158 }
00159
00160
00161
00162
00163 function setSequence( $sequence )
00164 {
00165 $this->InternalAttributes['sequence'] = $sequence;
00166 }
00167 }
00168
00169 ?>