1<?php 2/* DokuWiki Progressbar plugin 3 * Internal version 1.0.0 4 * 5 * Copyright (C) 2009 Mischa The Evil 6 * Copyright (C) 2006 Mike Smith 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 24if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 25require_once(DOKU_PLUGIN.'syntax.php'); 26 27class syntax_plugin_progressbar extends DokuWiki_Syntax_Plugin 28{ 29 30 /** 31 * return some info 32 */ 33 function getInfo() 34 { 35 return array 36 ( 37 'author' => 'Mischa The Evil', 38 'email' => 'mischa_the_evil@hotmail.com', 39 'date' => '2009-03-09', 40 'name' => 'Progressbar', 41 'desc' => 'Makes progress bars on wiki pages.', 42 'url' => 'https://www.dokuwiki.org/plugin:progressbar', 43 ); 44 } 45 46 /** 47 * What kind of syntax are we? 48 */ 49 function getType() 50 { 51 return 'substition'; 52 } 53 54 /** 55 * Where to sort in? 56 */ 57 function getSort() 58 { 59 return 999; 60 } 61 62 /** 63 * Connect pattern to lexer 64 */ 65 function connectTo($mode) 66 { 67 $this->Lexer->addSpecialPattern('<progress=(?:10|[1-9]?)0>', $mode, 'plugin_progressbar'); 68 } 69 70 /** 71 * Handle the match 72 */ 73 function handle($match, $state, $pos, &$handler) 74 { 75 substr($match, 10, -1); 76 return array(substr($match, 10, -1)); 77 } 78 79 /** 80 * Create output 81 */ 82 function render($mode, &$renderer, $data) 83 { 84 $renderer->doc .= '<img width="100" height="16" src="'. DOKU_URL .'lib/plugins/progressbar/images/' . $data[0] . '.gif" alt="' . $data[0] . '% completed" title="' . $data[0] . '% completed" />'; 85 return true; 86 } 87} 88