http://www.mediawiki.org/wiki/Special:Code/MediaWiki/54816

Revision: 54816
Author:   siebrand
Date:     2009-08-11 22:01:32 +0000 (Tue, 11 Aug 2009)

Log Message:
-----------
stylize.php, formatting updates, trailing whitespace removed

Modified Paths:
--------------
    trunk/extensions/MathStatFunctions/MathStatFunctions.i18n.magic.php
    trunk/extensions/MathStatFunctions/MathStatFunctions.i18n.php
    trunk/extensions/MathStatFunctions/MathStatFunctions.php

Modified: trunk/extensions/MathStatFunctions/MathStatFunctions.i18n.magic.php
===================================================================
--- trunk/extensions/MathStatFunctions/MathStatFunctions.i18n.magic.php 
2009-08-11 21:47:55 UTC (rev 54815)
+++ trunk/extensions/MathStatFunctions/MathStatFunctions.i18n.magic.php 
2009-08-11 22:01:32 UTC (rev 54816)
@@ -1,34 +1,34 @@
 <?php
 
 if ( !defined( 'MEDIAWIKI' ) ) {
-        die( 'This file is a MediaWiki extension, it is not a valid entry 
point' );
+       die( 'This file is a MediaWiki extension, it is not a valid entry 
point' );
 }
 
 $wgMathStatFunctionsMagic = array();
 
 $wgMathStatFunctionsMagic['en'] = array(
-        'const'         => array( 0, 'const' ),
-        'median'        => array( 0, 'median' ),
-        'mean'          => array( 0, 'mean' ),
-        'exp'           => array( 0, 'exp' ),
-        'log'           => array( 0, 'log' ),
-        'ln'            => array( 0, 'ln' ),
-        'tan'           => array( 0, 'tan' ),
-        'atan'          => array( 0, 'atan', 'arctan' ),
-        'tanh'          => array( 0, 'tanh' ),
-        'atanh'         => array( 0, 'atanh', 'arctanh' ),
-        'cot'           => array( 0, 'cot' ),
-        'acot'          => array( 0, 'acot', 'arccot' ),
-        'cos'           => array( 0, 'cos', ),
-        'acos'          => array( 0, 'acos', 'arccos' ),
-        'cosh'          => array( 0, 'cosh', ),
-        'acosh'         => array( 0, 'acosh', 'arccosh' ),
-        'sec'           => array( 0, 'sec' ),
-        'asec'          => array( 0, 'asec', 'arcsec' ),
-        'sin'           => array( 0, 'sin' ),
-        'asin'          => array( 0, 'asin', 'arcsin' ),
-        'sinh'          => array( 0, 'sinh' ),
-        'asinh'         => array( 0, 'asinh', 'arcsinh' ),
-        'csc'           => array( 0, 'csc' ),
-        'acsc'          => array( 0, 'acsc', 'arccsc' ),
+       'const'         => array( 0, 'const' ),
+       'median'        => array( 0, 'median' ),
+       'mean'          => array( 0, 'mean' ),
+       'exp'           => array( 0, 'exp' ),
+       'log'           => array( 0, 'log' ),
+       'ln'            => array( 0, 'ln' ),
+       'tan'           => array( 0, 'tan' ),
+       'atan'          => array( 0, 'atan', 'arctan' ),
+       'tanh'          => array( 0, 'tanh' ),
+       'atanh'         => array( 0, 'atanh', 'arctanh' ),
+       'cot'           => array( 0, 'cot' ),
+       'acot'          => array( 0, 'acot', 'arccot' ),
+       'cos'           => array( 0, 'cos', ),
+       'acos'          => array( 0, 'acos', 'arccos' ),
+       'cosh'          => array( 0, 'cosh', ),
+       'acosh'         => array( 0, 'acosh', 'arccosh' ),
+       'sec'           => array( 0, 'sec' ),
+       'asec'          => array( 0, 'asec', 'arcsec' ),
+       'sin'           => array( 0, 'sin' ),
+       'asin'          => array( 0, 'asin', 'arcsin' ),
+       'sinh'          => array( 0, 'sinh' ),
+       'asinh'         => array( 0, 'asinh', 'arcsinh' ),
+       'csc'           => array( 0, 'csc' ),
+       'acsc'          => array( 0, 'acsc', 'arccsc' ),
 );

Modified: trunk/extensions/MathStatFunctions/MathStatFunctions.i18n.php
===================================================================
--- trunk/extensions/MathStatFunctions/MathStatFunctions.i18n.php       
2009-08-11 21:47:55 UTC (rev 54815)
+++ trunk/extensions/MathStatFunctions/MathStatFunctions.i18n.php       
2009-08-11 22:01:32 UTC (rev 54816)
@@ -8,10 +8,10 @@
 $messages = array();
 
 $messages['en'] = array(
-        'msfunc_desc'     => 'A collection of mathematical and statistical 
functions',
-        'msfunc_nan'      => 'Resulting value is not a number',
-        'msfunc_inf'      => 'Resulting value is infinity',
-        'msfunc_div_zero' => 'Division by zero',
+       'msfunc_desc'     => 'A collection of mathematical and statistical 
functions',
+       'msfunc_nan'      => 'Resulting value is not a number',
+       'msfunc_inf'      => 'Resulting value is infinity',
+       'msfunc_div_zero' => 'Division by zero',
 );
 
 /** Message documentation (Message documentation)

Modified: trunk/extensions/MathStatFunctions/MathStatFunctions.php
===================================================================
--- trunk/extensions/MathStatFunctions/MathStatFunctions.php    2009-08-11 
21:47:55 UTC (rev 54815)
+++ trunk/extensions/MathStatFunctions/MathStatFunctions.php    2009-08-11 
22:01:32 UTC (rev 54816)
@@ -1,20 +1,20 @@
 <?php
 
 if ( !defined( 'MEDIAWIKI' ) ) {
-        die( 'This file is a MediaWiki extension, it is not a valid entry 
point' );
+       die( 'This file is a MediaWiki extension, it is not a valid entry 
point' );
 }
 
 $wgExtensionCredits['parserhook'][] = array(
        'path' => __FILE__,
-        'name' => 'MathStatFunctions',
-        'version' => '1.1',
-        'author' => 'Carl Fürstenberg (AzaToth)',
-        'description' => 'A collection of mathematical and statistical 
functions',
-        'descriptionmsg' => 'msfunc_desc',
-        'url' => 'http://www.mediawiki.org/wiki/Extension:MathStatFunctions',
+       'name' => 'MathStatFunctions',
+       'version' => '1.1',
+       'author' => 'Carl Fürstenberg (AzaToth)',
+       'description' => 'A collection of mathematical and statistical 
functions',
+       'descriptionmsg' => 'msfunc_desc',
+       'url' => 'http://www.mediawiki.org/wiki/Extension:MathStatFunctions',
 );
 
-$wgExtensionMessagesFiles['MathStatFunctions'] = dirname(__FILE__) . 
'/MathStatFunctions.i18n.php';
+$wgExtensionMessagesFiles['MathStatFunctions'] = dirname( __FILE__ ) . 
'/MathStatFunctions.i18n.php';
 $wgExtensionFunctions[] = 'wfSetupMathStatFunctions';
 $wgHooks['LanguageGetMagic'][]       = 'wfMathStatFunctionsLanguageGetMagic';
 
@@ -22,416 +22,446 @@
  * \brief Exception class identifying that ParserFunctions is not available
  */
 class ParserFunctionsNotFoundException extends Exception {
-        public function __construct(){
-                $this->message = "<span style=\"color: red; font-size: 
large;\">ERROR: ParserFunctions was not found</span>";
-        }
+       public function __construct() {
+               $this->message = "<span style=\"color: red; font-size: 
large;\">ERROR: ParserFunctions was not found</span>";
+       }
 }
 
 class ExtMathStatFunctions {
 
-        public function __construct() {
-                if(!class_exists('ExtParserFunctions'))
-                        throw new ParserFunctionsNotFoundException;
+       public function __construct() {
+               if ( !class_exists( 'ExtParserFunctions' ) )
+                       throw new ParserFunctionsNotFoundException;
                # FIXME: Strict Standards: Non-static method 
ExtParserFunctions::getExprParser() should not be called statically, assuming 
$this from incompatible context in MathStatFunctions.php on line 34
-                $this->exprParser = ExtParserFunctions::getExprParser();
-        }
+               $this->exprParser = ExtParserFunctions::getExprParser();
+       }
 
-        public function constHook(&$parser, $key=''){
-                switch($key){
-                case 'pi':
-                        return '3.14159265358979323846';
-                        break;
-                case 'pi/2':
-                        return '1.57079632679489661923';
-                        break;
-                case 'pi/4':
-                        return '0.78539816339744830962';
-                        break;
-                case '1/pi':
-                        return '0.31830988618379067154';
-                        break;
-                case '2/pi':
-                        return '0.63661977236758134308';
-                        break;
-                case 'sqrt(pi)':
-                        return '1.77245385090551602729';
-                        break;
-                case '2/sqrt(pi)':
-                        return '1.12837916709551257390';
-                        break;
-                case 'e':
-                        return '2.7182818284590452354';
-                        break;
-                case 'log_2(e)':
-                        return '1.4426950408889634074';
-                        break;
-                case 'log_10(e)':
-                        return '0.43429448190325182765';
-                        break;
-                case 'ln(2)':
-                        return '0.69314718055994530942';
-                        break;
-                case 'ln(10)':
-                        return '2.30258509299404568402';
-                        break;
-                case 'sqrt(2)':
-                        return '1.41421356237309504880';
-                        break;
-                case 'sqrt(3)':
-                        return '1.73205080756887729352';
-                        break;
-                case '1/sqrt(2)':
-                case 'sqrt(1/2)':
-                        return '0.70710678118654752440';
-                        break;
-                case 'ln(pi)':
-                        return '1.14472988584940017414';
-                        break;
-                case 'euler':
-                        return '0.57721566490153286061';
-                        break;
-                case 'brion':
-                        return '6'; //Brions constant
-                        break;
-                default:
-                        return '';
-                }
-        }
+       public function constHook( &$parser, $key = '' ) {
+               switch( $key ) {
+                       case 'pi':
+                               return '3.14159265358979323846';
+                               break;
+                       case 'pi/2':
+                               return '1.57079632679489661923';
+                               break;
+                       case 'pi/4':
+                               return '0.78539816339744830962';
+                               break;
+                       case '1/pi':
+                               return '0.31830988618379067154';
+                               break;
+                       case '2/pi':
+                               return '0.63661977236758134308';
+                               break;
+                       case 'sqrt(pi)':
+                               return '1.77245385090551602729';
+                               break;
+                       case '2/sqrt(pi)':
+                               return '1.12837916709551257390';
+                               break;
+                       case 'e':
+                               return '2.7182818284590452354';
+                               break;
+                       case 'log_2(e)':
+                               return '1.4426950408889634074';
+                               break;
+                       case 'log_10(e)':
+                               return '0.43429448190325182765';
+                               break;
+                       case 'ln(2)':
+                               return '0.69314718055994530942';
+                               break;
+                       case 'ln(10)':
+                               return '2.30258509299404568402';
+                               break;
+                       case 'sqrt(2)':
+                               return '1.41421356237309504880';
+                               break;
+                       case 'sqrt(3)':
+                               return '1.73205080756887729352';
+                               break;
+                       case '1/sqrt(2)':
+                       case 'sqrt(1/2)':
+                               return '0.70710678118654752440';
+                               break;
+                       case 'ln(pi)':
+                               return '1.14472988584940017414';
+                               break;
+                       case 'euler':
+                               return '0.57721566490153286061';
+                               break;
+                       case 'brion':
+                               return '6'; // Brions constant
+                               break;
+                       default:
+                               return '';
+               }
+       }
 
-        public function medianHook(&$parser) {
-                $args = func_get_args();
-                array_shift( $args );
+       public function medianHook( &$parser ) {
+               $args = func_get_args();
+               array_shift( $args );
 
-                try{
-                        foreach($args as $expr){
-                                $res = $this->exprParser->doExpression($expr);
-                                $values[] = $res;
-                        }
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                sort($values);
-                $nbr_values = count($values);
-                if($nbr_values % 2 == 1){ // odd number of values
-                        return $values[$nbr_values / 2];
-                } else { // even number of values
-                        return ($values[$nbr_values / 2 -1] + 
$values[$nbr_values / 2]) / 2;
-                }
-        }
+               try {
+                       foreach ( $args as $expr ) {
+                               $res = $this->exprParser->doExpression( $expr );
+                               $values[] = $res;
+                       }
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               sort( $values );
+               $nbr_values = count( $values );
+               if ( $nbr_values % 2 == 1 ) { // odd number of values
+                       return $values[$nbr_values / 2];
+               }
+               else { // even number of values
+                       return ( $values[$nbr_values / 2 - 1] + 
$values[$nbr_values / 2] ) / 2;
+               }
+       }
 
-        public function meanHook(&$parser) {
-                $args = func_get_args();
-                array_shift( $args );
-                try{
-                        foreach($args as $expr){
-                                $res = $this->exprParser->doExpression($expr);
-                                $values[] = $res;
-                        }
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                return array_sum($values)/count($values);
-        }
+       public function meanHook( &$parser ) {
+               $args = func_get_args();
+               array_shift( $args );
+               try {
+                       foreach ( $args as $expr ) {
+                               $res = $this->exprParser->doExpression( $expr );
+                               $values[] = $res;
+                       }
+                       }
+                       catch ( ExprError $e ) {
+                               return $e->getMessage();
+                       }
+                       return array_sum( $values ) / count( $values );
+               }
 
-        public function expHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = exp($res);
-                return $this->check($result);
-        }
+       public function expHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = exp( $res );
+               return $this->check( $result );
+       }
 
-        public function lnHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = log($res);
+       public function lnHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = log( $res );
 
-                return $this->check($result);
-        }
+               return $this->check( $result );
+       }
 
-        public function logHook(&$parser, $expr = '' , $base = 10) {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = log($res,$base);
-                return $this->check(log($res,$base));
-        }
+       public function logHook( &$parser, $expr = '' , $base = 10 ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = log( $res, $base );
+               return $this->check( log( $res, $base ) );
+       }
 
-        public function tanHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = tan($res);
-                return $this->check($result);
-        }
+       public function tanHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = tan( $res );
+               return $this->check( $result );
+       }
 
