first commit. dokuwiki.
[h2N7SspZmY.git] / lib / plugins / skill / syntax.php
blob8e12d032f040455a7e3a476c902bbae43da113d4
1 <?php
3 if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
4 if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
5 require_once(DOKU_PLUGIN.'syntax.php');
7 /**
8 * All DokuWiki plugins to extend the parser/rendering mechanism
9 * need to inherit from this class
11 class syntax_plugin_skill extends DokuWiki_Syntax_Plugin {
13 /**
14 * return some info
16 function getInfo(){
17 return array(
18 'author' => 'iDo',
19 'email' => 'iDo@woow-fr.com',
20 'date' => '13/10/2005',
21 'name' => 'Skill Plugin',
22 'desc' => 'Add the possibility to show skill level',
23 'url' => 'http://www.dokuwiki.org/plugin:skill',
27 /**
28 * What kind of syntax are we?
30 function getType(){
31 return 'substition';
34 /**
35 * Where to sort in?
37 function getSort(){
38 return 107;
41 /**
42 * Connect pattern to lexer
44 function connectTo($mode) {
45 $this->Lexer->addSpecialPattern("{{skill>[0-9]*/?[0-9]*}}",$mode,'plugin_skill');
48 /**
49 * Handle the match
51 function handle($match, $state, $pos, &$handler){
52 $match = substr($match,8,-2); // Strip markup
53 $match=split('/',$match); // Strip size
55 if (!isset($match[1])) $match[1] = $match[0];
56 if ($match[0]>$match[1]) $match[1]=$match[0];
57 return $match;
60 /**
61 * Create output
63 function render($mode, &$renderer, $data) {
64 if($mode == 'xhtml'){
65 $renderer->doc .= '<span>';
66 $renderer->doc .= $this->_Skill($data);
67 $renderer->doc .= '</span>';
68 return true;
70 return false;
73 function _Skill($d) {
74 $mRet='';
75 for($i=1;$i<=$d[0];$i++) {
76 $mRet.='<img src="lib/plugins/skill/star.png" alt="." style="" />';
78 for($i=1;$i<=($d[1]-$d[0]);$i++) {
79 $mRet.='<img src="lib/plugins/skill/star.png" alt="." style="filter:alpha(opacity=40);-moz-opacity:0.4;opacity: 0.4;" />';
82 return $mRet;
86 //Setup VIM: ex: et ts=4 enc=utf-8 :