<?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+
* 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
// $wgExtensionFunctions[] = 'wf_addtoany_share_save_ExtensionSetup';
//if $everyPage isn't set -> default = addToAny in every Page below header
if(!isset($everyPage))
$everyPage=true;
//EF is in the house!! YIIIHHAAAA
if($everyPage)
{
//addToAny below every Header
$wgHooks['SkinSubPageSubtitle'][] = 'wf_addtoany_share_save_below_header';
}
else
{
//addToAny in the area, you embedded the tag
$wgHooks['ParserFirstCallInit'][] = 'wf_addtoany_per_tag';
}
function wf_addtoany_per_tag( &$parser ) {
$parser->setHook("addtoany","add_to_any_per_tag");
return true;
}
function add_to_any_per_tag( $in, $param=array(), $parser=null, $frame=false) {
return wf_addtoany_share_save_markup();
}
function wf_addtoany_share_save_below_header(&$subpages) {
$subpages .=wf_addtoany_share_save_markup();
return true;
}
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) . '&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_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
Topic on Extension talk:Add to Any Share/Save/Bookmark Button/Archive 2
Appearance