Gergő Tisza has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/392719 )
Change subject: Improve file organization ...................................................................... Improve file organization Move PHP classes into includes/, match file names with class names, move hooks into their own file. Change-Id: Ia11c16a5111d016f0e814509941268c77e04affd --- M extension.json R includes/ApiSiteMatrix.php R includes/SiteMatrix.php A includes/SiteMatrixHooks.php R includes/SpecialSiteMatrix.php 5 files changed, 81 insertions(+), 73 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SiteMatrix refs/changes/19/392719/1 diff --git a/extension.json b/extension.json index de0c95a..3bb197c 100644 --- a/extension.json +++ b/extension.json @@ -28,19 +28,21 @@ "SiteMatrixMagic": "SiteMatrix.i18n.magic.php" }, "AutoloadClasses": { - "SiteMatrix": "SiteMatrix_body.php", - "SpecialSiteMatrix": "SpecialSiteMatrix.php", - "ApiSiteMatrix": "SiteMatrixApi.php" + "SiteMatrix": "includes/SiteMatrix.php", + "SpecialSiteMatrix": "includes/SpecialSiteMatrix.php", + "ApiSiteMatrix": "includes/ApiSiteMatrix.php", + "SiteMatrixHooks": "includes/SiteMatrixHooks.php" + }, "Hooks": { "APIQuerySiteInfoGeneralInfo": [ - "SiteMatrix::APIQuerySiteInfoGeneralInfo" + "SiteMatrixHooks::APIQuerySiteInfoGeneralInfo" ], "ParserGetVariableValueSwitch": [ - "SiteMatrix::onParserGetVariableValueSwitch" + "SiteMatrixHooks::onParserGetVariableValueSwitch" ], "MagicWordwgVariableIDs": [ - "SiteMatrix::onMagicWordwgVariableIDs" + "SiteMatrixHooks::onMagicWordwgVariableIDs" ] }, "config": { diff --git a/SiteMatrixApi.php b/includes/ApiSiteMatrix.php similarity index 100% rename from SiteMatrixApi.php rename to includes/ApiSiteMatrix.php diff --git a/SiteMatrix_body.php b/includes/SiteMatrix.php similarity index 83% rename from SiteMatrix_body.php rename to includes/SiteMatrix.php index 1e78f61..e3e4fc6 100644 --- a/SiteMatrix_body.php +++ b/includes/SiteMatrix.php @@ -352,71 +352,4 @@ private function extractFile( $filename ) { return array_map( 'trim', file( $filename ) ); } - - /** - * Handler method for the APISiteInfoGeneralInfo hook - * - * @param ApiQuerySiteinfo $module - * @param array &$results - * @return bool - */ - public static function APIQuerySiteInfoGeneralInfo( $module, &$results ) { - global $wgDBname, $wgConf; - - $matrix = new SiteMatrix(); - - list( $site, $lang ) = $wgConf->siteFromDB( $wgDBname ); - - if ( $matrix->isClosed( $lang, $site ) ) { - $results['closed'] = ''; - } - - if ( $matrix->isSpecial( $wgDBname ) ) { - $results['special'] = ''; - } - - if ( $matrix->isPrivate( $wgDBname ) ) { - $results['private'] = ''; - } - - if ( $matrix->isFishbowl( $wgDBname ) ) { - $results['fishbowl'] = ''; - } - - if ( $matrix->isNonGlobal( $wgDBname ) ) { - $results['nonglobal'] = ''; - } - - return true; - } - - /** - * @param Parser &$parser - * @param array &$cache - * @param string &$magicWordId - * @param string &$ret - * @param PPFrame $frame - * @return bool true - */ - public static function onParserGetVariableValueSwitch( - Parser &$parser, - &$cache, - &$magicWordId, - &$ret, - $frame = null ) { - if ( $magicWordId == 'numberofwikis' ) { - global $wgLocalDatabases; - $ret = count( $wgLocalDatabases ); - } - return true; - } - - /** - * @param array &$customVariableIds - * @return bool true - */ - public static function onMagicWordwgVariableIDs( &$customVariableIds ) { - $customVariableIds[] = 'numberofwikis'; - return true; - } } diff --git a/includes/SiteMatrixHooks.php b/includes/SiteMatrixHooks.php new file mode 100644 index 0000000..7f952b6 --- /dev/null +++ b/includes/SiteMatrixHooks.php @@ -0,0 +1,73 @@ +<?php + +/** + * Hook handlers + */ +class SiteMatrixHooks { + /** + * Handler method for the APISiteInfoGeneralInfo hook + * + * @param ApiQuerySiteinfo $module + * @param array &$results + * @return bool + */ + public static function APIQuerySiteInfoGeneralInfo( $module, &$results ) { + global $wgDBname, $wgConf; + + $matrix = new SiteMatrix(); + + list( $site, $lang ) = $wgConf->siteFromDB( $wgDBname ); + + if ( $matrix->isClosed( $lang, $site ) ) { + $results['closed'] = ''; + } + + if ( $matrix->isSpecial( $wgDBname ) ) { + $results['special'] = ''; + } + + if ( $matrix->isPrivate( $wgDBname ) ) { + $results['private'] = ''; + } + + if ( $matrix->isFishbowl( $wgDBname ) ) { + $results['fishbowl'] = ''; + } + + if ( $matrix->isNonGlobal( $wgDBname ) ) { + $results['nonglobal'] = ''; + } + + return true; + } + + /** + * @param Parser &$parser + * @param array &$cache + * @param string &$magicWordId + * @param string &$ret + * @param PPFrame $frame + * @return bool true + */ + public static function onParserGetVariableValueSwitch( + Parser &$parser, + &$cache, + &$magicWordId, + &$ret, + $frame = null ) { + if ( $magicWordId == 'numberofwikis' ) { + global $wgLocalDatabases; + $ret = count( $wgLocalDatabases ); + } + return true; + } + + /** + * @param array &$customVariableIds + * @return bool true + */ + public static function onMagicWordwgVariableIDs( &$customVariableIds ) { + $customVariableIds[] = 'numberofwikis'; + return true; + } +} diff --git a/SpecialSiteMatrix.php b/includes/SpecialSiteMatrix.php similarity index 100% rename from SpecialSiteMatrix.php rename to includes/SpecialSiteMatrix.php -- To view, visit https://gerrit.wikimedia.org/r/392719 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia11c16a5111d016f0e814509941268c77e04affd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SiteMatrix Gerrit-Branch: master Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits