4 * @subpackage Maintenance
7 define( 'REPORTING_INTERVAL', 10 );
9 function dumpHTML( $dest, $start ) {
10 global $wgUser, $wgTitle, $wgArticle, $wgEnablePersistentLC, $wgLinkCache, $wgOut;
11 global $wgMakeDumpLinks, $wgStylePath, $wgArticlePath, $wgUploadPath, $wgLogo;
12 $wgMakeDumpLinks = true;
13 $wgScriptPath = "../../..";
14 $wgStylePath = "$wgScriptPath/skins";
15 $wgUploadPath = "$wgScriptPath/images";
16 $wgLogo = "$wgStylePath/common/images/wiki.png";
17 $wgArticlePath = '../../$1';
18 $dbr =& wfGetDB( DB_SLAVE );
19 $end = $dbr->selectField( 'page', 'max(page_id)', false );
21 /*global $wgValidSkinNames;
22 var_dump( $wgValidSkinNames );
25 print("Creating static HTML dump. Starting from page_id $start of $end.\n");
28 $wgUser->setOption( 'skin', 'htmldump' );
29 $sk =& $wgUser->getSkin();
31 if ( !is_dir( $dest ) ) {
32 if ( !mkdir( $dest, 0755 ) ) {
33 print("Can't make directory $dir, exiting\n");
38 for ($id = $start; $id <= $end; $id++) {
39 if ( !($id % REPORTING_INTERVAL) ) {
43 $wgOut = new OutputPage;
44 $wgOut->setArticleFlag( true );
45 $wgOut->setRobotpolicy( 'index,follow' );
47 $wgTitle = Title::newFromID( $id );
48 if ( is_null( $wgTitle ) ) {
52 $wgArticle = new Article( $wgTitle );
53 $text = $wgArticle->getContent( true );
54 $wgLinkCache = new LinkCache;
55 $wgLinkCache->forUpdate( true );
57 global $wgLinkHolders;
58 $wgLinkHolders = array(
59 'namespaces' => array(),
67 # Parse the text and replace links with placeholders
68 $wgOut->setPageTitle( $wgTitle->getPrefixedText() );
69 $wgOut->addWikiText( $text );
70 $wgOut->transformBuffer();
72 # Execute skin to get complete HTML
74 $sk->outputPage( $wgOut );
75 $text = ob_get_contents();
79 $fname = $wgTitle->getHashedFilename();
80 $bits = explode( '/', $fname );
81 $parentDir = "$dest/{$bits[0]}";
82 $fullDir = "$dest/{$bits[0]}/{$bits[1]}";
83 $fullName = "$dest/$fname";
85 if ( !is_dir( $parentDir ) ) {
86 if ( !mkdir( $parentDir, 0744 ) ) {
87 print("Can't write to directory $parentDir\n");
91 if ( !is_dir( $fullDir ) ) {
92 if ( !mkdir( $fullDir, 0744 ) ) {
93 print("Can't write to directory $fullDir\n");
98 $file = fopen( $fullName, 'w' );
100 print("Can't open file $fullName for writing\n");
104 fwrite( $file, $text );