Index: trunk/phase3/includes/upload/UploadStash.php |
— | — | @@ -24,9 +24,6 @@ |
25 | 25 | // array of initialized objects obtained from session (lazily initialized upon getFile()) |
26 | 26 | private $files = array(); |
27 | 27 | |
28 | | - // the base URL for files in the stash |
29 | | - private $baseUrl; |
30 | | - |
31 | 28 | // TODO: Once UploadBase starts using this, switch to use these constants rather than UploadBase::SESSION* |
32 | 29 | // const SESSION_VERSION = 2; |
33 | 30 | // const SESSION_KEYNAME = 'wsUploadData'; |
— | — | @@ -53,19 +50,9 @@ |
54 | 51 | $_SESSION[UploadBase::SESSION_KEYNAME] = array(); |
55 | 52 | } |
56 | 53 | |
57 | | - $this->baseUrl = SpecialPage::getTitleFor( 'UploadStash' )->getLocalURL(); |
58 | 54 | } |
59 | 55 | |
60 | 56 | /** |
61 | | - * Get the base of URLs by which one can access the files |
62 | | - * |
63 | | - * @return String: url |
64 | | - */ |
65 | | - public function getBaseUrl() { |
66 | | - return $this->baseUrl; |
67 | | - } |
68 | | - |
69 | | - /** |
70 | 57 | * Get a file and its metadata from the stash. |
71 | 58 | * May throw exception if session data cannot be parsed due to schema change, or key not found. |
72 | 59 | * |
— | — | @@ -298,6 +285,16 @@ |
299 | 286 | return $thumbName; |
300 | 287 | } |
301 | 288 | |
| 289 | + /** |
| 290 | + * Helper function -- given a 'subpage', return the local URL e.g. /wiki/Special:UploadStash/subpage |
| 291 | + * @param {String} $subPage |
| 292 | + * @return {String} local URL for this subpage in the Special:UploadStash space. |
| 293 | + */ |
| 294 | + private function getSpecialUrl( $subPage ) { |
| 295 | + return SpecialPage::getTitleFor( 'UploadStash', $subPage )->getLocalURL(); |
| 296 | + } |
| 297 | + |
| 298 | + |
302 | 299 | /** |
303 | 300 | * Get a URL to access the thumbnail |
304 | 301 | * This is required because the model of how files work requires that |
— | — | @@ -308,11 +305,7 @@ |
309 | 306 | * @return String: URL to access thumbnail, or URL with partial path |
310 | 307 | */ |
311 | 308 | public function getThumbUrl( $thumbName = false ) { |
312 | | - $path = $this->sessionStash->getBaseUrl(); |
313 | | - if ( $thumbName !== false ) { |
314 | | - $path .= '/' . rawurlencode( $thumbName ); |
315 | | - } |
316 | | - return $path; |
| 309 | + return self::getSpecialUrl( $thumbName ); |
317 | 310 | } |
318 | 311 | |
319 | 312 | /** |
— | — | @@ -336,7 +329,7 @@ |
337 | 330 | */ |
338 | 331 | public function getUrl() { |
339 | 332 | if ( !isset( $this->url ) ) { |
340 | | - $this->url = $this->sessionStash->getBaseUrl() . '/' . $this->getUrlName(); |
| 333 | + $this->url = self::getSpecialUrl( $this->getUrlName() ); |
341 | 334 | } |
342 | 335 | return $this->url; |
343 | 336 | } |