Index: trunk/phase3/includes/specials/SpecialUploadStash.php |
— | — | @@ -1,10 +1,10 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Special:UploadStash |
| 4 | + * Implements Special:UploadStash |
5 | 5 | * |
6 | 6 | * Web access for files temporarily stored by UploadStash. |
7 | 7 | * |
8 | | - * For example -- files that were uploaded with the UploadWizard extension are stored temporarily |
| 8 | + * For example -- files that were uploaded with the UploadWizard extension are stored temporarily |
9 | 9 | * before committing them to the db. But we want to see their thumbnails and get other information |
10 | 10 | * about them. |
11 | 11 | * |
— | — | @@ -34,13 +34,13 @@ |
35 | 35 | /** |
36 | 36 | * If file available in stash, cats it out to the client as a simple HTTP response. |
37 | 37 | * n.b. Most sanity checking done in UploadStashLocalFile, so this is straightforward. |
38 | | - * |
39 | | - * @param {String} $subPage: subpage, e.g. in http://example.com/wiki/Special:UploadStash/foo.jpg, the "foo.jpg" part |
40 | | - * @return {Boolean} success |
| 38 | + * |
| 39 | + * @param $subPage String: subpage, e.g. in http://example.com/wiki/Special:UploadStash/foo.jpg, the "foo.jpg" part |
| 40 | + * @return Boolean: success |
41 | 41 | */ |
42 | 42 | public function execute( $subPage ) { |
43 | 43 | global $wgOut, $wgUser; |
44 | | - |
| 44 | + |
45 | 45 | if ( !$this->userCanExecute( $wgUser ) ) { |
46 | 46 | $this->displayRestrictionError(); |
47 | 47 | return; |
— | — | @@ -49,7 +49,7 @@ |
50 | 50 | // prevent callers from doing standard HTML output -- we'll take it from here |
51 | 51 | $wgOut->disable(); |
52 | 52 | |
53 | | - try { |
| 53 | + try { |
54 | 54 | $file = $this->getStashFile( $subPage ); |
55 | 55 | if ( $file->getSize() > $this->maxServeFileSize ) { |
56 | 56 | throw new MWException( 'file size too large' ); |
— | — | @@ -64,21 +64,23 @@ |
65 | 65 | } catch( Exception $e ) { |
66 | 66 | $code = 500; |
67 | 67 | } |
68 | | - |
| 68 | + |
69 | 69 | wfHttpError( $code, OutputPage::getStatusMessage( $code ), $e->getMessage() ); |
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | | - /** |
75 | | - * Convert the incoming url portion (subpage of Special page) into a stashed file, if available. |
76 | | - * @param {String} $subPage |
77 | | - * @return {File} file object |
| 74 | + /** |
| 75 | + * Convert the incoming url portion (subpage of Special page) into a stashed file, |
| 76 | + * if available. |
| 77 | + * |
| 78 | + * @param $subPage String |
| 79 | + * @return File object |
78 | 80 | * @throws MWException, UploadStashFileNotFoundException, UploadStashBadPathException |
79 | 81 | */ |
80 | 82 | private function getStashFile( $subPage ) { |
81 | | - // due to an implementation quirk (and trying to be compatible with older method) |
82 | | - // the stash key doesn't have an extension |
| 83 | + // due to an implementation quirk (and trying to be compatible with older method) |
| 84 | + // the stash key doesn't have an extension |
83 | 85 | $key = $subPage; |
84 | 86 | $n = strrpos( $subPage, '.' ); |
85 | 87 | if ( $n !== false ) { |
— | — | @@ -87,12 +89,12 @@ |
88 | 90 | |
89 | 91 | try { |
90 | 92 | $file = $this->stash->getFile( $key ); |
91 | | - } catch ( UploadStashFileNotFoundException $e ) { |
| 93 | + } catch ( UploadStashFileNotFoundException $e ) { |
92 | 94 | // if we couldn't find it, and it looks like a thumbnail, |
93 | 95 | // and it looks like we have the original, go ahead and generate it |
94 | 96 | $matches = array(); |
95 | 97 | if ( ! preg_match( '/^(\d+)px-(.*)$/', $key, $matches ) ) { |
96 | | - // that doesn't look like a thumbnail. re-raise exception |
| 98 | + // that doesn't look like a thumbnail. re-raise exception |
97 | 99 | throw $e; |
98 | 100 | } |
99 | 101 | |
— | — | @@ -102,11 +104,11 @@ |
103 | 105 | // let exceptions propagate to caller. |
104 | 106 | $origFile = $this->stash->getFile( $origKey ); |
105 | 107 | |
106 | | - // ok we're here so the original must exist. Generate the thumbnail. |
| 108 | + // ok we're here so the original must exist. Generate the thumbnail. |
107 | 109 | // because the file is a UploadStashFile, this thumbnail will also be stashed, |
108 | 110 | // and a thumbnailFile will be created in the thumbnailImage composite object |
109 | 111 | $thumbnailImage = $origFile->transform( array( 'width' => $width ) ); |
110 | | - if ( !$thumbnailImage ) { |
| 112 | + if ( !$thumbnailImage ) { |
111 | 113 | throw new MWException( 'Could not obtain thumbnail' ); |
112 | 114 | } |
113 | 115 | $file = $thumbnailImage->thumbnailFile; |
— | — | @@ -118,9 +120,10 @@ |
119 | 121 | /** |
120 | 122 | * Output HTTP response for file |
121 | 123 | * Side effects, obviously, of echoing lots of stuff to stdout. |
122 | | - * @param {File} file |
| 124 | + * |
| 125 | + * @param $file File object |
123 | 126 | */ |
124 | | - private function outputFile( $file ) { |
| 127 | + private function outputFile( $file ) { |
125 | 128 | header( 'Content-Type: ' . $file->getMimeType(), true ); |
126 | 129 | header( 'Content-Transfer-Encoding: binary', true ); |
127 | 130 | header( 'Expires: Sun, 17-Jan-2038 19:14:07 GMT', true ); |