r28178 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r28177‎ | r28178 | r28179 >
Date:08:14, 5 December 2007
Author:david
Status:old
Tags:
Comment:
Show notice when threads have been edited, with smarts.
Modified paths:
  • /trunk/extensions/LiquidThreads/Lqt.i18n.php (modified) (history)
  • /trunk/extensions/LiquidThreads/LqtBaseView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/LqtModel.php (modified) (history)
  • /trunk/extensions/LiquidThreads/README (modified) (history)
  • /trunk/extensions/LiquidThreads/lqt-schema-change-5.sql (added) (history)
  • /trunk/extensions/LiquidThreads/lqt.css (modified) (history)
  • /trunk/extensions/LiquidThreads/lqt.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/lqt-schema-change-5.sql
@@ -0,0 +1,13 @@
 2+alter table thread add column thread_editedness int(1) NOT NULL default 0;
 3+
 4+update thread join thread as child on child.thread_parent = thread.thread_id set thread.thread_editedness = 1;
 5+
 6+create temporary table counts ( thread_id int(8) unsigned, revision_count int(8) unsigned, author_count int(8) unsigned, rev_user int(8) unsigned );
 7+
 8+insert into counts (thread_id, revision_count, author_count, rev_user) select thread_id, count(thread_id), count(distinct rev_user), rev_user from thread join revision on rev_page = thread_root group by thread_id;
 9+
 10+update thread join counts on thread.thread_id = counts.thread_id set thread_editedness = 2 where revision_count > 1;
 11+
 12+update thread join counts on thread.thread_id = counts.thread_id set thread_editedness = 3 where author_count > 1 or (rev_user = 0 and revision_count > 1);
 13+
 14+drop table counts;
Index: trunk/extensions/LiquidThreads/Lqt.i18n.php
@@ -20,6 +20,8 @@
2121 'lqt_add_header' => 'Add header',
2222 'lqt_new_thread' => 'Start a new discussion',
2323 'lqt_in_response_to' => 'In reply to $1 by $2, above:',
 24+ 'lqt_edited_notice_author' => "This message was re-edited by the original author.",
 25+ 'lqt_edited_notice_others' => "This message was edited by someone other than the author.",
2426 'lqt_move_placeholder' => "''Placeholder left when the thread was moved to another page.''",
2527 'lqt_reply' => 'Reply',
2628 'lqt_delete' => 'Delete',
Index: trunk/extensions/LiquidThreads/LqtModel.php
@@ -168,6 +168,7 @@
169169 $this->changeComment = $t->changeComment;
170170 $this->changeUser = $t->changeUser;
171171 $this->changeUserText = $t->changeUserText;
 172+ $this->editedness = $t->editedness;
172173
173174 $this->replies = array();
174175 foreach ($t->replies as $r) {
@@ -239,6 +240,9 @@
240241 protected $revisionNumber;
241242 protected $type;
242243
 244+ /* Flag about who has edited or replied to this thread. */
 245+ protected $editedness;
 246+
243247 /* Information about what changed in this revision. */
244248 protected $changeType;
245249 protected $changeObject;
@@ -347,6 +351,18 @@
348352 $this->bumpRevisionsOnAncestors($change_type, $change_object, $reason, wfTimestampNow());
349353 self::setChangeOnDescendents($this->topmostThread(), $change_type, $change_object);
350354
 355+ if( $change_type == Threads::CHANGE_REPLY_CREATED
 356+ && $this->editedness == Threads::EDITED_NEVER ) {
 357+ $this->editedness = Threads::EDITED_HAS_REPLY;
 358+ }
 359+ else if( $change_type == Threads::CHANGE_EDITED_ROOT ) {
 360+ if( $wgUser->getId() == 0 || $wgUser->getId() != $this->root()->originalAuthor()->getId() ) {
 361+ $this->editedness = Threads::EDITED_BY_OTHERS;
 362+ } else if( $this->editedness == Threads::EDITED_HAS_REPLY ) {
 363+ $this->editedness = Threads::EDITED_BY_AUTHOR;
 364+ }
 365+ }
 366+
351367 /* SCHEMA changes must be reflected here. */
352368
353369 $dbr =& wfGetDB( DB_MASTER );
@@ -360,6 +376,7 @@
361377 // 'thread_revision' => $this->revisionNumber,
362378 'thread_article_namespace' => $this->articleNamespace,
363379 'thread_article_title' => $this->articleTitle,
 380+ 'thread_editedness' => $this->editedness,
364381 // 'thread_change_type' => $this->changeType,
365382 // 'thread_change_object' => $this->changeObject,
366383 // 'thread_change_comment' => $this->changeComment,
@@ -474,6 +491,7 @@
475492 $this->changeComment = $line->thread_change_comment;
476493 $this->changeUser = $line->thread_change_user;
477494 $this->changeUserText = $line->thread_change_user_text;
 495+ $this->editedness = $line->thread_editedness;
478496
479497 $root_title = Title::makeTitle( $line->page_namespace, $line->page_title );
480498 $this->root = new Post($root_title);
@@ -600,6 +618,10 @@
601619 return $this->rootRevision;
602620 }
603621
 622+ function editedness() {
 623+ return $this->editedness;
 624+ }
 625+
