Extension:Social Sidebar

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
Social Sidebar

Release status: beta

Extensions-SocialSideBar.jpg
Implementation Skin
Description Adds Links to Twitter and Facebook in the sidebar
Author(s) Joachim De Schrijver (joa_dsTalk)
Last version 0.2 (2011-09-12)
MediaWiki 1.15 or newer
Database changes no
License LGPL
Download see here
Example MountWiki.com
Parameters

$wgFBLink,
$wgTwitterLink

Hooks used
SkinBuildSidebar

Check usage (experimental)

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

Contents

[edit] Installation

  1. Download the extension (copy/paste the file from below)
  2. Create a directory SocialSidebar in your $IP/extensions directory.
  3. Add the files to that $IP/extensions/SocialSidebar directory.
  4. Add to the end of LocalSettings.php (MW 1.17+):
    require_once("$IP/extensions/SocialSidebar/SocialSidebar.php");
  5. Specifiy the Twitter and Facebook pages that should be used by adding
    $wgFacebook = The complete link to your Facebook page   // e.g. "https://www.facebook.com/pages/Mount-Wiki/94013348117";
    $wgTwitter = The name of your Twitter account           // e.g. "MountWiki"
    just after that line.
  6. Installation can now be verified through Special:Version on your wiki

Note Note:

  • 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

[edit] 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

[edit] Code

[edit] 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 {
        function FacebookTwitter( $skin, &$bar ) {
                global $wgFacebook,$wgTwitter;

                $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>';
                $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;
        }
}
Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox