Extension:Social Sidebar

From Linux Web Expert

MediaWiki extensions manual
Social Sidebar
Release status: unmaintained
File:Extensions-SocialSideBar.jpg
Implementation Skin
Description Adds Links to Twitter and Facebook in the sidebar
Author(s) Joachim De Schrijver (joa_dstalk)
Latest version 0.2 (2011-09-12)
MediaWiki 1.15+
Database changes No
License LGPL
Download see here
Example MountWiki.com
$wgFBLink,
$wgTwitterLink
Quarterly downloads Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Public wikis using Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').

The Social Sidebar extension adds links to a Twitter and Facebook account in the sidebar.

Installation

  • <translate> <tvar name=1>Copy the code into a file</tvar> and place the file(s) in a directory called <tvar name=name>SocialSidebar</tvar> in your <tvar name=ext>extensions/</tvar> folder.</translate>
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    require_once "$IP/extensions/SocialSidebar/SocialSidebar.php";
    // Specifiy the Twitter and Facebook pages:
    $wgFacebook = "The complete link to your Facebook page";
    // e.g. $wgFacebook = "https://www.facebook.com/pages/Mount-Wiki/94013348117";
    $wgTwitter = "The name of your Twitter account";
    // e.g. $wgTwitter = "MountWiki";
    
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>

File:OOjs UI icon lightbulb-yellow.svg <translate> Note:</translate>

  • The description (label) of the portlet should be set in [[MediaWiki:Socialsidebar]].
  • When used in combination with another plugin that adds boxes to the sidebar, the order of calling the extension in the LocalSettings.php will determine the order of the extension boxes in the sidebar.
  • Because of inconsistencies in the skin implementation, this extension will work with the following skins: cologneblue, standard, nostalgia

Update History

12 September 2011: v 0.2

  • Using Twitter's Follow button instead of own image
  • Using Facebook's Like button instead of own image

24 July 2011: v 0.1

  • First public version

Code

SocialSidebar.php
<?php
/**
 * MediaWiki extension to add a social sidebar in a portlet in the sidebar.
 * Installation instructions can be found on
 * https://www.mediawiki.org/wiki/Extension:Social_Sidebar
 *
 * This extension will not add the Social Sidebar portlet to *any* skin
 * that is used with MediaWiki. Because of inconsistencies in the skin
 * implementation, it will not be add to the following skins:
 * cologneblue, standard, nostalgia
 *
 * @addtogroup Extensions
 * @author Joachim De Schrijver
 * @license LGPL
 *
 * Social Sidebar
 */

/**
 * Exit if called outside of MediaWiki
 */
if( !defined( 'MEDIAWIKI' ) ) {
	echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
	die( 1 );
}

/**
 * SETTINGS
 * --------
 * The description of the portlet can be changed in [[MediaWiki:Socialsidebar]].
 *.
 * Variables should be set in the LocalSettings.php
 */
$wgTwitter  = "";
$wgFacebook = "";

$wgExtensionCredits['other'][] = array(
	'name'           => 'Social Sidebar',
	'version'        => '0.2',
	'author'         => '[https://www.mediawiki.org/wiki/User:Joa_ds Joachim De Schrijver]',
	'description'    => 'Adds [http://www.twitter.com Twitter] and [http://www.facebook.com Facebook] links to the sidebar',
	'url'            => 'https://www.mediawiki.org/wiki/Extension:Social_Sidebar',
);

// Hook to modify the sidebar
$wgHooks['SkinBuildSidebar'][] = 'SocialSidebar::FacebookTwitter';

// Class & Functions
class SocialSidebar {
	static function FacebookTwitter( $skin, &$bar ) {
		global $wgFacebook,$wgTwitter;
		
		if ($wgFacebook != "")
			$bar['socialsidebar']  = '<iframe src="http://www.facebook.com/plugins/like.php?app_id=150743178336313&amp;href='.rawurlencode($wgFacebook).'&amp;send=false&amp;layout=button_count&amp;width=135&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:135px; height:21px;" allowTransparency="true"></iframe>';
		if ($wgTwitter != "")
			$bar['socialsidebar'] .= '<a href="http://twitter.com/'.$wgTwitter.'" class="twitter-follow-button" data-show-count="false">Follow @'.$wgTwitter.'</a><script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>';
		return true;
	}
}