604626 function summary() {
605627 if ( !$this->summaryId ) return null;
606628 if ( !$this->summary ) $this->summary = new Post( Title::newFromID( $this->summaryId ) );
@@ -774,6 +796,12 @@
775797 static $VALID_CHANGE_TYPES = array(self::CHANGE_EDITED_SUMMARY, self::CHANGE_EDITED_ROOT,
776798 self::CHANGE_REPLY_CREATED, self::CHANGE_NEW_THREAD, self::CHANGE_DELETED, self::CHANGE_UNDELETED,
777799 self::CHANGE_MOVED_TALKPAGE);
 800+
 801+ // Possible values of Thread->editedness.
 802+ const EDITED_NEVER = 0;
 803+ const EDITED_HAS_REPLY = 1;
 804+ const EDITED_BY_AUTHOR = 2;
 805+ const EDITED_BY_OTHERS = 3;
778806
779807 static $cache_by_root = array();
780808 static $cache_by_id = array();
@@ -809,7 +837,8 @@
810838 'thread_change_comment' => "", // TODO
811839 'thread_change_user' => $wgUser->getID(),
812840 'thread_change_user_text' => $wgUser->getName(),
813 - 'thread_type' => $type),
 841+ 'thread_type' => $type,
 842+ 'thread_editedness' => self::EDITED_NEVER),
814843 __METHOD__);
815844
816845 $newid = $dbr->insertId();
Index: trunk/extensions/LiquidThreads/lqt.css
@@ -231,11 +231,15 @@
232232 .lqt_nonindent_message {
233233 color: #777;
234234 font-size: smaller;
235 - float: left;
236235 }
237236
238237
 238+.lqt_edited_notice {
 239+ color: #777;
 240+ font-size: smaller;
 241+}
239242
 243+
