-
Notifications
You must be signed in to change notification settings - Fork 4
/
Shariff.php
47 lines (39 loc) · 1.35 KB
/
Shariff.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/*
* Parser that inserts social media buttons
*
* For more info see http://mediawiki.org/wiki/Shariff
*
* @package MediaWiki
* @subpackage Extensions
* @author Niki Hansche
* @copyright © 2014-2018 Niki Hansche
* @licence The MIT License (MIT)
*/
class Shariff {
static function shariffLikeParserFunction_Setup( &$parser ) {
# Create a magic word
MediaWiki\MediaWikiServices::getInstance()->getContentLanguage()->mMagicExtensions['shariffLike'] = ['shariffike', 'ShariffLike'];
# Set a function hook associating the "shariffLike_parser" magic word with our function
$parser->setFunctionHook( 'shariffLike', 'Shariff::shariffLikeParserFunction_Render' );
return true;
}
static function shariffLikeParserFeedHead(&$out, &$sk) {
$out->addModules( 'ext.Shariff' );
return true;
}
static function shariffLikeParserFunction_Render( &$parser, $param1 = '', $param2 = '', $param3 = '' ) {
global $wgSitename;
global $wgScriptPath;
global $wgLanguageCode;
if (substr($wgLanguageCode, 0, 3) === 'de-') {
$datalang = "de";
}
else {
$datalang = $wgLanguageCode;
}
//Get page title and URL
$output = '<div class="shariff noprint" data-lang="'.$datalang.'" data-services="["twitter","facebook","pinterest"]"></div>';
return $parser->insertStripItem($output, $parser->getStripState());
}
}