| Index: trunk/extensions/LiquidThreads/LqtFunctions.php |
| — | — | @@ -56,6 +56,12 @@ |
| 57 | 57 | 'lqtpagelimit', |
| 58 | 58 | array( 'LqtParserFunctions', 'lqtPageLimit' ) |
| 59 | 59 | ); |
| | 60 | + |
| | 61 | + global $wgLiquidThreadsAllowEmbedding; |
| | 62 | + |
| | 63 | + if ($wgLiquidThreadsAllowEmbedding) { |
| | 64 | + $parser->setHook( 'talkpage', array( 'LqtParserFunctions', 'lqtTalkPage' ) ); |
| | 65 | + } |
| 60 | 66 | |
| 61 | 67 | return true; |
| 62 | 68 | } |
| Index: trunk/extensions/LiquidThreads/LiquidThreads.php |
| — | — | @@ -212,3 +212,6 @@ |
| 213 | 213 | |
| 214 | 214 | /** Whether or not to allow users to activate/deactivate LiquidThreads per-page */ |
| 215 | 215 | $wgLiquidThreadsAllowUserControl = true; |
| | 216 | + |
| | 217 | +/** Allow embedding */ |
| | 218 | +$wgLiquidThreadsAllowEmbedding = true; |
| Index: trunk/extensions/LiquidThreads/classes/View.php |
| — | — | @@ -843,25 +843,50 @@ |
| 844 | 844 | return; |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | | - global $wgOut, $wgStylePath; |
| 848 | | - global $wgScriptPath, $wgStyleVersion; |
| 849 | | - global $wgEnableJS2system; |
| 850 | | - global $wgLiquidThreadsExtensionName; |
| | 847 | + global $wgOut; |
| | 848 | + |
| | 849 | + $info = self::getScriptsAndStyles(); |
| | 850 | + |
| | 851 | + foreach( $info['inlineScripts'] as $script ) { |
| | 852 | + $wgOut->addInlineScript( $script ); |
| | 853 | + } |
| | 854 | + |
| | 855 | + foreach( $info['scripts'] as $script ) { |
| | 856 | + $wgOut->addScriptFile( $script ); |
| | 857 | + } |
| | 858 | + |
| | 859 | + foreach( $info['styles'] as $style ) { |
| | 860 | + $wgOut->addExtensionStyle( $style ); |
| | 861 | + } |
| 851 | 862 | |
| 852 | | - $wgOut->addInlineScript( 'var wgLqtMessages = ' . self::exportJSLocalisation() . ';' ); |
| 853 | | - |
| 854 | | - $basePath = "$wgScriptPath/extensions/$wgLiquidThreadsExtensionName"; |
| 855 | | - |
| 856 | | - $wgOut->addScriptFile( "$basePath/jquery/js2.combined.js" ); |
| 857 | | - $wgOut->addExtensionStyle( "$basePath/jquery/jquery-ui-1.7.2.css" ); |
| 858 | | - |
| 859 | | - $wgOut->addScriptFile( "$basePath/jquery/jquery.autogrow.js" ); |
| 860 | | - |
| 861 | | - $wgOut->addScriptFile( "$basePath/lqt.js" ); |
| 862 | | - $wgOut->addExtensionStyle( "$basePath/lqt.css?{$wgStyleVersion}" ); |
| 863 | | - |
| 864 | 863 | self::$stylesAndScriptsDone = true; |
| 865 | 864 | } |
| | 865 | + |
| | 866 | + static function getScriptsAndStyles() { |
| | 867 | + global $wgLiquidThreadsExtensionName, $wgStylePath, $wgScriptPath, $wgStyleVersion; |
| | 868 | + $basePath = "$wgScriptPath/extensions/$wgLiquidThreadsExtensionName"; |
| | 869 | + |
| | 870 | + $inlineScripts = array( |
| | 871 | + 'var wgLqtMessages = ' . self::exportJSLocalisation() . ';', |
| | 872 | + ); |
| | 873 | + |
| | 874 | + $scripts = array( |
| | 875 | + "$basePath/jquery/js2.combined.js", |
| | 876 | + "$basePath/jquery/jquery.autogrow.js", |
| | 877 | + "$basePath/lqt.js", |
| | 878 | + ); |
| | 879 | + |
| | 880 | + $styles = array( |
| | 881 | + "$basePath/jquery/jquery-ui-1.7.2.css", |
| | 882 | + "$basePath/lqt.css?{$wgStyleVersion}", |
| | 883 | + ); |
| | 884 | + |
| | 885 | + return array( |
| | 886 | + 'inlineScripts' => $inlineScripts, |
| | 887 | + 'scripts' => $scripts, |
| | 888 | + 'styles' => $styles, |
| | 889 | + ); |
| | 890 | + } |
| 866 | 891 | |
| 867 | 892 | static function exportJSLocalisation() { |
| 868 | 893 | wfLoadExtensionMessages( 'LiquidThreads' ); |
| Index: trunk/extensions/LiquidThreads/classes/ParserFunctions.php |
| — | — | @@ -20,4 +20,52 @@ |
| 21 | 21 | $parser->mOutput->setProperty( 'lqt-page-limit', $param ); |
| 22 | 22 | } |
| 23 | 23 | } |
| | 24 | + |
| | 25 | + static function lqtTalkPage( $parser, $args, $parser, $frame ) { |
| | 26 | + global $wgStyleVersion; |
| | 27 | + |
| | 28 | + // Grab article. |
| | 29 | + $title = null; |
| | 30 | + if ( $args['talkpage'] ) { |
| | 31 | + $title = Title::newFromText( $args['talkpage'] ); |
| | 32 | + } |
| | 33 | + if ( is_null($title) ) { |
| | 34 | + $title = $parser->getTitle(); |
| | 35 | + } |
| | 36 | + |
| | 37 | + $article = new Article( $title ); |
| | 38 | + $out = new OutputPage; |
| | 39 | + |
| | 40 | + global $wgUser, $wgRequest; |
| | 41 | + $view = new TalkpageView( $out, $article, $title, $wgUser, $wgRequest ); |
| | 42 | + |
| | 43 | + // Handle show/hide preferences. Header gone by default. |
| | 44 | + $view->hideItems( 'header' ); |
| | 45 | + |
| | 46 | + if ( array_key_exists( 'show', $args ) ) { |
| | 47 | + $show = explode( ' ', $args['show'] ); |
| | 48 | + $view->setShownItems( $show ); |
| | 49 | + } |
| | 50 | + |
| | 51 | + $view->show(); |
| | 52 | + |
| | 53 | + $scriptsStyles = LqtView::getScriptsAndStyles(); |
| | 54 | + $headItems = ''; |
| | 55 | + |
| | 56 | + foreach( $scriptsStyles['inlineScripts'] as $iscript ) { |
| | 57 | + $headItems .= Html::inlineScript( "\n$iscript\n" ); |
| | 58 | + } |
| | 59 | + |
| | 60 | + foreach( $scriptsStyles['scripts'] as $script ) { |
| | 61 | + $headItems .= Html::linkedScript( "$script?$wgStyleVersion" ); |
| | 62 | + } |
| | 63 | + |
| | 64 | + foreach( $scriptsStyles['styles'] as $style ) { |
| | 65 | + $headItems .= Html::linkedStyle( $style, 'all' ); |
| | 66 | + } |
| | 67 | + |
| | 68 | + $parser->getOutput()->addHeadItem( $headItems, 'lqt-talk-page' ); |
| | 69 | + |
| | 70 | + return $out->getHTML(); |
| | 71 | + } |
| 24 | 72 | } |
| Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php |
| — | — | @@ -3,6 +3,8 @@ |
| 4 | 4 | if ( !defined( 'MEDIAWIKI' ) ) die; |
| 5 | 5 | |
| 6 | 6 | class TalkpageView extends LqtView { |
| | 7 | + protected $mShowItems = array( 'toc', 'options', 'header' ); |
| | 8 | + |
| 7 | 9 | /* Added to SkinTemplateTabs hook in TalkpageView::show(). */ |
| 8 | 10 | static function customizeTalkpageTabs( $skintemplate, &$content_actions, $view ) { |
| 9 | 11 | // The arguments are passed in by reference. |
| — | — | @@ -241,7 +243,9 @@ |
| 242 | 244 | |
| 243 | 245 | } |
| 244 | 246 | |
| 245 | | - $this->showHeader(); |
| | 247 | + if ( $this->shouldShow('header') ) { |
| | 248 | + $this->showHeader(); |
| | 249 | + } |
| 246 | 250 | |
| 247 | 251 | $html = ''; |
| 248 | 252 | |
| — | — | @@ -266,7 +270,9 @@ |
| 267 | 271 | $talkpageHeader = Xml::tags( 'div', array( 'class' => 'lqt-talkpage-header' ), |
| 268 | 272 | $talkpageHeader ); |
| 269 | 273 | |
| 270 | | - $this->output->addHTML( $talkpageHeader ); |
| | 274 | + if ( $this->shouldShow('options') ) { |
| | 275 | + $this->output->addHTML( $talkpageHeader ); |
| | 276 | + } |
| 271 | 277 | |
| 272 | 278 | global $wgRequest; |
| 273 | 279 | if ( $this->methodApplies( 'talkpage_new_thread' ) ) { |
| — | — | @@ -283,9 +289,9 @@ |
| 284 | 290 | |
| 285 | 291 | $threads = $this->getPageThreads( $pager ); |
| 286 | 292 | |
| 287 | | - if ( count( $threads ) > 0 ) { |
| | 293 | + if ( count( $threads ) > 0 && $this->shouldShow('toc') ) { |
| 288 | 294 | $html .= $this->getTOC( $threads ); |
| 289 | | - } else { |
| | 295 | + } elseif ( count($threads) == 0 ) { |
| 290 | 296 | $html .= Xml::tags( 'div', array( 'class' => 'lqt-no-threads' ), |
| 291 | 297 | wfMsgExt( 'lqt-no-threads', 'parseinline' ) ); |
| 292 | 298 | } |
| — | — | @@ -353,6 +359,28 @@ |
| 354 | 360 | // Default |
| 355 | 361 | return LQT_NEWEST_CHANGES; |
| 356 | 362 | } |
| | 363 | + |
| | 364 | + // Hide a number of items from the view |
| | 365 | + // Valid values: toc, options, header |
| | 366 | + function hideItems( $items ) { |
| | 367 | + $this->mShowItems = array_diff( $this->mShowItems, (array)$items ); |
| | 368 | + } |
| | 369 | + |
| | 370 | + // Show a number of items in the view |
| | 371 | + // Valid values: toc, options, header |
| | 372 | + function showItems( $items ) { |
| | 373 | + $this->mShowItems = array_merge( $this->mShowItems, (array)$items ); |
| | 374 | + } |
| | 375 | + |
| | 376 | + // Whether or not to show an item |
| | 377 | + function shouldShow( $item ) { |
| | 378 | + return in_array( $item, $this->mShowItems ); |
| | 379 | + } |
| | 380 | + |
| | 381 | + // Set the items shown |
| | 382 | + function setShownItems( $items ) { |
| | 383 | + $this->mShowItems = $items; |
| | 384 | + } |
| 357 | 385 | } |
| 358 | 386 | |
| 359 | 387 | class LqtDiscussionPager extends IndexPager { |