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 class eZTemplateOperatorElement
00044 {
00045
00046
00047
00048 function eZTemplateOperatorElement( $name, $params, $resource = null, $templateName = null )
00049 {
00050 $this->Name = $name;
00051 $this->Params = $params;
00052 $this->Resource = $resource;
00053 $this->TemplateName = $templateName;
00054 }
00055
00056 function setResourceRelation( $resource )
00057 {
00058 $this->Resource = $resource;
00059 }
00060
00061 function setTemplateNameRelation( $templateName )
00062 {
00063 $this->TemplateName = $templateName;
00064 }
00065
00066 function resourceRelation()
00067 {
00068 return $this->Resource;
00069 }
00070
00071 function templateNameRelation()
00072 {
00073 return $this->TemplateName;
00074 }
00075
00076
00077
00078
00079 function &name()
00080 {
00081 return $this->Name;
00082 }
00083
00084 function serializeData()
00085 {
00086 return array( 'class_name' => 'eZTemplateOperatorElement',
00087 'parameters' => array( 'name', 'parameters', 'resource', 'template_name' ),
00088 'variables' => array( 'name' => 'Name',
00089 'parameters' => 'Params',
00090 'resource' => 'Resource',
00091 'template_name' => 'TemplateName' ) );
00092 }
00093
00094
00095
00096
00097
00098 function process( &$tpl, &$value, $nspace, $current_nspace )
00099 {
00100 $named_params = array();
00101 $param_list = $tpl->operatorParameterList( $this->Name );
00102 $i = 0;
00103 foreach ( $param_list as $param_name => $param_type )
00104 {
00105 if ( !isset( $this->Params[$i] ) or
00106 $this->Params[$i]["type"] == "null" )
00107 {
00108 if ( $param_type["required"] )
00109 {
00110 $tpl->warning( "eZTemplateOperatorElement", "Parameter '$param_name' ($i) missing" );
00111 $named_params[$param_name] = $param_type["default"];
00112 }
00113 else
00114 {
00115 $named_params[$param_name] = $param_type["default"];
00116 }
00117 }
00118 else
00119 {
00120 $param_data = $this->Params[$i];
00121 $named_params[$param_name] = $tpl->elementValue( $param_data, $nspace );
00122 }
00123 ++$i;
00124 }
00125 if ( $param_list !== null )
00126 $tpl->doOperator( $this, $nspace, $current_nspace, $value, $this->Name, $this->Params, $named_params );
00127 else
00128 $tpl->doOperator( $this, $nspace, $current_nspace, $value, $this->Name, $this->Params );
00129 }
00130
00131
00132
00133
00134 function ¶meters()
00135 {
00136 return $this->Params;
00137 }
00138
00139
00140 var $Name;
00141
00142 var $Params;
00143 var $Resource;
00144 var $TemplateName;
00145 }
00146
00147 ?>