[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/locale/ -> localefinder.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/file/finder/filefinder.class.php" );
   5      
   6      /**
   7       * \ingroup Locale
   8       *
   9        * updates the list of locales based on what we can find on disk. It will add new ones
  10       * and remove old ones.
  11       *
  12       * @see FileFinder
  13       */
  14      class LocaleFinder extends FileFinder
  15      {
  16  		function LocaleFinder( $localeFolder = null )
  17          {
  18              if( $localeFolder == null )
  19                  $localeFolder = Locale::getLocaleFolder();
  20  
  21              $this->_localeFolder = $localeFolder;
  22              
  23              $this->FileFinder( $this->_localeFolder );
  24          }
  25      
  26          /**
  27           * reimplemented from FileFinder::getKeyForFile so that we can adapt locale filenames
  28            * to look like keys from our array
  29           *
  30           * @see FileFinder::getKeyForFile()
  31           */
  32  		function getKeyForFile( $fileName )
  33          {
  34                // this regexp allows for more permissive locale names so that people can 
  35                // at least have things like locale_xx_YY_utf-8.php
  36              $result = preg_match( REGEXP_VALID_LOCALE, $fileName, $matches );
  37              
  38              // in case there is some crap in the locale/ folder, then ignore
  39              // it (that is, if the file name does not match our regexp!
  40              if( !$result ) 
  41                  $fileKey = null;
  42              else
  43                  $fileKey = $matches[1];
  44              
  45              return( $fileKey );
  46          }
  47  
  48          /**
  49           * provides default parameters for the FileFinder::find() method
  50            *
  51           * @see FileFinder::find()
  52           * @return An array with the new locales found in the disk
  53           */
  54  		function find()
  55          {
  56              // first find the new ones
  57              parent::find( Locales::getAvailableLocales(), "locale_*.php" );
  58              
  59              // and then return them, if any
  60              return( $this->getNew());
  61          }
  62      }
  63  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics