Index: branches/salvatoreingala/Gadgets/Gadgets_body.php |
— | — | @@ -660,7 +660,7 @@ |
661 | 661 | if ( !count( $pages ) ) { |
662 | 662 | return null; |
663 | 663 | } |
664 | | - return new GadgetResourceLoaderModule( $pages, $this->dependencies ); |
| 664 | + return new GadgetResourceLoaderModule( $pages, $this->dependencies, $this ); |
665 | 665 | } |
666 | 666 | |
667 | 667 | /** |
— | — | @@ -1080,7 +1080,7 @@ |
1081 | 1081 | * Class representing a list of resources for one gadget |
1082 | 1082 | */ |
1083 | 1083 | class GadgetResourceLoaderModule extends ResourceLoaderWikiModule { |
1084 | | - private $pages, $dependencies; |
| 1084 | + private $pages, $dependencies, $gadget; |
1085 | 1085 | |
1086 | 1086 | /** |
1087 | 1087 | * Creates an instance of this class |
— | — | @@ -1092,9 +1092,10 @@ |
1093 | 1093 | * ) |
1094 | 1094 | * @param $dependencies Array: Names of resources this module depends on |
1095 | 1095 | */ |
1096 | | - public function __construct( $pages, $dependencies ) { |
| 1096 | + public function __construct( $pages, $dependencies, $gadget ) { |
1097 | 1097 | $this->pages = $pages; |
1098 | 1098 | $this->dependencies = $dependencies; |
| 1099 | + $this->gadget = $gadget; |
1099 | 1100 | } |
1100 | 1101 | |
1101 | 1102 | /** |
— | — | @@ -1114,12 +1115,8 @@ |
1115 | 1116 | } |
1116 | 1117 | |
1117 | 1118 | public function getScript( ResourceLoaderContext $context ) { |
1118 | | - $moduleName = $this->getName(); |
1119 | | - $gadgetName = substr( $moduleName, strlen( 'ext.gadget.' ) ); |
1120 | | - $gadgets = Gadget::loadList(); |
1121 | | - $gadget = $gadgets[$gadgetName]; |
1122 | 1119 | |
1123 | | - $prefs = $gadget->getPrefs(); |
| 1120 | + $prefs = $this->gadget->getPrefs(); |
1124 | 1121 | |
1125 | 1122 | //Enclose gadget's code in a closure, with "this" bound to the |
1126 | 1123 | //configuration object (or to "window" for non-configurable gadgets) |