r23919 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23918‎ | r23919 | r23920 >
Date:20:59, 9 July 2007
Author:david
Status:old
Tags:
Comment:
hook into mediawiki with a proper hook, plus view classes are now overridable as intended
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/includes/Wiki.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -17,6 +17,13 @@
1818 require_once('PageHistory.php');
1919
2020 class LqtDispatch {
 21+ public static $views = array(
 22+ 'TalkpageArchiveView' => 'TalkpageArchiveView',
 23+ 'TalkpageView' => 'TalkpageView',
 24+ 'ThreadHistoryView' => 'ThreadHistoryView',
 25+ 'ThreadPermalinkView' => 'ThreadPermalinkView'
 26+ );
 27+
2128 static function talkpageMain(&$output, &$talk_article, &$title, &$user, &$request) {
2229 // We are given a talkpage article and title. Find the associated
2330 // non-talk article and pass that to the view.
@@ -25,10 +32,11 @@
2633 $article = new Article($article_title);
2734
2835 if ( $request->getVal('lqt_method') == 'talkpage_archive' ) {
29 - $view = new TalkpageArchiveView( $output, $article, $title, $user, $request );
 36+ $viewname = self::$views['TalkpageArchiveView'];
3037 } else {
31 - $view = new TalkpageView( $output, $article, $title, $user, $request );
 38+ $viewname = self::$views['TalkpageView'];
3239 }
 40+ $view = new $viewname( $output, $article, $title, $user, $request );
3341 $view->show();
3442 }
3543
@@ -36,10 +44,11 @@
3745 /* breaking the lqt_method paradigm to make the history tab work.
3846 (just changing the href doesn't make the highlighting correct.) */
3947 if( $request->getVal('action') == 'history' ) {
40 - $view = new ThreadHistoryView( $output, $article, $title, $user, $request );
 48+ $viewname = self::$views['ThreadHistoryView'];
4149 } else {
42 - $view = new ThreadPermalinkView( $output, $article, $title, $user, $request );
 50+ $viewname = self::$views['ThreadPermalinkView'];
4351 }
 52+ $view = new $viewname( $output, $article, $title, $user, $request );
4453 $view->show();
4554 }
4655
@@ -59,6 +68,8 @@
6069 }
6170 }
6271
 72+$wgHooks['MediaWikiPerformAction'][] = array('LqtDispatch::tryPage');
 73+
6374 class LqtView {
6475 protected $article;
6576 protected $output;
Index: branches/liquidthreads/includes/Wiki.php
@@ -373,18 +373,18 @@
374374
375375 wfProfileIn( 'MediaWiki::performAction' );
376376
 377+ // TODO LQT HACK
 378+ if ( !wfRunHooks('MediaWikiPerformAction', array($output, $article, $title, $user, $request)) ) {
 379+ wfProfileOut( 'MediaWiki::performAction' );
 380+ return;
 381+ }
 382+
377383 $action = $this->getVal('Action');
378384 if( in_array( $action, $this->getVal('DisabledActions',array()) ) ) {
379385 /* No such action; this will switch to the default case */
380386 $action = 'nosuchaction';
381387 }
382388
383 - // TODO LQT HACK
384 - if ( LqtDispatch::tryPage( $output, $article, $title, $user, $request ) ) {
385 - wfProfileOut( 'MediaWiki::performAction' );
386 - return;
387 - }
388 -
389389 switch( $action ) {
390390 case 'view':
391391 $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) );

Status & tagging log