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