title); if(strlen($data)+$totaldata >= $maxdata){ #finish this file's XML stuff fwrite($outfile,"\n"); #close the file fclose($outfile); #increment the file number $filenum++; #open a new file $outfile = fopen("$idifdir/wikipedia_$filenum.idif","w"); #append the new file's URL to the IDIF index $indexfile = fopen("$idifdir/idif_index.txt","a"); fwrite($indexfile,"$idifurl/wikipedia_$filenum.idif\n"); fclose($indexfile); #put the XML main tags in the new file outputHeader($outfile); $totaldata = 0; } fwrite($outfile,$data); $totaldata += strlen($data); } } function outputHeader($outfile){ fwrite($outfile,"\n"); fwrite($outfile, "\n"); } function getPageData($page){ $return = "\n"; $return .= "\n"; print "fetching \"$page\"\n"; global $wgTitle; $title = Title::NewFromText( $page ); $wgTitle = $title; if( !$title ) return ""; $t = wfStrencode( $title->getDBKey() ); $article = new Article($title); $text = $article->getContent($title); $parser = new Parser(); $parser_output = $parser->parse($text); $return .= "\n\n"; $title_text = $title->getText(); $return .= "Wikipedia: $title_text\n"; $return .= "\n"; $return .= "\n"; $return .= "\n"; $return .= $parser_output->getText(); $return .= "\n"; $return .= "\n\n\n"; return $return; } ?>