class TextPassDumper extends BackupDumper {
var $prefetch = null;
-
+
function dump() {
# This shouldn't happen if on console... ;)
header( 'Content-type: text/html; charset=UTF-8' );
-
+
# Notice messages will foul up your XML output even if they're
# relatively harmless.
// ini_set( 'display_errors', false );
-
+
$this->startTime = wfTime();
-
+
$this->db =& $this->backupDb();
$this->maxCount = $this->db->selectField( 'page', 'MAX(page_id)', '', 'BackupDumper::dump' );
$this->startTime = wfTime();
-
+
$this->egress = new ExportProgressFilter( $this->sink, $this );
$input = fopen( "php://stdin", "rt" );
$result = $this->readDump( $input );
-
+
if( WikiError::isError( $result ) ) {
$this->progress( $result->getMessage() );
}
-
+
$this->report( true );
}
-
+
function processOption( $opt, $val, $param ) {
if( $opt == 'prefetch' ) {
require_once 'maintenance/backupPrefetch.inc';
$this->prefetch = new BaseDump( $filename );
}
}
-
+
function readDump( $input ) {
$this->buffer = "";
$this->openElement = false;
$this->lastName = "";
$this->thisPage = 0;
$this->thisRev = 0;
-
+
$parser = xml_parser_create( "UTF-8" );
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false );
-
+
xml_set_element_handler( $parser, array( &$this, 'startElement' ), array( &$this, 'endElement' ) );
xml_set_character_data_handler( $parser, array( &$this, 'characterData' ) );
-
+
$offset = 0; // for context extraction on error reporting
$bufferSize = 512 * 1024;
do {
} while( $chunk !== false && !feof( $input ) );
xml_parser_free( $parser );
}
-
+
function getText( $id ) {
if( isset( $this->prefetch ) ) {
$text = $this->prefetch->prefetch( $this->thisPage, $this->thisRev );
$normalized = UtfNormal::cleanUp( $stripped );
return $normalized;
}
-
+
function startElement( $parser, $name, $attribs ) {
$this->clearOpenElement( null );
$this->lastName = $name;
-
+
if( $name == 'revision' ) {
$this->state = $name;
$this->egress->writeOpenPage( null, $this->buffer );
$this->atStart = false;
}
}
-
+
if( $name == "text" && isset( $attribs['id'] ) ) {
$text = $this->getText( $attribs['id'] );
$this->openElement = array( $name, array( 'xml:space' => 'preserve' ) );
$this->openElement = array( $name, $attribs );
}
}
-
+
function endElement( $parser, $name ) {
if( $this->openElement ) {
$this->clearOpenElement( "" );
} else {
$this->buffer .= "</$name>";
}
-
+
if( $name == 'revision' ) {
$this->egress->writeRevision( null, $this->buffer );
$this->buffer = "";
$this->buffer = "";
}
}
-
+
function characterData( $parser, $data ) {
$this->clearOpenElement( null );
if( $this->lastName == "id" ) {
}
$this->buffer .= htmlspecialchars( $data );
}
-
+
function clearOpenElement( $style ) {
if( $this->openElement ) {
$this->buffer .= wfElement( $this->openElement[0], $this->openElement[1], $style );