https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113575

Revision: 113575
Author:   reedy
Date:     2012-03-11 17:06:29 +0000 (Sun, 11 Mar 2012)
Log Message:
-----------
Add $wgExtensionCredits

Add all consonants

Documentation

Modified Paths:
--------------
    trunk/extensions/LuaFoo/LuaFoo.i18n.php
    trunk/extensions/LuaFoo/LuaFoo.php
    trunk/extensions/LuaFoo/includes/Converter.php
    trunk/extensions/LuaFoo/includes/SpecialLuaTranslation.php

Modified: trunk/extensions/LuaFoo/LuaFoo.i18n.php
===================================================================
--- trunk/extensions/LuaFoo/LuaFoo.i18n.php     2012-03-11 16:46:58 UTC (rev 
113574)
+++ trunk/extensions/LuaFoo/LuaFoo.i18n.php     2012-03-11 17:06:29 UTC (rev 
113575)
@@ -2,6 +2,7 @@
 
 $messages = array();
 $messages['en'] = array(
+       'luafoo-desc' => 'Translates templates to Lua',
        'luafoo-luatranslation' => 'Translate template to Lua',
        'luafoo-convert-title' => 'Template to convert to Lua:',
        'luafoo-convert-submit' => 'Convert',

Modified: trunk/extensions/LuaFoo/LuaFoo.php
===================================================================
--- trunk/extensions/LuaFoo/LuaFoo.php  2012-03-11 16:46:58 UTC (rev 113574)
+++ trunk/extensions/LuaFoo/LuaFoo.php  2012-03-11 17:06:29 UTC (rev 113575)
@@ -4,7 +4,16 @@
        exit( 1 );
 }
 
+$wgExtensionCredits['specialpage'][] = array(
+       'path' => __FILE__,
+       'name' => 'LuaFoo',
+       'url' => 'https://www.mediawiki.org/wiki/Extension:LuaFoo',
+       'author' => 'Tim Starling',
+       'descriptionmsg' => 'luafoo-desc',
+);
+
 $lfip = dirname( __FILE__ );
+
 $wgAutoloadClasses['LuaFoo_SpecialLuaTranslation'] = 
"$lfip/includes/SpecialLuaTranslation.php";
 $wgAutoloadClasses['LuaFoo_Converter'] = "$lfip/includes/Converter.php";
 

Modified: trunk/extensions/LuaFoo/includes/Converter.php
===================================================================
--- trunk/extensions/LuaFoo/includes/Converter.php      2012-03-11 16:46:58 UTC 
(rev 113574)
+++ trunk/extensions/LuaFoo/includes/Converter.php      2012-03-11 17:06:29 UTC 
(rev 113575)
@@ -24,6 +24,11 @@
                'pfunc_if' => 'pfunc_if'
        );
 
+       /**
+        * @param $title Title
+        * @param $language
+        * @return string
+        */
        static function convert( $title, $language ) {
                $converter = new self( $language );
                $code = $converter->convertTemplate( $title );
@@ -42,6 +47,10 @@
                }
        }
 
+       /**
+        * @param $title Title
+        * @return LuaFoo_Converter_Block
+        */
        function convertTemplate( $title ) {
                $funcName = $this->titleToIdentifier( $title );
                $deps = $this->newDeps();
@@ -63,10 +72,18 @@
                return $block;
        }
 
+       /**
+        * @return LuaFoo_Converter_Deps
+        */
        function newDeps() {
                return new LuaFoo_Converter_Deps;
        }
 
