r65997 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65996‎ | r65997 | r65998 >
Date:21:07, 6 May 2010
Author:ialex
Status:ok
Tags:
Comment:
Fixed some doxygen warnings and removed trailing spaces
Modified paths:
  • /trunk/phase3/includes/specials/SpecialExport.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialExport.php
@@ -22,22 +22,22 @@
2323 */
2424
2525 class SpecialExport extends SpecialPage {
26 -
 26+
2727 private $curonly, $doExport, $pageLinkDepth, $templates;
2828 private $images;
29 -
 29+
3030 public function __construct() {
3131 parent::__construct( 'Export' );
3232 }
33 -
 33+
3434 public function execute( $par ) {
3535 global $wgOut, $wgRequest, $wgSitename, $wgExportAllowListContributors;
3636 global $wgExportAllowHistory, $wgExportMaxHistory, $wgExportMaxLinkDepth;
3737 global $wgExportFromNamespaces;
38 -
 38+
3939 $this->setHeaders();
4040 $this->outputHeader();
41 -
 41+
4242 // Set some variables
4343 $this->curonly = true;
4444 $this->doExport = false;
@@ -46,11 +46,11 @@
4747 $this->pageLinkDepth = $this->validateLinkDepth(
4848 $wgRequest->getIntOrNull( 'pagelink-depth' ) );
4949 $nsindex = '';
50 -
 50+
5151 if ( $wgRequest->getCheck( 'addcat' ) ) {
5252 $page = $wgRequest->getText( 'pages' );
5353 $catname = $wgRequest->getText( 'catname' );
54 -
 54+
5555 if ( $catname !== '' && $catname !== null && $catname !== false ) {
5656 $t = Title::makeTitleSafe( NS_MAIN, $catname );
5757 if ( $t ) {
@@ -67,7 +67,7 @@
6868 else if( $wgRequest->getCheck( 'addns' ) && $wgExportFromNamespaces ) {
6969 $page = $wgRequest->getText( 'pages' );
7070 $nsindex = $wgRequest->getText( 'nsindex', '' );
71 -
 71+
7272 if ( strval( $nsindex ) !== '' ) {
7373 /**
7474 * Same implementation as above, so same @todo
@@ -106,7 +106,7 @@
107107 $history['dir'] = 'desc';
108108 }
109109 }
110 -
 110+
111111 if( $page != '' ) $this->doExport = true;
112112 } else {
113113 // Default to current-only for GET requests
@@ -117,18 +117,18 @@
118118 } else {
119119 $history = WikiExporter::CURRENT;
120120 }
121 -
 121+
122122 if( $page != '' ) $this->doExport = true;
123123 }
124 -
 124+
125125 if( !$wgExportAllowHistory ) {
126126 // Override
127127 $history = WikiExporter::CURRENT;
128128 }
129 -
 129+
130130 $list_authors = $wgRequest->getCheck( 'listauthors' );
131131 if ( !$this->curonly || !$wgExportAllowListContributors ) $list_authors = false ;
132 -
 132+
133133 if ( $this->doExport ) {
134134 $wgOut->disable();
135135 // Cancel output buffering and gzipping if set
@@ -143,22 +143,22 @@
144144 $this->doExport( $page, $history, $list_authors );
145145 return;
146146 }
147 -
 147+
148148 $wgOut->addWikiMsg( 'exporttext' );
149 -
 149+
150150 $form = Xml::openElement( 'form', array( 'method' => 'post',
151151 'action' => $this->getTitle()->getLocalUrl( 'action=submit' ) ) );
152152 $form .= Xml::inputLabel( wfMsg( 'export-addcattext' ) , 'catname', 'catname', 40 ) . ' ';
153153 $form .= Xml::submitButton( wfMsg( 'export-addcat' ), array( 'name' => 'addcat' ) ) . '<br />';
154 -
 154+
155155 if ( $wgExportFromNamespaces ) {
156156 $form .= Xml::namespaceSelector( $nsindex, null, 'nsindex', wfMsg( 'export-addnstext' ) ) . '&nbsp;';
157157 $form .= Xml::submitButton( wfMsg( 'export-addns' ), array( 'name' => 'addns' ) ) . '<br />';
158158 }
159 -
 159+
160160 $form .= Xml::element( 'textarea', array( 'name' => 'pages', 'cols' => 40, 'rows' => 10 ), $page, false );
161161 $form .= '<br />';
162 -
 162+
163163 if( $wgExportAllowHistory ) {
164164 $form .= Xml::checkLabel( wfMsg( 'exportcuronly' ), 'curonly', 'curonly', true ) . '<br />';
165165 } else {
@@ -171,28 +171,31 @@
172172 // Enable this when we can do something useful exporting/importing image information. :)
173173 //$form .= Xml::checkLabel( wfMsg( 'export-images' ), 'images', 'wpExportImages', false ) . '<br />';
174174 $form .= Xml::checkLabel( wfMsg( 'export-download' ), 'wpDownload', 'wpDownload', true ) . '<br />';
175 -
 175+
176176 $form .= Xml::submitButton( wfMsg( 'export-submit' ), array( 'accesskey' => 's' ) );
177177 $form .= Xml::closeElement( 'form' );
178178 $wgOut->addHTML( $form );
179179 }
180 -
 180+
181181 private function userCanOverrideExportDepth() {
182 - global $wgUser;
 182+ global $wgUser;
183183
184184 return $wgUser->isAllowed( 'override-export-depth' );
185185 }
186 -
 186+
187187 /**
188188 * Do the actual page exporting
189 - * @param string $page User input on what page(s) to export
190 - * @param mixed $history one of the WikiExporter history export constants
 189+ *
 190+ * @param $page String: user input on what page(s) to export
 191+ * @param $history Mixed: one of the WikiExporter history export constants
 192+ * @param $list_authors Boolean: Whether to add distinct author list (when
 193+ * not returning full history)
191194 */
192195 private function doExport( $page, $history, $list_authors ) {
193196 global $wgExportMaxHistory;
194 -
 197+
195198 $pageSet = array(); // Inverted index of all pages to look up
196 -
 199+
197200 // Split up and normalize input
198201 foreach( explode( "\n", $page ) as $pageName ) {
199202 $pageName = trim( $pageName );
@@ -202,26 +205,26 @@
203206 $pageSet[$title->getPrefixedText()] = true;
204207 }
205208 }
206 -
 209+
207210 // Set of original pages to pass on to further manipulation...
208211 $inputPages = array_keys( $pageSet );
209 -
 212+
210213 // Look up any linked pages if asked...
211214 if( $this->templates ) {
212215 $pageSet = $this->getTemplates( $inputPages, $pageSet );
213216 }
214 -
 217+
215218 if( $linkDepth = $this->pageLinkDepth ) {
216219 $pageSet = $this->getPageLinks( $inputPages, $pageSet, $linkDepth );
217220 }
218 -
 221+
219222 /*
220223 // Enable this when we can do something useful exporting/importing image information. :)
221224 if( $this->images ) ) {
222225 $pageSet = $this->getImages( $inputPages, $pageSet );
223226 }
224227 */
225 -
 228+
226229 $pages = array_keys( $pageSet );
227230
228231 // Normalize titles to the same format and remove dupes, see bug 17374
@@ -240,7 +243,7 @@
241244 $lb = wfGetLBFactory()->newMainLB();
242245 $db = $lb->getConnection( DB_SLAVE );
243246 $buffer = WikiExporter::STREAM;
244 -
 247+
245248 // This might take a while... :D
246249 wfSuppressWarnings();
247250 set_time_limit(0);
@@ -266,10 +269,10 @@
267270 $title = Title::newFromText( $page );
268271 if( is_null( $title ) ) continue; #TODO: perhaps output an <error> tag or something.
269272 if( !$title->userCanRead() ) continue; #TODO: perhaps output an <error> tag or something.
270 -
 273+
271274 $exporter->pageByTitle( $title );
272275 }
273 -
 276+
274277 $exporter->closeStream();
275278 if( $lb ) {
276279 $lb->closeAll();
@@ -278,15 +281,15 @@
279282
280283 private function getPagesFromCategory( $title ) {
281284 global $wgContLang;
282 -
 285+
283286 $name = $title->getDBkey();
284 -
 287+
285288 $dbr = wfGetDB( DB_SLAVE );
286289 $res = $dbr->select( array('page', 'categorylinks' ),
287290 array( 'page_namespace', 'page_title' ),
288291 array('cl_from=page_id', 'cl_to' => $name ),
289292 __METHOD__, array('LIMIT' => '5000'));
290 -
 293+
291294 $pages = array();
292295 while ( $row = $dbr->fetchObject( $res ) ) {
293296 $n = $row->page_title;
@@ -294,22 +297,22 @@
295298 $ns = $wgContLang->getNsText( $row->page_namespace );
296299 $n = $ns . ':' . $n;
297300 }
298 -
 301+
299302 $pages[] = $n;
300303 }
301304 $dbr->freeResult($res);
302 -
 305+
303306 return $pages;
304307 }
305 -
 308+
306309 private function getPagesFromNamespace( $nsindex ) {
307310 global $wgContLang;
308 -
 311+
309312 $dbr = wfGetDB( DB_SLAVE );
310313 $res = $dbr->select( 'page', array('page_namespace', 'page_title'),
311314 array('page_namespace' => $nsindex),
312315 __METHOD__, array('LIMIT' => '5000') );
313 -
 316+
314317 $pages = array();
315318 while ( $row = $dbr->fetchObject( $res ) ) {
316319 $n = $row->page_title;
@@ -317,13 +320,14 @@
318321 $ns = $wgContLang->getNsText( $row->page_namespace );
319322 $n = $ns . ':' . $n;
320323 }
321 -
 324+
322325 $pages[] = $n;
323326 }
324327 $dbr->freeResult($res);
325 -
 328+
326329 return $pages;
327330 }
 331+
328332 /**
329333 * Expand a list of pages to include templates used in those pages.
330334 * @param $inputPages array, list of titles to look up
@@ -336,7 +340,7 @@
337341 array( 'tl_namespace AS namespace', 'tl_title AS title' ),
338342 array( 'page_id=tl_from' ) );
339343 }
340 -
 344+
341345 /**
342346 * Validate link depth setting, if available.
343347 */
@@ -357,7 +361,7 @@
358362 */
359363 return intval( min( $depth, 5 ) );
360364 }
361 -
 365+
362366 /** Expand a list of pages to include pages linked to from that page. */
363367 private function getPageLinks( $inputPages, $pageSet, $depth ) {
364368 for( $depth=$depth; $depth>0; --$depth ) {
@@ -368,7 +372,7 @@
369373 }
370374 return $pageSet;
371375 }
372 -
 376+
373377 /**
374378 * Expand a list of pages to include images used in those pages.
375379 * @param $inputPages array, list of titles to look up
@@ -381,7 +385,7 @@
382386 array( NS_FILE . ' AS namespace', 'il_to AS title' ),
383387 array( 'page_id=il_from' ) );
384388 }
385 -
 389+
386390 /**
387391 * Expand a list of pages to include items used in those pages.
388392 * @private

Status & tagging log