Open main menu

Extension:StumbleUponButton

What can this extension do?Edit

Allows you to very simply include StumbleUpon button in five customized versions.

UsageEdit

With the tag <stumbleuponbutton></stumbleuponbutton>

  • Version 1: <stumbleuponbutton style="1"></stumbleuponbutton> (without counting box)

 

  • Version 2: <stumbleuponbutton style="2"></stumbleuponbutton> (with horizontal counting box)

 

  • Version 3: <stumbleuponbutton style="3"></stumbleuponbutton> (with vertical counting box)

 

  • Version 4: <stumbleuponbutton style="4"></stumbleuponbutton> (big icon)

 

  • Version 5: <stumbleuponbutton style="5"></stumbleuponbutton> (small icon)

 

Default version = 2 (with horizontal counting box)

Download instructionsEdit

You can download the php file from MediawikiExtStumbleUponButton_zip or copy and paste the code below to the file: $IP/extensions/StumbleUponButton/StumbleUponButton.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

InstallationEdit

To install this extension, add the following to LocalSettings.php:

require_once("$IP/extensions/StumbleUponButton/StumbleUponButton.php");

CodeEdit

<?php
/* Wiki StumbleUponButton MediaWiki extension
** Installation Instructions: http://www.mediawiki.org/wiki/Extension:StumbleUponButton
*/
 
$wgExtensionFunctions[] = "stumbleuponbuttonExtension";
 
function stumbleuponbuttonExtension() {
   global $wgParser;
   global $versions_stumbleuponbutton;
   
   $wgParser->setHook( "stumbleuponbutton", "renderStumbleUponButton" );
 
   $versions_stumbleuponbutton = array();
  
   $versions_stumbleuponbutton[1] = '<script src="http://www.stumbleupon.com/hostedbadge.php?s=3"></script>';
   $versions_stumbleuponbutton[2] = '<script src="http://www.stumbleupon.com/hostedbadge.php?s=1"></script>';
   $versions_stumbleuponbutton[3] = '<script src="http://www.stumbleupon.com/hostedbadge.php?s=5"></script>';
   $versions_stumbleuponbutton[4] = '<script src="http://www.stumbleupon.com/hostedbadge.php?s=6"></script>';
   $versions_stumbleuponbutton[5] = '<script src="http://www.stumbleupon.com/hostedbadge.php?s=4"></script>';
}

function renderStumbleUponButton( $input, $argv ) {
   global $versions_stumbleuponbutton;   
   $style= @$argv['style'];
   
   if (is_numeric($style)) {
	   $version = $style;
	   if (!$versions_stumbleuponbutton[$version]) {
		   $version = 1;              
	   }
   } else {              
	   $version = 1;           
   }
   
   $form=$versions_stumbleuponbutton[$version];
   
   $output = $form;
   return $output;
}
 
$wgExtensionCredits['parserhook'][] = array(
      'name' => 'Wiki StumbleUponButton',
      'version' => '1.0.0',
      'author' => 'Piotr Zuk',
      'url' => 'http://www.mediawiki.org/wiki/Extension:StumbleUponButton',
      'description' => 'Mediawiki StumbleUponButton Extension'
);