Index: trunk/phase3/includes/ExternalEdit.php |
— | — | @@ -47,12 +47,7 @@ |
48 | 48 | } elseif($this->mMode=="file") { |
49 | 49 | $type="Edit file"; |
50 | 50 | $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(); |
57 | 52 | $extension=substr($name, $pos); |
58 | 53 | } |
59 | 54 | $special=$wgLang->getNsText(NS_SPECIAL); |
Index: trunk/phase3/includes/Parser.php |
— | — | @@ -174,6 +174,7 @@ |
175 | 175 | $this->setFunctionHook( 'anchorencode', array( 'CoreParserFunctions', 'anchorencode' ), SFH_NO_HASH ); |
176 | 176 | $this->setFunctionHook( 'special', array( 'CoreParserFunctions', 'special' ) ); |
177 | 177 | $this->setFunctionHook( 'defaultsort', array( 'CoreParserFunctions', 'defaultsort' ), SFH_NO_HASH ); |
| 178 | + $this->setFunctionHook( 'filepath', array( 'CoreParserFunctions', 'filepath' ), SFH_NO_HASH ); |
178 | 179 | |
179 | 180 | if ( $wgAllowDisplayTitle ) { |
180 | 181 | $this->setFunctionHook( 'displaytitle', array( 'CoreParserFunctions', 'displaytitle' ), SFH_NO_HASH ); |
Index: trunk/phase3/includes/filerepo/File.php |
— | — | @@ -149,6 +149,21 @@ |
150 | 150 | } |
151 | 151 | return $this->url; |
152 | 152 | } |
| 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 | + } |
153 | 168 | |
154 | 169 | function getViewURL() { |
155 | 170 | if( $this->mustRender()) { |
Index: trunk/phase3/includes/CoreParserFunctions.php |
— | — | @@ -197,5 +197,18 @@ |
198 | 198 | $parser->setDefaultSort( $text ); |
199 | 199 | return ''; |
200 | 200 | } |
| 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 | + } |
201 | 214 | } |
202 | 215 | |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -340,6 +340,7 @@ |
341 | 341 | 'padright' => array( 0, 'PADRIGHT' ), |
342 | 342 | 'special' => array( 0, 'special', ), |
343 | 343 | 'defaultsort' => array( 1, 'DEFAULTSORT:', 'DEFAULTSORTKEY:', 'DEFAULTCATEGORYSORT:' ), |
| 344 | + 'filepath' => array( 0, 'FILEPATH:' ), |
344 | 345 | ); |
345 | 346 | |
346 | 347 | /** |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -22,7 +22,10 @@ |
23 | 23 | |
24 | 24 | === New features in 1.12 === |
25 | 25 | * 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. |
26 | 28 | |
| 29 | + |
27 | 30 | === Bug fixes in 1.12 === |
28 | 31 | |
29 | 32 | * Subpages are now indexed for searching properly when using PostgreSQL |