Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -17,6 +17,13 @@ |
18 | 18 | require_once('PageHistory.php'); |
19 | 19 | |
20 | 20 | class LqtDispatch { |
| 21 | + public static $views = array( |
| 22 | + 'TalkpageArchiveView' => 'TalkpageArchiveView', |
| 23 | + 'TalkpageView' => 'TalkpageView', |
| 24 | + 'ThreadHistoryView' => 'ThreadHistoryView', |
| 25 | + 'ThreadPermalinkView' => 'ThreadPermalinkView' |
| 26 | + ); |
| 27 | + |
21 | 28 | static function talkpageMain(&$output, &$talk_article, &$title, &$user, &$request) { |
22 | 29 | // We are given a talkpage article and title. Find the associated |
23 | 30 | // non-talk article and pass that to the view. |
— | — | @@ -25,10 +32,11 @@ |
26 | 33 | $article = new Article($article_title); |
27 | 34 | |
28 | 35 | if ( $request->getVal('lqt_method') == 'talkpage_archive' ) { |
29 | | - $view = new TalkpageArchiveView( $output, $article, $title, $user, $request ); |
| 36 | + $viewname = self::$views['TalkpageArchiveView']; |
30 | 37 | } else { |
31 | | - $view = new TalkpageView( $output, $article, $title, $user, $request ); |
| 38 | + $viewname = self::$views['TalkpageView']; |
32 | 39 | } |
| 40 | + $view = new $viewname( $output, $article, $title, $user, $request ); |
33 | 41 | $view->show(); |
34 | 42 | } |
35 | 43 | |
— | — | @@ -36,10 +44,11 @@ |
37 | 45 | /* breaking the lqt_method paradigm to make the history tab work. |
38 | 46 | (just changing the href doesn't make the highlighting correct.) */ |
39 | 47 | if( $request->getVal('action') == 'history' ) { |
40 | | - $view = new ThreadHistoryView( $output, $article, $title, $user, $request ); |
| 48 | + $viewname = self::$views['ThreadHistoryView']; |
41 | 49 | } else { |
42 | | - $view = new ThreadPermalinkView( $output, $article, $title, $user, $request ); |
| 50 | + $viewname = self::$views['ThreadPermalinkView']; |
43 | 51 | } |
| 52 | + $view = new $viewname( $output, $article, $title, $user, $request ); |
44 | 53 | $view->show(); |
45 | 54 | } |
46 | 55 | |
— | — | @@ -59,6 +68,8 @@ |
60 | 69 | } |
61 | 70 | } |
62 | 71 | |
| 72 | +$wgHooks['MediaWikiPerformAction'][] = array('LqtDispatch::tryPage'); |
| 73 | + |
63 | 74 | class LqtView { |
64 | 75 | protected $article; |
65 | 76 | protected $output; |
Index: branches/liquidthreads/includes/Wiki.php |
— | — | @@ -373,18 +373,18 @@ |
374 | 374 | |
375 | 375 | wfProfileIn( 'MediaWiki::performAction' ); |
376 | 376 | |
| 377 | + // TODO LQT HACK |
| 378 | + if ( !wfRunHooks('MediaWikiPerformAction', array($output, $article, $title, $user, $request)) ) { |
| 379 | + wfProfileOut( 'MediaWiki::performAction' ); |
| 380 | + return; |
| 381 | + } |
| 382 | + |
377 | 383 | $action = $this->getVal('Action'); |
378 | 384 | if( in_array( $action, $this->getVal('DisabledActions',array()) ) ) { |
379 | 385 | /* No such action; this will switch to the default case */ |
380 | 386 | $action = 'nosuchaction'; |
381 | 387 | } |
382 | 388 | |
383 | | - // TODO LQT HACK |
384 | | - if ( LqtDispatch::tryPage( $output, $article, $title, $user, $request ) ) { |
385 | | - wfProfileOut( 'MediaWiki::performAction' ); |
386 | | - return; |
387 | | - } |
388 | | - |
389 | 389 | switch( $action ) { |
390 | 390 | case 'view': |
391 | 391 | $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) ); |