r25854 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25853‎ | r25854 | r25855 >
Date:15:29, 14 September 2007
Author:brion
Status:old
Tags:
Comment:
* Add {{filepath:}} parser function to get full path to an uploaded file, complementing {{fullurl:}} for pages.
Giving this a |nowiki option to wrap the returned path in <nowiki>s for non-linked standalone use.
Added File::getFullURL() function for cleaner calls; using full path to ensure consistency here.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/includes/ExternalEdit.php (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/includes/filerepo/File.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ExternalEdit.php
@@ -47,12 +47,7 @@
4848 } elseif($this->mMode=="file") {
4949 $type="Edit file";
5050 $image = wfLocalFile( $this->mTitle );
51 - $img_url = $image->getURL();
52 - if(strpos($img_url,"://")) {
53 - $url = $img_url;
54 - } else {
55 - $url = $wgServer . $img_url;
56 - }
 51+ $url = $image->getFullURL();
5752 $extension=substr($name, $pos);
5853 }
5954 $special=$wgLang->getNsText(NS_SPECIAL);
Index: trunk/phase3/includes/Parser.php
@@ -174,6 +174,7 @@
175175 $this->setFunctionHook( 'anchorencode', array( 'CoreParserFunctions', 'anchorencode' ), SFH_NO_HASH );
176176 $this->setFunctionHook( 'special', array( 'CoreParserFunctions', 'special' ) );
177177 $this->setFunctionHook( 'defaultsort', array( 'CoreParserFunctions', 'defaultsort' ), SFH_NO_HASH );
 178+ $this->setFunctionHook( 'filepath', array( 'CoreParserFunctions', 'filepath' ), SFH_NO_HASH );
178179
179180 if ( $wgAllowDisplayTitle ) {
180181 $this->setFunctionHook( 'displaytitle', array( 'CoreParserFunctions', 'displaytitle' ), SFH_NO_HASH );
Index: trunk/phase3/includes/filerepo/File.php
@@ -149,6 +149,21 @@
150150 }
151151 return $this->url;
152152 }
 153+
 154+ /**
 155+ * Return a fully-qualified URL to the file.
 156+ * Upload URL paths _may or may not_ be fully qualified, so
 157+ * we check. Local paths are assumed to belong on $wgServer.
 158+ * @return string
 159+ */
 160+ public function getFullUrl() {
 161+ $url = $this->getUrl();
 162+ if( substr( $url, 0, 1 ) == '/' ) {
 163+ global $wgServer;
 164+ return $wgServer . $url;
 165+ }
 166+ return $url;
 167+ }
153168
154169 function getViewURL() {
155170 if( $this->mustRender()) {
Index: trunk/phase3/includes/CoreParserFunctions.php
@@ -197,5 +197,18 @@
198198 $parser->setDefaultSort( $text );
199199 return '';
200200 }
 201+
 202+ public static function filepath( $parser, $name='', $option='' ) {
 203+ $file = wfFindFile( $name );
 204+ if( $file ) {
 205+ $url = $file->getFullUrl();
 206+ if( $option == 'nowiki' ) {
 207+ return "<nowiki>$url</nowiki>";
 208+ }
 209+ return $url;
 210+ } else {
 211+ return '';
 212+ }
 213+ }
201214 }
202215
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -340,6 +340,7 @@
341341 'padright' => array( 0, 'PADRIGHT' ),
342342 'special' => array( 0, 'special', ),
343343 'defaultsort' => array( 1, 'DEFAULTSORT:', 'DEFAULTSORTKEY:', 'DEFAULTCATEGORYSORT:' ),
 344+ 'filepath' => array( 0, 'FILEPATH:' ),
344345 );
345346
346347 /**
Index: trunk/phase3/RELEASE-NOTES
@@ -22,7 +22,10 @@
2323
2424 === New features in 1.12 ===
2525 * Add a warning for non-descriptive filenames at Special:Upload
 26+* Add {{filepath:}} parser function to get full path to an uploaded file,
 27+ complementing {{fullurl:}} for pages.
2628
 29+
2730 === Bug fixes in 1.12 ===
2831
2932 * Subpages are now indexed for searching properly when using PostgreSQL

Follow-up revisions

RevisionCommit summaryAuthorDate
r25861Merged revisions 25849-25860 via svnmerge from...david20:03, 14 September 2007

Status & tagging log