Extension:Add to Any Share/Save/Bookmark Button

From MediaWiki.org

Jump to: navigation, search

         

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
Add to Any Share/Save/Bookmark Button

Release status: stable

Bookmark Button & Smart Menu version .1.png
Description Helps visitors share, save, bookmark, and e-mail your pages using any service, such as Delicious, Digg, Facebook, Twitter, and over 100 more.
Author(s)  micropatTalk
Last Version  0.1
MediaWiki  1.6+
License MIT
Download http://www.addtoany.com/ext/mediawiki/add-to-any-share-save.zip
Example  [http://www.yahowto.com

Contents

[edit] What can this extension do?

Save 171 16.gif Share icon 16 16.png

Helps visitors share, save, bookmark, and e-mail your pages using any service, such as Delicious, Digg, Facebook, Twitter, and over 100 more.

The button comes with Add to Any's customizable Smart Menu, which places the services visitors use at the top of the menu, based on each visitor's browsing history.

  • Add to Any Smart Menu
  • Includes all services (100+)
  • E-mail using
    • Gmail
    • Yahoo! Mail
    • Live Hotmail
    • AOL
    • Program
    • Add to Any e-mailer (generic example)
  • Services updated automatically
  • Optimized to always load content first
  • Many more publisher and user features
  • Bookmarking tab
    • "Add to Favorites" (automatic for Internet Explorer)
    • "Bookmark" (instructions for other browsers)


[edit] Download instructions

Download and unpack the folder (and all contents) to $IP/extensions/add-to-any-share-save/. 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/add-to-any-share-save/add-to-any-share-save.php");

[edit] Official website

[edit] Code

  <?php
 
/*
 * add-to-any-share-save - Helps visitors share, save, bookmark, and email your pages using any service, such as Delicious, Digg, Facebook, Twitter, and over 100 more.
 * @authors Add to Any
 * @version 0.1
 * @copyright Copyright (C) addtoany.com
 * @license The MIT License - http://www.opensource.org/licenses/mit-license.php 
 * -----------------------------------------------------------------------
 * Description:
 *     Helps visitors share, save, bookmark, and email your pages using any service, such as Delicious, Digg, Facebook, Twitter, and over 100 more. 
 *     The button comes with Add to Any's customizable Smart Menu, which places the services visitors use at the top of the menu, based on each visitor's browsing history.
 * Requirements:
 *     MediaWiki 1.6.x+
 * Installation:
 *     1. Upload the `add-to-any-share-save` folder (and all contents) to your MediaWiki extensions directory so you have: `/extensions/add-to-any-share-save/`
 *     2. Enable the extension by adding this line to your LocalSettings.php:
 *            require_once('extensions/add-to-any-share-save/add-to-any-share-save.php');
 * Version Notes:
 *     0.1:
 *        Initial release. Add to Any is available for MediaWiki!
 * To-do:
 *     1. Have the <sharesave /> tag (functions below) additionally load the external JavaScript call before the </body> tag - please get in touch if you have any ideas on how to do this!
 */
 
// Confirm MW environment
if (defined('MEDIAWIKI')) {
 
 
	// OPTIONS
	$wg_addtoany_share_save_button_filename = "share_save_171_16.png"; // Located in /extensions/add-to-any-share-save/
	$wg_addtoany_share_save_button_width = "171";
	$wg_addtoany_share_save_button_height = "16";
 
 
	// Version
	define('ADDTOANY_SHARE_SAVE_VERSION','0.1');
 
	// Credits
	$wgExtensionCredits['parserhook'][] = array(
		'name'=>'Add to Any Share/Save/Bookmark Button',
		'author'=>'Add to Any',
		'url'=>'http://www.addtoany.com/contact/',
		'description'=>'Helps visitors share, save, bookmark, and email your pages using any service, such as Delicious, Digg, Facebook, Twitter, and over 100 more.',
		'version'=>ADDTOANY_SHARE_SAVE_VERSION
	);
 
	// Call Share/Save widget
	$wgHooks['SkinSubPageSubtitle'][] = 'wf_addtoany_share_save_below_header';
	// $wgExtensionFunctions[] = 'wf_addtoany_share_save_ExtensionSetup';
 
	function wf_addtoany_share_save_markup(){
		// MediaWiki globals
		global $wgTitle, $wgScriptPath, $wgHooks;
 
		// Add to Any Share/Save extension globals
		global $wg_addtoany_share_save_button_filename, 
			$wg_addtoany_share_save_button_width, 
			$wg_addtoany_share_save_button_height;
 
		$button_src = $wg_addtoany_share_save_button_filename;
		$button_width = ' width="'.$wg_addtoany_share_save_button_width.'"';
		$button_height = ' height="'.$wg_addtoany_share_save_button_height.'"';
 
		// Load external JavaScript before closing </body> tag
		$wgHooks['SkinAfterBottomScripts'][] = 'wf_addtoany_share_save_external_script_call';
 
		$link_title = $wgTitle->getText();
		$link_url = $wgTitle->getFullURL();
 
		$markup = 
			'<a class="a2a_dd" href="http://www.addtoany.com/share_save?linkurl=' . rawurlencode($link_url) . '&amp;linkname=' . rawurlencode($link_title) . '">' .
			'<img src="'.$wgScriptPath.'/extensions/add-to-any-share-save/'.$button_src.'"' . $button_width.$button_height . ' alt="Share/Save/Bookmark"/>' .
			'</a>' .
			'<script type="text/javascript">a2a_linkname="' .$link_title. '";a2a_linkurl="' .$link_url. '";</script>';
 
		return $markup;
	}
 
	function wf_addtoany_share_save_below_header(&$subpages) {
		$subpages .= wf_addtoany_share_save_markup();
		return true;
	}
 
	function wf_addtoany_share_save_external_script_call($skin, &$text='') {
		$text .= '<script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>';
		return true;
	}
 
	/* 
 
		See "To-do" section above
 
	// Sets up the parser hook and global messages
	function wf_addtoany_share_save_ExtensionSetup() {
		global $wgParser, $wgMessageCache;
 
		// <sharesave /> tag
		$wgParser->setHook('sharesave', 'wf_addtoany_share_save_ParserHook');
	}
 
	// Parser hook for the <sharesave /> tag extension.
	function wf_addtoany_share_save_ParserHook($text, $params, &$parser) {
 
		$output = '';
 
		$output .= wf_addtoany_share_save_markup();
 
		return $output;
	}
	*/
 
} // Closing MW Environment wrapper