Index: trunk/extensions/LiquidThreads/classes/View.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | |
27 | 27 | protected $sort_order = LQT_NEWEST_CHANGES; |
28 | 28 | |
29 | | - static $stylesAndScriptsDone = false; |
| 29 | + static $stylesAndScriptsDone = array(); |
30 | 30 | |
31 | 31 | function __construct( &$output, &$article, &$title, &$user, &$request ) { |
32 | 32 | $this->article = $article; |
— | — | @@ -1182,8 +1182,19 @@ |
1183 | 1183 | * Output methods * |
1184 | 1184 | *************************/ |
1185 | 1185 | |
1186 | | - static function addJSandCSS() { |
1187 | | - if ( self::$stylesAndScriptsDone ) { |
| 1186 | + static function sendMoreScripts( $scripts = array() ) { |
| 1187 | + global $wgOut; |
| 1188 | + foreach( $scripts as $file ) { |
| 1189 | + if( !in_array( $file, self::$stylesAndScriptsDone ) ) { |
| 1190 | + $wgOut->addScriptFile( $file ); |
| 1191 | + self::$stylesAndScriptsDone[] = $file; |
| 1192 | + } |
| 1193 | + } |
| 1194 | + } |
| 1195 | + |
| 1196 | + static function addJSandCSS( $scripts = array() ) { |
| 1197 | + if ( count( self::$stylesAndScriptsDone ) ) { |
| 1198 | + self::sendMoreScripts( $scripts ); |
1188 | 1199 | return; |
1189 | 1200 | } |
1190 | 1201 | |
— | — | @@ -1193,22 +1204,22 @@ |
1194 | 1205 | |
1195 | 1206 | LqtHooks::$scriptVariables['wgLqtMessages'] = self::exportJSLocalisation(); |
1196 | 1207 | |
| 1208 | + |
| 1209 | + $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/jquery/jquery-ui-1.7.2.css" ); |
| 1210 | + $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/lqt.css?{$wgStyleVersion}" ); |
| 1211 | + |
| 1212 | + array_unshift( $scripts, "$wgLiquidThreadsExtensionPath/js/lqt.toolbar.js" ); |
| 1213 | + array_unshift( $scripts, "$wgLiquidThreadsExtensionPath/jquery/jquery.autogrow.js" ); |
| 1214 | + array_unshift( $scripts, "$wgLiquidThreadsExtensionPath/lqt.js" ); |
| 1215 | + |
1197 | 1216 | if ( method_exists( $wgOut, 'includeJQuery' ) ) { |
1198 | 1217 | $wgOut->includeJQuery(); |
1199 | | - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/plugins.js" ); |
| 1218 | + array_unshift( $scripts, "$wgLiquidThreadsExtensionPath/jquery/plugins.js" ); |
1200 | 1219 | } else { |
1201 | | - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/js2.combined.js" ); |
| 1220 | + array_unshift( $scripts, "$wgLiquidThreadsExtensionPath/jquery/js2.combined.js" ); |
1202 | 1221 | } |
1203 | 1222 | |
1204 | | - $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/jquery/jquery-ui-1.7.2.css" ); |
1205 | | - |
1206 | | - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/jquery.autogrow.js" ); |
1207 | | - |
1208 | | - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/lqt.js" ); |
1209 | | - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/js/lqt.toolbar.js" ); |
1210 | | - $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/lqt.css?{$wgStyleVersion}" ); |
1211 | | - |
1212 | | - self::$stylesAndScriptsDone = true; |
| 1223 | + self::sendMoreScripts( $scripts ); |
1213 | 1224 | } |
1214 | 1225 | |
1215 | 1226 | static function exportJSLocalisation() { |
— | — | @@ -1888,7 +1899,8 @@ |
1889 | 1900 | |
1890 | 1901 | $html = ''; |
1891 | 1902 | if ( wfRunHooks( 'EditPageBeforeEditToolbar', array( &$html ) ) ) { |
1892 | | - self::addJSandCSS(); |
| 1903 | + $scripts = isset( $options['addScripts'] ) ? $options['addScripts'] : array(); |
| 1904 | + self::addJSandCSS( $scripts ); |
1893 | 1905 | } |
1894 | 1906 | |
1895 | 1907 | $class = $this->threadDivClass( $thread ); |
Index: trunk/extensions/LiquidThreads/pages/NewUserMessagesView.php |
— | — | @@ -85,13 +85,6 @@ |
86 | 86 | function showOnce() { |
87 | 87 | NewMessages::recacheMessageCount( $this->user->getId() ); |
88 | 88 | |
89 | | - static $scriptDone = false; |
90 | | - |
91 | | - if ( !$scriptDone ) { |
92 | | - global $wgOut, $wgLiquidThreadsExtensionPath; |
93 | | - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/newmessages.js" ); |
94 | | - } |
95 | | - |
96 | 89 | $this->user->setNewtalk( false ); |
97 | 90 | |
98 | 91 | if ( $this->methodApplies( 'mark_as_unread' ) ) { |
— | — | @@ -207,8 +200,9 @@ |
208 | 201 | |
209 | 202 | $mustShowThreads = $this->targets[$t->id()]; |
210 | 203 | |
211 | | - $this->showThread( $t, 1, 1, array( 'mustShowThreads' => $mustShowThreads ) ); |
212 | | - |
| 204 | + global $wgLiquidThreadsExtensionPath; |
| 205 | + $this->showThread( $t, 1, 1, array( 'mustShowThreads' => $mustShowThreads, |
| 206 | + 'addScripts' => array( "$wgLiquidThreadsExtensionPath/newmessages.js" ) ) ); |
213 | 207 | $this->output->addHTML( "</td></tr>" ); |
214 | 208 | } |
215 | 209 | |