+       /**
+        * @param $value
+        * @return LuaFoo_Converter_Expression
+        * @throws MWException
+        */
        function newLiteral( $value ) {
                if ( !is_string( $value ) && !is_numeric( $value ) && 
!is_array( $value ) ) {
                        throw new MWException( __METHOD__.': invalid literal 
type' );
@@ -74,12 +91,20 @@
                return new LuaFoo_Converter_Expression( 'literal', array( 
$value ) );
        }
 
+       /**
+        * @param $hash
+        * @return LuaFoo_Converter_Expression
+        */
        function newHash( $hash ) {
                return new LuaFoo_Converter_Expression( 'hash', array_merge(
                        array_map( array( $this, 'newLiteral' ), array_keys( 
$hash ) ),
                        array_values( $hash ) ) );
        }
 
+       /**
+        * @param $items
+        * @return LuaFoo_Converter_Expression|mixed
+        */
        function newConcat( $items ) {
                $filteredItems = array();
                foreach ( $items as $item ) {
@@ -142,6 +167,11 @@
                }
        }
 
+       /**
+        * @param $expr
+        * @param $deps
+        * @return LuaFoo_Converter_Expression
+        */
        function newTrim( $expr, $deps ) {
                if ( $expr->op === 'literal' ) {
                        // Trim a literal
@@ -166,6 +196,12 @@
                }
        }
 
+       /**
+        * @param $name
+        * @param $args
+        * @param $deps
+        * @return LuaFoo_Converter_Expression
+        */
        function newParserFunctionCall( $name, $args, $deps ) {
                if ( isset( $this->inlineFunctions[$name] ) ) {
                        $inlineFunc = $this->inlineFunctions[$name];
@@ -177,10 +213,19 @@
                return $this->newExpression( 'call', $args );
        }
 
+       /**
+        * @param $op
+        * @param $args
+        * @return LuaFoo_Converter_Expression
+        */
        function newExpression( $op, $args ) {
                return new LuaFoo_Converter_Expression( $op, $args );
        }
 
+       /**
+        * @param $title Title
+        * @return mixed|string
+        */
        function titleToIdentifier( $title ) {
                $id = '';
                if ( $title->getNamespace() == NS_TEMPLATE ) {
@@ -195,11 +240,20 @@
                return $id;
        }
 
+       /**
+        * @param $name string
+        * @return string
+        */
        function parserFunctionToIdentifier( $name ) {
                $name = preg_replace( '/[^\w\177-\377]/', '_', $name );
                return "pfunc_$name";
        }
 
+       /**
+        * @param $title Title
+        * @param $deps
+        * @return LuaFoo_Converter_Expression|mixed
+        */
        function getTemplateExpression( $title, $deps ) {
                $rev = Revision::newFromTitle( $title );
                if ( !$rev ) {
@@ -217,6 +271,12 @@
                return $expression;
        }
 
+       /**
+        * @param $contextNode 
PPNode_Hash_Array|PPNode_Hash_Attr|PPNode_Hash_Text|PPNode_Hash_Tree
+        * @param $deps
+        * @return LuaFoo_Converter_Expression|mixed
+        * @throws MWException
+        */
        function expand( $contextNode, $deps ) {
                if ( is_string( $contextNode ) ) {
                        return $this->newLiteral( $contextNode );
@@ -256,6 +316,11 @@
                }
        }
 
+       /**
+        * @param $bits
+        * @param $deps
+        * @return LuaFoo_Converter_Expression|mixed
+        */
        function expandTemplate( $bits, $deps ) {
                global $wgContLang;
 
@@ -365,6 +430,11 @@
                }
        }
 
+       /**
+        * @param $piece
+        * @param $deps
+        * @return LuaFoo_Converter_Expression
+        */
        function expandTemplateArg( $piece, $deps ) {
                $parts = $piece['parts'];
                $nameExpr = $this->newTrim( $this->expand( $piece['title'], 
$deps ), $deps );
@@ -394,6 +464,11 @@
                ) );
        }
 
+       /**
+        * @param $args
+        * @param $deps
+        * @return LuaFoo_Converter_Expression
+        */
        function pfunc_if( $args, $deps ) {
                if ( isset( $args[0] ) ) {
                        $condition = $this->newExpression( 'equals', array(
@@ -428,14 +503,24 @@
                $this->converter = $converter;
        }
 
+       /**
+        * @return LuaFoo_Converter_Block
+        */
        function newBlock() {
                return new LuaFoo_Converter_Block( $this );
        }
 
+       /**
+        * @param $seed
+        * @return LuaFoo_Converter_Frame
+        */
        function newFrame( $seed ) {
                return new LuaFoo_Converter_Frame( $this, $seed );
        }
 
+       /**
+        * @param $name
+        */
        function getRuntimeBlock( $name ) {
                if ( $this->runtimeBlocks === null ) {
                        $this->setupRuntime();
@@ -485,6 +570,12 @@
                'while'
        );
 
+       /**
+        * @param $name
+        * @param $argNames
+        * @param $expression
+        * @return LuaFoo_Converter_Block
+        */
        public function makeFunction( $name, $argNames, $expression ) {
                $frame = $this->newFrame( $name );
                $block = $this->expressionToBlock( $expression, $frame );
@@ -504,10 +595,19 @@
                return $func;
        }
 
+       /**
+        * @return array
+        */
        public function getKeywords() {
                return $this->keywords;
        }
 
+       /**
+        * @param $expression
+        * @param $frame LuaFoo_Converter_Frame
+        * @return LuaFoo_Converter_Block
+        * @throws MWException
+        */
        protected function expressionToBlock( $expression, $frame ) {
                if ( !($expression instanceof LuaFoo_Converter_Expression ) ) {
                        throw new MWException( 'Non-expression passed to ' . 
__METHOD__ );
@@ -616,11 +716,20 @@
                return $block;
        }
 
+       /**
+        * @param $name string
+        * @return bool
+        */
        public function isName( $name ) {
                return !in_array( $name, $this->keywords )
                        && preg_match( '/^[a-zA-Z_][a-zA-Z0-9_]*$/', $name );
        }
 
+       /**
+        * @param $input
+        * @return float|string
+        * @throws MWException
+        */
        protected function encodeLiteral( $input ) {
                if ( is_string( $input ) ) {
                        $result = strtr( $input, array(
@@ -654,6 +763,11 @@
                }
        }
 
+       /**
+        * @param $context
+        * @param $arg
+        * @return bool
+        */
        protected function needsBrackets( $context, $arg ) {
                if ( isset( $this->binaryPrecedence[ $context->op ] )
                        && isset( $this->binaryPrecedence[ $arg->op ] ) )
@@ -720,6 +834,10 @@
                }       
        }
 
+       /**
+        * @param $name
+        * @return LuaFoo_Converter_Block
+        */
        protected function getRuntimeUnimplementedBlock( $name ) {
                $block = $this->newBlock();
                $block->addItems( array(
@@ -732,6 +850,10 @@
                return $block;
        }
 
+       /**
+        * @param $block LuaFoo_Converter_Block
+        * @param $frame
+        */
        protected function addLocalDeclarations( $block, $frame ) {
                foreach ( $frame->variables as $var => $dummy ) {
                        $block->prependItem( "local $var" );
@@ -784,10 +906,16 @@
                return $out;
        }
 
+       /**
+        * @return LuaFoo_Converter_Indent
+        */
        function indent() {
                return new LuaFoo_Converter_Indent;
        }
 
+       /**
+        * @return LuaFoo_Converter_Unindent
+        */
        function unindent() {
                return new LuaFoo_Converter_Unindent;
        }
@@ -822,7 +950,7 @@
 }
 
 class LuaFoo_Converter_Frame {
-       static $consonants = 'bdfghjklmnprstvwz';
+       static $consonants = 'bcdfghjklmnpqrstvwxyz';
        static $vowels = 'aeiou';
 
        var $variables = array();
@@ -834,6 +962,9 @@
                srand( crc32( $seed ) );
        }
 
+       /**
+        * @return string
+        */
        public function newVariable() {
                do {
                        $length = rand( 5, 8 );
@@ -852,6 +983,10 @@
                return $s;
        }
 
+       /**
+        * @param $expr
+        * @return bool
+        */
        public function getVariable( $expr ) {
                $hash = $expr->getHash();
                if ( isset( $this->variablesByHash[$hash] ) ) {

Modified: trunk/extensions/LuaFoo/includes/SpecialLuaTranslation.php
===================================================================
--- trunk/extensions/LuaFoo/includes/SpecialLuaTranslation.php  2012-03-11 
16:46:58 UTC (rev 113574)
+++ trunk/extensions/LuaFoo/includes/SpecialLuaTranslation.php  2012-03-11 
17:06:29 UTC (rev 113575)
@@ -10,8 +10,6 @@
        }
 
        function execute( $par ) {
-               global $wgRequest;
-
                $this->setHeaders();
 
                $form = new HTMLForm( array(


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to