Extension:StumbleUponButton

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

Release status: stable

Implementation Tag
Description Creates a StumbleUpon button.
Author(s) Piotr Zuk (zukoTalk)
Last version 1.0.0 (2011-08-11)
MediaWiki 1.16
License GNU public License
Download MediawikiExtStumbleUponButton_zip

or
this page

Example C++Book reference
Hooks used
ParserFirstCallInit

Check usage (experimental)

Contents

[edit] What can this extension do?

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

[edit] Usage

With the tag <stumbleuponbutton></stumbleuponbutton>

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

Stumbleuponbutton1.jpg

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

Stumbleuponbutton2.jpg

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

Stumbleuponbutton3.jpg

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

Stumbleuponbutton4.jpg

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

Stumbleuponbutton5.jpg

Default version = 2 (with horizontal counting box)

[edit] Download instructions

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.

[edit] Installation

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

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

[edit] Code

<?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'
);
Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox