[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/eztemplate/classes/ -> eztemplatedelimitfunction.php (source)

   1  <?php
   2  //
   3  // Definition of eZTemplateDelimitFunction class
   4  //
   5  // Created on: <01-Mar-2002 13:49:07 amos>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*!
  30    \class eZTemplateDelimitFunction eztemplatedelimitfunction.php
  31    \ingroup eZTemplateFunctions
  32    \brief Displays left and right delimiter in templates
  33  
  34    This class iss a template function for outputting the left and right delimiters.
  35    Since the left and right delimiters are always parsed by the template engine
  36    it's not possible to output these characters. By registering an instance of this
  37    class as template functions you can get these characters with {ldelim} and {rdelim}.
  38  
  39    The name of these functions can also be controlled by passing the names to the
  40    constructor.
  41  
  42    Example:
  43  \code
  44  $tpl->registerFunctions( new eZTemplateDelimitFunction() );
  45  // or custom names
  46  $tpl->registerFunctions( new eZTemplateDelimitFunction( "l", "r" ) );
  47  // alternatively
  48  $obj = new eZTemplateDelimitFunction();
  49  $tpl->registerFunction( "ldelim", $obj );
  50  $tpl->registerFunction( "rdelim", $obj );
  51  \endcode
  52  */
  53  
  54  class eZTemplateDelimitFunction
  55  {
  56      /*!
  57       Initializes the object with a name for the left and right delimiter.
  58       Default is ldelim for left and rdelim for right.
  59      */
  60      function eZTemplateDelimitFunction()
  61      {
  62          $this->LName = 'ldelim';
  63          $this->RName = 'rdelim';
  64      }
  65  
  66      /*!
  67       Returns an array of the function names, required for eZTemplate::registerFunctions.
  68      */
  69      function functionList()
  70      {
  71          return array( $this->LName, $this->RName );
  72      }
  73  
  74      /*!
  75       Returns an array with hints for the template compiler.
  76      */
  77      function functionTemplateHints()
  78      {
  79          return array(
  80              $this->LName => array( 'parameters' => false, 'static' => false, 'tree-transformation' => true ),
  81              $this->RName => array( 'parameters' => false, 'static' => false, 'tree-transformation' => true )
  82          );
  83      }
  84  
  85      function templateNodeTransformation( $functionName, &$node,
  86                                           &$tpl, $parameters, $privateData )
  87      {
  88          $newNodes = array();
  89  
  90          if ( $functionName == $this->LName )
  91          {
  92              $newNodes = array ( eZTemplateNodeTool::createTextNode( $tpl->leftDelimiter() ) );
  93          }
  94          else
  95          {
  96              $newNodes = array ( eZTemplateNodeTool::createTextNode( $tpl->rightDelimiter() ) );
  97          }
  98          return $newNodes;
  99      }
 100  
 101      /*!
 102       Outputs the left or right delimiter if the function names match.
 103      */
 104      function process( &$tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $nspace, $current_nspace )
 105      {
 106          switch ( $functionName )
 107          {
 108              case $this->LName:
 109              {
 110                  $textElements[] = $tpl->leftDelimiter();
 111              } break;
 112              case $this->RName:
 113              {
 114                  $textElements[] = $tpl->rightDelimiter();
 115              } break;
 116          }
 117      }
 118  
 119      /*!
 120       Returns false, telling the template parser that this is a single tag.
 121      */
 122      function hasChildren()
 123      {
 124          return false;
 125      }
 126  
 127      /// The name of the left delimiter tag
 128      var $LName;
 129      /// The name of the right delimiter tag
 130      var $RName;
 131  }
 132  
 133  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7