Ljonka has uploaded a new change for review.
https://gerrit.wikimedia.org/r/313603
Change subject: Add hitcounter value to every page as semantic mediawiki
property
......................................................................
Add hitcounter value to every page as semantic mediawiki property
Depends on BlueSpiceSMWConnector,
which debends on SemanticExtraSpecialProperties
Change-Id: I1be878d520492eb239774cebf930e3a92ba1fef7
---
M HitCounters.php
M includes/HitCounters.body.php
M includes/HitCounters.hooks.php
3 files changed, 36 insertions(+), 16 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/HitCounters
refs/changes/03/313603/1
diff --git a/HitCounters.php b/HitCounters.php
index 706aab4..71b8317 100644
--- a/HitCounters.php
+++ b/HitCounters.php
@@ -35,19 +35,25 @@
* @file
*/
-call_user_func(
- function () {
- if ( function_exists( 'wfLoadExtension' ) ) {
- wfLoadExtension( 'HitCounters' );
- wfWarn(
- 'Deprecated PHP entry point used for HitCounters
extension. ' .
- 'Please use wfLoadExtension instead, ' .
- 'see
https://www.mediawiki.org/wiki/Extension_registration ' .
- 'for more details.'
- );
- return;
- } else {
- die( 'This extension requires MediaWiki 1.25+' );
- }
- }
-);
+
+if ( function_exists( 'wfLoadExtension' ) ) {
+ wfLoadExtension( 'HitCounters' );
+ wfWarn(
+ 'Deprecated PHP entry point used for HitCounters extension. ' .
+ 'Please use wfLoadExtension instead, ' .
+ 'see https://www.mediawiki.org/wiki/Extension_registration ' .
+ 'for more details.'
+ );
+} else {
+ die( 'This extension requires MediaWiki 1.25+' );
+}
+
+$GLOBALS["bssDefinitions"]["_HITCOUNTERS"] = array(
+ "id" => "___HITCOUNTERS",
+ "type" => 1,
+ "show" => false,
+ "msgkey" => "hitcounters-extensionname",
+ "alias" => "Hit counter",
+ "label" => "HitCounters",
+ "mapping" => "HitCounters\\HitCounters::smwMappingFunction"
+);
\ No newline at end of file
diff --git a/includes/HitCounters.body.php b/includes/HitCounters.body.php
index f607f87..b30fb52 100644
--- a/includes/HitCounters.body.php
+++ b/includes/HitCounters.body.php
@@ -133,4 +133,15 @@
)
);
}
+
+ public static function smwMappingFunction(
+ \SMW\SemanticData $aSemanticData,
+ \WikiPage $aWikiPage,
+ \SMW\DIProperty $aProperty ) {
+ $intCount = ( int ) self::getCount( $aWikiPage->getTitle() );
+ //add data finally
+ $aSemanticData->addPropertyObjectValue(
+ $aProperty, new \SMWDINumber( $intCount )
+ );
+ }
}
diff --git a/includes/HitCounters.hooks.php b/includes/HitCounters.hooks.php
index f38e388..1d624ea 100644
--- a/includes/HitCounters.hooks.php
+++ b/includes/HitCounters.hooks.php
@@ -129,6 +129,9 @@
);
DeferredUpdates::addUpdate( new SiteStatsUpdate( 1, 0,
0 ) );
}
+ if ( $wikipage->getContent() != null ) {
+ \DataUpdate::runUpdates(
$wikipage->getContent()->getSecondaryDataUpdates( $wikipage->getTitle() ) );
+ }
}
public static function onSkinTemplateOutputPageBeforeExec(
--
To view, visit https://gerrit.wikimedia.org/r/313603
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1be878d520492eb239774cebf930e3a92ba1fef7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/HitCounters
Gerrit-Branch: master
Gerrit-Owner: Ljonka <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits