|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZTemplateFunctionElement class 00004 // 00005 // Created on: <01-Mar-2002 13:49:30 amos> 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 /*! \defgroup eZTemplateFunctions Template functions 00032 \ingroup eZTemplate */ 00033 00034 /*! 00035 \class eZTemplateFunctionElement eztemplatefunctionelement.php 00036 \ingroup eZTemplateElements 00037 \brief Represents a function element in the template tree. 00038 00039 This class represents a function with it's parameters. 00040 It also contains child elements if the function was registered as having 00041 children. 00042 00043 */ 00044 00045 class eZTemplateFunctionElement 00046 { 00047 /*! 00048 Initializes the function with a name and parameter array. 00049 */ 00050 function eZTemplateFunctionElement( $name, $params, $children = array() ) 00051 { 00052 $this->Name = $name; 00053 $this->Params =& $params; 00054 $this->Children = $children; 00055 } 00056 00057 function setResourceRelation( $resource ) 00058 { 00059 $this->Resource = $resource; 00060 } 00061 00062 function setTemplateNameRelation( $templateName ) 00063 { 00064 $this->TemplateName = $templateName; 00065 } 00066 00067 function resourceRelation() 00068 { 00069 return $this->Resource; 00070 } 00071 00072 function templateNameRelation() 00073 { 00074 return $this->TemplateName; 00075 } 00076 00077 /*! 00078 Returns the name of the function. 00079 */ 00080 function name() 00081 { 00082 return $this->Name; 00083 } 00084 00085 function serializeData() 00086 { 00087 return array( 'class_name' => 'eZTemplateFunctionElement', 00088 'parameters' => array( 'name', 'parameters', 'children' ), 00089 'variables' => array( 'name' => 'Name', 00090 'parameters' => 'Params', 00091 'children' => 'Children' ) ); 00092 } 00093 00094 /*! 00095 Tries to run the function with the children, the actual function execution 00096 is done by the template class. 00097 */ 00098 function process( $tpl, &$text, $nspace, $current_nspace ) 00099 { 00100 $tmp = $tpl->doFunction( $this->Name, $this, $nspace, $current_nspace ); 00101 if ( $tmp === false ) 00102 return; 00103 $tpl->appendElement( $text, $tmp, $nspace, $current_nspace ); 00104 } 00105 00106 /*! 00107 Returns a reference to the parameter list. 00108 */ 00109 function ¶meters() 00110 { 00111 return $this->Params; 00112 } 00113 00114 /*! 00115 Returns a reference to the children. 00116 */ 00117 function &children() 00118 { 00119 return $this->Children; 00120 } 00121 00122 /*! 00123 Appends the child element $node to the child list. 00124 */ 00125 function appendChild( &$node ) 00126 { 00127 $this->Children[] =& $node; 00128 } 00129 00130 /// The name of the function 00131 public $Name; 00132 /// The parameter list 00133 public $Params; 00134 /// The child elements 00135 public $Children = array(); 00136 00137 public $Resource; 00138 public $TemplateName; 00139 } 00140 00141 ?>