This is an extension I wrote for MediaWiki to insert polldaddy.com polls into Lostpedia. It was originally based off of Sylvain Machefert's googlevideo and youtube video extensions, but has been re-written to use parameters within the tag to make it more elegant and secure.

Usage: <polldaddy pollid="12345"/> Note: In version 1.3 the height and width parameters are no longer used.


Using the javascript code from the polldaddy.com website:

<script type="text/javascript" language="javascript" src="http://s3.polldaddy.com/p/12345.js"></script><noscript> <a href ="http://answers.polldaddy.com/poll/12345/" >Is the sky blue?</a>  <br/> <span style="font-size:9px;"> (<a href ="http://www.polldaddy.com">  surveys</a>)</span></noscript>

Use this tag in Mediawiki:

<polldaddy pollid="12345"/>

Here's the code:

<?php

/**
 * An extension that allows embedding of polldaddy.com polls into Mediawiki
 *
 * @package MediaWiki
 * @subpackage Extensions
 *
 * @author Jabberwock @ Lostpedia
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 *
 * Version 1.3
 *
 * Changes:  	1.2: --use parameters from tag instead of delimited $input
 *		1.3: --polldaddy no longer supporting flash polls.  Using javascript instead
 *		     --width and height no longer required		
 *
 * Tag:  <polldaddy pollid="12345"/>
 */
# Confirm MW environment
if ( !defined( 'MEDIAWIKI' ) ) {
	die( 'This file is a MediaWiki extension, it is not a valid entry point' );
}

$wgExtensionFunctions[] = 'wfPolldaddy';
$wgExtensionCredits['parserhook'][] = array(
        'name' => 'PollDaddy (version 1.3)',
        'description' => 'Display polls from polldaddy.com',
        'author' => '[http://lostpedia.com/wiki/User:jabrwocky7 Jabberwock]',
        'url' => 'http://en.lostpedia.com/wiki/User:jabrwocky7/polldaddy'
);

function wfPolldaddy() {
        global $wgParser;
        $wgParser->setHook('polldaddy', 'renderPolldaddy');
}

# The callback function for converting the input text to HTML output
function renderPolldaddy($input, $params) {
        //$v = htmlspecialchars($params['v']);
        $pollid = htmlspecialchars($params['pollid']);
        
        if ($pollid==null) {
          $output = '<i>Poll Error:  no poll specified!</i>';
          return $output;
        }
 	$output =    '<script type="text/javascript" language="javascript" src="http://s3.polldaddy.com/p/'.$pollid.'.js"></script><noscript> <a href ="http://answers.polldaddy.com/poll/'.$pollid.'/" >Link</a>  <br/> <span style="font-size:9px;"> (<a href ="http://www.polldaddy.com">  surveys</a>)</span></noscript>';

        return $output;
}

?>
Community content is available under CC BY-NC-ND unless otherwise noted.