summaryrefslogtreecommitdiff
path: root/buildscripts/wikibuilder/dumpHTML.php
blob: d34e53edb7bebd6ac516b2ae56aec34785aa7ca5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
/**
 * @todo document
 * @package MediaWiki
 * @subpackage Maintenance
 */

/**
 * 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
 */


$optionsWithArgs = array( 's', 'd', 'e' );

require_once($wiki_dir. "/maintenance/commandLine.inc" );
require_once(dirname(__FILE__)."/dumpHTML.inc" );

class DummyUser extends User
{
	function getSkin()
	{
		require_once(dirname(__FILE__).'/DumpSkin.php' );
		$this->mSkin =& new DumpSkin;
		return $this->mSkin;
	}
}

class DumpTitle extends Title
{
	function getHashedDirectory() 
	{
		return strtr(parent::getHashedDirectory(), '~:', '__');
	}
}

error_reporting( E_ALL & (~E_NOTICE) );
define( 'CHUNK_SIZE', 50 );

if ( !empty( $options['s'] ) ) {
	$start = $options['s'];
} else {
	$start = 1280;
}

if ( !empty( $options['e'] ) ) {
	$end = $options['e'];
} else {
	$dbr =& wfGetDB( DB_SLAVE );
	$end = $dbr->selectField( 'page', 'max(page_id)', false );	
}

if ( !empty( $options['d'] ) ) {
	$dest = $options['d'];
} else {
	$dest = $output_dir;
}

class DumpHTMLSkined extends DumpHTML
{
	function setupGlobals( $depth = NULL ) 
	{
		parent::setupGlobals($depth);
		global $wgUser,$wgServer,$wiki_url;
		$wgUser = new DummyUser;
		$wgServer = $wiki_url;
	}
}

$d = new DumpHTMLSkined( array( 
	'dest' => $dest, 
	'forceCopy' => $options['force-copy'],
	'alternateScriptPath' => $options['interlang'],
	'interwiki' => $options['interlang'],
));


if ( $options['special'] ) {
	$d->doSpecials();
} elseif ( $options['images'] ) {
	$d->doImageDescriptions();
} elseif ( $options['categories'] ) {
	$d->doCategories();
} 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->doMainPage();
}

?>