1<?php 2 3/** 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Gerrit <klapinklapin@gmail.com> 7 * 8 * based on cloud.php. Build a list of tags ordered by their counts. 9 */ 10 11/** 12 * Class syntax_plugin_data_taglist 13 */ 14class syntax_plugin_data_taglist extends syntax_plugin_data_cloud 15{ 16 /** 17 * Connect pattern to lexer 18 */ 19 public function connectTo($mode) 20 { 21 $this->Lexer->addSpecialPattern( 22 '----+ *datataglist(?: [ a-zA-Z0-9_]*)?-+\n.*?\n----+', 23 $mode, 24 'plugin_data_taglist' 25 ); 26 } 27 28 protected $before_item = '<ul class="dataplugin_taglist %s">'; 29 protected $after_item = '</ul>'; 30 protected $before_val = '<li class="tl">'; 31 protected $after_val = '</li>'; 32 33 /** 34 * Create a weighted tag distribution 35 * 36 * @param &$tags array The tags to weight ( tag => count) 37 * @param $min int The lowest count of a single tag 38 * @param $max int The highest count of a single tag 39 * @param $levels int The number of levels you want. A 5 gives levels 0 to 4. 40 */ 41 protected function cloudWeight(&$tags, $min, $max, $levels) 42 { 43 parent::cloudWeight($tags, $min, $max, $levels); 44 45 // sort by values. Key is name of the single tag, value the count 46 arsort($tags); 47 } 48} 49