-        public function atanHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = atan($res);
-                return $this->check($result);
-        }
+       public function atanHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = atan( $res );
+               return $this->check( $result );
+       }
 
-        public function tanhHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = tanh($res);
-                return $this->check($result);
-        }
+       public function tanhHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = tanh( $res );
+               return $this->check( $result );
+       }
 
-        public function cosHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = cos($res);
-                return $this->check($result);
-        }
+       public function cosHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = cos( $res );
+               return $this->check( $result );
+       }
 
-        public function acosHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = acos($res);
-                return $this->check($result);
-        }
+       public function acosHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = acos( $res );
+               return $this->check( $result );
+       }
 
-        public function coshHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = cosh($res);
-                return $this->check($result);
-        }
+       public function coshHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = cosh( $res );
+               return $this->check( $result );
+       }
 
-        public function sinHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = sin($res);
-                return $this->check($result);
-        }
+       public function sinHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = sin( $res );
+               return $this->check( $result );
+       }
 
-        public function asinHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = asin($res);
-                return $this->check($result);
-        }
+       public function asinHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = asin( $res );
+               return $this->check( $result );
+       }
 
-        public function sinhHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = sinh($res);
-                return $this->check($result);
-        }
+       public function sinhHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = sinh( $res );
+               return $this->check( $result );
+       }
 
