TITLE: A test task
PRIORITY: High
ESTIMATE: 4h
PROGRESS: 10%
ASSIGNED: Sherri
DESCRIPTION: Some stuff for you. You can have newlines in this part. Description must be the last item.
* The labels for each item are //not// case sensitive. I just make them all caps to make them visible.
* Each item must take up only one line, except the description can be on multiple lines.
* The description will maintain newlines.
* The description must be the last item in the list before the tag. The other items can be in any order before the description item.
* You can leave out any of the items(attributes), or leave them blank, and it will still look okay.
* The entire thing is wrapped in a span with the CSS class "avtaskbox" so you can style it in your CSS.
===== Output =====
{{http://syntaxseed.com/assets/screenshots/avtaskbox.png?nolink}}
===== Installation =====
* **Plugin Manager:** Paste this URL into the Plugin Manager to install AVTaskBox automatically: [[http://syntaxseed.com/downloads/plugin-avtaskbox.zip]]
* **Manually:** To get the plugin to work, manually install the plugin:
- Make a new directory ''avtaskbox/'' in your plugins directory.
- Add the source code below to a file ''syntax.php'' in the avtaskbox directory.
===== Known Bugs =====
* None.
===== To Do =====
* Nothing.
===== Changelog =====
** 2009-11-19 **
* created plugin.
===== Source =====
==== syntax.php ====
* TITLE: A test task
* PRIORITY: High
* ESTIMATE: 4h
* PROGRESS: 10%
* ASSIGNED: Sherri
* DESCRIPTION: Some stuff for you. You can have newlines in this part. Description must be the last item.
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
class syntax_plugin_avtaskbox extends DokuWiki_Syntax_Plugin
{
/**
* return some info
*/
function getInfo()
{
return array
(
'author' => 'Sherri Wheeler',
'email' => 'Use my website: www.start.ofitall.com',
'date' => '2009-11-19',
'name' => 'AV Task Box',
'desc' => 'Creates task/user story table boxes.',
'url' => 'http://www.source.ofitall.com',
);
}
/**
* What kind of syntax are we?
*/
function getType()
{
return 'substition';
}
/**
* Where to sort in?
*/
function getSort()
{
return 999;
}
/**
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addEntryPattern('\',$mode,'plugin_avtaskbox');
}
function postConnect() {
$this->Lexer->addExitPattern('\ ','plugin_avtaskbox');
}
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler){
switch ($state) {
case DOKU_LEXER_ENTER :
return array($state, '');
case DOKU_LEXER_MATCHED :
break;
case DOKU_LEXER_UNMATCHED :
$resultStr = '';
preg_match('/^Title:(.*?)$/isxm', $match, $matches);
$title = (!empty($matches[1]) && strlen(trim($matches[1]))>0) ? trim($matches[1]) : ' ';
preg_match('/^Priority:(.*?)$/isxm', $match, $matches);
$priority =(!empty($matches[1]) && strlen(trim($matches[1]))>0) ? 'Priority: '.trim($matches[1]) : ' ';
preg_match('/^Estimate:(.*?)$/isxm', $match, $matches);
$estimate = (!empty($matches[1]) && strlen(trim($matches[1]))>0) ? ' of '.trim($matches[1]) : ' ';
preg_match('/^Assigned:(.*?)$/isxm', $match, $matches);
$assigned = (!empty($matches[1]) && strlen(trim($matches[1]))>0) ? '('.trim($matches[1]).')' : ' ';
preg_match('/^Progress:(.*?)$/isxm', $match, $matches);
$progress = (!empty($matches[1]) && strlen(trim($matches[1]))>0) ? intval(preg_replace('[^0-9]','',$matches[1])) : '0';
preg_match('/Description:(.*)/isx', $match, $matches);
$description = (!empty($matches[1]) && strlen(trim($matches[1]))>0) ? trim($matches[1]) : ' ';
if($progress<0){$progress=0;}
if($progress>100){$progress=100;}
$sizeLeft = 100-$progress;
$progbar .= ''.($progress<=0 ? '' : '
') . ($progress>=100 ? '' : '
') .'';
$resultStr .= ''.$title.''.$assigned.' ';
$resultStr .= ''.nl2br($description).' ';
$resultStr .= ''.$priority.'('.$progress.'%'.$estimate.') '.$progbar.' ';
$resultStr .= '
';
$match = $resultStr;
return array($state, $match);
case DOKU_LEXER_EXIT :
return array($state, '');
case DOKU_LEXER_SPECIAL :
break;
}
return array();
}
/**
* Create output
*/
function render($mode, &$renderer, $data) {
if($mode == 'xhtml'){
list($state, $match) = $data;
switch ($state) {
case DOKU_LEXER_ENTER :
$renderer->doc .= "";
break;
case DOKU_LEXER_MATCHED :
break;
case DOKU_LEXER_UNMATCHED :
$renderer->doc .= $match; break;
case DOKU_LEXER_EXIT :
$renderer->doc .= "";
break;
case DOKU_LEXER_SPECIAL :
break;
}
return true;
}
return false;
}
}
?>
===== Comments / Discussion =====
Hi everyone, let me know what you think. ~Sherri
I needed a small fix to get the progress bar work on my wiki:
.'**/**lib/images/blank.gif)
TITLE: A test task
PRIORITY: High
DEADLINE: 12/10/2010
OPENED: 10/29/2010
ESTIMATE: 4h
PROGRESS: 10%
ASSIGNED: Sherri
DESCRIPTION: Some stuff for you. You can have newlines in this part. Description must be the last item.
Copy the following and replace **syntax.php** to use it:
| '.$title.''.$assigned.' |
|---|
| '.nl2br($description).' |
| Termin: '.date("d.m.Y", strtotime($deadline)).'Eingestellt: '.date("d.m.Y", strtotime($opened)).' |
| Priorität: '.$priority.'('.$progress.'%'.$estimate.') '.$progbar.' |
| '.$title.''.$assigned.' |
|---|
| '.nl2br($description).' |
| Deadline: '.date("m.d.Y", strtotime($deadline)).'Start: '.date("m.d.Y", strtotime($opened)).' |
| Priority: '.$priority.'('.$progress.'%'.$estimate.') '.$progbar.' |