Extension:Yahoo
From MediaWiki.org
|
Yahoo Button Release status: stable |
|||
|---|---|---|---|
| Implementation | Tag | ||
| Description | Render Yahoo Button showing users online status | ||
| Author(s) | Guy Taylor | ||
| Last version | 1.2 (23 December 2010) | ||
| MediaWiki | 1.12+ | ||
| License | No license specified | ||
| Download | Download Changelog |
||
|
|||
|
Check usage (experimental) |
|||
Please Upgrade to 1.0a or above from all version to prevent a XSS attack
The Yahoo Button rendered inside MediaWiki
- syntax
- "
<yahoo style="style" action="action">Yahoo-Username</yahoo>"
Use Extension talk:Yahoo for feedback
Contents |
[edit] Code
<?php /** * MediaWiki Yahoo extension * * @file * @ingroup Extensions * @version 1.2 * @author Guy Taylor * @link http://wwww.mediawiki.org/wiki/Extension:Yahoo Documentation */ if ( !defined( 'MEDIAWIKI' ) ) { die( 'This is not a valid entry point.' ); } // Extension credits that show up on Special:Version $wgExtensionCredits['parserhook'][] = array( 'name' => 'Yahoo', 'author' => 'Guy Taylor', 'version' => '1.2', 'description' => 'Render Yahoo Button showing users online status.', 'url' => 'http://www.mediawiki.org/wiki/Extension:Yahoo', ); // set up MediaWiki to react to the <yahoo> tag $wgHooks['ParserFirstCallInit'][] = 'wfYahoo'; function wfYahoo( &$parser ) { $parser->setHook( 'yahoo', 'renderYahoo' ); return true; } // the function that reacts to "<yahoo>" function renderYahoo( $input, $argv ) { // set your defaults for the style and action (addfriend, call or sendim) (0, 1, 2, 3 and 4) $style_default = '2'; $action_default = 'sendim'; // escape $input to prevent XSS $input = htmlspecialchars( $input ); // the varibles are: <yahoo style="$argv['style']" action="$argv['action']">$input</yahoo> // Test to see if the optinal elements of the tags are set and supported. // If not, set them to the defaults. if( isset( $argv['style'] ) ) { $style = $argv['style']; if( !( $style == '0' || $style == '1' || $style == '2' || $style == '3' || $style == '4' || $style == '5' ) ) { $style = $style_default; } } else { $style = $style_default; } if( isset( $argv['action'] ) ) { $action = $argv['action']; if( !( $action == 'addfriend' || $action == 'sendim' || $action == 'call' ) ) { $action = $action_default; } } else { $action = $action_default; } // set the url to the image and the style of the image switch( $style ) { case '0': $image = '<img src="http://opi.yahoo.com/online?u=' . $input . '&m=g&t=0" '; $image .= ' style="border: none; width: 12px; height: 12px;" alt="My status" />'; break; case '1': $image = '<img src="http://opi.yahoo.com/online?u=' . $input . '&m=g&t=1" '; $image .= ' style="border: none; width: 64px; height: 16px;" alt="My status" />'; break; case '2': $image = '<img src="http://opi.yahoo.com/online?u=' . $input . '&m=g&t=2" '; $image .= ' style="border: none; width: 125px; height: 25px;" alt="My status" />'; break; case '3': $image = '<img src="http://opi.yahoo.com/online?u=' . $input . '&m=g&t=3" '; $image .= ' style="border: none; width: 86px; height: 16px;" alt="My status" />'; break; case '4': $image = '<img src="http://opi.yahoo.com/online?u=' . $input . '&m=g&t=4" '; $image .= ' style="border: none; width: 12px; height: 12px;" alt="My status" />'; break; case '5': $image = '<img src="http://opi.yahoo.com/online?u=' . $input . '&m=g&t=5" '; $image .= ' style="border: none; width: 12px; height: 12px;" alt="My status" />'; break; } // start the rendering the html outupt $output = '<!-- MediaWiki extension http://www.mediawiki.org/wiki/Extension:Yahoo -->'; $output .= '<a href="ymsgr:' . $action . '?' . $input . '">' . $image . '</a>'; $output .= '<!-- end of Yahoo button -->'; // send the output to MediaWiki return $output; }
[edit] Installation
- Copy the code into a file (e.g. Yahoo.php)
- Save the file in the extensions directory of your MediaWiki folder
- Add the line
require_once($IP . '/extensions/Yahoo.php');to the end of your LocalSettings.php file
Now you can use the extension with <yahoo>Yahoo-Username</yahoo> in the wiki
[edit] Example
See an example of this add-on in action at: Syncleus Technology Wiki or Cubic Path Wiki (both run by the author of the AIM extension)
[edit] ChangeLog
- 1.2
- Coding style cleanup
- 1.1
- Added new style "5"
- 1.0a
- Fixed XSS flaw
[edit] References
http://messenger.yahoo.com/addpresence.php
[edit] Related extensions
| Chat Extensions | AIM · ICQ · IM Status · Jabber · Skype · Yahoo |
|---|