00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class eZAlphabetOperator
00039 {
00040
00041
00042 function eZAlphabetOperator( $alphabet = 'alphabet' )
00043 {
00044 $this->Operators = array( $alphabet );
00045 $this->Alphabet = $alphabet;
00046 }
00047
00048
00049
00050
00051 function &operatorList()
00052 {
00053 return $this->Operators;
00054 }
00055
00056
00057
00058
00059 function namedParameterPerOperator()
00060 {
00061 return true;
00062 }
00063
00064
00065
00066
00067 function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$value, &$namedParameters )
00068 {
00069 switch ( $operatorName )
00070 {
00071 case $this->Alphabet:
00072 {
00073 $alphabet = eZAlphabetOperator::fetchAlphabet();
00074 $value = $alphabet;
00075 } break;
00076 }
00077 }
00078
00079
00080
00081
00082
00083 function fetchAlphabet()
00084 {
00085 include_once( "lib/ezutils/classes/ezini.php" );
00086 $contentINI =& eZINI::instance( 'content.ini' );
00087
00088 $alphabetRangeList = $contentINI->hasVariable( 'AlphabeticalFilterSettings', 'AlphabetList' )
00089 ? $contentINI->variable( 'AlphabeticalFilterSettings', 'AlphabetList' )
00090 : array();
00091
00092 $alphabetFromArray = $contentINI->hasVariable( 'AlphabeticalFilterSettings', 'ContentFilterList' )
00093 ? $contentINI->variable( 'AlphabeticalFilterSettings', 'ContentFilterList' )
00094 : array( 'default' );
00095
00096
00097 if ( count( $alphabetFromArray ) == 0 )
00098 return false;
00099
00100 $alphabetRangeList = array_merge( $alphabetRangeList, array( 'default' => '97-122' ) );
00101 $alphabet = array();
00102 foreach ( $alphabetFromArray as $alphabetFrom )
00103 {
00104
00105 if ( isset( $alphabetRangeList[$alphabetFrom] ) )
00106 {
00107 $lettersArray = explode( ',', $alphabetRangeList[$alphabetFrom] );
00108 foreach ( $lettersArray as $letter )
00109 {
00110 $rangeArray = explode( '-', $letter );
00111 if ( isset( $rangeArray[1] ) )
00112 {
00113 $alphabet = array_merge( $alphabet, range( trim( $rangeArray[0] ), trim( $rangeArray[1] ) ) );
00114 }
00115 else
00116 $alphabet = array_merge( $alphabet, array( trim( $letter ) ) );
00117 }
00118 }
00119 }
00120
00121 if ( count( $alphabet ) == 0 )
00122 {
00123 $rangeArray = explode( '-', $alphabetRangeList['default'] );
00124 $alphabet = range( $rangeArray[0], $rangeArray[1] );
00125 }
00126 $resAlphabet = array();
00127 $i18nINI =& eZINI::instance( 'i18n.ini' );
00128 $charset = $i18nINI->variable( 'CharacterSettings', 'Charset' );
00129
00130 include_once( 'lib/ezi18n/classes/eztextcodec.php' );
00131 $codec =& eZTextCodec::instance( 'utf-8', $charset );
00132
00133 include_once( "lib/ezi18n/classes/ezutf8codec.php" );
00134 $utf8_codec =& eZUTF8Codec::instance();
00135
00136 foreach ( $alphabet as $item )
00137 {
00138 $utf8Letter = $utf8_codec->toUtf8( $item );
00139 $resAlphabet[] = $codec ? $codec->convertString( $utf8Letter ) : $utf8Letter;
00140 }
00141
00142 return $resAlphabet;
00143 }
00144
00145
00146 var $Operators;
00147 var $Alphabet;
00148 };
00149
00150 ?>