-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShareThis.php
56 lines (43 loc) · 1.87 KB
/
ShareThis.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
48
49
50
51
52
53
54
55
56
<?php
# Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
if (!defined('MEDIAWIKI')) {
die();
}
$wgExtensionCredits['specialpage'][] = array(
'name' => 'ShareThis',
'author' =>'Wesley Ellis',
'url' => 'http://appropedia.org/User:Tahnok',
'description' => 'This will add a tweet page link to your toolbox',
'descriptionmsg' => 'This will add a tweet page link to your toolbox',
'version' => 1
);
$dir = dirname(__FILE__) . '/';
$wgExtensionMessagesFiles['ShareThis'] = $dir . 'ShareThis.i18n.php'; # Location of a messages file (Tell MediaWiki to load this file)
$wgSpecialPages['ShareThis'] = 'SpecialShareThis'; # Tell MediaWiki about the new special page and its class name
$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = 'urlBuilder';
$wgHooks['SkinTemplateToolboxEnd'][] = 'ShareToolbox';
function ShareToolbox( &$monobook) {
if( isset( $monobook->data['nav_urls']['ShareThis'])){
?><li id="Test"><a href="<?php echo htmlspecialchars($monobook->data['nav_urls']['ShareThis']['href'])?>" target="_blank"><?php echo htmlspecialchars($monobook->data['nav_urls']['ShareThis']['text'])?></a></li>
<?php
}
return true;
}
function urlBuilder( &$skintemplate, &$nav_urls, &$oldid, &$revid ) {
#uncomment this when we have multi-lang support
wfLoadExtensionMessages( 'ShareThis' );
global $wgTwitterUserName;
$title = Title::newFromText(wfUrlEncode("{$skintemplate->thispage}"));
$url = $title->getFullURL();
$pagename = urlencode($title->getFullText());
$href = "http://twitter.com/share?text=" . $pagename . "&url=" . $url;
if(isset($wgTwitterUserName)){
$href = $href . "&via=" . $wgTwitterUserName;
}
$nav_urls['ShareThis'] = array(
'text' => wfMsg( 'sharethis_link'),
'href' => $href
);
return true;
}
?>