'iDo',
'email' => 'iDo@woow-fr.com',
'date' => '13/10/2005',
'name' => 'Skill Plugin',
'desc' => 'Add the possibility to show skill level',
'url' => 'http://www.dokuwiki.org/plugin:skill',
);
}
/**
* What kind of syntax are we?
*/
function getType(){
return 'substition';
}
/**
* Where to sort in?
*/
function getSort(){
return 107;
}
/**
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addSpecialPattern("{{skill>[0-9]*/?[0-9]*}}",$mode,'plugin_skill');
}
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler){
$match = substr($match,8,-2); // Strip markup
$match=split('/',$match); // Strip size
if (!isset($match[1])) $match[1] = $match[0];
if ($match[0]>$match[1]) $match[1]=$match[0];
return $match;
}
/**
* Create output
*/
function render($mode, &$renderer, $data) {
if($mode == 'xhtml'){
$renderer->doc .= '';
$renderer->doc .= $this->_Skill($data);
$renderer->doc .= '';
return true;
}
return false;
}
function _Skill($d) {
$mRet='';
for($i=1;$i<=$d[0];$i++) {
$mRet.='';
}
for($i=1;$i<=($d[1]-$d[0]);$i++) {
$mRet.='';
}
return $mRet;
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
?>
Other resource:
You must put this image in the same directory as syntax.php: http://www.woow-fr.com/wikistuce/lib/plugins/skill/star.png
===== Comments =====
> What about making this plugin "plugin manager" compatible to provide automatic install ?
> Thank you for this plugin ;-) [[http://leedoriden.free.fr/tutodir/doku.php|Leedoriden]]
This is a great plugin! I have one request: a max number of stars, to prevent users from entering (for example) 3,000 stars. Also, I made a couple of changes:
The first is to put the stars in a instead of
$renderer->doc .= '';
$renderer->doc .= $this->_Skill($data);
$renderer->doc .= '';
return true;
And then:
function _Skill($d) {
$mRet='';
for($i=1;$i<=$d[0];$i++) {
$mRet.='';
}
for($i=1;$i<=($d[1]-$d[0]);$i++) {
$mRet.='';
}
I added some code to limit the number of stars to 10. Simply insert these two lines in **function handle**, before the line 'return $match'.
if ($match[0]>10) $match[0]=10;
if ($match[1]>10) $match[1]=10;
> Please, provide an archive so that we can use the plug-in manager. I spend most of my time at some strange place called //work// where I have much spare time but no FTP access to my wiki, so that I cannot do anything except using the plug-in manager...
> I have changed the above max star = 10 with calculations...
if ($match[1]>10) {
$match[0] = 10 * $match[0] / $match[1];
$match[1] = 10;
}
> This keeps the ratio, rather than a roof cut-off. (kenc)