240244 .lqt_header {
241245 clear:both;
242246 padding-right: 7em; /* so as not to bump into threadlevel_commands. */
@@ -278,22 +282,22 @@
279283 width: 80%;
280284 }
281285
282 -.lqt_post .lqt_footer a, .lqt_threadlevel_commands a {
 286+.lqt_post .lqt_footer a, .lqt_nonindent_message a, .lqt_threadlevel_commands a {
283287 color: #5874d1;
284288 }
285 -.lqt_post .lqt_footer a:visited, .lqt_threadlevel_commands a:visited {
 289+.lqt_post .lqt_footer a:visited, .lqt_nonindent_message a:visited, .lqt_threadlevel_commands a:visited {
286290 color: #937cba;
287291 }
288 -.lqt_post .lqt_footer a:active, .lqt_threadlevel_commands a:active {
 292+.lqt_post .lqt_footer a:active, .lqt_nonindent_message a:active, .lqt_threadlevel_commands a:active {
289293 color: #faa700;
290294 }
291 -.lqt_post .lqt_footer a.stub, .lqt_threadlevel_commands a.stub {
 295+.lqt_post .lqt_footer a.stub, .lqt_nonindent_message a.stub, .lqt_threadlevel_commands a.stub {
292296 color: #a66e7a;
293297 }
294 -.lqt_post .lqt_footer a.new, #p-personal a.new, .lqt_threadlevel_commands a.new, #p-personal a.new {
 298+.lqt_post .lqt_footer a.new, #p-personal a.new, .lqt_threadlevel_commands a.new, .lqt_nonindent_message a.new, #p-personal a.new, .lqt_threadlevel_commands a.new, #p-personal a.new {
295299 color: #d25858;
296300 }
297 -.lqt_post .lqt_footer a.new:visited, #p-personal a.new:visited, .lqt_threadlevel_commands a.new:visited, #p-personal a.new:visited {
 301+.lqt_post .lqt_footer a.new:visited, #p-personal a.new:visited, .lqt_threadlevel_commands a.new:visited, .lqt_nonindent_message a.new:visited, #p-personal a.new:visited, .lqt_threadlevel_commands a.new:visited, #p-personal a.new:visited {
298302 color: #c49292;
299303 }
300304
@@ -305,27 +309,27 @@
306310 border-color: #aaa;
307311 }*/
308312
309 -.lqt_post .lqt_footer:hover a, .lqt_threadlevel_commands:hover a {
 313+.lqt_post .lqt_footer:hover a, .lqt_nonindent_message:hover a, .lqt_threadlevel_commands:hover a {
310314 color: #002bb8;
311315 text-decoration: none;
312316 }
313 -.lqt_post .lqt_footer:hover a:visited, .lqt_threadlevel_commands:hover a:visited {
 317+.lqt_post .lqt_footer:hover a:visited, .lqt_nonindent_message:hover a:visited, .lqt_threadlevel_commands:hover a:visited {
314318 color: #5a3696;
315319 text-decoration: none;
316320 }
317 -.lqt_post .lqt_footer:hover a:active, .lqt_threadlevel_commands:hover a:active {
 321+.lqt_post .lqt_footer:hover a:active, .lqt_nonindent_message:hover a:active, .lqt_threadlevel_commands:hover a:active {
318322 color: #faa700;
319323 text-decoration: none;
320324 }
321 -.lqt_post .lqt_footer:hover a.stub, .lqt_threadlevel_commands:hover a.stub {
 325+.lqt_post .lqt_footer:hover a.stub, .lqt_nonindent_message:hover a.stub, .lqt_threadlevel_commands:hover a.stub {
322326 color: #772233;
323327 text-decoration: none;
324328 }
325 -.lqt_post .lqt_footer:hover a.new, #p-personal a.new, .lqt_threadlevel_commands:hover a.new, #p-personal a.new {
 329+.lqt_post .lqt_footer:hover a.new, #p-personal a.new, .lqt_threadlevel_commands:hover a.new, .lqt_nonindent_message:hover a.new, #p-personal a.new, .lqt_threadlevel_commands:hover a.new, #p-personal a.new {
326330 color: #ba0000;
327331 text-decoration: none;
328332 }
329 -.lqt_post .lqt_footer:hover a.new:visited, #p-personal a.new:visited, .lqt_threadlevel_commands:hover a.new:visited, #p-personal a.new:visited {
 333+.lqt_post .lqt_footer:hover a.new:visited, #p-personal a.new:visited, .lqt_threadlevel_commands:hover a.new:visited, .lqt_nonindent_message:hover a.new:visited, #p-personal a.new:visited, .lqt_threadlevel_commands:hover a.new:visited, #p-personal a.new:visited {
330334 color: #a55858;
331335 text-decoration: none;
332336 }
Index: trunk/extensions/LiquidThreads/LqtBaseView.php
@@ -719,7 +719,7 @@
720720 );
721721
722722 $this->output->addHTML($this->listItemsForCommands($this->threadFooterCommands($thread)));
723 -
 723+
724724 $this->output->addHTML('</ul>');
725725 }
726726
@@ -871,6 +871,13 @@
872872 ) .'</p>');
873873 }
874874
 875+
 876+ if( $thread->editedness() == Threads::EDITED_BY_AUTHOR ) {
 877+ $this->output->addHTML('<div class="lqt_edited_notice">'.wfMsg('lqt_edited_notice_author').'</div>');
 878+ } else if($thread->editedness() == Threads::EDITED_BY_OTHERS ) {
 879+ $this->output->addHTML('<div class="lqt_edited_notice">'.wfMsg('lqt_edited_notice_others').'</div>');
 880+ }
 881+
875882 $this->openDiv('lqt_thread', "lqt_thread_id_{$thread->id()}");
876883
877884 $this->showRootPost( $thread );
Index: trunk/extensions/LiquidThreads/README
@@ -38,6 +38,7 @@
3939 lqt-schema-change-2.sql for before r26550
4040 lqt-schema-change-3.sql for before r26563
4141 lqt-schema-change-4.sql for before r26575
 42+lqt-schema-change-5.sql for before r28178
4243
4344 CONTACT:
4445 =======
Index: trunk/extensions/LiquidThreads/lqt.sql
@@ -9,6 +9,8 @@
1010 thread_created char(14) binary NOT NULL default '',
1111 thread_revision int(8) unsigned NOT NULL default 1,
1212
 13+ thread_editedness int(1) NOT NULL default 0,
 14+
1315 thread_article_namespace int NOT NULL,
1416 thread_article_title varchar(255) binary NOT NULL,
1517

Status & tagging log