* Usage:
* php dumpHTML.php [options...]
*
- * -d <dest> destination directory
- * -s <start> start ID
- * -e <end> end ID
- * --images only do image description pages
- * --categories only do category pages
- * --special only do miscellaneous stuff
- * --force-copy copy commons instead of symlink, needed for Wikimedia
- * --interlang allow interlanguage links
+ * -d <dest> destination directory
+ * -s <start> start ID
+ * -e <end> end ID
+ * -k <skin> skin to use (defaults to htmldump)
+ * --images only do image description pages
+ * --categories only do category pages
+ * --redirects only do redirects
+ * --special only do miscellaneous stuff
+ * --force-copy copy commons instead of symlink, needed for Wikimedia
+ * --interlang allow interlanguage links
+ * --image-snapshot copy all images used to the destination directory
*/
-$optionsWithArgs = array( 's', 'd', 'e' );
+$optionsWithArgs = array( 's', 'd', 'e', 'k' );
+
+$profiling = false;
+
+if ( $profiling ) {
+ define( 'MW_CMDLINE_CALLBACK', 'wfSetupDump' );
+ function wfSetupDump() {
+ global $wgProfiling, $wgProfileToDatabase, $wgProfileSampleRate;
+ $wgProfiling = true;
+ $wgProfileToDatabase = false;
+ $wgProfileSampleRate = 1;
+ }
+}
require_once( "commandLine.inc" );
require_once( "dumpHTML.inc" );
$end = $options['e'];
} else {
$dbr =& wfGetDB( DB_SLAVE );
- $end = $dbr->selectField( 'page', 'max(page_id)', false );
+ $end = $dbr->selectField( 'page', 'max(page_id)', false );
}
if ( !empty( $options['d'] ) ) {
$dest = 'static';
}
-$d = new DumpHTML( array(
- 'dest' => $dest,
+$skin = isset( $options['k'] ) ? $options['k'] : 'htmldump';
+
+$wgHTMLDump = new DumpHTML( array(
+ 'dest' => $dest,
'forceCopy' => $options['force-copy'],
'alternateScriptPath' => $options['interlang'],
'interwiki' => $options['interlang'],
+ 'skin' => $skin,
+ 'makeSnapshot' => $options['image-snapshot'],
));
if ( $options['special'] ) {
- $d->doSpecials();
+ $wgHTMLDump->doSpecials();
} elseif ( $options['images'] ) {
- $d->doImageDescriptions();
+ $wgHTMLDump->doImageDescriptions();
} elseif ( $options['categories'] ) {
- $d->doCategories();
+ $wgHTMLDump->doCategories();
+} elseif ( $options['redirects'] ) {
+ $wgHTMLDump->doRedirects();
} else {
print("Creating static HTML dump in directory $dest. \n".
"Starting from page_id $start of $end.\n");
- $d->doArticles( $start, $end );
- $d->doImageDescriptions();
- $d->doCategories();
- $d->doSpecials();
-
+
+ $dbr =& wfGetDB( DB_SLAVE );
+ $server = $dbr->getProperty( 'mServer' );
+ print "Using database {$server}\n";
+
+ $wgHTMLDump->doArticles( $start, $end );
+ if ( !isset( $options['e'] ) ) {
+ $wgHTMLDump->doImageDescriptions();
+ $wgHTMLDump->doCategories();
+ $wgHTMLDump->doSpecials();
+ }
+
/*
if ( $end - $start > CHUNK_SIZE * 2 ) {
// Split the problem into smaller chunks, run them in different PHP instances
*/
}
-exit();
+if ( isset( $options['debug'] ) ) {
+ print_r($GLOBALS);
+}
+
+if ( $profiling ) {
+ echo $wgProfiler->getOutput();
+}
?>