Index: trunk/phase3/maintenance/renderDump.php |
— | — | @@ -39,19 +39,34 @@ |
40 | 40 | parent::__construct(); |
41 | 41 | $this->mDescription = "Take page text out of an XML dump file and render basic HTML out to files"; |
42 | 42 | $this->addOption( 'output-dir', 'The directory to output the HTML files to', true, true ); |
| 43 | + $this->addOption( 'prefix', 'Prefix for the rendered files (defaults to wiki)', false, true ); |
| 44 | + $this->addOption( 'parser', 'Use an alternative parser class', false, true ); |
43 | 45 | } |
44 | 46 | |
45 | 47 | public function execute() { |
46 | 48 | $this->outputDirectory = $this->getOption( 'output-dir' ); |
| 49 | + $this->prefix = $this->getOption( 'prefix', 'wiki' ); |
47 | 50 | $this->startTime = wfTime(); |
48 | 51 | |
| 52 | + if ( $this->hasOption( 'parser' ) ) { |
| 53 | + global $wgParserConf; |
| 54 | + $wgParserConf['class'] = $this->getOption( 'parser' ); |
| 55 | + $this->prefix .= "-{$wgParserConf['class']}"; |
| 56 | + } |
| 57 | + |
49 | 58 | $source = new ImportStreamSource( $this->getStdin() ); |
50 | 59 | $importer = new WikiImporter( $source ); |
51 | 60 | |
52 | 61 | $importer->setRevisionCallback( |
53 | 62 | array( &$this, 'handleRevision' ) ); |
54 | 63 | |
55 | | - return $importer->doImport(); |
| 64 | + $importer->doImport(); |
| 65 | + |
| 66 | + $delta = wfTime() - $this->startTime; |
| 67 | + $this->error( "Rendered {$this->count} pages in " . round($delta, 2) . " seconds " ); |
| 68 | + if ($delta > 0) |
| 69 | + $this->error( round($this->count / $delta, 2) . " pages/sec" ); |
| 70 | + $this->error( "\n" ); |
56 | 71 | } |
57 | 72 | |
58 | 73 | /** |
— | — | @@ -59,6 +74,8 @@ |
60 | 75 | * @param $rev Revision |
61 | 76 | */ |
62 | 77 | public function handleRevision( $rev ) { |
| 78 | + global $wgParserConf; |
| 79 | + |
63 | 80 | $title = $rev->getTitle(); |
64 | 81 | if ( !$title ) { |
65 | 82 | $this->error( "Got bogus revision with null title!" ); |
— | — | @@ -69,15 +86,15 @@ |
70 | 87 | $this->count++; |
71 | 88 | |
72 | 89 | $sanitized = rawurlencode( $display ); |
73 | | - $filename = sprintf( "%s/wiki-%07d-%s.html", |
| 90 | + $filename = sprintf( "%s/%s-%07d-%s.html", |
74 | 91 | $this->outputDirectory, |
| 92 | + $this->prefix, |
75 | 93 | $this->count, |
76 | 94 | $sanitized ); |
77 | 95 | $this->output( sprintf( "%s\n", $filename, $display ) ); |
78 | 96 | |
79 | | - // fixme (what?) |
80 | 97 | $user = new User(); |
81 | | - $parser = new Parser(); |
| 98 | + $parser = new $wgParserConf['class'](); |
82 | 99 | $options = ParserOptions::newFromUser( $user ); |
83 | 100 | |
84 | 101 | $output = $parser->parse( $rev->getText(), $title, $options ); |