Extension:Progress
From MediaWiki.org
|
Progress Release status: beta |
|
|---|---|
| Implementation | Parser function |
| Description | Easy way to see the progress of several tasks. |
| Author(s) | Shizheng Ding (Bistoletalk) |
| Last version | 0.8.0 (2008-11-28) |
| MediaWiki | 1.6.0 |
| License | GPL |
| Download | No link |
| Check usage and version matrix | |
Contents |
Instruction [edit]
This is a very simple visual progress monitor in Wiki. Several tasks can be set on the same table. Each task has it's name, developer, start day and deadline.
Usage [edit]
{{#progress: day=[TODAY] week=[HOW MANY WEEKS LISTED ON THE TABLE] |
FIRSTJOB DEVELOPER STARTDATE ENDDATE
FIRSTJOB DEVELOPER STARTDATE ENDDATE
FIRSTJOB DEVELOPER STARTDATE ENDDATE
FIRSTJOB DEVELOPER STARTDATE ENDDATE
}}
For example:
{{#progress: week=6 |
[[Address]] [[Simon]],[[Bistole]] 2008-11-10 2009-11-28
[[Trade]] [[Simon]],[[Bistole]] 2008-12-10 2009-07-03
}}
Installation [edit]
Copy the code below and save into your extensions directory then include in your LocalSettings.php file, for example:
include("$IP/extensions/SimpleCalendar.php");
Code [edit]
<?php /** * MediaWiki SimpleProgress Extension * * @package MediaWiki * @subpackage Extensions * @author Shizheng Ding [http://www.mediawiki.org/wiki/User:Bistole] * @licence GNU General Public Licence 2.0 or later */ define('SIMPLEPROGRESS_VERSION','0.8.0, 2008-11-28'); $wgExtensionFunctions[] = 'wfSetupSimpleProgress'; $wgHooks['LanguageGetMagic'][] = 'wfProgressLanguageGetMagic'; $wgExtensionCredits['parserhook'][] = array( 'name' => 'Simple Progress', 'author' => '[http://www.mediawiki.org/wiki/User:Bistole]', 'description' => 'A simple progress extension', 'url' => 'http://www.mediawiki.org/wiki/Extension:Simple_Progress', 'version' => SIMPLEPROGRESS_VERSION ); function wfProgressLanguageGetMagic(&$magicWords,$langCode = 0) { $magicWords['progress'] = array(0,'progress'); return true; } function wfSetupSimpleProgress() { global $wgParser; $wgParser->setFunctionHook('progress','wfRenderProgress'); return true; } # Renders a table of all the individual month tables function wfRenderProgress($input, $args, $parser) { $parser->mOutput->mCacheTime = -1; $argv = array(); $arglines = explode(" ",$args); foreach ($arglines as $argline) { list($key , $value) = explode("=", trim($argline)); $argv[$key] = $value; } echo time(); if (isset($argv['day'])) $timestamp = strtotime("last sunday", strtotime($argv['day']) - 7 * 86400); else $timestamp = strtotime("last sunday", time() - 7 * 86400); if (isset($argv['week'])) $w = $argv['week']; else $w = 4; $week = 'SMTWTFS'; $todaystamp = strtotime(date("Y-m-d")); $todayblock = floor(($todaystamp - $timestamp) / 86400); $str = "<br/><table class='progress' cellspacing='0' cellpadding='0'><tr class='heading'><td colspan='2'>Time:</td>"; for ($i = 0 ; $i < $w ; $i++) $str.= "<td colspan='7' class='worke'> ".date("M d", $timestamp + $i * 7 * 86400)."</td>"; $str.= "</tr><tr><td>Task</td><td>Relative</td>"; for ($i = 0 ; $i < $w ; $i ++) for ($j = 0 ; $j < 7 ; $j++) { $weekname = date("D", $timestamp + $j * 86400); $weekend = $j == 0 || $j == 6; $str.= "<td class='".($i*7+$j==$todayblock?"workt":($weekend?'workw':'work'))."'>".$weekname."</td>"; } $str.= "</tr>"; $todolist = explode("\n", $parser); foreach ($todolist as $todo) { list($name, $user, $start, $final) = explode(" ", $todo); $startstamp = strtotime($start); $finalstamp = strtotime($final); if ($finalstamp < $timestamp) continue; if ($startstamp > $timestamp + $w * 7 * 86400) continue; if ($startstamp < $timestamp) $startstamp = $timestamp; if ($finalstamp >= $timestamp + ($w * 7 - 1) * 86400) $finalstamp = $timestamp + ($w * 7 - 1) * 86400; $startblock = floor(($startstamp - $timestamp) / 86400); $finalblock = floor(($finalstamp - $timestamp) / 86400); $str2 = "\n<tr><td>".$name."</td><td>".$user."</td>"; if ($startblock != 0) for ($i = 0 ; $i < $startblock ; $i++) { $weekend = ($i % 7 == 0 || $i % 7 == 6)?true:false; $str2.="<td class='".($i==$todayblock?"freet":($weekend?"freew":"free"))."'> </td>"; } if ($finalblock >= $startblock) for ($i = $startblock ; $i <= $finalblock ; $i++) { $weekend = ($i % 7 == 0 || $i % 7 == 6)?true:false; $str2.="<td class='".($i==$todayblock?"workt":($weekend?"workw":"work"))."'> </td>"; } if ($finalblock < $w * 7 - 1) for ($i = $finalblock + 1 ; $i < $w * 7; $i++) { $weekend = ($i % 7 == 0 || $i % 7 == 6)?true:false; $str2.="<td class='".($i==$todayblock?"freet":($weekend?"freew":"free"))."'> </td>"; } $str .= $str2."</tr>"; } $str.= "</table><br/>"; return $str; }
CSS Style [edit]
CSS is required in this extension. Add the CSS rules to your MediaWiki:Common.css article (MediaWiki:Monobook.css on older wiki's). Here's the CSS we use which you can use and adjust:
table.progress {width:100%;white-space:nowrap;border:1px solid #666;border-width:1px 1px 0px 0px} table.progress tr td {border:1px solid #666;border-width:0px 0px 1px 1px} table.progress .heading td {background:#999; font-weight:heavy} table.progress tr td.free {background:#fff} table.progress tr td.work {background:#999} table.progress tr td.freew {background:#eee} table.progress tr td.workw {background:#ccc} table.progress tr td.freet {background:#9ff} table.progress tr td.workt {background:#3aa}
