r49399 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49398‎ | r49399 | r49400 >
Date:10:59, 11 April 2009
Author:philip
Status:reverted (Comments)
Tags:
Comment:
Add a new function named 'convert()', allow user to convert a string to specified variant in Abuse Filter. With the support of LanguageConverter which updated on r49397.
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.class.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.i18n.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.parser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php
@@ -365,6 +365,7 @@
366366 'bool' => 'castBool',
367367 'norm' => 'funcNorm',
368368 'ccnorm' => 'funcCCNorm',
 369+ 'convert' => 'funcConvert',
369370 'specialratio' => 'funcSpecialRatio',
370371 'rmspecials' => 'funcRMSpecials',
371372 'rmdoubles' => 'funcRMDoubles',
@@ -1254,6 +1255,16 @@
12551256 return new AFPData( AFPData::DString, $wgContLang->lc( $s ) );
12561257 }
12571258
 1259+ protected function funcConvert( $args ) {
 1260+ global $wgContLang;
 1261+ if( count( $args ) < 2 )
 1262+ throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos,
 1263+ array( 'lang_convert', 2, count($args) ) );
 1264+ $v = $args[0]->toString();
 1265+ $s = $args[1]->toString();
 1266+ return new AFPData( AFPData::DString, $wgContLang->convert( $s, false, $v ) );
 1267+ }
 1268+
12581269 protected function funcLen( $args ) {
12591270 if( count( $args ) < 1 )
12601271 throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos,
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php
@@ -57,6 +57,7 @@
5858 'length(string)' => 'length',
5959 'lcase(string)' => 'lcase',
6060 'ccnorm(string)' => 'ccnorm',
 61+ 'convert("vairant", string)' => 'convert',
6162 'rmdoubles(string)' => 'rmdoubles',
6263 'specialratio(string)' => 'specialratio',
6364 'norm(string)' => 'norm',
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php
@@ -243,6 +243,7 @@
244244 'abusefilter-edit-builder-funcs-length' => 'String length (length)',
245245 'abusefilter-edit-builder-funcs-lcase' => 'To lower case (lcase)',
246246 'abusefilter-edit-builder-funcs-ccnorm' => 'Normalise confusable characters (ccnorm)',
 247+ 'abusefilter-edit-builder-funcs-convert' => 'Convert string to specified variant (convert)',
247248 'abusefilter-edit-builder-funcs-rmdoubles' => 'Remove double-characters (rmdoubles)',
248249 'abusefilter-edit-builder-funcs-specialratio' => 'Special characters / total characters (specialratio)',
249250 'abusefilter-edit-builder-funcs-norm' => 'Normalise (norm)',
@@ -15939,6 +15940,7 @@
1594015941 'abusefilter-edit-builder-funcs-length' => '字符串长度(length)',
1594115942 'abusefilter-edit-builder-funcs-lcase' => '字母小写化(lcase)',
1594215943 'abusefilter-edit-builder-funcs-ccnorm' => '规范化易混淆字符(ccnorm)',
 15944+ 'abusefilter-edit-builder-funcs-convert' => '转换字符串到指定语言(convert)',
1594315945 'abusefilter-edit-builder-funcs-rmdoubles' => '去除双字节字符(rmdoubles)',
1594415946 'abusefilter-edit-builder-funcs-specialratio' => '特殊字符比(specialratio)',
1594515947 'abusefilter-edit-builder-funcs-norm' => '规范化(norm)',
@@ -16299,13 +16301,14 @@
1630016302 'abusefilter-edit-builder-misc-cond' => '條件式(if X then Y else Z)',
1630116303 'abusefilter-edit-builder-group-funcs' => '函數',
1630216304 'abusefilter-edit-builder-funcs-length' => '字串長度(length)',
16303 - 'abusefilter-edit-builder-funcs-lcase' => '改為小寫(lcase)',
16304 - 'abusefilter-edit-builder-funcs-ccnorm' => '修正混淆字符(ccnorm)',
16305 - 'abusefilter-edit-builder-funcs-rmdoubles' => '去除雙字元(rmdoubles)',
16306 - 'abusefilter-edit-builder-funcs-specialratio' => '特殊字元數與整體字元數比(specialratio)',
 16305+ 'abusefilter-edit-builder-funcs-lcase' => '改為小寫(lcase)',
 16306+ 'abusefilter-edit-builder-funcs-ccnorm' => '修正混淆字符(ccnorm)',
 16307+ 'abusefilter-edit-builder-funcs-convert' => '轉換字串到指定語言(convert)',
 16308+ 'abusefilter-edit-builder-funcs-rmdoubles' => '去除雙字元(rmdoubles)',
 16309+ 'abusefilter-edit-builder-funcs-specialratio' => '特殊字元數與整體字元數比(specialratio)',
1630716310 'abusefilter-edit-builder-funcs-norm' => '正常化(norm)',
16308 - 'abusefilter-edit-builder-funcs-count' => '字串 X 在字串 Y 裡出現的次數(count)',
16309 - 'abusefilter-edit-builder-funcs-rcount' => '正則表示式 X 出現在字串 Y 的次數(rcount)',
 16311+ 'abusefilter-edit-builder-funcs-count' => '字串 X 在字串 Y 裡出現的次數(count)',
 16312+ 'abusefilter-edit-builder-funcs-rcount' => '正則表示式 X 出現在字串 Y 的次數(rcount)',
1631016313 'abusefilter-edit-builder-funcs-rmwhitespace' => '去除空白字元(rmwhitespace)',
1631116314 'abusefilter-edit-builder-funcs-rmspecials' => '去除特殊字元(rmspecials)',
1631216315 'abusefilter-edit-builder-funcs-ip_in_range' => 'IP是否在範圍內?(ip_in_range)',

Follow-up revisions

RevisionCommit summaryAuthorDate
r51002Reverted r49855, r49656, r49401, r49399, r49397. The language converter canno...tstarling07:46, 26 May 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49397A new optional param for LanguageConverter::convert(), to enable a new functi...philip10:56, 11 April 2009

Comments

#Comment by Tim Starling (talk | contribs)   08:40, 19 May 2009

Suggest revert as per r49397

Status & tagging log