Extension:EntreCard

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
EntreCard

Release status: stable

Description EntreCard extension allow you to put EntreCard widgets on your Wiki pages.
Author(s) Jung Lee aka Max Lee (zedomaxtalk)
Last version 0.1
License No license specified
Download Download
Check usage and version matrix

Contents

What can this extension do? [edit]

EntreCard extension allows you to put EntreCard widgets on your wiki pages.

Usage [edit]

Use the following wiki syntax in your pages.

Set the id for your campagin and size.

<entrecard id="10" size="127"></entrecard>

Installation [edit]

To install this extension, add the following to LocalSettings.php:

require_once("$IP/extensions/EntreCard.php");

Code [edit]

<?php
/**
 * EntreCard extension for MediaWiki
 *
 * @version 0.1
 * @author Max Lee
 * @link http://www.mediawiki.org/wiki/Extension:EntreCard
 */
 
//Extension credits that show up on Special:Version 
$wgExtensionCredits['parserhook'][] = array(
        'name' => 'EntreCard',
        'author' => 'Max Lee',
        'url' => 'http://www.mediawiki.org/wiki/Extension:EntreCard',
        'version' => '0.1',
        'description' => 'Allows you to put [http://entrecard.com EntreCard] widgets on your wiki pages',
); 
 
//Avoid unstubbing $wgParser too early on setHook() on modern (1.12+) MW versions, as per r35980
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
        $wgHooks['ParserFirstCallInit'][] = 'wfEntreCard';
} else {
        $wgExtensionFunctions[] = 'wfEntreCard';
}
 
//Registers the <entrecard> tag with the WikiText parser
function wfEntreCard() {
        global $wgParser;
        $wgParser->setHook( 'entrecard', 'renderEntreCard' );
        return true;
}
 
//The callback function for converting the input text to HTML output
function renderEntreCard( $input, $argv ) {
        $output = '<script type="text/javascript" src="http://entrecard.s3.amazonaws.com/widget.js?user_id='.htmlspecialchars($argv["id"]).'';
        $output .='&type=standard_'.htmlspecialchars($argv["size"]).'" type="text/javascript" id="ecard_widget">"';
        $output .= '</script>';
        return $output;
}

Sites using this extension [edit]