Index: trunk/extensions/QrCode/QrCode.php |
— | — | @@ -85,8 +85,9 @@ |
86 | 86 | |
87 | 87 | private $_parser; // simply a link to the parser object |
88 | 88 | private $_title; // the current page's title object |
| 89 | + private $_label; // contents of the qrcode |
89 | 90 | private $_dstFileName; // what the file will be named? |
90 | | - private $_label; // What will the qrcode contain? |
| 91 | + private $_uploadComment; // comment to be added to the upload |
91 | 92 | private $_ecc; // error correction |
92 | 93 | private $_size; // qrcode size |
93 | 94 | private $_margin; // qrcode margin |
— | — | @@ -113,8 +114,10 @@ |
114 | 115 | // Also strip all non-alphanumeric characters |
115 | 116 | if ( $label ) { |
116 | 117 | $this->_label = preg_replace("/[^0-9a-zA-Z_]+/", "", $label); |
| 118 | + $this->_uploadComment = $label; // should we sanitize this? |
117 | 119 | } else { |
118 | 120 | $this->_label = $this->_title->getFullURL(); |
| 121 | + $this->_uploadComment = 'Encoded URL for '.$this->_title->getFullText(); |
119 | 122 | } |
120 | 123 | |
121 | 124 | // Use this page's title as part of the filename (Also regenerates qrcodes when the label changes). |
— | — | @@ -183,16 +186,18 @@ |
184 | 187 | $ft = Title::makeTitleSafe( NS_FILE, $this->_dstFileName ); |
185 | 188 | $localfile = wfLocalFile( $ft ); // Get an object referring to a locally registered file. |
186 | 189 | $saveName = $localfile->getName(); |
| 190 | + |
187 | 191 | $pageText = 'QrCode '.$saveName.', generated on '.date( "r" ) |
188 | 192 | .' by the QrCode Extension for page '.$this->_title->getFullText().'.'; |
189 | | - $status = $localfile->upload( $tmpName, $this->_label, $pageText, File::DELETE_SOURCE, false, false, $this->_getBot() ); |
190 | 193 | |
| 194 | + $status = $localfile->upload( $tmpName, $this->_uploadComment, $pageText, |
| 195 | + File::DELETE_SOURCE, false, false, $this->_getBot() ); |
| 196 | + |
191 | 197 | if( !$status->isGood() ){ |
192 | 198 | $wgOut->addWikiText( $status->getWikiText() ); |
193 | 199 | return false; |
194 | 200 | } else { |
195 | | - // now that we generated the file, let's display it |
196 | | - return $this->_displayImage( $ft ); |
| 201 | + return $this->_displayImage( $ft ); // display the generated file |
197 | 202 | } |
198 | 203 | } |
199 | 204 | |