Foxtrott has submitted this change and it was merged.

Change subject: just forget RL and do own dependency resolving
......................................................................


just forget RL and do own dependency resolving

Change-Id: I05ad4ba24f0f951d3f51e4d1a53e1e38162840ed
---
M Bootstrap.class.php
M Bootstrap.php
2 files changed, 31 insertions(+), 27 deletions(-)

Approvals:
  Foxtrott: Verified; Looks good to me, approved



diff --git a/Bootstrap.class.php b/Bootstrap.class.php
index 9b7ce65..d6136cf 100644
--- a/Bootstrap.class.php
+++ b/Bootstrap.class.php
@@ -67,7 +67,7 @@
                // Components w/ JavaScript
                'modals'               => array( 'styles' => 'modals', 
'scripts' => 'bootstrap/js/modal.js' ),
                'tooltip'              => array( 'styles' => 'tooltip', 
'scripts' => 'bootstrap/js/tooltip.js' ),
-               'popovers'             => array( 'styles' => 'popovers', 
'scripts' => 'bootstrap/js/popover.js', 'dependencies' => 
'ext.bootstrap.tooltip' ),
+               'popovers'             => array( 'styles' => 'popovers', 
'scripts' => 'bootstrap/js/popover.js', 'dependencies' => 'tooltip' ),
                'carousel'             => array( 'styles' => 'carousel', 
'scripts' => 'bootstrap/js/carousel.js' ),
 
                // Utility classes
@@ -85,6 +85,7 @@
                'transition'           => array( 'scripts' => 
'bootstrap/js/transition.js' ),
 
        );
+
        static private $coreModules = array( 'variables', 'mixins', 
'normalize', 'print', 'scaffolding', 'type', 'code',
                                                                                
 'grid', 'tables', 'forms', 'buttons' );
        static private $optionalModules = array( 'component-animations', 
'glyphicons', 'dropdowns', 'button-groups',
@@ -93,6 +94,12 @@
                                                                                
         'media', 'list-group', 'panels', 'wells', 'close', 'modals', 'tooltip',
                                                                                
         'popovers', 'carousel', 'utilities', 'responsive-utilities', 'affix',
                                                                                
         'alert', 'button', 'collapse', 'dropdown', 'scrollspy', 'tab', 
'transition' );
+
+       private $mModuleDescriptions;
+
+       public function __construct() {
+               $this->mModuleDescriptions = self::$moduleDescriptions;
+       }
 
        /**
         * Returns the Bootstrap singleton.
@@ -114,24 +121,6 @@
         */
        protected static function initializeBootstrap() {
 
-               global $wgResourceModules;
-
-               // register resource loader modules for JS components
-               foreach ( self::$moduleDescriptions as $module => $description 
) {
-                       if ( isset( $description[ 'scripts' ] ) ) {
-
-                               $wgResourceModules[ 'ext.bootstrap.' . $module 
] = array(
-                                       'localBasePath' => $wgResourceModules[ 
'ext.bootstrap' ][ 'localBasePath' ],
-                                       'remoteExtPath' => 'Bootstrap',
-                                       'scripts'       => $description[ 
'scripts' ],
-                               );
-
-                               if ( isset( $description[ 'dependencies' ] ) ) {
-                                       $wgResourceModules[ 'ext.bootstrap.' . 
$module ][ 'dependencies' ] = $description[ 'dependencies' ];
-                               }
-                       }
-               }
-
                self::$bootstrap = new Bootstrap();
 
                // add core Bootstrap modules
@@ -150,23 +139,38 @@
                foreach ( $modules as $module ) {
 
                        // if the module is known
-                       if ( array_key_exists( $module, 
self::$moduleDescriptions ) ) {
+                       if ( array_key_exists( $module, 
$this->mModuleDescriptions ) ) {
 
                                global $wgResourceModules;
 
                                // add less files to $wgResourceModules
-                               if ( isset( self::$moduleDescriptions[ $module 
][ 'styles' ] ) ) {
-                                       $wgResourceModules[ 
'ext.bootstrap.styles' ][ 'styles' ] = array_merge( $wgResourceModules[ 
'ext.bootstrap.styles' ][ 'styles' ], (array)self::$moduleDescriptions[ $module 
][ 'styles' ] );
+                               if ( isset( $this->mModuleDescriptions[ $module 
][ 'styles' ] ) ) {
+                                       $wgResourceModules[ 
'ext.bootstrap.styles' ][ 'styles' ] = array_merge( $wgResourceModules[ 
'ext.bootstrap.styles' ][ 'styles' ], (array)$this->mModuleDescriptions[ 
$module ][ 'styles' ] );
                                }
 
                                // ensure loading of js files using dependencies
-                               if ( isset( self::$moduleDescriptions[ $module 
][ 'scripts' ] ) ) {
-                                       $wgResourceModules[ 
'ext.bootstrap.scripts' ][ 'dependencies' ][ ] = 'ext.bootstrap.' . $module;
+                               if ( isset( $this->mModuleDescriptions[ $module 
][ 'scripts' ] ) ) {
+                                       $wgResourceModules[ 
'ext.bootstrap.scripts' ][ 'scripts' ] = array_merge( $wgResourceModules[ 
'ext.bootstrap.scripts' ][ 'scripts' ], (array)$this->mModuleDescriptions[ 
$module ][ 'scripts' ] );
 
                                }
 
-                               // prevent adding this module again
-                               unset( self::$moduleDescriptions[ $module ] );
+                               if ( isset( $this->mModuleDescriptions[ $module 
][ 'dependencies' ] ) ) {
+
+                                       // store dependencies before unsetting 
dependency information in the module descriptions
+                                       $dependencies = 
$this->mModuleDescriptions[ $module ][ 'dependencies' ];
+
+                                       // prevent adding this module again; 
this also prevents infinite recursion
+                                       unset( $this->mModuleDescriptions[ 
$module ] );
+
+                                       // add dependencies
+                                       $this->addBootstrapModule( 
$dependencies );
+
+                               } else {
+
+                                       // prevent adding this module again
+                                       unset( $this->mModuleDescriptions[ 
$module ] );
+                               }
+
                        }
                }
 
diff --git a/Bootstrap.php b/Bootstrap.php
index 35921e5..d0fe7fe 100644
--- a/Bootstrap.php
+++ b/Bootstrap.php
@@ -85,7 +85,7 @@
 $wgResourceModules['ext.bootstrap.scripts'] = array(
        'localBasePath' => $dir,
        'remoteExtPath' => 'Bootstrap',
-       'dependencies' => array(),
+       'scripts' => array(),
 );
 
 $wgResourceModules[ 'ext.bootstrap' ] = array(

-- 
To view, visit https://gerrit.wikimedia.org/r/122121
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I05ad4ba24f0f951d3f51e4d1a53e1e38162840ed
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Bootstrap
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <s7ep...@gmail.com>
Gerrit-Reviewer: Foxtrott <s7ep...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to