[MediaWiki-commits] [Gerrit] Add String Functions (version 0.4.2) - change (mediawiki...Foxway)

2013-06-11 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Add String Functions (version 0.4.2)
..


Add String Functions (version 0.4.2)

* add $wgNamespacesWithFoxway
* add Settings.php
* fix for passByReference
* small optimization for FArray

Change-Id: Id3a7f6ed3303660cff3bd3c3a41ffd45fa887993
---
M Foxway.body.php
M Foxway.i18n.php
M Foxway.php
A Settings.php
M includes/Debug.php
M includes/Interpreter.php
M includes/Runtime.php
M includes/RuntimeDebug.php
M includes/functions/BaseFunction.php
M includes/functions/FArray.php
A includes/functions/FString.php
M tests/phpunit/includes/InterpreterTest.php
12 files changed, 575 insertions(+), 158 deletions(-)

Approvals:
  Pastakhov: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Foxway.body.php b/Foxway.body.php
index 0013902..f707185 100644
--- a/Foxway.body.php
+++ b/Foxway.body.php
@@ -11,38 +11,12 @@
 
static $frames=array();
 
-   /**
-* Render function used in hook ParserFirstCallInit
-*
-* @param Parser $parser
-* @return string
-*/
-   public static function renderParserFunction(Parser $parser) {
-   $params = func_get_args();
-   array_shift( $params );
-
-   if( count($params)  2 ) {
-   return 'span class=error' . wfMessage( 
'foxway-not-enough-parameters' )-escaped() . '/span';
-   }
-
-   $action = strtolower( $params[0] );
-   switch ($action) {
-   case 'set':
-   $matches = array();
-   if( 
preg_match('/^\s*([^=]+)\s*=\s*(.+)\s*$/si', $params[1], $matches) ) {
-   $propertyName = $matches[1];
-   $propertyValue = $matches[2];
-   return \Foxway\ORM::SetProperty($propertyName, 
$propertyValue);
-   break;
-   }
-   break;
-   default:
-   return 'span class=error' . wfMessage( 
'foxway-unknown-action', $action )-escaped() . '/span';
-   break;
-   }
-   }
-
public static function render($input, array $args, Parser $parser, 
PPFrame $frame) {
+   global $wgNamespacesWithFoxway;
+   if( $wgNamespacesWithFoxway !== true  
empty($wgNamespacesWithFoxway[$frame-getTitle()-getNamespace()]) ) {
+   return Html::element( 'span', array('class'='error'), 
wfMessage('foxway-disabled-for-namespace', 
$frame-getTitle()-getNsText())-escaped() );
+   }
+
$is_debug = isset($args['debug']);
$return = '';
 
@@ -56,9 +30,7 @@
foreach ($result as $value) {
if( $value instanceof Foxway\iRawOutput ) {
$value = (string)$value;
-   }/*else{ // @todo 
-   $value = strtr( $value, array(''='amp;', 
''='lt;') );
-   }*/
+   }
}
 
if( $is_debug ) {
@@ -66,7 +38,7 @@
$return .= self::insertNoWiki( $parser, 
array_shift($result) ) . \n;
}
 
-   return $return . self::insertGeneral( $parser, 
$parser-recursiveTagParse(implode('', $result),$frame) );
+   return $return . self::insertGeneral( $parser, 
$parser-recursiveTagParse(implode($result),$frame) );
}
 
/**
diff --git a/Foxway.i18n.php b/Foxway.i18n.php
index 124afe8..fdc0eb9 100644
--- a/Foxway.i18n.php
+++ b/Foxway.i18n.php
@@ -13,7 +13,8 @@
  * @author pastakhov
  */
 $messages['en'] = array(
-   'foxway-desc' = 'Allows to store an object-oriented data and 
implements its own runtime for PHP code on pages',
+   'foxway-desc' = 'Adds in the wikitext parser the ability to use the 
syntax and functions of PHP',
+   'foxway-disabled-for-namespace' = 'Extension foxway disabled for this 
namespace $1',
'foxway-php-fatal-error-undefined-function' = 'PHP fatal error: Call 
to undefined function $1() on page $2 line $3.',
'foxway-php-not-variable-passed-by-reference' = 'PHP fatal error: Only 
variables can be passed by reference, function $1() on page $2 line $3.',
'foxway-php-syntax-error-unexpected' = 'PHP parse error: Syntax error, 
unexpected $1 in command line code on line $2.',
@@ -27,6 +28,8 @@
  */
 $messages['qqq'] = array(
'foxway-desc' = 
'{{desc|name=Foxway|url=https://www.mediawiki.org/wiki/Extension:Foxway}}',
+   'foxway-disabled-for-namespace' = 'Error message when trying use this 
extension on the pages of the namespace where it is not permitted, parameters:
+* $1 - the namespace name',

[MediaWiki-commits] [Gerrit] Add String Functions (version 0.4.2) - change (mediawiki...Foxway)

2013-06-10 Thread Pastakhov (Code Review)
Pastakhov has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/67651


Change subject: Add String Functions (version 0.4.2)
..

Add String Functions (version 0.4.2)

* fix for passByReference

Change-Id: Id3a7f6ed3303660cff3bd3c3a41ffd45fa887993
---
M Foxway.body.php
M Foxway.php
M includes/Debug.php
M includes/Interpreter.php
M includes/Runtime.php
M includes/RuntimeDebug.php
A includes/functions/FString.php
M tests/phpunit/includes/InterpreterTest.php
8 files changed, 302 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Foxway 
refs/changes/51/67651/1

diff --git a/Foxway.body.php b/Foxway.body.php
index 0013902..10aade1 100644
--- a/Foxway.body.php
+++ b/Foxway.body.php
@@ -66,7 +66,7 @@
$return .= self::insertNoWiki( $parser, 
array_shift($result) ) . \n;
}
 
-   return $return . self::insertGeneral( $parser, 
$parser-recursiveTagParse(implode('', $result),$frame) );
+   return $return . self::insertGeneral( $parser, 
$parser-recursiveTagParse(implode($result),$frame) );
}
 
