[ 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/ -> ez1337translator.php (source)

   1  <?php
   2  //
   3  // Definition of eZ1337Translator class
   4  //
   5  // Created on: <07-Jun-2002 12:40:42 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 ez1337translator.php
  30  */
  31  
  32  /*!
  33    \class eZ1337Translator ez1337translator.php
  34    \ingroup eZTranslation
  35    \brief Translates text into the leet (1337) language
  36  
  37    It translates the following characters/strings
  38    - to - 2
  39    - for - 4
  40    - ate - 8
  41    - you - u
  42    - l - 1
  43    - e - 3
  44    - o - 0
  45    - a - 4
  46    - t - 7
  47  
  48  */
  49  
  50  include_once ( "lib/ezi18n/classes/eztranslatorhandler.php" );
  51  
  52  class eZ1337Translator extends eZTranslatorHandler
  53  {
  54      /*!
  55       Construct the translator and loads the translation file $file if is set and exists.
  56      */
  57      function eZ1337Translator()
  58      {
  59          $this->eZTranslatorHandler( false );
  60  
  61          $this->Messages = array();
  62      }
  63  
  64      /*!
  65       \reimp
  66      */
  67      function findMessage( $context, $source, $comment = null )
  68      {
  69          $man = eZTranslatorManager::instance();
  70          $key = $man->createKey( $context, $source, $comment );
  71  
  72          if ( !isset( $this->Messages[$key] ) )
  73          {
  74              $translation = $this->leetify( $source );
  75              $this->Messages[$key] = $man->createMessage( $context, $source, $comment, $translation );
  76          }
  77  
  78          return $this->Messages[$key];
  79      }
  80  
  81      /*!
  82       Translates the text into 1337 code.
  83      */
  84      function &leetify( $text )
  85      {
  86          $text = preg_replace( "/to/", "2", $text );
  87          $text = preg_replace( "/for/", "4", $text );
  88          $text = preg_replace( "/ate/", "8", $text );
  89          $text = preg_replace( "/you/", "u", $text );
  90          $text = preg_replace( array( "/l/",
  91                                       "/e/",
  92                                       "/o/",
  93                                       "/a/",
  94                                       "/t/" ),
  95                                array( "1",
  96                                       "3",
  97                                       "0",
  98                                       "4",
  99                                       "7" ), $text );
 100          return $text;
 101      }
 102  
 103      /*!
 104       \reimp
 105      */
 106      function translate( $context, $source, $comment = null )
 107      {
 108          $msg = $this->findMessage( $context, $source, $comment );
 109          if ( $msg !== null )
 110          {
 111              return $msg["translation"];
 112          }
 113  
 114          return null;
 115      }
 116  
 117      /*!
 118       \static
 119       Initialize the bork translator if this is not allready done.
 120      */
 121      function &initialize()
 122      {
 123          $translator =& $GLOBALS["eZ1337Translator"];
 124          if ( isset( $translator ) and get_class( $translator ) == "ez1337translator" )
 125              return $translator;
 126          $translator = new eZ1337Translator();
 127          $man =& eZTranslatorManager::instance();
 128          $man->registerHandler( $translator );
 129          return $translator;
 130      }
 131  
 132      /// \privatesection
 133      /// Contains the hash table with cached 1337 translations
 134      var $Messages;
 135  }
 136  
 137  ?>


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