[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/kernel/common/ -> ezalphabetoperator.php (source)

   1  <?php
   2  //
   3  // Definition of eZi18nOperator class
   4  //
   5  // Created on: <15-Aug-2006 12:15:07 vd>
   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  //!! eZKernel
  30  //! The class eZAlphabetOperator does
  31  /*!
  32  
  33  */
  34  
  35  
  36  class eZAlphabetOperator
  37  {
  38      /*!
  39      */
  40      function eZAlphabetOperator( $alphabet = 'alphabet' )
  41      {
  42          $this->Operators = array( $alphabet );
  43          $this->Alphabet = $alphabet;
  44      }
  45  
  46      /*!
  47       Returns the operators in this class.
  48      */
  49      function &operatorList()
  50      {
  51          return $this->Operators;
  52      }
  53  
  54      /*!
  55       \return true to tell the template engine that the parameter list exists per operator type.
  56      */
  57      function namedParameterPerOperator()
  58      {
  59          return true;
  60      }
  61  
  62      /*!
  63       \reimp
  64      */
  65      function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$value, &$namedParameters )
  66      {
  67          switch ( $operatorName )
  68          {
  69              case $this->Alphabet:
  70              {
  71                  $alphabet = eZAlphabetOperator::fetchAlphabet();
  72                  $value = $alphabet;
  73              } break;
  74          }
  75      }
  76  
  77      /*!
  78        Static
  79        Returns alphabet.
  80      */
  81      function fetchAlphabet()
  82      {
  83          include_once ( "lib/ezutils/classes/ezini.php" );
  84          $contentINI =& eZINI::instance( 'content.ini' );
  85  
  86          $alphabetRangeList = $contentINI->hasVariable( 'AlphabeticalFilterSettings', 'AlphabetList' )
  87                               ? $contentINI->variable( 'AlphabeticalFilterSettings', 'AlphabetList' )
  88                               : array();
  89  
  90          $alphabetFromArray = $contentINI->hasVariable( 'AlphabeticalFilterSettings', 'ContentFilterList' )
  91                               ? $contentINI->variable( 'AlphabeticalFilterSettings', 'ContentFilterList' )
  92                               : array( 'default' );
  93  
  94          // If alphabet list is empty
  95          if ( count( $alphabetFromArray ) == 0 )
  96              return false;
  97  
  98          $alphabetRangeList = array_merge( $alphabetRangeList, array( 'default' => '97-122' ) );
  99          $alphabet = array();
 100          foreach ( $alphabetFromArray as $alphabetFrom )
 101          {
 102              // If $alphabetFrom exists in range array $alphabetRangeList
 103              if ( isset( $alphabetRangeList[$alphabetFrom] ) )
 104              {
 105                  $lettersArray = explode( ',', $alphabetRangeList[$alphabetFrom] );
 106                  foreach ( $lettersArray as $letter )
 107                  {
 108                      $rangeArray =  explode( '-', $letter );
 109                      if ( isset( $rangeArray[1] ) )
 110                      {
 111                          $alphabet = array_merge( $alphabet, range( trim( $rangeArray[0] ), trim( $rangeArray[1] ) ) );
 112                      }
 113                      else
 114                          $alphabet = array_merge( $alphabet, array( trim( $letter ) ) );
 115                  }
 116              }
 117          }
 118          // Get alphabet by default (eng-GB)
 119          if ( count( $alphabet ) == 0 )
 120          {
 121              $rangeArray = explode( '-', $alphabetRangeList['default'] );
 122              $alphabet = range( $rangeArray[0], $rangeArray[1] );
 123          }
 124          $resAlphabet = array();
 125          $i18nINI =& eZINI::instance( 'i18n.ini' );
 126          $charset = $i18nINI->variable( 'CharacterSettings', 'Charset' );
 127  
 128          include_once ( 'lib/ezi18n/classes/eztextcodec.php' );
 129          $codec =& eZTextCodec::instance( 'utf-8', $charset );
 130  
 131          include_once ( "lib/ezi18n/classes/ezutf8codec.php" );
 132          $utf8_codec =& eZUTF8Codec::instance();
 133          // Convert all letters of alphabet from unicode to utf-8 and from utf-8 to current locale
 134          foreach ( $alphabet as $item )
 135          {
 136              $utf8Letter = $utf8_codec->toUtf8( $item );
 137              $resAlphabet[] = $codec ? $codec->convertString( $utf8Letter ) : $utf8Letter;
 138          }
 139  
 140          return $resAlphabet;
 141      }
 142  
 143      /// \privatesection
 144      var $Operators;
 145      var $Alphabet;
 146  };
 147  
 148  ?>


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