-        public function atanhHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                if(function_exists('atanh')){
-                        $result = atanh($res);
-                } else {
-                        $result = log(sqrt(1-$res^2)/(1-$res));
-                }
-                return $this->check($result);
-        }
+       public function atanhHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               if ( function_exists( 'atanh' ) ) {
+                       $result = atanh( $res );
+               }
+               else {
+                       $result = log( sqrt( 1 - $res ^ 2 ) / ( 1 - $res ) );
+               }
+               return $this->check( $result );
+       }
 
-        public function acoshHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                if(function_exists('acosh')){
-                        $result = acosh($res);
-                } else {
-                        $result = log($res + abs(sqrt($res^2+1))); //may be 
wrong
-                }
-                return $this->check($result);
-        }
+       public function acoshHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               if ( function_exists( 'acosh' ) ) {
+                       $result = acosh( $res );
+               }
+               else {
+                       $result = log( $res + abs( sqrt( $res ^ 2 + 1 ) ) ); // 
may be wrong
+               }
+               return $this->check( $result );
+       }
 
-        public function asinhHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                if(function_exists('asinh')){
-                        $result = asinh($res);
-                } else {
-                        $result = log($res + sqrt($res^2+1));
-                }
-                $result = asinh($res);
-                return $this->check($result);
-        }
+       public function asinhHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               if ( function_exists( 'asinh' ) ) {
+                       $result = asinh( $res );
+               }
+               else {
+                       $result = log( $res + sqrt( $res ^ 2 + 1 ) );
+               }
+               $result = asinh( $res );
+               return $this->check( $result );
+       }
 
