Extension:SNSButtonsInSidebar
Appearance
This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net . |
This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. |
SNSButtonsInSidebar Release status: unmaintained |
|
---|---|
Implementation | Tag |
Description | Adds SNS buttons in the sidebar |
Author(s) | Jmkim dot com |
Latest version | 1.0.0 (2012-08-18) |
MediaWiki | 1.18+ |
Database changes | No |
License | GNU General Public License 2.0 |
Download | see below |
The SNSButtonsInSidebar adds SNS buttons in the sidebar on every page.
Installation
[edit]- Copy the code into the respective files and place the file(s) in a directory called
SNSButtonsInSidebar
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php file:
require_once "$IP/extensions/SNSButtonsInSidebar/SNSButtonsInSidebar.php";
- Done â Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Code
[edit]- SNSButtonsInSidebar.php
<?php
/**
* MediaWiki extension to add SNS buttons in the sidebar
* Installation instructions can be found on
* http://www.mediawiki.org/wiki/Extension:SNSButtonsInSidebar
*
* @ingroup Extensions
* @author Jmkim dot com
* @license GNU Public License
*/
// Exit if called outside of MediaWiki
if( !defined( 'MEDIAWIKI' ) ) exit;
// SETTINGS
$wgSNSButtonsTitle = 'Recommendations';
$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => 'SNSButtonsInSidebar',
'version' => '1.0.0',
'author' => 'Jmkim dot com',
'description' => 'SNSButtonsInSidebar Extension',
'url' => 'https://www.mediawiki.org/wiki/Extension:SNSButtonsInSidebar'
);
// Register class and localisations
$dir = dirname(__FILE__) . '/';
$wgAutoloadClasses['SNSButtonsInSidebar'] = $dir.'SNSButtonsInSidebar.class.php';
// Hook to modify the sidebar
$wgHooks['SkinBuildSidebar'][] = 'SNSButtonsInSidebar::renderSNSButtonsInSidebar';
- SNSButtonsInSidebar.class.php
<?php
if (!defined('MEDIAWIKI')) exit;
class SNSButtonsInSidebar {
static function renderSNSButtonsInSidebar( $skin, &$bar ) {
global $wgFacebookCommonScriptWritten, $wgFacebookAppId;
$btnsText = '';
if( !isset($wgFacebookCommonScriptWritten) || !$wgFacebookCommonScriptWritten ) {
if( !isset($wgFacebookAppId) ) $wgFacebookAppId = '';
$wgFacebookCommonScriptWritten = true;
$btnsText .= '<div id="fb-root">';
$btnsText .= '</div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1&appId='.$wgFacebookAppId.'"></script>';
}
$btnsText .= '<script type="text/javascript">';
$btnsText .= '(function() {';
$btnsText .= "var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;";
$btnsText .= "po.src = 'https://apis.google.com/js/plusone.js';";
$btnsText .= "var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);";
$btnsText .= '})();';
$btnsText .= '</script>';
global $wgServer;
$btnsText .= '<div class="fb-like" data-href="'.$wgServer.'"';
$btnsText .= ' data-send="false" data-layout="button_count"';
$btnsText .= ' data-width="130" data-show-faces="false"';
$btnsText .= ' data-action="like" data-colorscheme="light"';
$btnsText .= '></div>';
$btnsText .= '<div style="height:5px"></div>';
$btnsText .= '<div class="g-plusone" data-width="130" data-href="'.$wgServer.'"></div>';
global $wgSNSButtonsTitle;
$bar[$wgSNSButtonsTitle] = $btnsText;
return true;
}
}