|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZTemplateNl2BrOperator class 00004 // 00005 // Created on: <10-Mar-2003 11:22:29 bf> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ Publish 00009 // SOFTWARE RELEASE: 4.0.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00011 // SOFTWARE LICENSE: GNU General Public License v2.0 00012 // NOTICE: > 00013 // This program is free software; you can redistribute it and/or 00014 // modify it under the terms of version 2.0 of the GNU General 00015 // Public License as published by the Free Software Foundation. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of version 2.0 of the GNU General 00023 // Public License along with this program; if not, write to the Free 00024 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00025 // MA 02110-1301, USA. 00026 // 00027 // 00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00029 // 00030 00031 /*! 00032 \class eZTemplateNl2BrOperator eztemplatenl2broperator.php 00033 \ingroup eZTemplateOperators 00034 \code 00035 00036 \endcode 00037 00038 */ 00039 00040 class eZTemplateNl2BrOperator 00041 { 00042 /*! 00043 Initializes the object with the name $name, default is "nl2br". 00044 */ 00045 function eZTemplateNl2BrOperator() 00046 { 00047 $this->Operators = array( 'nl2br' ); 00048 $this->Nl2brName = 'nl2br'; 00049 } 00050 00051 /*! 00052 Returns the template operators. 00053 */ 00054 function operatorList() 00055 { 00056 return $this->Operators; 00057 } 00058 00059 /*! 00060 See eZTemplateOperator::namedParameterList() 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 Display the variable. 00099 */ 00100 function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters ) 00101 { 00102 $operatorValue = str_replace( "\n", 00103 "<br />", 00104 $operatorValue ); 00105 } 00106 00107 /// The array of operators, used for registering operators 00108 public $Operators; 00109 } 00110 00111 ?>