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 class eZTemplateNl2BrOperator
00041 {
00042
00043
00044
00045 function eZTemplateNl2BrOperator()
00046 {
00047 $this->Operators = array( 'nl2br' );
00048 $this->Nl2brName = 'nl2br';
00049 }
00050
00051
00052
00053
00054 function &operatorList()
00055 {
00056 return $this->Operators;
00057 }
00058
00059
00060
00061
00062 function namedParameterList()
00063 {
00064 return array( );
00065 }
00066
00067 function operatorTemplateHints()
00068 {
00069 return array( $this->Nl2brName => array( 'input' => true,
00070 'output' => true,
00071 'parameters' => true,
00072 'element-transformation' => true,
00073 'transform-parameters' => true,
00074 'input-as-parameter' => true,
00075 'element-transformation-func' => 'nl2brTransformation') );
00076 }
00077
00078 function nl2brTransformation( $operatorName, &$node, &$tpl, &$resourceData,
00079 &$element, &$lastElement, &$elementList, &$elementTree, &$parameters )
00080 {
00081 $values = array();
00082 $function = $operatorName;
00083
00084 if ( ( count( $parameters ) != 1) )
00085 {
00086 return false;
00087 }
00088 $newElements = array();
00089
00090 $values[] = $parameters[0];
00091 $code = "%output% = nl2br( %1% );\n";
00092
00093 $newElements[] = eZTemplateNodeTool::createCodePieceElement( $code, $values );
00094 return $newElements;
00095 }
00096
00097
00098
00099
00100 function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters )
00101 {
00102 $operatorValue = str_replace( "\n",
00103 "<br />",
00104 $operatorValue );
00105 }
00106
00107
00108 var $Operators;
00109 }
00110
00111 ?>