From 678ee35b5a702c279bf23cf607108b4d200cf2e8 Mon Sep 17 00:00:00 2001 From: Neil Kandalgaonkar Date: Tue, 16 Nov 2010 01:15:58 +0000 Subject: [PATCH] removed URL hackery, now using SpecialPage::getTitleFor(). Followup to r75906 --- includes/upload/UploadStash.php | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index 29124d4310..5a66144ca6 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -24,9 +24,6 @@ class UploadStash { // array of initialized objects obtained from session (lazily initialized upon getFile()) private $files = array(); - // the base URL for files in the stash - private $baseUrl; - // TODO: Once UploadBase starts using this, switch to use these constants rather than UploadBase::SESSION* // const SESSION_VERSION = 2; // const SESSION_KEYNAME = 'wsUploadData'; @@ -53,16 +50,6 @@ class UploadStash { $_SESSION[UploadBase::SESSION_KEYNAME] = array(); } - $this->baseUrl = SpecialPage::getTitleFor( 'UploadStash' )->getLocalURL(); - } - - /** - * Get the base of URLs by which one can access the files - * - * @return String: url - */ - public function getBaseUrl() { - return $this->baseUrl; } /** @@ -298,6 +285,16 @@ class UploadStashFile extends UnregisteredLocalFile { return $thumbName; } + /** + * Helper function -- given a 'subpage', return the local URL e.g. /wiki/Special:UploadStash/subpage + * @param {String} $subPage + * @return {String} local URL for this subpage in the Special:UploadStash space. + */ + private function getSpecialUrl( $subPage ) { + return SpecialPage::getTitleFor( 'UploadStash', $subPage )->getLocalURL(); + } + + /** * Get a URL to access the thumbnail * This is required because the model of how files work requires that @@ -308,11 +305,7 @@ class UploadStashFile extends UnregisteredLocalFile { * @return String: URL to access thumbnail, or URL with partial path */ public function getThumbUrl( $thumbName = false ) { - $path = $this->sessionStash->getBaseUrl(); - if ( $thumbName !== false ) { - $path .= '/' . rawurlencode( $thumbName ); - } - return $path; + return self::getSpecialUrl( $thumbName ); } /** @@ -336,7 +329,7 @@ class UploadStashFile extends UnregisteredLocalFile { */ public function getUrl() { if ( !isset( $this->url ) ) { - $this->url = $this->sessionStash->getBaseUrl() . '/' . $this->getUrlName(); + $this->url = self::getSpecialUrl( $this->getUrlName() ); } return $this->url; } -- 2.20.1