Extension:WatchWidget
From MediaWiki.org
|
WatchWidget Release status: beta |
|||
|---|---|---|---|
| Implementation | Tag | ||
| Description | Display the most recent episodes for your favorite TV show. | ||
| Last version | 1.0 (2011-10-10) | ||
| MediaWiki | 1.16.5 (should work on most versions) | ||
| PHP | 5.2.17 (should work on earlier versions) | ||
| License | MIT | ||
| Download | WatchWidget.zip | ||
|
|||
|
Check usage (experimental) |
|||
Contents |
[edit] What can this extension do?
With the Watch Widget, you can display a list of the most recent episodes of your favorite TV show, wherever on the web they may be.
[edit] Usage
<watchwidget show="showname" size="300x250" exact="true" model="1" />
- show is the name of the show to be queried. If not supplied, the most recent 4 shows will be returned.
- size is specified as Width x Height. At the time of this publication, only 300x250 and 225x250 are supported.
- exact specifies that the results should be an exact match for Show. The search term 'vampire' in show could return 'Buffy the Vampire Slayer' and 'The Vampire Diaries' if exact is FALSE;
- model specifies the model of widget. Currently, this option = 1
- Check Watch.io Watch Widget for more information.
[edit] Download instructions
Create the extension directory as $IP/extensions/watchwidget/ Cut and paste the code found below and place it in $IP/extensions/watchwidget/WatchWidget.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/watchwidget/WatchWidget.php");
[edit] Code
<?php /* License: The following code for the MediaWiki WatchWidget extension is license under the MIT license. Usage: <watchwidget show="glee" size="300x250" exact="true" model="1" /> All arguments are optional. By default, a list of the most recent episodes for all shows will be returned as a small widget. Show is the name of the show to be queries. If not supplied, the most recent 4 shows will be returned. Size is specified as Width X Height. At the time of this publication, only 300x250 and 225x250 were supported. Exact specifies that the results should be an exact match for Show. The search term 'vampire' in show could return 'Buffy the Vampire Slayer' and 'The Vampire Diaries' if exact is FALSE; Model specifies the model of widget. Currently, this option = 1 Check http://watch.io/watchwidget.php for more information. Create the directory watchwidget in the MediaWiki extensions folder. Add the following line to LocalSettings.php in the root mediawiki folder require_once("$IP/extensions/watchwidget/WatchWidget.php"); */ if(!defined('MEDIAWIKI')){ die(); } $wgExtensionCredits['specialpage'][] = array( 'path' => __FILE__, 'name' => 'Watch Widget', 'version' => '0.1', 'author' => 'Lance Ward', 'url' => 'http://watch.io/watchwidget.php', 'description' => 'Display the most recent episodes for your favorite TV show.' ); $wgExtensionFunctions[] = "WatchWidget"; function WatchWidget() { global $wgParser; $wgParser->setHook("watchwidget", "GenWatchWidget"); } function GenWatchWidget($input, $args) { if(is_null($args)){ return; } $query = ''; $width = '225'; $height = '250'; $params = array(); foreach($args as $key => $val) { switch(strtolower($key)) //limit input to valid parameters { case 'show': break; case 'size': $size = explode('x', strtolower($val)); if(count($size) == 2 && is_numeric($size[0]) && is_numeric($size[1])) { $width = $size[0]; $height = $size[1]; } else{ continue; } case 'exact': if(strtolower($val) !== 'true' && strtolower($val) !== 'false'){ continue; } break; case 'model': if(!is_numeric($val)){ continue; } break; default: continue; break; } $params[] = $key .'=' .htmlentities(strip_tags($val), ENT_QUOTES); } $query = implode('&', $params); $iframe = '<div class="watchwidgetext"> <iframe src="http://watch.io/api/widget.php?' .$query .'" marginwidth="0" marginheight="0" width="' .$width .'" height="' .$height .'" border="0" frameborder="0" style="border:none;" scrolling="no" > </iframe> </div>'; return $iframe; } ?>
