Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/59641
Change subject: Add a "ucase" function to convert the provided string to
uppercase.
......................................................................
Add a "ucase" function to convert the provided string to uppercase.
I basically took the lcase code and tweaked it to work for uppercase.
Bug: 47321
Change-Id: I230dbd99c27bf3a4a042befd6d334b4c0439bde0
---
M AbuseFilter.i18n.php
M AbuseFilter.parser.php
2 files changed, 23 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter
refs/changes/41/59641/1
diff --git a/AbuseFilter.i18n.php b/AbuseFilter.i18n.php
index be3f5ed..43d79df 100644
--- a/AbuseFilter.i18n.php
+++ b/AbuseFilter.i18n.php
@@ -283,6 +283,7 @@
'abusefilter-edit-builder-group-funcs' => 'Functions',
'abusefilter-edit-builder-funcs-length' => 'String length (length)',
'abusefilter-edit-builder-funcs-lcase' => 'To lower case (lcase)',
+ 'abusefilter-edit-builder-funcs-ucase' => 'To upper case (ucase)',
'abusefilter-edit-builder-funcs-ccnorm' => 'Normalize confusable
characters (ccnorm)',
'abusefilter-edit-builder-funcs-rmdoubles' => 'Remove double-characters
(rmdoubles)',
'abusefilter-edit-builder-funcs-specialratio' => 'Special characters /
total characters (specialratio)',
@@ -819,6 +820,7 @@
'abusefilter-edit-builder-group-funcs' => 'Group entry in dropdown
menu.',
'abusefilter-edit-builder-funcs-length' => "{{doc-important|Do not
translate \"'''length'''\".}} Abuse filter syntax option in a dropdown from the
group {{msg-mw|abusefilter-edit-builder-group-funcs}}.",
'abusefilter-edit-builder-funcs-lcase' => "{{doc-important|Do not
translate \"'''lcase'''\".}} Abuse filter syntax option in a dropdown from the
group {{msg-mw|abusefilter-edit-builder-group-funcs}}.",
+ 'abusefilter-edit-builder-funcs-ucase' => "{{doc-important|Do not
translate \"'''ucase'''\".}} Abuse filter syntax option in a dropdown from the
group {{msg-mw|abusefilter-edit-builder-group-funcs}}.",
'abusefilter-edit-builder-funcs-ccnorm' => "{{doc-important|Do not
translate \"'''ccnorm'''\".}} Abuse filter syntax option in a dropdown from the
group {{msg-mw|abusefilter-edit-builder-group-funcs}}.",
'abusefilter-edit-builder-funcs-rmdoubles' => '{{doc-important|Do not
translate "\'\'\'rmdoubles\'\'\'".}}
Abuse filter syntax option in a dropdown from the group
{{msg-mw|abusefilter-edit-builder-group-funcs}}.
diff --git a/AbuseFilter.parser.php b/AbuseFilter.parser.php
index fa38d5d..84e764f 100644
--- a/AbuseFilter.parser.php
+++ b/AbuseFilter.parser.php
@@ -583,9 +583,10 @@
*/
var $mVars;
- // length,lcase,ccnorm,rmdoubles,specialratio,rmspecials,norm,count
+ //
length,lcase,ucase,ccnorm,rmdoubles,specialratio,rmspecials,norm,count
static $mFunctions = array(
'lcase' => 'funcLc',
+ 'ucase' => 'funcUc',
'length' => 'funcLen',
'string' => 'castString',
'int' => 'castInt',
@@ -1679,6 +1680,25 @@
* @return AFPData
* @throws AFPUserVisibleException
*/
+ protected function funcUc( $args ) {
+ global $wgContLang;
+ if ( count( $args ) < 1 ) {
+ throw new AFPUserVisibleException(
+ 'notenoughargs',
+ $this->mCur->pos,
+ array( 'uc', 2, count( $args ) )
+ );
+ }
+ $s = $args[0]->toString();
+ return new AFPData( AFPData::DString, $wgContLang->uc( $s ) );
+ }
+
+
+ /**
+ * @param $args
+ * @return AFPData
+ * @throws AFPUserVisibleException
+ */
protected function funcLen( $args ) {
if ( count( $args ) < 1 ) {
throw new AFPUserVisibleException(
--
To view, visit https://gerrit.wikimedia.org/r/59641
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I230dbd99c27bf3a4a042befd6d334b4c0439bde0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits