Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezalphabetoperator.php
Go to the documentation of this file.
1 <?php
13
18 class eZAlphabetOperator
19 {
25 public function __construct( $alphabet = 'alphabet' )
26 {
27 $this->Operators = array( $alphabet );
28 $this->Alphabet = $alphabet;
29 }
30
34 function operatorList()
35 {
36 return $this->Operators;
37 }
38
42 function namedParameterPerOperator()
43 {
44 return true;
45 }
46
47 function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$value, $namedParameters, $placement )
48 {
49 switch ( $operatorName )
50 {
51 case $this->Alphabet:
52 {
53 $alphabet = eZAlphabetOperator::fetchAlphabet();
54 $value = $alphabet;
55 } break;
56 }
57 }
58
63 static function fetchAlphabet()
64 {
65 $contentINI = eZINI::instance( 'content.ini' );
66
67 $alphabetRangeList = $contentINI->hasVariable( 'AlphabeticalFilterSettings', 'AlphabetList' )
68 ? $contentINI->variable( 'AlphabeticalFilterSettings', 'AlphabetList' )
69 : array();
70
71 $alphabetFromArray = $contentINI->hasVariable( 'AlphabeticalFilterSettings', 'ContentFilterList' )
72 ? $contentINI->variable( 'AlphabeticalFilterSettings', 'ContentFilterList' )
73 : array( 'default' );
74
75 // If alphabet list is empty
76 if ( count( $alphabetFromArray ) == 0 )
77 return false;
78
79 $alphabetRangeList = array_merge( $alphabetRangeList, array( 'default' => '97-122' ) );
80 $alphabet = array();
81 foreach ( $alphabetFromArray as $alphabetFrom )
82 {
83 // If $alphabetFrom exists in range array $alphabetRangeList
84 if ( isset( $alphabetRangeList[$alphabetFrom] ) )
85 {
86 $lettersArray = explode( ',', $alphabetRangeList[$alphabetFrom] );
87 foreach ( $lettersArray as $letter )
88 {
89 $rangeArray = explode( '-', $letter );
90 if ( isset( $rangeArray[1] ) )
91 {
92 $alphabet = array_merge( $alphabet, range( trim( $rangeArray[0] ), trim( $rangeArray[1] ) ) );
93 }
94 else
95 $alphabet = array_merge( $alphabet, array( trim( $letter ) ) );
96 }
97 }
98 }
99 // Get alphabet by default (eng-GB)
100 if ( count( $alphabet ) == 0 )
101 {
102 $rangeArray = explode( '-', $alphabetRangeList['default'] );
103 $alphabet = range( $rangeArray[0], $rangeArray[1] );
104 }
105 $resAlphabet = array();
106 $i18nINI = eZINI::instance( 'i18n.ini' );
107 $charset = $i18nINI->variable( 'CharacterSettings', 'Charset' );
108
109 $codec = eZTextCodec::instance( 'utf-8', $charset );
110
111 $utf8_codec = eZUTF8Codec::instance();
112 // Convert all letters of alphabet from unicode to utf-8 and from utf-8 to current locale
113 foreach ( $alphabet as $item )
114 {
115 $utf8Letter = $utf8_codec->toUtf8( $item );
116 $resAlphabet[] = $codec ? $codec->convertString( $utf8Letter ) : $utf8Letter;
117 }
118
119 return $resAlphabet;
120 }
121
123 public $Operators;
124 public $Alphabet;
125 }
126
127 ?>
eZAlphabetOperator
Definition: ezalphabetoperator.php:19
eZAlphabetOperator\operatorList
operatorList()
Definition: ezalphabetoperator.php:34
eZAlphabetOperator\$Alphabet
$Alphabet
Definition: ezalphabetoperator.php:124
eZAlphabetOperator\fetchAlphabet
static fetchAlphabet()
Definition: ezalphabetoperator.php:63
eZAlphabetOperator\modify
modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$value, $namedParameters, $placement)
Definition: ezalphabetoperator.php:47
eZAlphabetOperator\$Operators
$Operators
Definition: ezalphabetoperator.php:123
eZAlphabetOperator\namedParameterPerOperator
namedParameterPerOperator()
Definition: ezalphabetoperator.php:42
eZAlphabetOperator\__construct
__construct( $alphabet='alphabet')
Definition: ezalphabetoperator.php:25
eZTextCodec\instance
static instance( $inputCharsetCode, $outputCharsetCode=false, $alwaysReturn=true)
Definition: eztextcodec.php:446
eZUTF8Codec\instance
static instance()
Definition: ezutf8codec.php:239
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.