r38221 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38220‎ | r38221 | r38222 >
Date:07:46, 30 July 2008
Author:demon
Status:old
Tags:
Comment:
Add new parser function {{apiurl}}. Also, add new global $wgApiScript because manually constructing the api script's path seemed like a bad idea.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -25,6 +25,7 @@
2626 $parser->setFunctionHook( 'localurle', array( __CLASS__, 'localurle' ), SFH_NO_HASH );
2727 $parser->setFunctionHook( 'fullurl', array( __CLASS__, 'fullurl' ), SFH_NO_HASH );
2828 $parser->setFunctionHook( 'fullurle', array( __CLASS__, 'fullurle' ), SFH_NO_HASH );
 29+ $parser->setFunctionHook( 'apiurl', array( __CLASS__, 'apiurl' ), SFH_NO_HASH );
2930 $parser->setFunctionHook( 'formatnum', array( __CLASS__, 'formatnum' ), SFH_NO_HASH );
3031 $parser->setFunctionHook( 'grammar', array( __CLASS__, 'grammar' ), SFH_NO_HASH );
3132 $parser->setFunctionHook( 'plural', array( __CLASS__, 'plural' ), SFH_NO_HASH );
@@ -119,6 +120,19 @@
120121 static function localurle( $parser, $s = '', $arg = null ) { return self::urlFunction( 'escapeLocalURL', $s, $arg ); }
121122 static function fullurl( $parser, $s = '', $arg = null ) { return self::urlFunction( 'getFullURL', $s, $arg ); }
122123 static function fullurle( $parser, $s = '', $arg = null ) { return self::urlFunction( 'escapeFullURL', $s, $arg ); }
 124+ static function apiurl( $parser, $s = '', $arg = null ) {
 125+ global $wgEnableApi;
 126+ # Don't bother linking to the API if they can't use it.
 127+ if ( $wgEnableApi === false ) {
 128+ return array( 'found' => false );
 129+ }
 130+ global $wgServer, $wgApiScript;
 131+ $path = $wgServer . $wgApiScript . '?action=' . $s;
 132+ if ( !is_null($arg ) ) {
 133+ $path .= '&' . $arg;
 134+ }
 135+ return $path;
 136+ }
123137
124138 static function urlFunction( $func, $s = '', $arg = null ) {
125139 $title = Title::newFromText( $s );
Index: trunk/phase3/includes/Setup.php
@@ -53,6 +53,7 @@
5454
5555 if( $wgReadOnlyFile === false ) $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
5656 if( $wgFileCacheDirectory === false ) $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
 57+if( $wgApiScript == false ) $wgApiScript = "$wgScriptPath/api$wgScriptExtension";
5758
5859 if ( empty( $wgFileStore['deleted']['directory'] ) ) {
5960 $wgFileStore['deleted']['directory'] = "{$wgUploadDirectory}/deleted";
Index: trunk/phase3/includes/DefaultSettings.php
@@ -166,6 +166,7 @@
167167 $wgMathDirectory = false; ///< defaults to "{$wgUploadDirectory}/math"
168168 $wgTmpDirectory = false; ///< defaults to "{$wgUploadDirectory}/tmp"
169169 $wgUploadBaseUrl = "";
 170+$wgApiScript = false; ///< defaults to "{$wgScriptPath}/api{$wgScriptExtension}"
170171 /**@}*/
171172
172173 /**
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -312,6 +312,7 @@
313313 'plural' => array( 0, 'PLURAL:' ),
314314 'fullurl' => array( 0, 'FULLURL:' ),
315315 'fullurle' => array( 0, 'FULLURLE:' ),
 316+ 'apiurl' => array( 0, 'APIURL:' ),
316317 'lcfirst' => array( 0, 'LCFIRST:' ),
317318 'ucfirst' => array( 0, 'UCFIRST:' ),
318319 'lc' => array( 0, 'LC:' ),
Index: trunk/phase3/RELEASE-NOTES
@@ -25,6 +25,9 @@
2626 empt all content namespaces.)
2727 * $wgForwardSearchUrl has been removed entirely. Documented setting since 1.4
2828 has been $wgSearchForwardUrl.
 29+* $wgApiScript can now be defined if your API isn't named api.php or it's not
 30+ in the usual location. Setting to false defaults to "$wgScriptPath/api
 31+ $wgScriptExtension".
2932
3033 === New features in 1.14 ===
3134
@@ -36,6 +39,8 @@
3740 'EditSectionLinkForOther' hook has been removed, but 'EditSectionLink' is
3841 run in all cases instead, so extensions using the old hooks should still work
3942 if they ran roughly the same code for both hooks (as is almost certain).
 43+* New parser function {{apiurl:}} links to the local API. {{apiurl:help}} would
 44+ link to action=help. Other params are passed as well.
4045
4146 === Bug fixes in 1.14 ===
4247

Follow-up revisions

RevisionCommit summaryAuthorDate
r38247Revert r38221, 38238 -- "Add new parser function {{apiurl}}. Also, add new gl...brion19:45, 30 July 2008

Status & tagging log