r73785 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73784‎ | r73785 | r73786 >
Date:17:48, 26 September 2010
Author:kwisatz
Status:deferred
Tags:
Comment:
Using a different approach for uploading files, parser object is still being replaced though.
Modified paths:
  • /trunk/extensions/QrCode/QrCode.php (modified) (history)

Diff [purge]

Index: trunk/extensions/QrCode/QrCode.php
@@ -125,8 +125,7 @@
126126
127127 $file = wfFindFile( $this->_dstFileName ); // Shortcut for RepoGroup::singleton()->findFile()
128128 if( $file && $file->isVisible() ){
129 - $ft = $file->getTitle();
130 - return $this->_displayImage( $ft );
 129+ return $this->_displayImage( $file );
131130 } else {
132131 return $this->_generate();
133132 }
@@ -136,8 +135,9 @@
137136 * This only creates the wikitext to display an image.
138137 * @return wikitext for image display
139138 */
140 - private function _displayImage( $fileTitle ){
141 - return '[['.$fileTitle->getFullText().']]';
 139+ private function _displayImage( $file ){
 140+ $ft = $file->getTitle();
 141+ return '[['.$ft->getFullText().']]';
142142 }
143143
144144 /**
@@ -184,22 +184,22 @@
185185 */
186186 private function _publish( $tmpName ){
187187 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();
192188
 189+ $mUpload = new UploadFromFile();
 190+ $mUpload->initialize( $this->_dstFileName, $tmpName, null ); // we don't know the filesize, how could we?
 191+
193192 $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().']].';
195194
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 {
200202 $wgOut->addWikiText( $status->getWikiText() );
201203 return false;
202 - } else {
203 - return $this->_displayImage( $ft ); // display the generated file
204204 }
205205 }
206206

Status & tagging log