Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

eztemplatephpoperator.php
Go to the documentation of this file.
1 <?php
29 class eZTemplatePHPOperator
30 {
36 public function __construct( $php_names )
37 {
38 if ( !is_array( $php_names ) )
39 $php_names = array( $php_names );
40 $this->PHPNames = $php_names;
41 reset( $php_names );
42 foreach ( $php_names as $key => $val )
43 {
44 $this->Operators[] = $key;
45 }
46 }
47
51 function operatorList()
52 {
53 return $this->Operators;
54 }
55
56 function operatorTemplateHints()
57 {
58 $hints = array();
59 foreach ( array_keys( $this->PHPNames ) as $name )
60 {
61 $hints[$name] = array( 'input' => true,
62 'output' => true,
63 'parameters' => false,
64 'element-transformation' => true,
65 'transform-parameters' => true,
66 'input-as-parameter' => true,
67 'element-transformation-func' => 'phpOperatorTransformation');
68 }
69 return $hints;
70 }
71
72 function phpOperatorTransformation( $operatorName, &$node, $tpl, &$resourceData,
73 $element, $lastElement, $elementList, $elementTree, &$parameters )
74 {
75 $values = array();
76 $function = $operatorName;
77
78 if ( !isset( $parameters[0] ) )
79 {
80 return false;
81 }
82 $newElements = array();
83 $phpname = $this->PHPNames[$operatorName];
84
85 $values[] = $parameters[0];
86 $code = "%output% = $phpname( %1% );\n";
87
88 $newElements[] = eZTemplateNodeTool::createCodePieceElement( $code, $values );
89 return $newElements;
90 }
91
95 function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$value, $namedParameters, $placement )
96 {
97 $phpname = $this->PHPNames[$operatorName];
98 if ( $value !== null )
99 $operand = $value;
100 else
101 $operand = $tpl->elementValue( $operatorParameters[0], $rootNamespace, $currentNamespace, $placement );
102 $value = $phpname( $operand );
103 }
104
106 public $Operators;
108 public $PHPNames;
109 }
110
111 ?>
eZTemplateNodeTool\createCodePieceElement
static createCodePieceElement( $codePiece, $values=false, $placement=false, $tmpValues=false, $knownTypes=true)
Definition: eztemplatenodetool.php:437
eZTemplatePHPOperator
Makes it easy to add php functions as operators.
Definition: eztemplatephpoperator.php:30
eZTemplatePHPOperator\$Operators
$Operators
The array of operators, used for registering operators.
Definition: eztemplatephpoperator.php:106
eZTemplatePHPOperator\__construct
__construct( $php_names)
Definition: eztemplatephpoperator.php:36
eZTemplatePHPOperator\operatorTemplateHints
operatorTemplateHints()
Definition: eztemplatephpoperator.php:56
eZTemplatePHPOperator\operatorList
operatorList()
Definition: eztemplatephpoperator.php:51
eZTemplatePHPOperator\modify
modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$value, $namedParameters, $placement)
Definition: eztemplatephpoperator.php:95
eZTemplatePHPOperator\phpOperatorTransformation
phpOperatorTransformation( $operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
Definition: eztemplatephpoperator.php:72
eZTemplatePHPOperator\$PHPNames
$PHPNames
The associative array of operator/php function redirection.
Definition: eztemplatephpoperator.php:108
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.