+
+ /**
+ * Dumps a <logitem> section on the output stream, with
+ * data filled in from the given database row.
+ *
+ * @param $row object
+ * @return string
+ * @access private
+ */
+ function writeLogItem( $row ) {
+ wfProfileIn( __METHOD__ );
+
+ $out = " <logitem>\n";
+ $out .= " " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
+
+ $out .= $this->writeTimestamp( $row->log_timestamp );
+
+ if( $row->log_deleted & LogPage::DELETED_USER ) {
+ $out .= " " . Xml::element( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
+ } else {
+ $out .= $this->writeContributor( $row->log_user, $row->user_name );
+ }
+
+ if( $row->log_deleted & LogPage::DELETED_COMMENT ) {
+ $out .= " " . Xml::element( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
+ } elseif( $row->log_comment != '' ) {
+ $out .= " " . Xml::elementClean( 'comment', null, strval( $row->log_comment ) ) . "\n";
+ }
+
+ $out .= " " . Xml::element( 'type', null, strval( $row->log_type ) ) . "\n";
+ $out .= " " . Xml::element( 'action', null, strval( $row->log_action ) ) . "\n";
+
+ if( $row->log_deleted & LogPage::DELETED_ACTION ) {
+ $out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
+ } else {
+ $title = Title::makeTitle( $row->log_namespace, $row->log_title );
+ $out .= " " . Xml::elementClean( 'logtitle', null, $title->getPrefixedText() ) . "\n";
+ $out .= " " . Xml::elementClean( 'params',
+ array( 'xml:space' => 'preserve' ),
+ strval( $row->log_params ) ) . "\n";
+ }
+
+ $out .= " </logitem>\n";
+
+ wfProfileOut( __METHOD__ );
+ return $out;
+ }
+
+ function writeTimestamp( $timestamp ) {
+ $ts = wfTimestamp( TS_ISO_8601, $timestamp );
+ return " " . Xml::element( 'timestamp', null, $ts ) . "\n";
+ }
+
+ function writeContributor( $id, $text ) {
+ $out = " <contributor>\n";
+ if( $id ) {
+ $out .= " " . Xml::elementClean( 'username', null, strval( $text ) ) . "\n";
+ $out .= " " . Xml::element( 'id', null, strval( $id ) ) . "\n";
+ } else {
+ $out .= " " . Xml::elementClean( 'ip', null, strval( $text ) ) . "\n";
+ }
+ $out .= " </contributor>\n";
+ return $out;
+ }
+
+ /**
+ * Warning! This data is potentially inconsistent. :(
+ */
+ function writeUploads( $row ) {
+ if( $row->page_namespace == NS_IMAGE ) {
+ $img = wfFindFile( $row->page_title );
+ if( $img ) {
+ $out = '';
+ foreach( array_reverse( $img->getHistory() ) as $ver ) {
+ $out .= $this->writeUpload( $ver );
+ }
+ $out .= $this->writeUpload( $img );
+ return $out;
+ }
+ }
+ return '';
+ }
+
+ function writeUpload( $file ) {
+ return " <upload>\n" .
+ $this->writeTimestamp( $file->getTimestamp() ) .
+ $this->writeContributor( $file->getUser( 'id' ), $file->getUser( 'text' ) ) .
+ " " . Xml::elementClean( 'comment', null, $file->getDescription() ) . "\n" .
+ " " . Xml::element( 'filename', null, $file->getName() ) . "\n" .
+ " " . Xml::element( 'src', null, $file->getFullUrl() ) . "\n" .
+ " " . Xml::element( 'size', null, $file->getSize() ) . "\n" .
+ " </upload>\n";
+ }