[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/lib/ezi18n/classes/ -> eztranslatorgroup.php (source)

   1  <?php
   2  //
   3  // Definition of eZTranslatorGroup class
   4  //
   5  // Created on: <10-Jun-2002 11:05:00 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  /*! \file eztranslatorgroup.php
  30  */
  31  
  32  /*!
  33    \class eZTranslatorGroup eztranslatorgroup.php
  34    \ingroup eZTranslation
  35    \brief Allows for picking translator handlers according to context
  36  
  37  */
  38  
  39  include_once ( "lib/ezi18n/classes/eztranslatorhandler.php" );
  40  
  41  class eZTranslatorGroup extends eZTranslatorHandler
  42  {
  43      /*!
  44       Constructor
  45      */
  46      function eZTranslatorGroup( $is_key_based )
  47      {
  48          $this->eZTranslatorHandler( $is_key_based );
  49          $this->Handlers = array();
  50      }
  51  
  52      /*!
  53       \pure
  54       \return the translation message for the key \a $key or null if the key does not exist.
  55  
  56       This function must overridden if isKeyBased() is true.
  57      */
  58      function findKey( $key )
  59      {
  60          $num = $this->keyPick( $key );
  61          if ( $num >=0 and $num <= count( $this->Handlers ) )
  62          {
  63              $handler = $this->Handlers[$num];
  64              return $handler->findKey( $key );
  65          }
  66          $retValue = null;
  67          return $retValue;
  68      }
  69  
  70      /*!
  71       \pure
  72       \return the translation message for \a $source and \a $context or null if the key does not exist.
  73  
  74       If you know the translation key use findKey() instead.
  75  
  76       This function must overridden if isKeyBased() is true.
  77      */
  78      function findMessage( $context, $source, $comment = null )
  79      {
  80          $num = $this->pick( $context, $source, $comment );
  81          if ( $num >=0 and $num <= count( $this->Handlers ) )
  82          {
  83              $handler = $this->Handlers[$num];
  84              return $handler->findMessage( $context, $source, $comment );
  85          }
  86          $retValue = null;
  87          return $retValue;
  88      }
  89  
  90      /*!
  91       \pure
  92       \return the translation string for \a $source and \a $context or null if the translation does not exist.
  93  
  94       \sa findMessage, findKey
  95      */
  96      function translate( $context, $source, $comment = null )
  97      {
  98          $num = $this->pick( $context, $source, $comment );
  99          if ( $num >=0 and $num <= count( $this->Handlers ) )
 100          {
 101              $handler = $this->Handlers[$num];
 102              return $handler->translate( $context, $source, $comment );
 103          }
 104  
 105          return null;
 106      }
 107  
 108      /*!
 109       \pure
 110       \return the translation string for \a $key or null if the translation does not exist.
 111  
 112       \sa findMessage, findKey
 113      */
 114      function keyTranslate( $key )
 115      {
 116          $num = $this->keyPick( $key );
 117          if ( $num >=0 and $num <= count( $this->Handlers ) )
 118          {
 119              $handler = $this->Handlers[$num];
 120              return $handler->keyTranslate( $key );
 121          }
 122  
 123          return null;
 124      }
 125  
 126      /*!
 127       \pure
 128       Reimplement this to pick one of the registered handlers based on \a $key.
 129       \return -1 for no handler or a number within the handler range (starting from 0).
 130       \sa pick
 131      */
 132      function keyPick( $key )
 133      {
 134      }
 135  
 136      /*!
 137       \pure
 138       Reimplement this to pick one of the registered handlers based on \a $context, \a $source and \a $comment.
 139       \return -1 for no handler or a number within the handler range (starting from 0).
 140       \sa keyPick
 141      */
 142      function pick( $context, $source, $comment )
 143      {
 144      }
 145  
 146      /*!
 147       \return the number of registered handlers.
 148      */
 149      function handlerCount()
 150      {
 151          return count( $this->Handlers );
 152      }
 153  
 154      /*!
 155       Registers the handler object \a $handler.
 156      */
 157      function registerHandler( &$handler )
 158      {
 159          if ( !$this->isKeyBased() and $handler->isKeyBased() )
 160          {
 161              eZDebug::writeError( "Cannot register keybased handler for non-keybased group", "eZTranslatorGroup" );
 162              return false;
 163          }
 164          $this->Handlers[] =& $handler;
 165          return true;
 166      }
 167  
 168      /// \privatesection
 169      /// The array of grouped handlers
 170      var $Handlers;
 171  }
 172  
 173  ?>


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