-        public function cotHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $tmp = tan($res);
-                if($tmp == 0){
+       public function cotHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $tmp = tan( $res );
+               if ( $tmp == 0 ) {
                        wfLoadExtensionMessages( 'MathStatFunctions' );
-                        return wfMsg('msfunc_div_zero');
-                }
-                $result = 1/$tmp;
-                return $this->check($result);
-        }
+                       return wfMsg( 'msfunc_div_zero' );
+               }
+               $result = 1 / $tmp;
+               return $this->check( $result );
+       }
 
-        public function secHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $tmp = cos($res);
-                if($tmp == 0){
+       public function secHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $tmp = cos( $res );
+               if ( $tmp == 0 ) {
                        wfLoadExtensionMessages( 'MathStatFunctions' );
-                        return wfMsg('msfunc_div_zero');
-                }
+                       return wfMsg( 'msfunc_div_zero' );
+               }
 
-                $result = 1/$tmp;
-                return $this->check($result);
-        }
+               $result = 1 / $tmp;
+               return $this->check( $result );
+       }
 
-        public function cscHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $tmp = sin($res);
-                if($tmp == 0){
+       public function cscHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $tmp = sin( $res );
+               if ( $tmp == 0 ) {
                        wfLoadExtensionMessages( 'MathStatFunctions' );
-                        return wfMsg('msfunc_div_zero');
-                }
-                $result = 1/$tmp;
-                return $this->check($result);
-        }
+                       return wfMsg( 'msfunc_div_zero' );
+               }
+               $result = 1 / $tmp;
+               return $this->check( $result );
+       }
 
