r22547 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22546‎ | r22547 | r22548 >
Date:01:44, 30 May 2007
Author:david
Status:old
Tags:
Comment:
Links back to the context from thread permalinks; cosmetics.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)
  • /branches/liquidthreads/skins/monobook/main.css (modified) (history)

Diff [purge]

Index: branches/liquidthreads/skins/monobook/main.css
@@ -140,25 +140,39 @@
141141 border-color: #aaa;
142142 }
143143
144 -.lqt_post:hover a {
 144+.lqt_post .lqt_footer:hover a {
145145 color: #002bb8;
 146+ text-decoration: none;
146147 }
147 -.lqt_post:hover a:visited {
 148+.lqt_post .lqt_footer:hover a:visited {
148149 color: #5a3696;
 150+ text-decoration: none;
149151 }
150 -.lqt_post:hover .lqt_footer a:active {
 152+.lqt_post .lqt_footer:hover .lqt_footer a:active {
151153 color: #faa700;
 154+ text-decoration: none;
152155 }
153 -.lqt_post:hover a.stub {
 156+.lqt_post .lqt_footer:hover a.stub {
154157 color: #772233;
 158+ text-decoration: none;
155159 }
156 -.lqt_post:hover a.new, #p-personal a.new {
 160+.lqt_post .lqt_footer:hover a.new, #p-personal a.new {
157161 color: #ba0000;
 162+ text-decoration: none;
158163 }
159 -.lqt_post:hover a.new:visited, #p-personal a.new:visited {
 164+.lqt_post .lqt_footer:hover a.new:visited, #p-personal a.new:visited {
160165 color: #a55858;
 166+ text-decoration: none;
161167 }
162168
 169+.lqt_context_message {
 170+ display: table; /* Occupy only the width of the text, */
 171+ width: auto; /* not the entire available width. */
 172+
 173+ border: 1px solid #ddd;
 174+ margin: 2em 0;
 175+ padding: .5em;
 176+}
163177
164178
165179 /**
Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -145,7 +145,7 @@
146146 $this->perpetuate('lqt_reply_to', 'hidden') .
147147 $this->perpetuate('lqt_new_thread_form', 'hidden');
148148
149 - if ( $thread == null || $thread->superthread() == null ) {
 149+ if ( /*$thread == null*/ $edit_type=='new' || ($thread && $thread->superthread() == null) ) {
150150 // This is a top-level post; show the subject line.
151151 $subject = $this->request->getVal('lqt_subject_field', $thread ? $thread->subject() : '');
152152 $e->editFormTextBeforeContent .= <<<HTML
@@ -327,20 +327,42 @@
328328 }
329329
330330 class ThreadPermalinkView extends LqtView {
 331+ function showThreadHeading( $thread ) {
 332+ if ( $thread->hasSubject() && $this->headerLevel == 1 ) {
 333+ $this->output->setPageTitle( "Thread: " . $thread->subject() );
 334+ } else {
 335+ parent::showThreadHeading($thread);
 336+ }
 337+ }
 338+
331339 function show() {
332340 /* Extract the numeric ID after the slash in the URL. */
333341 $title_string = $this->request->getVal('title');
334342 $a = explode('/', $title_string);
335343 if ( $a == false || count( $a ) < 2 || !ctype_digit($a[1]) ) {
336 - echo("bad request"); // TODO this is not a very friendly way to handle this.
 344+ echo("bad request (TODO real error msg?)");
337345 die();
338346 }
339347 $thread_id = intval($a[1]);
 348+
 349+ $t = Thread::newFromId( $thread_id );
 350+ $this->article = $t->article(); # for creating reply threads.
340351
341 - $this->output->setPageTitle( "Thread #$thread_id" );
 352+ $this->output->setPageTitle( "Thread: #$thread_id" ); // Default if no subject line.
 353+
 354+$talkpage_link = $this->user->getSkin()->makeKnownLinkObj($t->article()->getTitle()->getTalkpage());
 355+ if ( $t->superthread() ) {
 356+/* $this->output->addHTML(<<<HTML
 357+ <p class="lqt_context_message">You are viewing a reply to another post.
 358+ <a href="{$this->permalinkUrl($t->topmostThread())}">View the entire discussion.</a></p>
 359+HTML
 360+);*/
 361+ $this->output->setSubtitle( "a fragment of <a href=\"{$this->permalinkUrl($t->topmostThread())}\">a discussion</a> from " . $talkpage_link );
 362+ } else {
 363+
 364+ $this->output->setSubtitle( "from " . $talkpage_link );
 365+ }
342366
343 - $t = Thread::newFromId( $thread_id );
344 - $this->article = $t->article();
345367 $this->showThread($t);
346368 }
347369 }
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -25,6 +25,8 @@
2626
2727 }
2828
 29+// TODO when exactly do we update thraed_touched?
 30+
2931 class Thread {
3032
3133 /* ID references to other objects that are loaded on demand: */
@@ -57,6 +59,11 @@
5860 return $this->superthread;
5961 }
6062
 63+ function topmostThread() {
 64+ if ( !$this->superthread() ) return $this;
 65+ else return $this->superthread()->topmostThread();
 66+ }
 67+
6168 function setArticle($a) {
6269 $this->articleId = $a->getID();
6370 $this->updateRecord();
@@ -100,10 +107,9 @@
101108 return Thread::threadsWhere( array('thread_subthread_of' => $this->id),
102109 array('ORDER BY' => 'thread_touched') );
103110 }
104 -
 111+
105112 protected function updateRecord() {
106113 $dbr =& wfGetDB( DB_MASTER );
107 -
108114 $res = $dbr->update( 'lqt_thread',
109115 /* SET */ array( 'thread_root_post' => $this->rootPostId,
110116 'thread_article' => $this->articleId,