Extension:Yahoo
Appearance
From mediawiki.org
This extension stores its source code on a editable wiki page rather than in a code repository. As a result, this code may be maliciously altered.
It may contain security vulnerabilities, and will not receive localisation updates from translatewiki.net . Developers are strongly encouraged to host their code in a code repository rather than a wiki page so that the extension can be properly maintained, reviewed, and kept secure.
It may contain security vulnerabilities, and will not receive localisation updates from translatewiki.net . Developers are strongly encouraged to host their code in a code repository rather than a wiki page so that the extension can be properly maintained, reviewed, and kept secure.
This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored.
Release status: unmaintained |
|
|---|---|
| Implementation | Tag |
| Description | Render Yahoo Button showing users online status |
| Author(s) | Guy Taylor (TheBigGuy talk ) |
| Latest version | 1.2 (2010年12月23日) |
| MediaWiki | 1.12+ |
| Database changes | No |
|
<yahoo> |
|
| Licence | No licence specified |
| Download | Download Changelog |
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
Code
<?php /** * MediaWiki Yahoo extension * * @file * @ingroup Extensions * @version 1.2 * @author Guy Taylor * @link https://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' => 'Renders the Yahoo Button showing users online status', 'url' => 'https://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 optional 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 https://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; }
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
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)
ChangeLog
- 1.2
- Coding style cleanup
- 1.1
- Added new style "5"
- 1.0a
- Fixed XSS flaw
References
http://messenger.yahoo.com/addpresence.php
Related extensions
Chat Extension [[Category:Yahoo extensionsTemplate:Translation]]