Index: trunk/extensions/CategoryMultisortChinese/CategoryMultisortChinese.hooks.php |
— | — | @@ -100,66 +100,66 @@ |
101 | 101 | } |
102 | 102 | |
103 | 103 | function onCategoryMultisortSortkeys_splitString( $str ) { |
104 | | - global $wgContLang; |
105 | | - |
106 | | - $result = array(); |
107 | | - while ( $str ) { |
108 | | - $fc = $wgContLang->firstChar( $str ); |
109 | | - $result[] = $fc; |
110 | | - $str = substr( $str, strlen( $fc ) ); |
111 | | - } |
112 | | - return $result; |
| 104 | + global $wgContLang; |
| 105 | + |
| 106 | + $result = array(); |
| 107 | + while ( $str ) { |
| 108 | + $fc = $wgContLang->firstChar( $str ); |
| 109 | + $result[] = $fc; |
| 110 | + $str = substr( $str, strlen( $fc ) ); |
| 111 | + } |
| 112 | + return $result; |
113 | 113 | } |
114 | 114 | |
115 | 115 | function onCategoryMultisortSortkeys_buildMandarinSortkey( $data, $str ) { |
116 | | - $result = ''; |
117 | | - foreach ( $this->onCategoryMultisortSortkeys_splitString( $str ) as $ch ) { |
118 | | - # One UTF-8 character can have 4 bytes max. |
119 | | - $c = str_pad( $ch, 4 ); |
120 | | - $chcp = utf8ToCodepoint( $ch ); |
121 | | - # One Mandarin entry can have 7 bytes max. |
122 | | - $md = str_pad( array_key_exists( $chcp, $data->mandarin ) ? $data->mandarin[$chcp] : '', 7 ); |
123 | | - $result .= $md . $c; |
124 | | - } |
125 | | - return $result; |
| 116 | + $result = ''; |
| 117 | + foreach ( $this->onCategoryMultisortSortkeys_splitString( $str ) as $ch ) { |
| 118 | + # One UTF-8 character can have 4 bytes max. |
| 119 | + $c = str_pad( $ch, 4 ); |
| 120 | + $chcp = utf8ToCodepoint( $ch ); |
| 121 | + # One Mandarin entry can have 7 bytes max. |
| 122 | + $md = str_pad( array_key_exists( $chcp, $data->mandarin ) ? $data->mandarin[$chcp] : '', 7 ); |
| 123 | + $result .= $md . $c; |
| 124 | + } |
| 125 | + return $result; |
126 | 126 | } |
127 | 127 | |
128 | 128 | function onCategoryMultisortSortkeys_buildCantoneseSortkey( $data, $str ) { |
129 | | - $result = ''; |
130 | | - foreach ( $this->onCategoryMultisortSortkeys_splitString( $str ) as $ch ) { |
131 | | - # One UTF-8 character can have 4 bytes max. |
132 | | - $c = str_pad( $ch, 4 ); |
133 | | - $chcp = utf8ToCodepoint( $ch ); |
134 | | - # One Cantonese entry can have 7 bytes max ([a-z]{1,6}[1-6]). |
135 | | - $md = str_pad( array_key_exists( $chcp, $data->cantonese ) ? $data->cantonese[$chcp] : '', 7 ); |
136 | | - $result .= $md . $c; |
137 | | - } |
138 | | - return $result; |
| 129 | + $result = ''; |
| 130 | + foreach ( $this->onCategoryMultisortSortkeys_splitString( $str ) as $ch ) { |
| 131 | + # One UTF-8 character can have 4 bytes max. |
| 132 | + $c = str_pad( $ch, 4 ); |
| 133 | + $chcp = utf8ToCodepoint( $ch ); |
| 134 | + # One Cantonese entry can have 7 bytes max ([a-z]{1,6}[1-6]). |
| 135 | + $md = str_pad( array_key_exists( $chcp, $data->cantonese ) ? $data->cantonese[$chcp] : '', 7 ); |
| 136 | + $result .= $md . $c; |
| 137 | + } |
| 138 | + return $result; |
139 | 139 | } |
140 | 140 | |
141 | 141 | function onCategoryMultisortSortkeys_buildStrokeSortkey( $data, $str ) { |
142 | | - $result = ''; |
143 | | - foreach ( $this->onCategoryMultisortSortkeys_splitString( $str ) as $ch ) { |
144 | | - # One UTF-8 character can have 4 bytes max. |
145 | | - $c = str_pad( $ch, 4 ); |
146 | | - $chcp = utf8ToCodepoint( $ch ); |
147 | | - # One stroke entry always has 3 bytes, or blank if unavailable. |
148 | | - $s = str_pad( $this->onCategoryMultisortSortkeys_getStroke( $data, $chcp ), 3 ); |
149 | | - $result .= $s . $c; |
150 | | - } |
151 | | - return $result; |
| 142 | + $result = ''; |
| 143 | + foreach ( $this->onCategoryMultisortSortkeys_splitString( $str ) as $ch ) { |
| 144 | + # One UTF-8 character can have 4 bytes max. |
| 145 | + $c = str_pad( $ch, 4 ); |
| 146 | + $chcp = utf8ToCodepoint( $ch ); |
| 147 | + # One stroke entry always has 3 bytes, or blank if unavailable. |
| 148 | + $s = str_pad( $this->onCategoryMultisortSortkeys_getStroke( $data, $chcp ), 3 ); |
| 149 | + $result .= $s . $c; |
| 150 | + } |
| 151 | + return $result; |
152 | 152 | } |
153 | 153 | |
154 | 154 | function onCategoryMultisortSortkeys_buildRadicalSortkey( $data, $str ) { |
155 | | - $result = ''; |
156 | | - foreach ( $this->onCategoryMultisortSortkeys_splitString( $str ) as $ch ) { |
157 | | - # One UTF-8 character can have 4 bytes max. |
158 | | - $c = str_pad( $ch, 4 ); |
159 | | - $chcp = utf8ToCodepoint( $ch ); |
160 | | - # One radical-stroke entry always has 3 (radical) + 3 (stroke) = 6 bytes, or blank if unavailable. |
161 | | - $r = str_pad( $this->onCategoryMultisortSortkeys_getRadical( $data, $chcp ), 6 ); |
162 | | - $result .= $r . $c; |
163 | | - } |
164 | | - return $result; |
| 155 | + $result = ''; |
| 156 | + foreach ( $this->onCategoryMultisortSortkeys_splitString( $str ) as $ch ) { |
| 157 | + # One UTF-8 character can have 4 bytes max. |
| 158 | + $c = str_pad( $ch, 4 ); |
| 159 | + $chcp = utf8ToCodepoint( $ch ); |
| 160 | + # One radical-stroke entry always has 3 (radical) + 3 (stroke) = 6 bytes, or blank if unavailable. |
| 161 | + $r = str_pad( $this->onCategoryMultisortSortkeys_getRadical( $data, $chcp ), 6 ); |
| 162 | + $result .= $r . $c; |
| 163 | + } |
| 164 | + return $result; |
165 | 165 | } |
166 | 166 | } |