-        public function acscHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = asin(pow($res,-1));
-                return $this->check($result);
-        }
+       public function acscHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = asin( pow( $res, - 1 ) );
+               return $this->check( $result );
+       }
 
-        public function asecHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = acos(pow($res,-1));
-                return $this->check($result);
-        }
+       public function asecHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = acos( pow( $res, - 1 ) );
+               return $this->check( $result );
+       }
 
-        public function acotHook(&$parser, $expr = '') {
-                try{
-                        $res = $this->exprParser->doExpression($expr);
-                } catch (ExprError $e){
-                        return $e->getMessage();
-                }
-                $result = M_PI2 - atan($res);
-                return $this->check($result);
-        }
+       public function acotHook( &$parser, $expr = '' ) {
+               try {
+                       $res = $this->exprParser->doExpression( $expr );
+               }
+               catch ( ExprError $e ) {
+                       return $e->getMessage();
+               }
+               $result = M_PI2 - atan( $res );
+               return $this->check( $result );
+       }
 
-        // Private
+       // Private
 
-        private $exprParser;
+       private $exprParser;
 
-        private function check($value) {
-                if(is_nan($value)){
+       private function check( $value ) {
+               if ( is_nan( $value ) ) {
                        wfLoadExtensionMessages( 'MathStatFunctions' );
-                        return wfMsg('msfunc_nan');
-                } elseif(is_infinite($value) and false){
+                       return wfMsg( 'msfunc_nan' );
+               }
+               elseif ( is_infinite( $value ) and false ) {
                        wfLoadExtensionMessages( 'MathStatFunctions' );
-                        return wfMsg('msfunc_inf').($value < 0 ? '-' : '+');
-                } else {
-                        return $value;
-                }
-        }
+                       return wfMsg( 'msfunc_inf' ) . ( $value < 0 ? '-' : '+' 
);
+               }
+               else {
+                       return $value;
+               }
+       }
 }
 
 function wfSetupMathStatFunctions() {
-        global $wgParser, $wgExtMathStatFunctions;
+       global $wgParser, $wgExtMathStatFunctions;
 
-        try {
-                $wgExtMathStatFunctions = new ExtMathStatFunctions;
-        } catch (ParserFunctionsNotFoundException $e) {
-                throw new FatalError('in '.$e->getFile().' on line 
'.$e->getLine().': '.$e->getMessage());
-        }
+       try {
+               $wgExtMathStatFunctions = new ExtMathStatFunctions;
+       }
+       catch ( ParserFunctionsNotFoundException $e ) {
+               throw new FatalError( 'in ' . $e->getFile() . ' on line ' . 
$e->getLine() . ': ' . $e->getMessage() );
+       }
 
-        $wgParser->setFunctionHook( 'const', array( &$wgExtMathStatFunctions, 
'constHook' ) );
-        $wgParser->setFunctionHook( 'median',        array( 
&$wgExtMathStatFunctions, 'medianHook' ) );
-        $wgParser->setFunctionHook( 'mean',          array( 
&$wgExtMathStatFunctions, 'meanHook' ) );
-        $wgParser->setFunctionHook( 'exp',           array( 
&$wgExtMathStatFunctions, 'expHook' ) );
-        $wgParser->setFunctionHook( 'log',           array( 
&$wgExtMathStatFunctions, 'logHook' ) );
-        $wgParser->setFunctionHook( 'ln',            array( 
&$wgExtMathStatFunctions, 'lnHook' ) );
-        $wgParser->setFunctionHook( 'tan',           array( 
&$wgExtMathStatFunctions, 'tanHook' ) );
-        $wgParser->setFunctionHook( 'atan',          array( 
&$wgExtMathStatFunctions, 'atanHook' ) );
-        $wgParser->setFunctionHook( 'tanh',          array( 
&$wgExtMathStatFunctions, 'tanhHook' ) );
-        $wgParser->setFunctionHook( 'atanh', array( &$wgExtMathStatFunctions, 
'atanhHook' ) );
-        $wgParser->setFunctionHook( 'cot',           array( 
&$wgExtMathStatFunctions, 'cotHook' ) );
-        $wgParser->setFunctionHook( 'acot',          array( 
&$wgExtMathStatFunctions, 'acotHook' ) );
-        $wgParser->setFunctionHook( 'cos',           array( 
&$wgExtMathStatFunctions, 'cosHook' ) );
-        $wgParser->setFunctionHook( 'acos',          array( 
&$wgExtMathStatFunctions, 'acosHook' ) );
-        $wgParser->setFunctionHook( 'cosh',          array( 
&$wgExtMathStatFunctions, 'coshHook' ) );
-        $wgParser->setFunctionHook( 'acosh', array( &$wgExtMathStatFunctions, 
'acoshHook' ) );
-        $wgParser->setFunctionHook( 'sec',           array( 
&$wgExtMathStatFunctions, 'secHook' ) );
-        $wgParser->setFunctionHook( 'asec',          array( 
&$wgExtMathStatFunctions, 'asecHook' ) );
-        $wgParser->setFunctionHook( 'sin',           array( 
&$wgExtMathStatFunctions, 'sinHook' ) );
-        $wgParser->setFunctionHook( 'asin',          array( 
&$wgExtMathStatFunctions, 'asinHook' ) );
-        $wgParser->setFunctionHook( 'sinh',          array( 
&$wgExtMathStatFunctions, 'sinhHook' ) );
-        $wgParser->setFunctionHook( 'asinh', array( &$wgExtMathStatFunctions, 
'asinhHook' ) );
-        $wgParser->setFunctionHook( 'csc',           array( 
&$wgExtMathStatFunctions, 'cscHook' ) );
-        $wgParser->setFunctionHook( 'acsc',          array( 
&$wgExtMathStatFunctions, 'acscHook' ) );
+       $wgParser->setFunctionHook( 'const',  array( &$wgExtMathStatFunctions, 
'constHook' ) );
+       $wgParser->setFunctionHook( 'median', array( &$wgExtMathStatFunctions, 
'medianHook' ) );
+       $wgParser->setFunctionHook( 'mean',   array( &$wgExtMathStatFunctions, 
'meanHook' ) );
+       $wgParser->setFunctionHook( 'exp',    array( &$wgExtMathStatFunctions, 
'expHook' ) );
+       $wgParser->setFunctionHook( 'log',    array( &$wgExtMathStatFunctions, 
'logHook' ) );
+       $wgParser->setFunctionHook( 'ln',     array( &$wgExtMathStatFunctions, 
'lnHook' ) );
+       $wgParser->setFunctionHook( 'tan',    array( &$wgExtMathStatFunctions, 
'tanHook' ) );
+       $wgParser->setFunctionHook( 'atan',   array( &$wgExtMathStatFunctions, 
'atanHook' ) );
+       $wgParser->setFunctionHook( 'tanh',   array( &$wgExtMathStatFunctions, 
'tanhHook' ) );
+       $wgParser->setFunctionHook( 'atanh',  array( &$wgExtMathStatFunctions, 
'atanhHook' ) );
+       $wgParser->setFunctionHook( 'cot',    array( &$wgExtMathStatFunctions, 
'cotHook' ) );
+       $wgParser->setFunctionHook( 'acot',   array( &$wgExtMathStatFunctions, 
'acotHook' ) );
+       $wgParser->setFunctionHook( 'cos',    array( &$wgExtMathStatFunctions, 
'cosHook' ) );
+       $wgParser->setFunctionHook( 'acos',   array( &$wgExtMathStatFunctions, 
'acosHook' ) );
+       $wgParser->setFunctionHook( 'cosh',   array( &$wgExtMathStatFunctions, 
'coshHook' ) );
+       $wgParser->setFunctionHook( 'acosh',  array( &$wgExtMathStatFunctions, 
'acoshHook' ) );
+       $wgParser->setFunctionHook( 'sec',    array( &$wgExtMathStatFunctions, 
'secHook' ) );
+       $wgParser->setFunctionHook( 'asec',   array( &$wgExtMathStatFunctions, 
'asecHook' ) );
+       $wgParser->setFunctionHook( 'sin',    array( &$wgExtMathStatFunctions, 
'sinHook' ) );
+       $wgParser->setFunctionHook( 'asin',   array( &$wgExtMathStatFunctions, 
'asinHook' ) );
+       $wgParser->setFunctionHook( 'sinh',   array( &$wgExtMathStatFunctions, 
'sinhHook' ) );
+       $wgParser->setFunctionHook( 'asinh',  array( &$wgExtMathStatFunctions, 
'asinhHook' ) );
+       $wgParser->setFunctionHook( 'csc',    array( &$wgExtMathStatFunctions, 
'cscHook' ) );
+       $wgParser->setFunctionHook( 'acsc',   array( &$wgExtMathStatFunctions, 
'acscHook' ) );
 
-        return true;
+       return true;
 }
 
 function wfMathStatFunctionsLanguageGetMagic( &$magicWords, $langCode ) {
-        global $wgMathStatFunctionsMagic;
+       global $wgMathStatFunctionsMagic;
        require_once( dirname(__FILE__) . '/MathStatFunctions.i18n.magic.php' );
 
-        if(!in_array($langCode,$wgMathStatFunctionsMagic)) $langCode = 'en';
-        $magicWords = array_merge($magicWords, 
$wgMathStatFunctionsMagic[$langCode]);
-        return true;
+       if ( !in_array( $langCode, $wgMathStatFunctionsMagic ) ) $langCode = 
'en';
+       $magicWords = array_merge( $magicWords, 
$wgMathStatFunctionsMagic[$langCode] );
+       return true;
 }



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to