Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

eztemplateattributeoperator.php
Go to the documentation of this file.
1 <?php
55 class eZTemplateAttributeOperator
56 {
57 public $AttributeName;
58 public $DumpName;
65 public function __construct( $attributeName = 'attribute', $dumpName = 'dump' )
66 {
67 $this->AttributeName = $attributeName;
68 $this->DumpName = $dumpName;
69 $this->Operators = array( $attributeName, $dumpName );
70 }
71
75 function operatorList()
76 {
77 return $this->Operators;
78 }
79
80 function operatorTemplateHints()
81 {
82 return array( $this->AttributeName => array( 'input' => true,
83 'output' => true,
84 'parameters' => 3 ),
85 $this->DumpName => array( 'input' => true,
86 'outpout' => true,
87 'parameters' => 3 ) );
88 }
89
93 function namedParameterList()
94 {
95 return array( $this->AttributeName => array( "show_values" => array( "type" => "string",
96 "required" => false,
97 "default" => "" ),
98 "max_val" => array( "type" => "numerical",
99 "required" => false,
100 "default" => 2 ),
101 "format" => array( "type" => "boolean",
102 "required" => false,
103 "default" => eZINI::instance( 'template.ini' )->variable( 'AttributeOperator', 'DefaultFormatter' ) ) ),
104 $this->DumpName => array( "show_values" => array( "type" => "string",
105 "required" => false,
106 "default" => "show" ),
107 "max_val" => array( "type" => "numerical",
108 "required" => false,
109 "default" => 1 ),
110 "format" => array( "type" => "boolean",
111 "required" => false,
112 "default" => eZINI::instance( 'template.ini' )->variable( 'AttributeOperator', 'DefaultFormatter' ) ) ) );
113 }
114
118 function namedParameterPerOperator()
119 {
120 return true;
121 }
122
126 function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement )
127 {
128 $showValues = $namedParameters[ 'show_values' ] == 'show';
129 $max = $namedParameters[ 'max_val' ];
130 $format = $namedParameters[ 'format' ];
131
132 $formatter = ezpAttributeOperatorManager::getOutputFormatter( $format );
133
134 // check for an object or an array that is not empty
135 if ( is_object( $operatorValue ) || ( is_array( $operatorValue ) && !empty( $operatorValue ) ) )
136 {
137 $outputString = "";
138 $this->displayVariable( $operatorValue, $formatter, $showValues, $max, 0, $outputString );
139
140 if ( $formatter instanceof ezpAttributeOperatorFormatterInterface )
141 $operatorValue = $formatter->header( $outputString, $showValues );
142 }
143 else if ( $formatter instanceof ezpAttributeOperatorFormatterInterface )
144 {
145 $operatorValue = $formatter->exportScalar( $operatorValue );
146 }
147 }
148
156 function displayVariable( &$value, ezpAttributeOperatorFormatterInterface $formatter, $showValues, $max, $level, &$outputString )
157 {
158 if ( $max !== false and $level >= $max )
159 return;
160
161 if ( is_array( $value ) )
162 {
163 foreach ( $value as $key => $item )
164 {
165 $outputString .= $formatter->line( $key, $item, $showValues, $level );
166
167 $this->displayVariable( $item, $formatter, $showValues, $max, $level + 1, $outputString );
168 }
169 }
170 else if ( is_object( $value ) )
171 {
172 if ( !method_exists( $value, "attributes" ) or
173 !method_exists( $value, "attribute" ) )
174 return;
175
176 foreach ( $value->attributes() as $key )
177 {
178 $item = $value->attribute( $key );
179
180 $outputString .= $formatter->line( $key, $item, $showValues, $level );
181
182 $this->displayVariable( $item, $formatter, $showValues, $max, $level + 1, $outputString );
183 }
184 }
185 }
186
188 public $Operators;
189 }
190
191 ?>
eZTemplateAttributeOperator
Display of variable attributes using operator "attribute" or dumps a variable using the operator "dum...
Definition: eztemplateattributeoperator.php:56
eZTemplateAttributeOperator\namedParameterPerOperator
namedParameterPerOperator()
Definition: eztemplateattributeoperator.php:118
eZTemplateAttributeOperator\$Operators
$Operators
The array of operators, used for registering operators.
Definition: eztemplateattributeoperator.php:188
eZTemplateAttributeOperator\modify
modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement)
Definition: eztemplateattributeoperator.php:126
eZTemplateAttributeOperator\operatorTemplateHints
operatorTemplateHints()
Definition: eztemplateattributeoperator.php:80
eZTemplateAttributeOperator\$DumpName
$DumpName
Definition: eztemplateattributeoperator.php:58
eZTemplateAttributeOperator\displayVariable
displayVariable(&$value, ezpAttributeOperatorFormatterInterface $formatter, $showValues, $max, $level, &$outputString)
Definition: eztemplateattributeoperator.php:156
eZTemplateAttributeOperator\__construct
__construct( $attributeName='attribute', $dumpName='dump')
Definition: eztemplateattributeoperator.php:65
eZTemplateAttributeOperator\namedParameterList
namedParameterList()
Definition: eztemplateattributeoperator.php:93
eZTemplateAttributeOperator\operatorList
operatorList()
Definition: eztemplateattributeoperator.php:75
eZTemplateAttributeOperator\$AttributeName
$AttributeName
Definition: eztemplateattributeoperator.php:57
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.