Index: trunk/phase3/maintenance/dumpTextPass.php |
— | — | @@ -56,9 +56,9 @@ |
57 | 57 | |
58 | 58 | var $xmlwriterobj = false; |
59 | 59 | |
60 | | - # when we spend more than maxTimeAllowed seconds on this run, we continue |
61 | | - # processing until we write out the next complete page, then save output file(s), |
62 | | - # rename it/them and open new one(s) |
| 60 | + // when we spend more than maxTimeAllowed seconds on this run, we continue |
| 61 | + // processing until we write out the next complete page, then save output file(s), |
| 62 | + // rename it/them and open new one(s) |
63 | 63 | var $maxTimeAllowed = 0; // 0 = no limit |
64 | 64 | var $timeExceeded = false; |
65 | 65 | var $firstPageWritten = false; |
— | — | @@ -72,11 +72,11 @@ |
73 | 73 | } |
74 | 74 | |
75 | 75 | function dump( $history, $text = WikiExporter::TEXT ) { |
76 | | - # This shouldn't happen if on console... ;) |
| 76 | + // This shouldn't happen if on console... ;) |
77 | 77 | header( 'Content-type: text/html; charset=UTF-8' ); |
78 | 78 | |
79 | | - # Notice messages will foul up your XML output even if they're |
80 | | - # relatively harmless. |
| 79 | + // Notice messages will foul up your XML output even if they're |
| 80 | + // relatively harmless. |
81 | 81 | if ( ini_get( 'display_errors' ) ) |
82 | 82 | ini_set( 'display_errors', 'stderr' ); |
83 | 83 | |
— | — | @@ -86,10 +86,10 @@ |
87 | 87 | |
88 | 88 | $this->egress = new ExportProgressFilter( $this->sink, $this ); |
89 | 89 | |
90 | | - # it would be nice to do it in the constructor, oh well. need egress set |
| 90 | + // it would be nice to do it in the constructor, oh well. need egress set |
91 | 91 | $this->finalOptionCheck(); |
92 | 92 | |
93 | | - # we only want this so we know how to close a stream :-P |
| 93 | + // we only want this so we know how to close a stream :-P |
94 | 94 | $this->xmlwriterobj = new XmlDumpWriter(); |
95 | 95 | |
96 | 96 | $input = fopen( $this->input, "rt" ); |
— | — | @@ -234,23 +234,20 @@ |
235 | 235 | } |
236 | 236 | |
237 | 237 | function finalOptionCheck() { |
238 | | - if (($this->checkpointFiles && ! $this->maxTimeAllowed) || |
239 | | - ($this->maxTimeAllowed && !$this->checkpointFiles)) { |
| 238 | + if ( ( $this->checkpointFiles && ! $this->maxTimeAllowed ) || |
| 239 | + ( $this->maxTimeAllowed && !$this->checkpointFiles ) ) { |
240 | 240 | throw new MWException("Options checkpointfile and maxtime must be specified together.\n"); |
241 | 241 | } |
242 | 242 | foreach ($this->checkpointFiles as $checkpointFile) { |
243 | | - $count = substr_count ($checkpointFile,"%s"); |
244 | | - if (substr_count ($checkpointFile,"%s") != 2) { |
| 243 | + $count = substr_count ( $checkpointFile,"%s" ); |
| 244 | + if ( $count != 2 ) { |
245 | 245 | throw new MWException("Option checkpointfile must contain two '%s' for substitution of first and last pageids, count is $count instead, file is $checkpointFile.\n"); |
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | | - if ($this->checkpointFiles) { |
250 | | - $filenameList = $this->egress->getFilename(); |
251 | | - if (! is_array($filenameList)) { |
252 | | - $filenameList = array( $filenameList ); |
253 | | - } |
254 | | - if (count($filenameList) != count($this->checkpointFiles)) { |
| 249 | + if ( $this->checkpointFiles ) { |
| 250 | + $filenameList = (array)$this->egress->getFilename(); |
| 251 | + if ( count( $filenameList ) != count( $this->checkpointFiles ) ) { |
255 | 252 | throw new MWException("One checkpointfile must be specified for each output option, if maxtime is used.\n"); |
256 | 253 | } |
257 | 254 | } |
— | — | @@ -285,19 +282,16 @@ |
286 | 283 | $offset += strlen( $chunk ); |
287 | 284 | } while ( $chunk !== false && !feof( $input ) ); |
288 | 285 | if ($this->maxTimeAllowed) { |
289 | | - $filenameList = $this->egress->getFilename(); |
290 | | - # we wrote some stuff after last checkpoint that needs renamed */ |
291 | | - if (! is_array($filenameList)) { |
292 | | - $filenameList = array( $filenameList ); |
293 | | - } |
| 286 | + $filenameList = (array)$this->egress->getFilename(); |
| 287 | + // we wrote some stuff after last checkpoint that needs renamed |
294 | 288 | if (file_exists($filenameList[0])) { |
295 | 289 | $newFilenames = array(); |
296 | 290 | $firstPageID = str_pad($this->firstPageWritten,9,"0",STR_PAD_LEFT); |
297 | 291 | $lastPageID = str_pad($this->lastPageWritten,9,"0",STR_PAD_LEFT); |
298 | | - for ($i =0; $i < count($filenameList); $i++) { |
299 | | - $checkpointNameFilledIn = sprintf($this->checkpointFiles[$i], $firstPageID, $lastPageID); |
| 292 | + for ( $i = 0; $i < count( $filenameList ); $i++ ) { |
| 293 | + $checkpointNameFilledIn = sprintf( $this->checkpointFiles[$i], $firstPageID, $lastPageID ); |
300 | 294 | $fileinfo = pathinfo($filenameList[$i]); |
301 | | - $newFilenames[] = $fileinfo{'dirname'} . '/' . $checkpointNameFilledIn; |
| 295 | + $newFilenames[] = $fileinfo['dirname'] . '/' . $checkpointNameFilledIn; |
302 | 296 | } |
303 | 297 | $this->egress->closeAndRename( $newFilenames ); |
304 | 298 | } |
— | — | @@ -566,8 +560,8 @@ |
567 | 561 | $this->lastPageWritten = trim($this->thisPage); |
568 | 562 | if ($this->timeExceeded) { |
569 | 563 | $this->egress->writeClosePage( $this->buffer ); |
570 | | - # nasty hack, we can't just write the chardata after the |
571 | | - # page tag, it will include leading blanks from the next line |
| 564 | + // nasty hack, we can't just write the chardata after the |
| 565 | + // page tag, it will include leading blanks from the next line |
572 | 566 | $this->egress->sink->write("\n"); |
573 | 567 | |
574 | 568 | $this->buffer = $this->xmlwriterobj->closeStream(); |
— | — | @@ -575,20 +569,16 @@ |
576 | 570 | |
577 | 571 | $this->buffer = ""; |
578 | 572 | $this->thisPage = ""; |
579 | | - /* this could be more than one file if we had more than one output arg */ |
| 573 | + // this could be more than one file if we had more than one output arg |
580 | 574 | $checkpointFilenames = array(); |
581 | | - $filenameList = $this->egress->getFilename(); |
582 | | - |
583 | | - if (! is_array($filenameList)) { |
584 | | - $filenameList = array( $filenameList ); |
585 | | - } |
| 575 | + $filenameList = (array)$this->egress->getFilename(); |
586 | 576 | $newFilenames = array(); |
587 | 577 | $firstPageID = str_pad($this->firstPageWritten,9,"0",STR_PAD_LEFT); |
588 | 578 | $lastPageID = str_pad($this->lastPageWritten,9,"0",STR_PAD_LEFT); |
589 | | - for ($i =0; $i < count($filenameList); $i++) { |
590 | | - $checkpointNameFilledIn = sprintf($this->checkpointFiles[$i], $firstPageID, $lastPageID); |
| 579 | + for ( $i = 0; $i < count( $filenameList ); $i++ ) { |
| 580 | + $checkpointNameFilledIn = sprintf( $this->checkpointFiles[$i], $firstPageID, $lastPageID ); |
591 | 581 | $fileinfo = pathinfo($filenameList[$i]); |
592 | | - $newFilenames[] = $fileinfo{'dirname'} . '/' . $checkpointNameFilledIn; |
| 582 | + $newFilenames[] = $fileinfo['dirname'] . '/' . $checkpointNameFilledIn; |
593 | 583 | } |
594 | 584 | $this->egress->closeRenameAndReopen( $newFilenames ); |
595 | 585 | $this->buffer = $this->xmlwriterobj->openStream(); |
— | — | @@ -618,8 +608,8 @@ |
619 | 609 | $this->thisPage .= $data; |
620 | 610 | } |
621 | 611 | } |
622 | | - # have to skip the newline left over from closepagetag line of |
623 | | - # end of checkpoint files. nasty hack!! |
| 612 | + // have to skip the newline left over from closepagetag line of |
| 613 | + // end of checkpoint files. nasty hack!! |
624 | 614 | if ($this->checkpointJustWritten) { |
625 | 615 | if ($data[0] == "\n") { |
626 | 616 | $data = substr($data,1); |