/**
diff --git a/Foxway.php b/Foxway.php
index 2ddd4b0..6e5df7b 100644
--- a/Foxway.php
+++ b/Foxway.php
@@ -15,7 +15,7 @@
die( 'This file is an extension to MediaWiki and thus not a valid entry 
point.' );
 }
 
-define( 'Foxway_VERSION' , '0.4.1' );
+define( 'Foxway_VERSION' , '0.4.2' );
 
 // Register this extension on Special:Version
 $wgExtensionCredits['parserhook'][] = array(
@@ -64,6 +64,7 @@
 
 $wgAutoloadClasses['Foxway\\BaseFunction'] = $dir . 
'/includes/functions/BaseFunction.php';
 $wgAutoloadClasses['Foxway\\FArray']   = $dir . 
'/includes/functions/FArray.php';
+$wgAutoloadClasses['Foxway\\FString']  = $dir . 
'/includes/functions/FString.php';
 $wgAutoloadClasses['Foxway\\FVariable']= $dir . 
'/includes/functions/FVariable.php';
 
 // Resources
@@ -111,6 +112,7 @@
'rsort' = 1,
'shuffle' = 1,
'sort' = 1,
+   'similar_text' = 4, // 0b100
 );
 
 $wgFoxwayFunctions = array(
@@ -208,4 +210,39 @@
'sizeof',
'sort',
),
+   'FString' = array( // String Functions @see 
http://www.php.net/manual/en/ref.strings.php
+   'addcslashes',
+   'addslashes',
+   'chop',
+   'chr',
+   'chunk_split',
+   'convert_cyr_string',
+   'convert_uudecode',
+   'convert_uuencode',
+   'count_chars',
+   'crc32',
+   'crypt',
+   'explode',
+   'html_entity_decode',
+   'htmlentities',
+   'htmlspecialchars_decode',
+   'htmlspecialchars',
+   'implode',
+   'join',
+   'lcfirst',
+   'levenshtein',
+   'ltrim',
+   'md5',
+   'metaphone',
+   'money_format',
+   'nl_langinfo',
+   'nl2br',
+   'number_format',
+   'ord',
+   'printf',
+   'quotemeta',
+   'rtrim',
+   'sha1',
+   'similar_text',
+   ),
 );
diff --git a/includes/Debug.php b/includes/Debug.php
index 25f7d23..437bfca 100644
--- a/includes/Debug.php
+++ b/includes/Debug.php
@@ -77,6 +77,7 @@
case T_BOOL_CAST: // (bool)
case T_UNSET_CAST: // (unset)
case T_ECHO:
+   case T_PRINT:
case T_IF:
case T_ELSE:
case T_ELSEIF:
diff --git a/includes/Interpreter.php b/includes/Interpreter.php
index 57f0955..6426da0 100644
--- a/includes/Interpreter.php
+++ b/includes/Interpreter.php
@@ -292,6 +292,10 @@
$runtime-addCommand($id);
$parenthesFlags = 
FOXWAY_ALLOW_LIST_PARAMS | FOXWAY_EXPECT_SEMICOLON;
break;
+   case T_PRINT:
+   $runtime-addCommand($id);
+   $parenthesFlags = 
FOXWAY_EXPECT_SEMICOLON;
+   break;
case T_CONSTANT_ENCAPSED_STRING:
$is_apostrophe = substr($text, 0, 1) == 
'\'' ? true : false;
$string = substr($text, 1, -1);
@@ -443,6 +447,7 @@
}
switch ($command) {
case T_ECHO:
+   case T_PRINT: