Index: trunk/extensions/QrCode/QrCode.php |
— | — | @@ -125,8 +125,7 @@ |
126 | 126 | |
127 | 127 | $file = wfFindFile( $this->_dstFileName ); // Shortcut for RepoGroup::singleton()->findFile() |
128 | 128 | if( $file && $file->isVisible() ){ |
129 | | - $ft = $file->getTitle(); |
130 | | - return $this->_displayImage( $ft ); |
| 129 | + return $this->_displayImage( $file ); |
131 | 130 | } else { |
132 | 131 | return $this->_generate(); |
133 | 132 | } |
— | — | @@ -136,8 +135,9 @@ |
137 | 136 | * This only creates the wikitext to display an image. |
138 | 137 | * @return wikitext for image display |
139 | 138 | */ |
140 | | - private function _displayImage( $fileTitle ){ |
141 | | - return '[['.$fileTitle->getFullText().']]'; |
| 139 | + private function _displayImage( $file ){ |
| 140 | + $ft = $file->getTitle(); |
| 141 | + return '[['.$ft->getFullText().']]'; |
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
— | — | @@ -184,22 +184,22 @@ |
185 | 185 | */ |
186 | 186 | private function _publish( $tmpName ){ |
187 | 187 | global $wgOut; |
188 | | - |
189 | | - $ft = Title::makeTitleSafe( NS_FILE, $this->_dstFileName ); |
190 | | - $localfile = wfLocalFile( $ft ); // Get an object referring to a locally registered file. |
191 | | - $saveName = $localfile->getName(); |
192 | 188 | |
| 189 | + $mUpload = new UploadFromFile(); |
| 190 | + $mUpload->initialize( $this->_dstFileName, $tmpName, null ); // we don't know the filesize, how could we? |
| 191 | + |
193 | 192 | $pageText = 'QrCode '.$saveName.', generated on '.date( "r" ) |
194 | | - .' by the QrCode Extension for page [['.$this->_title->getFullText().']].'; |
| 193 | + .' by the QrCode Extension for page [['.$this->_title->getFullText().']].'; |
195 | 194 | |
196 | | - $status = $localfile->upload( $tmpName, $this->_uploadComment, $pageText, |
197 | | - File::DELETE_SOURCE, false, false, $this->_getBot() ); |
198 | | - |
199 | | - if( !$status->isGood() ){ |
| 195 | + wfDebug( 'QrCode::_publish: Uploading qrcode, c: '.$this->_uploadComment . ' t: ' . $pageText."\n" ); |
| 196 | + $status = $mUpload->performUpload( $this->_uploadComment, $pageText, false, $this->_getBot() ); |
| 197 | + |
| 198 | + if ( $status->isGood() ) { |
| 199 | + $file = $mUpload->getLocalFile(); |
| 200 | + return $this->_displayImage( $file ); |
| 201 | + } else { |
200 | 202 | $wgOut->addWikiText( $status->getWikiText() ); |
201 | 203 | return false; |
202 | | - } else { |
203 | | - return $this->_displayImage( $ft ); // display the generated file |
204 | 204 | } |
205 | 205 | } |
206 | 206 | |