3 define( 'REPORTING_INTERVAL', 10 );
5 function dumpHTML( $dest, $start ) {
6 global $wgUser, $wgTitle, $wgArticle, $wgEnablePersistentLC, $wgLinkCache, $wgOut;
7 global $wgMakeDumpLinks, $wgStylePath, $wgArticlePath, $wgUploadPath, $wgLogo;
8 $wgMakeDumpLinks = true;
9 $wgScriptPath = "../../..";
10 $wgStylePath = "$wgScriptPath/skins";
11 $wgUploadPath = "$wgScriptPath/images";
12 $wgLogo = "$wgStylePath/common/images/wiki.png";
13 $wgArticlePath = '../../$1';
14 $dbr =& wfGetDB( DB_SLAVE );
15 $end = $dbr->selectField( 'cur', 'max(cur_id)', false );
17 /*global $wgValidSkinNames;
18 var_dump( $wgValidSkinNames );
21 print("Creating static HTML dump. Starting from cur_id $start of $end.\n");
24 $wgUser->setOption( 'skin', 'htmldump' );
25 $sk =& $wgUser->getSkin();
27 if ( !is_dir( $dest ) ) {
28 if ( !mkdir( $dest, 0644 ) ) {
29 print("Can't make directory $dir, exiting\n");
34 for ($id = $start; $id <= $end; $id++) {
35 if ( !($id % REPORTING_INTERVAL) ) {
39 $wgOut = new OutputPage;
40 $wgOut->setArticleFlag( true );
41 $wgOut->setRobotpolicy( 'index,follow' );
43 $wgTitle = Title::newFromID( $id );
44 if ( is_null( $wgTitle ) ) {
48 $wgArticle = new Article( $wgTitle );
49 $text = $wgArticle->getContent( true );
50 $wgLinkCache = new LinkCache;
51 $wgLinkCache->forUpdate( true );
53 global $wgLinkHolders;
54 $wgLinkHolders = array(
55 'namespaces' => array(),
63 # Parse the text and replace links with placeholders
64 $wgOut->setPageTitle( $wgTitle->getPrefixedText() );
65 $wgOut->addWikiText( $text );
66 $wgOut->transformBuffer();
68 # Execute skin to get complete HTML
70 $sk->outputPage( $wgOut );
71 $text = ob_get_contents();
75 $fname = $wgTitle->getHashedFilename();
76 $bits = explode( '/', $fname );
77 $parentDir = "$dest/{$bits[0]}";
78 $fullDir = "$dest/{$bits[0]}/{$bits[1]}";
79 $fullName = "$dest/$fname";
82 if ( !is_dir( $parentDir ) ) {
83 if ( !mkdir( $parentDir, 0644 ) ) {
84 print("Can't write to directory $parentDir\n");
88 if ( !is_dir( $fullDir ) ) {
89 if ( !mkdir( $fullDir, 0644 ) ) {
90 print("Can't write to directory $fullDir\n");
95 $file = fopen( $fullName, 'w' );
97 print("Can't open file $fullName for writing\n");
101 fwrite( $file, $text );