Jeroen De Dauw has uploaded a new change for review. https://gerrit.wikimedia.org/r/56768
Change subject: Display statistics using the SpecialStatsAddExtra hook ...................................................................... Display statistics using the SpecialStatsAddExtra hook This is a cherry-pick from the 1.9.x branch: -------------- commit 357b04b68b1ecaeca7c8fa46b18b172c66447a12 Author: mwjames <[email protected]> Date: Sat Nov 3 17:54:22 2012 +0900 SMW 1.9: Display statistics using the SpecialStatsAddExtra hook Its depends on a core change proposed with ... ------------- Change-Id: I75b78c7eaf570be1fc41228aa69c95edf314df0e --- M SemanticMediaWiki.hooks.php M includes/Setup.php M languages/SMW_Messages.php M specials/Statistics/SMW_SpecialStatistics.php 4 files changed, 53 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki refs/changes/68/56768/1 diff --git a/SemanticMediaWiki.hooks.php b/SemanticMediaWiki.hooks.php index 1a6315a..6ad30be 100644 --- a/SemanticMediaWiki.hooks.php +++ b/SemanticMediaWiki.hooks.php @@ -407,7 +407,6 @@ * @return true */ public static function onResourceLoaderGetConfigVars( &$vars ) { - $vars['smw'] = array( 'version' => SMW_VERSION, 'options' => array( @@ -418,4 +417,37 @@ return true; } + + /** + * Add extra statistic at the end of Special:Statistics. + * @see http://www.mediawiki.org/wiki/Manual:Hooks/SpecialStatsAddExtra + * + * @since 1.9 + * + * @param $extraStats + * @return boolean + */ + public static function onSpecialStatsAddExtra( $context, &$extraStats ) { + global $wgVersion, $wgLang; + + $semanticStatistics = smwfGetStore()->getStatistics(); + + if ( version_compare( $wgVersion, '1.21', '<' ) ) { + // Legacy approach to display statistical items + $extraStats[wfMessage( 'smw-statistics-property-instance' )->text()] = $wgLang->formatNum( $semanticStatistics['PROPUSES'] ); + $extraStats[wfMessage( 'smw-statistics-property-total-legacy' )->text()] = $wgLang->formatNum( $semanticStatistics['USEDPROPS'] ); + $extraStats[wfMessage( 'smw-statistics-property-page' )->text()] = $wgLang->formatNum( $semanticStatistics['OWNPAGE'] ); + $extraStats[wfMessage( 'smw-statistics-property-type' )->text()] = $wgLang->formatNum( $semanticStatistics['DECLPROPS'] ); + $extraStats[wfMessage( 'smw-statistics-query-inline' )->text()] = $wgLang->formatNum( $semanticStatistics['QUERY'] ); + } else { + $extraStats['smw-statistics'] = array(); + $extraStats['smw-statistics']['smw-statistics-property-instance'] = $semanticStatistics['PROPUSES']; + $extraStats['smw-statistics']['smw-statistics-property-total'] = $semanticStatistics['USEDPROPS']; + $extraStats['smw-statistics']['smw-statistics-property-page'] = $semanticStatistics['OWNPAGE']; + $extraStats['smw-statistics']['smw-statistics-property-type'] = $semanticStatistics['DECLPROPS']; + $extraStats['smw-statistics']['smw-statistics-query-inline'] = $semanticStatistics['QUERY']; + } + + return true; + } } diff --git a/includes/Setup.php b/includes/Setup.php index 9d600f4..3e6020a 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -71,6 +71,9 @@ $wgHooks['UnitTestsList'][] = 'SMWHooks::registerUnitTests'; $wgHooks['ResourceLoaderTestModules'][] = 'SMWHooks::registerQUnitTests'; + // Statistics + $wgHooks['SpecialStatsAddExtra'][] = 'SMWHooks::onSpecialStatsAddExtra'; + // User preference $wgHooks['GetPreferences'][] = 'SMWHooks::onGetPreferences'; diff --git a/languages/SMW_Messages.php b/languages/SMW_Messages.php index 221754f..a7ed7ab 100644 --- a/languages/SMW_Messages.php +++ b/languages/SMW_Messages.php @@ -214,6 +214,14 @@ Some of the existing properties might be [[Special:UnusedProperties|unused properties]]. Properties that still lack a page are found on the [[Special:WantedProperties|list of wanted properties]].', + 'smw-statistics' => 'Semantic statistics', + 'smw-statistics-property-instance' => 'Property value {{PLURAL:$1|assignment|assignments}}', + 'smw-statistics-property-total' => 'Total of [[Special:Properties|{{PLURAL:$1|property|different properties}}]]', + 'smw-statistics-property-total-legacy' => 'Total of {{PLURAL:$1|property|different properties}}', + 'smw-statistics-property-page' => '{{PLURAL:$1|Property|Properties}} with their own page', + 'smw-statistics-property-type' => '{{PLURAL:$1|Property|Properties}} with an assigned datatype', + 'smw-statistics-query-inline' => 'Total of inline {{PLURAL:$1|query|queries}}', + // Name of the URI Resolver Special (no content) 'smw_uri_doc' => 'The URI resolver implements the [$1 W3C TAG finding on httpRange-14]. It takes care that humans do not turn into websites.', @@ -926,6 +934,14 @@ 'smw-ui-tooltip-title-legend' => '{{doc-smw-ui-label|legend}} {{Identical|Legend}}', 'smw_unknowntype' => 'Error message shown for properties that have a type unknown to the system', + + 'smw-statistics' => 'Is a label that is displayed on the [[Special:Statistics Statistics]] page', + 'smw-statistics-property-instance' => 'Is a label that is displayed on the [[Special:Statistics Statistics]] page', + 'smw-statistics-property-total' => 'Is a label that is displayed on the [[Special:Statistics Statistics]] page', + 'smw-statistics-property-total-legacy' => 'Is a label that is displayed on the [[Special:Statistics Statistics]] page', + 'smw-statistics-property-page' => 'Is a label that is displayed on the [[Special:Statistics Statistics]] page', + 'smw-statistics-property-type' => 'Is a label that is displayed on the [[Special:Statistics Statistics]] page', + 'smw-statistics-query-inline' => 'Is a label that is displayed on the [[Special:Statistics Statistics]] page', ); /** Afrikaans (Afrikaans) diff --git a/specials/Statistics/SMW_SpecialStatistics.php b/specials/Statistics/SMW_SpecialStatistics.php index da82072..19be04b 100644 --- a/specials/Statistics/SMW_SpecialStatistics.php +++ b/specials/Statistics/SMW_SpecialStatistics.php @@ -22,7 +22,7 @@ $wgOut->setPageTitle( wfMessage( 'semanticstatistics' )->text() ); $semanticStatistics = smwfGetStore()->getStatistics(); - + $dbr = wfGetDB( DB_SLAVE ); $propertyPageAmount = $dbr->estimateRowCount( -- To view, visit https://gerrit.wikimedia.org/r/56768 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I75b78c7eaf570be1fc41228aa69c95edf314df0e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SemanticMediaWiki Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <[email protected]> Gerrit-Reviewer: Mwjames <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
