'Keeyai', 'email' => 'keeyai@keeyai.com', 'date' => '27/09/2008', 'name' => 'Stars Plugin', 'desc' => 'Show stars for difficulty, ratings, etc', 'url' => 'http://www.dokuwiki.org/plugin:stars', ); } // end function getInfo() function getType(){ return 'substition'; }// spelling error is intentional to work with dokuwiki} function getSort(){ return 107; } function connectTo($mode) { $this->Lexer->addSpecialPattern("\[stars=\d*\.?\d*/?\d*\.?\d*\]",$mode,'plugin_stars'); } // end function connectTo($mode) function handle($match, $state, $pos, &$handler) { $match = substr($match,7,-1); // Strip markup $match=split('/',$match); // Strip size if (!isset($match[1])) $match[1] = $match[0]; if ($match[0]>$match[1]) $match[1]=$match[0]; if ($match[1]>10) { $match[0] = 10 * $match[0] / $match[1]; $match[1] = 10; } // end if ($match[1]>10) return $match; } // end function handle($match, $state, $pos, &$handler) function render($mode, &$renderer, $data) { if($mode == 'xhtml') { $renderer->doc .= $this->_Stars($data); return true; } // end if($mode == 'xhtml') return false; } // end function render($mode, &$renderer, $data) function _Stars($d) { $string=""; // render full stars for($i=1; $i<=$d[0]; $i++) $string .= ''; // render half star if necessary if($i-.5 <= $d[0]) { $string .= ''; $i+= .5; } // end if($i-$d[0] > 0) for($i;$i<=$d[1];$i++) $string .= ''; $string .= ''; return $string; } // end function _Stars($d) } // end class syntax_plugin_stars extends DokuWiki_Syntax_Plugin { //Setup VIM: ex: et ts=4 enc=utf-8 : ?>