eZ Publish  [4.0]
eztemplateroot.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZTemplateRoot class
00004 //
00005 // Created on: <01-Mar-2002 13:50:20 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 eZTemplateElements Template elements
00032     \ingroup eZTemplate
00033 */
00034 
00035 /*!
00036   \class eZTemplateRoot eztemplateroot.php
00037   \ingroup eZTemplateElements
00038   \brief Represents a root element of the template tree.
00039 
00040   This starts the template tree and is the base of template includes.
00041 
00042   It has a list of child elements and runs process() on each child.
00043 */
00044 
00045 class eZTemplateRoot
00046 {
00047     /*!
00048      Initializes the object.
00049     */
00050     function eZTemplateRoot( $children = array() )
00051     {
00052         $this->Children = $children;
00053     }
00054 
00055     /*!
00056      Returns #root as the name.
00057     */
00058     function name()
00059     {
00060         return "#root";
00061     }
00062 
00063     function serializeData()
00064     {
00065         return array( 'class_name' => 'eZTemplateRoot',
00066                       'parameters' => array( 'children' ),
00067                       'variables' => array( 'children' => 'Children' ) );
00068     }
00069 
00070     /*!
00071      Runs process() on all child elements.
00072     */
00073     function process( $tpl, &$text, $nspace, $current_nspace )
00074     {
00075         foreach( array_keys( $this->Children ) as $key )
00076         {
00077             $this->Children[$key]->process( $tpl, $text, $nspace, $current_nspace );
00078         }
00079     }
00080 
00081     /*!
00082      Removes all children.
00083     */
00084     function clear()
00085     {
00086         $this->Children = array();
00087     }
00088 
00089     /*!
00090      Returns a reference to the child array.
00091     */
00092     function &children()
00093     {
00094         return $this->Children;
00095     }
00096 
00097     /*!
00098      Appends the child $node to the child array.
00099     */
00100     function appendChild( &$node )
00101     {
00102         $this->Children[] =& $node;
00103     }
00104 
00105     /// The child array
00106     public $Children = array();
00107 }
00108 
00109 ?>