[MediaWiki-commits] [Gerrit] Added composer dependency management Fixed bug where globals... - change (mediawiki...SideBarMenu)
Netbrain has submitted this change and it was merged. Change subject: Added composer dependency management Fixed bug where globals were not available to config mechanism Fixed bug where tag parsing occurred more than once. Removed legacy/unused code .. Added composer dependency management Fixed bug where globals were not available to config mechanism Fixed bug where tag parsing occurred more than once. Removed legacy/unused code Change-Id: I6385275f6ffacfd7b50c9e0b1686daceef50c8e0 --- M SideBarMenu.php M SideBarMenu.settings.php A composer.json M src/Hooks.php M src/MenuParser.php M src/SubPage/SubPageRenderer.php 6 files changed, 53 insertions(+), 47 deletions(-) Approvals: Netbrain: Verified; Looks good to me, approved diff --git a/SideBarMenu.php b/SideBarMenu.php index 567cb80..8e27064 100644 --- a/SideBarMenu.php +++ b/SideBarMenu.php @@ -8,6 +8,10 @@ die('SideBarMenu requires extension ParamProcessor'); } +if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) { + include_once( __DIR__ . '/vendor/autoload.php' ); +} + //SideBarMenu constants const SBM_EXPANDED = 'expanded'; const SBM_CONTROLS_SHOW = 'show'; @@ -28,32 +32,6 @@ SBM_STYLE, SBM_MINIMIZED, ); - -spl_autoload_register( function ( $className ) { - $className = ltrim( $className, '\\' ); - $fileName = ''; - $namespace = ''; - - if ( $lastNsPos = strripos( $className, '\\') ) { - $namespace = substr( $className, 0, $lastNsPos ); - $className = substr( $className, $lastNsPos + 1 ); - $fileName = str_replace( '\\', '/', $namespace ) . '/'; - } - - $fileName .= str_replace( '_', '/', $className ) . '.php'; - - $namespaceSegments = explode( '\\', $namespace ); - - if ( $namespaceSegments[0] === 'SideBarMenu' ) { - $fileName = substr($fileName,strlen($namespaceSegments[0])); - if ( count( $namespaceSegments ) === 1 || $namespaceSegments[1] !== 'Tests' ) { - require_once (__DIR__ . '/src/' . $fileName); - } - } -} ); - -call_user_func( function() { - global $wgExtensionCredits, $wgExtensionMessagesFiles, $wgExtensionFunctions, $wgResourceModules; $wgExtensionCredits['parserhook'][] = array( 'path' = __FILE__, @@ -96,7 +74,5 @@ // Sepcify phpunit tests $wgHooks['UnitTestsList'][] = 'SideBarMenu\Hooks::registerUnitTests'; }; - -} ); require_once(__DIR__.'/SideBarMenu.settings.php'); \ No newline at end of file diff --git a/SideBarMenu.settings.php b/SideBarMenu.settings.php index 8c62122..d328c57 100644 --- a/SideBarMenu.settings.php +++ b/SideBarMenu.settings.php @@ -1,8 +1,8 @@ ?php -$wgSideBarMenuConfig[SBM_CONTROLS_SHOW] = null; -$wgSideBarMenuConfig[SBM_CONTROLS_HIDE] = null; -$wgSideBarMenuConfig[SBM_JS_ANIMATE] = true; -$wgSideBarMenuConfig[SBM_EXPANDED] = true; -$wgSideBarMenuConfig[SBM_EDIT_LINK] = true; -$wgSideBarMenuConfig[SBM_MINIMIZED] = false; \ No newline at end of file +$GLOBALS['wgSideBarMenuConfig'][SBM_CONTROLS_SHOW] = null; +$GLOBALS['wgSideBarMenuConfig'][SBM_CONTROLS_HIDE] = null; +$GLOBALS['wgSideBarMenuConfig'][SBM_JS_ANIMATE] = true; +$GLOBALS['wgSideBarMenuConfig'][SBM_EXPANDED] = true; +$GLOBALS['wgSideBarMenuConfig'][SBM_EDIT_LINK] = true; +$GLOBALS['wgSideBarMenuConfig'][SBM_MINIMIZED] = false; \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 000..3cd598d --- /dev/null +++ b/composer.json @@ -0,0 +1,27 @@ +{ +name: mediawiki/side-bar-menu, +type: mediawiki-extension, +description: Allows for a simple sidebar menu which supports infinite number of sub-menus., +license: GPL-3.0+, +require: { +php: =5.3.0, +composer/installers: 1.*,=1.0.1, +mediawiki/validator: =1.0.0.1 +}, +authors: [ +{ +name: Kim Eik, +email: k...@heldig.org, +role: Developer +} +], +autoload: { +files : [ +SideBarMenu.php +], +classmap:[ +src/, +test/ +] + } +} diff --git a/src/Hooks.php b/src/Hooks.php index 2153407..78ce199 100644 --- a/src/Hooks.php +++ b/src/Hooks.php @@ -24,15 +24,16 @@ public static function renderSideBarMenuFromTag( $input, array $args, Parser $parser, PPFrame $frame ) { try { $parser-getOutput()-addModules( 'ext.sidebarmenu.core' ); - $input = $parser-recursiveTagParse( $input, $frame ); if ( strpos( $input, '#subpage ' ) !== false ) { //subpages handling $parser-disableCache(); SubPageRenderer::renderSubPages( $input );
[MediaWiki-commits] [Gerrit] Added composer dependency management Fixed bug where globals... - change (mediawiki...SideBarMenu)
Netbrain has uploaded a new change for review. https://gerrit.wikimedia.org/r/116098 Change subject: Added composer dependency management Fixed bug where globals were not available to config mechanism Fixed bug where tag parsing occurred more than once. Removed legacy/unused code .. Added composer dependency management Fixed bug where globals were not available to config mechanism Fixed bug where tag parsing occurred more than once. Removed legacy/unused code Change-Id: I6385275f6ffacfd7b50c9e0b1686daceef50c8e0 --- M SideBarMenu.php M SideBarMenu.settings.php A composer.json M src/Hooks.php M src/MenuParser.php M src/SubPage/SubPageRenderer.php 6 files changed, 53 insertions(+), 47 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SideBarMenu refs/changes/98/116098/1 diff --git a/SideBarMenu.php b/SideBarMenu.php index 567cb80..8e27064 100644 --- a/SideBarMenu.php +++ b/SideBarMenu.php @@ -8,6 +8,10 @@ die('SideBarMenu requires extension ParamProcessor'); } +if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) { + include_once( __DIR__ . '/vendor/autoload.php' ); +} + //SideBarMenu constants const SBM_EXPANDED = 'expanded'; const SBM_CONTROLS_SHOW = 'show'; @@ -28,32 +32,6 @@ SBM_STYLE, SBM_MINIMIZED, ); - -spl_autoload_register( function ( $className ) { - $className = ltrim( $className, '\\' ); - $fileName = ''; - $namespace = ''; - - if ( $lastNsPos = strripos( $className, '\\') ) { - $namespace = substr( $className, 0, $lastNsPos ); - $className = substr( $className, $lastNsPos + 1 ); - $fileName = str_replace( '\\', '/', $namespace ) . '/'; - } - - $fileName .= str_replace( '_', '/', $className ) . '.php'; - - $namespaceSegments = explode( '\\', $namespace ); - - if ( $namespaceSegments[0] === 'SideBarMenu' ) { - $fileName = substr($fileName,strlen($namespaceSegments[0])); - if ( count( $namespaceSegments ) === 1 || $namespaceSegments[1] !== 'Tests' ) { - require_once (__DIR__ . '/src/' . $fileName); - } - } -} ); - -call_user_func( function() { - global $wgExtensionCredits, $wgExtensionMessagesFiles, $wgExtensionFunctions, $wgResourceModules; $wgExtensionCredits['parserhook'][] = array( 'path' = __FILE__, @@ -96,7 +74,5 @@ // Sepcify phpunit tests $wgHooks['UnitTestsList'][] = 'SideBarMenu\Hooks::registerUnitTests'; }; - -} ); require_once(__DIR__.'/SideBarMenu.settings.php'); \ No newline at end of file diff --git a/SideBarMenu.settings.php b/SideBarMenu.settings.php index 8c62122..d328c57 100644 --- a/SideBarMenu.settings.php +++ b/SideBarMenu.settings.php @@ -1,8 +1,8 @@ ?php -$wgSideBarMenuConfig[SBM_CONTROLS_SHOW] = null; -$wgSideBarMenuConfig[SBM_CONTROLS_HIDE] = null; -$wgSideBarMenuConfig[SBM_JS_ANIMATE] = true; -$wgSideBarMenuConfig[SBM_EXPANDED] = true; -$wgSideBarMenuConfig[SBM_EDIT_LINK] = true; -$wgSideBarMenuConfig[SBM_MINIMIZED] = false; \ No newline at end of file +$GLOBALS['wgSideBarMenuConfig'][SBM_CONTROLS_SHOW] = null; +$GLOBALS['wgSideBarMenuConfig'][SBM_CONTROLS_HIDE] = null; +$GLOBALS['wgSideBarMenuConfig'][SBM_JS_ANIMATE] = true; +$GLOBALS['wgSideBarMenuConfig'][SBM_EXPANDED] = true; +$GLOBALS['wgSideBarMenuConfig'][SBM_EDIT_LINK] = true; +$GLOBALS['wgSideBarMenuConfig'][SBM_MINIMIZED] = false; \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 000..3cd598d --- /dev/null +++ b/composer.json @@ -0,0 +1,27 @@ +{ +name: mediawiki/side-bar-menu, +type: mediawiki-extension, +description: Allows for a simple sidebar menu which supports infinite number of sub-menus., +license: GPL-3.0+, +require: { +php: =5.3.0, +composer/installers: 1.*,=1.0.1, +mediawiki/validator: =1.0.0.1 +}, +authors: [ +{ +name: Kim Eik, +email: k...@heldig.org, +role: Developer +} +], +autoload: { +files : [ +SideBarMenu.php +], +classmap:[ +src/, +test/ +] + } +} diff --git a/src/Hooks.php b/src/Hooks.php index 2153407..78ce199 100644 --- a/src/Hooks.php +++ b/src/Hooks.php @@ -24,15 +24,16 @@ public static function renderSideBarMenuFromTag( $input, array $args, Parser $parser, PPFrame $frame ) { try { $parser-getOutput()-addModules( 'ext.sidebarmenu.core' ); - $input = $parser-recursiveTagParse( $input, $frame ); if ( strpos( $input, '#subpage ' ) !== false ) { //subpages handling $parser-disableCache();