Add new parser function {{apiurl}}. Also, add new global $wgApiScript because manuall...
authorChad Horohoe <demon@users.mediawiki.org>
Wed, 30 Jul 2008 07:46:25 +0000 (07:46 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Wed, 30 Jul 2008 07:46:25 +0000 (07:46 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/Setup.php
includes/parser/CoreParserFunctions.php
languages/messages/MessagesEn.php

index f2a6209..aac2744 100644 (file)
@@ -25,6 +25,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   empt all content namespaces.)
 * $wgForwardSearchUrl has been removed entirely. Documented setting since 1.4
   has been $wgSearchForwardUrl.
+* $wgApiScript can now be defined if your API isn't named api.php or it's not
+  in the usual location. Setting to false defaults to "$wgScriptPath/api
+  $wgScriptExtension".
 
 === New features in 1.14 ===
 
@@ -36,6 +39,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   'EditSectionLinkForOther' hook has been removed, but 'EditSectionLink' is
   run in all cases instead, so extensions using the old hooks should still work
   if they ran roughly the same code for both hooks (as is almost certain).
+* New parser function {{apiurl:}} links to the local API. {{apiurl:help}} would
+  link to action=help. Other params are passed as well.
 
 === Bug fixes in 1.14 ===
 
index e50f662..127b81d 100644 (file)
@@ -166,6 +166,7 @@ $wgMathPath         = false; ///< defaults to "{$wgUploadPath}/math"
 $wgMathDirectory    = false; ///< defaults to "{$wgUploadDirectory}/math"
 $wgTmpDirectory     = false; ///< defaults to "{$wgUploadDirectory}/tmp"
 $wgUploadBaseUrl    = "";
+$wgApiScript        = false; ///< defaults to "{$wgScriptPath}/api{$wgScriptExtension}"
 /**@}*/
 
 /**
index cf8aa9b..5d3322b 100644 (file)
@@ -53,6 +53,7 @@ if( $wgTmpDirectory === false ) $wgTmpDirectory = "{$wgUploadDirectory}/tmp";
 
 if( $wgReadOnlyFile === false ) $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
 if( $wgFileCacheDirectory === false ) $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
+if( $wgApiScript == false ) $wgApiScript = "$wgScriptPath/api$wgScriptExtension";
 
 if ( empty( $wgFileStore['deleted']['directory'] ) ) {
        $wgFileStore['deleted']['directory'] = "{$wgUploadDirectory}/deleted";
index cce00ab..90a33c1 100644 (file)
@@ -25,6 +25,7 @@ class CoreParserFunctions {
                $parser->setFunctionHook( 'localurle',        array( __CLASS__, 'localurle'        ), SFH_NO_HASH );
                $parser->setFunctionHook( 'fullurl',          array( __CLASS__, 'fullurl'          ), SFH_NO_HASH );
                $parser->setFunctionHook( 'fullurle',         array( __CLASS__, 'fullurle'         ), SFH_NO_HASH );
+               $parser->setFunctionHook( 'apiurl',           array( __CLASS__, 'apiurl'           ), SFH_NO_HASH );
                $parser->setFunctionHook( 'formatnum',        array( __CLASS__, 'formatnum'        ), SFH_NO_HASH );
                $parser->setFunctionHook( 'grammar',          array( __CLASS__, 'grammar'          ), SFH_NO_HASH );
                $parser->setFunctionHook( 'plural',           array( __CLASS__, 'plural'           ), SFH_NO_HASH );
@@ -119,6 +120,19 @@ class CoreParserFunctions {
        static function localurle( $parser, $s = '', $arg = null ) { return self::urlFunction( 'escapeLocalURL', $s, $arg ); }
        static function fullurl( $parser, $s = '', $arg = null ) { return self::urlFunction( 'getFullURL', $s, $arg ); }
        static function fullurle( $parser, $s = '', $arg = null ) { return self::urlFunction( 'escapeFullURL', $s, $arg ); }
+       static function apiurl( $parser, $s = '', $arg = null ) { 
+               global $wgEnableApi;
+               # Don't bother linking to the API if they can't use it.
+               if ( $wgEnableApi === false ) {
+                       return array( 'found' => false );
+               }
+               global $wgServer, $wgApiScript;
+               $path = $wgServer . $wgApiScript . '?action=' . $s;
+               if ( !is_null($arg ) ) {
+                       $path .= '&' . $arg;
+               }
+               return $path;
+       }
 
        static function urlFunction( $func, $s = '', $arg = null ) {
                $title = Title::newFromText( $s );
index 487217f..6768f1f 100644 (file)
@@ -312,6 +312,7 @@ $magicWords = array(
        'plural'                 => array( 0,    'PLURAL:'                ),
        'fullurl'                => array( 0,    'FULLURL:'               ),
        'fullurle'               => array( 0,    'FULLURLE:'              ),
+       'apiurl'                 => array( 0,    'APIURL:'                ),
        'lcfirst'                => array( 0,    'LCFIRST:'               ),
        'ucfirst'                => array( 0,    'UCFIRST:'               ),
        'lc'                     => array( 0,    'LC:'                    ),