r22471 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22470‎ | r22471 | r22472 >
Date:07:21, 27 May 2007
Author:david
Status:old
Tags:
Comment:
Added user signatures. We access Post::originalAuthor directly from the view; not sure there shouldn't be an intermediary method in Thread.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -21,7 +21,7 @@
2222 require_once('LqtModel.php');
2323
2424 class LqtDispatch {
25 - /** Invoked from performAction() in Wiki.php if this is a discussion namespace. */
 25+ /* Invoked from performAction() in Wiki.php if this is a discussion namespace. */
2626 static function talkpageMain(&$output, &$talk_article, &$title, &$user, &$request) {
2727 // We are given a talkpage article and title. Find the associated
2828 // non-talk article and pass that to the view.
@@ -67,18 +67,18 @@
6868 }
6969 return $q;
7070 }
71 -
 71+
7272 /**
73 - @return href for a link to the same page as is being currently viewed,
74 - but with additional query variables.
75 - @param $vars array( 'query_variable_name' => 'value', ... ).
 73+ * @return href for a link to the same page as is being currently viewed,
 74+ * but with additional query variables.
 75+ * @param $vars array( 'query_variable_name' => 'value', ... ).
7676 */
7777 function selflink( $vars = null ) {
7878 return $this->title->getFullURL( $this->queryStringFromArray($vars) );
7979 }
8080
8181 /**
82 - @return true if the value of the give query variable name is equal to the given post's ID.
 82+ * @return true if the value of the give query variable name is equal to the given post's ID.
8383 */
8484 function commandApplies( $command, $post ) {
8585 return $this->request->getVal($command) == $post->getTitle()->getPrefixedURL();
@@ -210,13 +210,18 @@
211211 }
212212 }
213213
214 - function showThreadCommands( $thread ) {
215 -
 214+ function showThreadFooter( $thread ) {
 215+
 216+ $this->output->addHTML(wfOpenElement('ul', array('class'=>'lqt_footer')));
 217+
 218+ $this->output->addHTML( wfOpenElement( 'li' ) );
 219+ $p = new Parser(); $sig = $p->getUserSig( $thread->rootPost()->originalAuthor() );
 220+ $this->output->addWikitext( $sig, false );
 221+ $this->output->addHTML( wfCloseElement( 'li' ) );
 222+
216223 $commands = array( 'Edit' => $this->selflink( array( LQT_COMMAND_EDIT_POST => $thread->rootPost()->getTitle()->getPrefixedURL() ) ),
217224 'Reply' => $this->selflink( array( LQT_COMMAND_REPLY_TO_POST => $thread->id() ) ));
218225
219 - $this->output->addHTML(wfOpenElement('ul', array('class'=>'lqt_footer')));
220 -
221226 foreach( $commands as $label => $href ) {
222227 $this->output->addHTML( wfOpenElement( 'li' ) );
223228 $this->output->addHTML( wfElement('a', array('href'=>$href), $label) );
@@ -235,7 +240,7 @@
236241 $this->showPostEditingForm( $thread );
237242 } else{
238243 $this->showPostBody( $post );
239 - $this->showThreadCommands( $thread );
 244+ $this->showThreadFooter( $thread );
240245 }
241246
242247 $this->closeDiv();
@@ -281,7 +286,7 @@
282287 if( $this->request->getBool('lqt_new_thread_form') ) {
283288 $this->showNewThreadForm();
284289 } else {
285 - $this->output->addHTML("<a href=\"{$this->title->getFullURL('lqt_new_thread_form=1')}\">New Thread</a>");
 290+ $this->output->addHTML("<a href=\"{$this->title->getFullURL('lqt_new_thread_form=1')}\">Start a Discussion</a>");
286291 }
287292 $threads = Thread::allThreadsOfArticle($this->article);
288293 foreach($threads as $t) {
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -4,7 +4,25 @@
55
66
77 class Post extends Article {
8 - // Empty for the time being.
 8+ /**
 9+ * Return the User object representing the author of the first revision
 10+ * (or null, if the database is screwed up).
 11+ */
 12+ function originalAuthor() {
 13+ $dbr =& wfGetDB( DB_SLAVE );
 14+
 15+ $line = $dbr->selectRow( array('revision', 'page'), 'rev_user_text',
 16+ array('rev_page = page_id',
 17+ 'page_id' => $this->getID()),
 18+ __METHOD__,
 19+ array('ORDER BY'=> 'rev_timestamp',
 20+ 'LIMIT' => '1') );
 21+ if ( $line )
 22+ return User::newFromName($line->rev_user_text, false);
 23+ else
 24+ return null;
 25+ }
 26+
927 }
1028
1129 class Thread {