r25323 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25322‎ | r25323 | r25324 >
Date:17:21, 30 August 2007
Author:david
Status:old
Tags:
Comment:
basic thread protection without regard to replies
Modified paths:
  • /branches/liquidthreads/extensions/LqtBaseView.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtPages.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtPages.php
@@ -359,6 +359,7 @@
360360 function customizeTabs( $skintemplate, $content_actions ) {
361361 // The arguments are passed in by reference.
362362 unset($content_actions['edit']);
 363+ unset($content_actions['viewsource']);
363364 unset($content_actions['talk']);
364365 /* unset($content_actions['history']);
365366 unset($content_actions['watch']);
@@ -440,15 +441,73 @@
441442
442443
443444 /*
444 -CREATE TABLE historical_thread (
445 - -- Note that many hthreads can share an id, which is the same as the id
446 - -- of the live thread. It is only the id/revision combo which must be unique.
447 - hthread_id int(8) unsigned NOT NULL,
448 - hthread_revision int(8) unsigned NOT NULL,
449 - hthread_contents BLOB NOT NULL,
450 - PRIMARY KEY hthread_id_revision (hthread_id, hthread_revision)
451 -) TYPE=InnoDB;
452 -*/
 445+ * Cheap views that just pass through to MW functions.
 446+ */
 447+
 448+class TalkpageHeaderView {
 449+ function customizeTabs( $skintemplate, $content_actions ) {
 450+ unset($content_actions['edit']);
 451+ unset($content_actions['addsection']);
 452+ unset($content_actions['history']);
 453+ unset($content_actions['watch']);
 454+ unset($content_actions['move']);
 455+
 456+ $content_actions['talk']['class'] = false;
 457+ $content_actions['header'] = array( 'class'=>'selected',
 458+ 'text'=>'header',
 459+ 'href'=>'');
 460+
 461+ return true;
 462+ }
 463+
 464+ function show() {
 465+ global $wgHooks;
 466+ $wgHooks['SkinTemplateTabs'][] = array($this, 'customizeTabs');
 467+ return true;
 468+ }
 469+}
 470+
 471+class ThreadDiffView {
 472+ function customizeTabs( $skintemplate, $content_actions ) {
 473+ unset($content_actions['edit']);
 474+ unset($content_actions['viewsource']);
 475+ unset($content_actions['talk']);
 476+
 477+ $content_actions['talk']['class'] = false;
 478+ $content_actions['history']['class'] = 'selected';
 479+
 480+ return true;
 481+ }
 482+
 483+ function show() {
 484+ global $wgHooks;
 485+ $wgHooks['SkinTemplateTabs'][] = array($this, 'customizeTabs');
 486+ return true;
 487+ }
 488+}
 489+
 490+class ThreadProtectionFormView {
 491+ function customizeTabs( $skintemplate, $content_actions ) {
 492+ unset($content_actions['edit']);
 493+ unset($content_actions['viewsource']);
 494+ unset($content_actions['talk']);
 495+
 496+ $content_actions['talk']['class'] = false;
 497+ if ( array_key_exists('protect', $content_actions) )
 498+ $content_actions['protect']['class'] = 'selected';
 499+ else if ( array_key_exists('unprotect', $content_actions) )
 500+ $content_actions['unprotect']['class'] = 'selected';
 501+
 502+ return true;
 503+ }
 504+
 505+ function show() {
 506+ global $wgHooks;
 507+ $wgHooks['SkinTemplateTabs'][] = array($this, 'customizeTabs');
 508+ return true;
 509+ }
 510+}
 511+
453512 /**
454513 * @addtogroup Pager
455514 */
Index: branches/liquidthreads/extensions/LqtBaseView.php
@@ -25,6 +25,9 @@
2626 require_once('Pager.php');
2727 require_once('PageHistory.php');
2828
 29+$wgHooks['MediaWikiPerformAction'][] = array('LqtDispatch::tryPage');
 30+$wgHooks['SpecialMovepageAfterMove'][] = array('LqtDispatch::onPageMove');
 31+
2932 class LqtDispatch {
3033 public static $views = array(
3134 'TalkpageArchiveView' => 'TalkpageArchiveView',
@@ -33,7 +36,8 @@
3437 'ThreadHistoryListingView' => 'ThreadHistoryListingView',
3538 'ThreadHistoricalRevisionView' => 'ThreadHistoricalRevisionView',
3639 'ThreadDiffView' => 'ThreadDiffView',
37 - 'ThreadPermalinkView' => 'ThreadPermalinkView'
 40+ 'ThreadPermalinkView' => 'ThreadPermalinkView',
 41+ 'ThreadProtectionFormView' => 'ThreadProtectionFormView'
3842 );
3943
4044 static function talkpageMain(&$output, &$talk_article, &$title, &$user, &$request) {
@@ -67,8 +71,11 @@
6872 static function threadPermalinkMain(&$output, &$article, &$title, &$user, &$request) {
6973 /* breaking the lqt_method paradigm to make the history tab work.
7074 (just changing the href doesn't make the highlighting correct.) */
71 - if( $request->getVal('action') == 'history' ) {
 75+ $action = $request->getVal('action');
 76+ if( $action == 'history' ) {
7277 $viewname = self::$views['ThreadHistoryListingView'];
 78+ } else if ( $action == 'protect' || $action == 'unprotect' ) {
 79+ $viewname = self::$views['ThreadProtectionFormView'];
7380 } else if ( $request->getVal('lqt_method') == 'diff' ) {
7481 $viewname = self::$views['ThreadDiffView'];
7582 } else if ( $request->getVal('lqt_oldid', null) !== null ) {
@@ -107,56 +114,6 @@
108115 }
109116 }
110117
111 -
112 -class TalkpageHeaderView /* doesn't derive from LqtView -- why bother? */ {
113 - function customizeTabs( $skintemplate, $content_actions ) {
114 - unset($content_actions['edit']);
115 - unset($content_actions['addsection']);
116 - unset($content_actions['history']);
117 - unset($content_actions['watch']);
118 - unset($content_actions['move']);
119 -
120 - $content_actions['talk']['class'] = false;
121 - $content_actions['header'] = array( 'class'=>'selected',
122 - 'text'=>'header',
123 - 'href'=>'');
124 -
125 - return true;
126 - }
127 -
128 - function show() {
129 - global $wgHooks;
130 - $wgHooks['SkinTemplateTabs'][] = array($this, 'customizeTabs');
131 - return true;
132 - }
133 -}
134 -
135 -class ThreadDiffView {
136 - function customizeTabs( $skintemplate, $content_actions ) {
137 - unset($content_actions['edit']);
138 - unset($content_actions['addsection']);
139 - unset($content_actions['history']);
140 - unset($content_actions['watch']);
141 - unset($content_actions['move']);
142 -
143 - $content_actions['talk']['class'] = false;
144 - $content_actions['header'] = array( 'class'=>'selected',
145 - 'text'=>'header',
146 - 'href'=>'');
147 -
148 - return true;
149 - }
150 -
151 - function show() {
152 - global $wgHooks;
153 - $wgHooks['SkinTemplateTabs'][] = array($this, 'customizeTabs');
154 - return true;
155 - }
156 -}
157 -
158 -$wgHooks['MediaWikiPerformAction'][] = array('LqtDispatch::tryPage');
159 -$wgHooks['SpecialMovepageAfterMove'][] = array('LqtDispatch::onPageMove');
160 -
161118
162119 class LqtView {
163120 protected $article;
@@ -501,7 +458,9 @@
502459 $this->output->addHTML( $wgLang->timeanddate($thread->timestamp()) );
503460 $this->output->addHTML( wfCloseElement( 'li' ) );
504461
505 - $commands = array( 'Edit' => $this->talkpageUrl( $this->title, 'edit', $thread ),
 462+ $edit_label = $thread->root()->getTitle()->isProtected('edit') ? 'View source' : 'Edit';
 463+
 464+ $commands = array( $edit_label => $this->talkpageUrl( $this->title, 'edit', $thread ),
506465 'Reply' => $this->talkpageUrl( $this->title, 'reply', $thread ),
507466 'Permalink' => $this->permalinkUrl( $thread ) );
508467

Status & tagging log