Extension:Toggl

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

Release status: beta

Implementation User interface
Description Allows user to embed a Toggl timer into a wiki page.
Author(s) Clif Johnston (Cliftalk)
Last version 0.1 (12/01/2009)
MediaWiki Tested on 1.11.0
License GPL
Download No link
Tags
<toggl />
Check usage and version matrix

Contents

What can this extension do? [edit]

Allows user to embed a Toggl timer into a wiki page.

Usage [edit]

There are two styles of Toggl timers, "classic" and "nano". You can choose which timer to embed using the style argument. "Classic" is the default.

<toggl />
or
<toggl style="nano" />

Download instructions [edit]

Please cut and paste the code found below and place it in $IP/extensions/toggl.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation [edit]

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

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

Code [edit]

<?php
# Toggl Timer Embed
#
# Tag :
#   <toggl style="" />
# Args : style: 'classic' or 'nano' (classic is default)

$wgExtensionFunctions[] = 'wfToggl';
$wgExtensionCredits['parserhook'][] = array(
        'name' => 'Toggl',
        'description' => 'Display Toggl Timer',
        'author' => 'Clif Johnston',
        'url' => 'http://www.musicin2d.com/wiki/Code/MediaWiki/Toggl'
);
 
function wfToggl() {
        global $wgParser;
        $wgParser->setHook('toggl', 'renderToggl');
}
 
function renderToggl($text, $args = array(), $parser) {
        $parser->disableCache();
 
        if (array_key_exists('style', $args) && strtolower($args['style']) == 'nano') {
                $togglStyle = "nano";
        } else {
                $togglStyle = "classic";
        }
 
        if ($togglStyle == "nano") {
                $output = '<iframe src="http://www.toggl.com/nano" style="width:175px;height:320px;border:none;"></iframe>';
        } else {
                $output = '<iframe src="http://www.toggl.com/timer" style="width:275px;height:500px;border:none;"></iframe>';
        }
 
        return $output;
}