r53940 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53939‎ | r53940 | r53941 >
Date:14:17, 29 July 2009
Author:werdna
Status:deferred
Tags:
Comment:
Cleanup for inclusion of thread data in XML dumps:
* Reduce redundancy in generation code.
* Add a few more fields that might or might not be useful
TODO: Update import scripts to handle the extra data correctly
Modified paths:
  • /trunk/extensions/LiquidThreads/LqtFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/LqtFunctions.php
@@ -139,17 +139,36 @@
140140 }
141141
142142 function lqtDumpThreadData( $writer, &$out, $row, $title ) {
 143+ $editedStati = array( Threads::EDITED_NEVER => 'never',
 144+ Threads::EDITED_HAS_REPLY => 'has-reply',
 145+ Threads::EDITED_BY_AUTHOR => 'by-author',
 146+ Threads::EDITED_BY_OTHERS => 'by-others' );
 147+ $threadTypes = array( Threads::TYPE_NORMAL => 'normal',
 148+ Threads::TYPE_MOVED => 'moved',
 149+ Threads::TYPE_DELETED => 'deleted' );
143150 // Is it a thread
144151 if ( $row->thread_id ) {
145152 $thread = new Thread( $row );
146153 $threadInfo = "\n";
147 - $threadInfo .= Xml::element( 'ThreadSubject', null, $thread->subject() ) . "\n";
 154+ $attribs = array();
 155+ $attribs['ThreadSubject'] = $thread->subject();
148156 if ($thread->hasSuperThread()) {
149 - $threadInfo .= Xml::element( 'ThreadParent', null, $thread->superThread()->id() ) . "\n";
 157+ $attribs['ThreadParent'] = $thread->superThread()->id();
150158 }
151 - $threadInfo .= Xml::element( 'ThreadAncestor', null, $thread->topmostThread()->id() ) . "\n";
152 - $threadInfo .= Xml::element( 'ThreadPage', null, $thread->article()->getId() ) . "\n";
 159+ $attribs['ThreadAncestor'] = $thread->topmostThread()->id();
 160+ $attribs['ThreadPage'] = $thread->article()->getId();
 161+ $attribs['ThreadID'] = $thread->id();
 162+ if ( $thread->hasSummary() ) {
 163+ $attribs['ThreadSummaryPage'] = $thread->summary()->getId();
 164+ }
 165+ $attribs['ThreadAuthor'] = $thread->author()->getName();
 166+ $attribs['ThreadEditStatus'] = $editedStati[$thread->editedness()];
 167+ $attribs['ThreadType'] = $threadTypes[$thread->type()];
153168
 169+ foreach( $attribs as $key => $value ) {
 170+ $threadInfo .= "\t".Xml::element( $key, null, $value ) . "\n";
 171+ }
 172+
154173 $out .= Xml::tags( 'DiscussionThreading', null, $threadInfo ) . "\n";
155174 }
156175

Status & tagging log