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

   1  <?php
   2  //
   3  // Definition of eZRandomTranslator 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 eZRandomTranslator eztranslatorgroup.php
  34    \ingroup eZTranslation
  35    \brief Translates text by picking randomly among it's sub handlers
  36  
  37  */
  38  
  39  include_once ( "lib/ezi18n/classes/eztranslatorgroup.php" );
  40  
  41  class eZRandomTranslator extends eZTranslatorGroup
  42  {
  43      /*!
  44       Constructor
  45      */
  46      function eZRandomTranslator( $is_key_based )
  47      {
  48          $this->eZTranslatorGroup( $is_key_based );
  49          srand( $this->makeSeed() );
  50      }
  51  
  52      /*!
  53       \reimp
  54       Returns a random pick from the registered handlers.
  55      */
  56      function keyPick( $key )
  57      {
  58          if ( $this->handlerCount() == 0 )
  59              return -1;
  60          return rand( 0, $this->handlerCount() - 1 );
  61      }
  62  
  63      /*!
  64       \reimp
  65       Returns a random pick from the registered handlers.
  66      */
  67      function pick( $context, $source, $comment )
  68      {
  69          if ( $this->handlerCount() == 0 )
  70              return -1;
  71          return rand( 0, $this->handlerCount() - 1 );
  72      }
  73  
  74      /*!
  75       \private
  76       Generates a seed usable for srand() and returns it.
  77      */
  78      function makeSeed()
  79      {
  80          list( $usec, $sec ) = explode( ' ', microtime() );
  81          return (float) $sec + ( (float) $usec * 100000 );
  82      }
  83  }
  84  
  85  ?>


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