Extension:Social Bookmarking

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

Release status: stable

Implementation Parser extension
Description This extension allows you to add social bookmarking for digg, delicious, stumbleupon,etc...etc... The extension uses addthis.com and socialmarker.com bookmarking system.
Author(s) Jung Lee aka Max Lee (zedomaxtalk)
Latest version 0.1 (2007-12-19)
MediaWiki 1.11.x, 1.16.x
License CC-BY-SA
Download see below
Hooks used
BeforePageDisplay

Translate the Social Bookmarking extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

What can this extension do?[edit | edit source]

This extension allows you to add social bookmarking for Digg, delicious, StumbleUpon, etc...etc... The extension uses addthis.com and socialmarker.com bookmarking system.

Usage[edit | edit source]

Make it easy for your visitors to submit your wiki pages to Digg, StumbleUpon, Reddit, etc...etc...

Download instructions[edit | edit source]

Copy and paste following code and save as SocialBookmarking.php.

Installation[edit | edit source]

To install it put this file in the extensions directory. To activate the extension, include it from your LocalSettings.php with:

require_once("extensions/SocialBookmarking.php");

Once activated, you should see bookmarks appear at the bottom of your pages.

Code[edit | edit source]

original version[edit | edit source]

for SocialBookmarking.php see how other Social Bookmarking sites have added this code.

<?php
/**
 * Social Bookmarking extension
 * 
 * @version 0.1
 * @author Max Lee
 * @link http://www.mediawiki.org/wiki/Extension:Social_Bookmarking
 */
 
//Extension credits that show up on Special:Version
$wgExtensionCredits['parserhook'][] = array(
	'name' => 'Social Bookmarking',
	'author' => 'Max Lee',
	'url' => 'http://www.mediawiki.org/wiki/Extension:Social_Bookmarking',
	'version' => '0.1',
	'description' => 'Bookmark plugin for MediaWiki',
);
 
$wgHooks['BeforePageDisplay'][] = 'wfBookmark';
 
function wfBookmark(&$out) {
	global $wgArticle, $wgTitle;
	if ($wgArticle == null) return $out;
	//if ($wgArticle->getTitle()->mNamespace != 0 || $wgTitle->getArticleID()<=1) return  $out;
	if ($wgArticle->getTitle()->mNamespace != 0) return  $out;
 
	$out->mBodytext .='<script type="text/javascript">';
	$out->mBodytext .='addthis_url    = location.href;';
	$out->mBodytext .='addthis_title  = document.title;';
	$out->mBodytext .='addthis_pub    = \'zedomax\';';
	$out->mBodytext .='</script>';
	$out->mBodytext .='<script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12"></script>';
 
	$out->mBodytext.='<a href="javascript:window.location = \'http://www.socialmarker.com/?link=\'+encodeURIComponent (location.href)+\'&title=\'+encodeURIComponent( document.title);"><img src= "http://www.socialmarker.com/bookmark.gif" border="0" /></a>';
 
	return $out;
}

alternative version[edit | edit source]

for SocialBookmarking.php Note: This alternative version centers the bookmarking button and uses just addthis.com.

<?php
/**
 * Social Bookmarking extension
 * 
 * @version 0.1var
 * @author Max Lee
 * @link http://www.mediawiki.org/wiki/Extension:Social_Bookmarking
 */
 
//Extension credits that show up on Special:Version
$wgExtensionCredits['parserhook'][] = array(
        'name' => 'Social Bookmarking',
        'author' => 'Max Lee',
        'url' => 'http://www.mediawiki.org/wiki/Extension:Social_Bookmarking',
        'version' => '0.1var',
        'description' => 'Ermöglicht Links zu Bookmarkingdiensten',
);
 
$wgHooks['BeforePageDisplay'][] = 'wfBookmark';
 
function wfBookmark(&$out) {
        global $wgArticle, $wgTitle;
        if ($wgArticle == null) return $out;
        //if ($wgArticle->getTitle()->mNamespace != 0 || $wgTitle->getArticleID()<=1) return  $out;
        if ($wgArticle->getTitle()->mNamespace != 0) return  $out;
 
        $out->mBodytext .='<script type="text/javascript">';
        $out->mBodytext .='addthis_url    = location.href;';
        $out->mBodytext .='addthis_title  = document.title;';
        $out->mBodytext .='addthis_pub    = \'zedomax\';';
        $out->mBodytext .='</script>';
        $out->mBodytext .='<center><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12"></script>';
 
        $out->mBodytext.='<a href="javascript:window.location = +encodeURIComponent (location.href)+\'&title=\'+encodeURIComponent( document.title);"></a></center>';
 
        return $out;
}

See also[edit | edit source]

Websites using this plugin[edit | edit source]