Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

eztemplatedigestoperator.php
Go to the documentation of this file.
1 <?php
20 class eZTemplateDigestOperator
21 {
22 public $Crc32Name;
23 public $Md5Name;
24 public $Sha1Name;
25 public $Rot13Name;
26 public function __construct()
27 {
28 $this->Operators = array( 'crc32', 'md5', 'rot13' );
29 if ( function_exists( 'sha1' ) )
30 {
31 $this->Operators[] = 'sha1';
32 }
33 foreach ( $this->Operators as $operator )
34 {
35 $name = $operator . 'Name';
36 $name[0] = $name[0] & "\xdf";
37 $this->$name = $operator;
38 }
39 }
40
44 function operatorList()
45 {
46 return $this->Operators;
47 }
48
49 function operatorTemplateHints()
50 {
51 return array( $this->Crc32Name => array( 'input' => true,
52 'output' => true,
53 'parameters' => false,
54 'element-transformation' => true,
55 'transform-parameters' => true,
56 'input-as-parameter' => 'always',
57 'element-transformation-func' => 'hashTransformation'),
58 $this->Md5Name => array( 'input' => true,
59 'output' => true,
60 'parameters' => true,
61 'element-transformation' => true,
62 'transform-parameters' => true,
63 'input-as-parameter' => 'always',
64 'element-transformation-func' => 'hashTransformation'),
65 $this->Sha1Name => array( 'input' => true,
66 'output' => true,
67 'parameters' => true,
68 'element-transformation' => true,
69 'transform-parameters' => true,
70 'input-as-parameter' => 'always',
71 'element-transformation-func' => 'hashTransformation'),
72 $this->Rot13Name => array( 'input' => true,
73 'output' => true,
74 'parameters' => true,
75 'element-transformation' => true,
76 'transform-parameters' => true,
77 'input-as-parameter' => 'always',
78 'element-transformation-func' => 'hashTransformation') );
79 }
80
84 function namedParameterPerOperator()
85 {
86 return true;
87 }
88
92 function namedParameterList()
93 {
94 return false;
95 }
96
97 function hashTransformation( $operatorName, &$node, $tpl, &$resourceData,
98 $element, $lastElement, $elementList, $elementTree, &$parameters )
99 {
100 if ( ( count( $parameters ) != 1) )
101 {
102 return false;
103 }
104
105 $code = '';
106 $function = '';
107 $newElements = array();
108 $values = array( $parameters[0] );
109
110 switch ( $operatorName )
111 {
112 case 'crc32':
113 {
114 $function = "eZSys::ezcrc32";
115 } break;
116
117 case 'rot13':
118 {
119 $function = 'str_rot13';
120 } break;
121
122 default:
123 {
124 $function = $operatorName;
125 } break;
126 }
127
128 $code .= "%output% = $function( %1% );\n";
129
130 $newElements[] = eZTemplateNodeTool::createCodePieceElement( $code, $values );
131 return $newElements;
132 }
133
137 function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters,
138 $placement )
139 {
140 $digestData = $operatorValue;
141 switch ( $operatorName )
142 {
143 // Calculate and return crc32 polynomial.
144 case $this->Crc32Name:
145 {
146 $operatorValue = eZSys::ezcrc32( $digestData );
147 }break;
148
149 // Calculate the MD5 hash.
150 case $this->Md5Name:
151 {
152 $operatorValue = md5( $digestData );
153 }break;
154
155 // Calculate the SHA1 hash.
156 case $this->Sha1Name:
157 {
158 $operatorValue = sha1( $digestData );
159 }break;
160
161 // Preform rot13 transform on the string.
162 case $this->Rot13Name:
163 {
164 $operatorValue = str_rot13( $digestData );
165 }break;
166
167 // Default case: something went wrong - unknown things...
168 default:
169 {
170 $tpl->warning( $operatorName, "Unknown input type '$operatorName'", $placement );
171 } break;
172 }
173 }
174
176 public $Operators;
177 }
178
179 ?>
eZSys\ezcrc32
static ezcrc32( $string)
Definition: ezsys.php:1297
eZTemplateDigestOperator
Definition: eztemplatedigestoperator.php:21
eZTemplateDigestOperator\$Rot13Name
$Rot13Name
Definition: eztemplatedigestoperator.php:25
eZTemplateDigestOperator\$Crc32Name
$Crc32Name
Definition: eztemplatedigestoperator.php:22
eZTemplateDigestOperator\$Sha1Name
$Sha1Name
Definition: eztemplatedigestoperator.php:24
eZTemplateDigestOperator\operatorTemplateHints
operatorTemplateHints()
Definition: eztemplatedigestoperator.php:49
eZTemplateDigestOperator\namedParameterList
namedParameterList()
Definition: eztemplatedigestoperator.php:92
eZTemplateDigestOperator\namedParameterPerOperator
namedParameterPerOperator()
Definition: eztemplatedigestoperator.php:84
eZTemplateDigestOperator\__construct
__construct()
Definition: eztemplatedigestoperator.php:26
eZTemplateDigestOperator\modify
modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement)
Definition: eztemplatedigestoperator.php:137
eZTemplateDigestOperator\hashTransformation
hashTransformation( $operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
Definition: eztemplatedigestoperator.php:97
eZTemplateDigestOperator\$Operators
$Operators
The array of operators, used for registering operators.
Definition: eztemplatedigestoperator.php:176
eZTemplateDigestOperator\operatorList
operatorList()
Definition: eztemplatedigestoperator.php:44
eZTemplateDigestOperator\$Md5Name
$Md5Name
Definition: eztemplatedigestoperator.php:23
eZTemplateNodeTool\createCodePieceElement
static createCodePieceElement( $codePiece, $values=false, $placement=false, $tmpValues=false, $knownTypes=true)
Definition: eztemplatenodetool.php:437
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.