Index: branches/liquidthreads/extensions/LqtPages.php |
— | — | @@ -359,6 +359,7 @@ |
360 | 360 | function customizeTabs( $skintemplate, $content_actions ) { |
361 | 361 | // The arguments are passed in by reference. |
362 | 362 | unset($content_actions['edit']); |
| 363 | + unset($content_actions['viewsource']); |
363 | 364 | unset($content_actions['talk']); |
364 | 365 | /* unset($content_actions['history']); |
365 | 366 | unset($content_actions['watch']); |
— | — | @@ -440,15 +441,73 @@ |
441 | 442 | |
442 | 443 | |
443 | 444 | /* |
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 | + |
453 | 512 | /** |
454 | 513 | * @addtogroup Pager |
455 | 514 | */ |
Index: branches/liquidthreads/extensions/LqtBaseView.php |
— | — | @@ -25,6 +25,9 @@ |
26 | 26 | require_once('Pager.php'); |
27 | 27 | require_once('PageHistory.php'); |
28 | 28 | |
| 29 | +$wgHooks['MediaWikiPerformAction'][] = array('LqtDispatch::tryPage'); |
| 30 | +$wgHooks['SpecialMovepageAfterMove'][] = array('LqtDispatch::onPageMove'); |
| 31 | + |
29 | 32 | class LqtDispatch { |
30 | 33 | public static $views = array( |
31 | 34 | 'TalkpageArchiveView' => 'TalkpageArchiveView', |
— | — | @@ -33,7 +36,8 @@ |
34 | 37 | 'ThreadHistoryListingView' => 'ThreadHistoryListingView', |
35 | 38 | 'ThreadHistoricalRevisionView' => 'ThreadHistoricalRevisionView', |
36 | 39 | 'ThreadDiffView' => 'ThreadDiffView', |
37 | | - 'ThreadPermalinkView' => 'ThreadPermalinkView' |
| 40 | + 'ThreadPermalinkView' => 'ThreadPermalinkView', |
| 41 | + 'ThreadProtectionFormView' => 'ThreadProtectionFormView' |
38 | 42 | ); |
39 | 43 | |
40 | 44 | static function talkpageMain(&$output, &$talk_article, &$title, &$user, &$request) { |
— | — | @@ -67,8 +71,11 @@ |
68 | 72 | static function threadPermalinkMain(&$output, &$article, &$title, &$user, &$request) { |
69 | 73 | /* breaking the lqt_method paradigm to make the history tab work. |
70 | 74 | (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' ) { |
72 | 77 | $viewname = self::$views['ThreadHistoryListingView']; |
| 78 | + } else if ( $action == 'protect' || $action == 'unprotect' ) { |
| 79 | + $viewname = self::$views['ThreadProtectionFormView']; |
73 | 80 | } else if ( $request->getVal('lqt_method') == 'diff' ) { |
74 | 81 | $viewname = self::$views['ThreadDiffView']; |
75 | 82 | } else if ( $request->getVal('lqt_oldid', null) !== null ) { |
— | — | @@ -107,56 +114,6 @@ |
108 | 115 | } |
109 | 116 | } |
110 | 117 | |
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 | | - |
161 | 118 | |
162 | 119 | class LqtView { |
163 | 120 | protected $article; |
— | — | @@ -501,7 +458,9 @@ |
502 | 459 | $this->output->addHTML( $wgLang->timeanddate($thread->timestamp()) ); |
503 | 460 | $this->output->addHTML( wfCloseElement( 'li' ) ); |
504 | 461 | |
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 ), |
506 | 465 | 'Reply' => $this->talkpageUrl( $this->title, 'reply', $thread ), |
507 | 466 | 'Permalink' => $this->permalinkUrl( $thread ) ); |
508 | 467 | |