r93290 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93289‎ | r93290 | r93291 >
Date:17:35, 27 July 2011
Author:kipcool
Status:deferred (Comments)
Tags:
Comment:
Using addScriptFile , addStyle.
Removed Gadget-rtl.css (not used)
Modified paths:
  • /trunk/extensions/Wikidata/Wikidata.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/Wikidata.hooks.php
@@ -4,20 +4,16 @@
55
66 public static function onBeforePageDisplay( &$out, &$skin ) {
77 global $wgLang, $wgScriptPath;
8 - $out->addScript( "<script type='text/javascript' src='$wgScriptPath/extensions/Wikidata/OmegaWiki/suggest.js'></script>" );
9 - $out->addScript( "<script type='text/javascript' src='$wgScriptPath/extensions/Wikidata/OmegaWiki/omegawiki-ajax.js'></script>" );
108
11 - if ( $wgLang->isRTL() ) {
12 - $rtl = '-rtl';
 9+ $out->addScriptFile ( "{$wgScriptPath}/extensions/Wikidata/OmegaWiki/suggest.js");
 10+ $out->addScriptFile ( "{$wgScriptPath}/extensions/Wikidata/OmegaWiki/omegawiki-ajax.js");
1311
14 - # FIXME: Why are we including Gadget CSS here, this is Wikidata?
15 - $wgOut->addHTML( '<style type="text/css">/*<![CDATA[*/ @import "/index.php?title=MediaWiki:Gadget-rtl.css&action=raw&ctype=text/css"; /*]]>*/</style>' );
16 - } else {
17 - $rtl = '';
18 - }
 12+ $rtl = '' ;
 13+ if ( $wgLang->isRTL() ) $rtl = '-rtl';
1914
20 - $out->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => "$wgScriptPath/extensions/Wikidata/OmegaWiki/suggest$rtl.css" ) );
21 - $out->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => "$wgScriptPath/extensions/Wikidata/OmegaWiki/tables$rtl.css" ) );
 15+ $out->addStyle("{$wgScriptPath}/extensions/Wikidata/OmegaWiki/suggest{$rtl}.css", 'screen');
 16+ $out->addStyle("{$wgScriptPath}/extensions/Wikidata/OmegaWiki/tables{$rtl}.css", 'screen');
 17+
2218 return true;
2319 }
2420

Comments

#Comment by Hashar (talk | contribs)   18:10, 27 July 2011

You should use the resource loader instead of addStyle / addScriptFile :) Have a look at http://www.mediawiki.org/wiki/ResourceLoader

#Comment by Kipmaster (talk | contribs)   19:02, 27 July 2011

I tried but with no success... If you say it's possible then I'll try harder :) Thanks!

#Comment by Hashar (talk | contribs)   21:03, 5 August 2011

You probably want to start with a basic script to get familiar with the resourceloader. Then feel free to ask for help either on IRC or the mediawiki-l mailing list.

Status & tagging log