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// must be run within Dokuwiki
10if(!defined('DOKU_INC')) die();
11
12/**
13 * Class syntax_plugin_dataau_taglist
14 */
15class syntax_plugin_dataau_taglist extends syntax_plugin_dataau_cloud {
16
17    /**
18     * Connect pattern to lexer
19     */
20    function connectTo($mode) {
21        $this->Lexer->addSpecialPattern('----+ *datataglist(?: [ a-zA-Z0-9_]*)?-+\n.*?\n----+', $mode, 'plugin_dataau_taglist');
22    }
23
24    protected $before_item = '<ul class="dataauplugin_taglist %s">';
25    protected $after_item  = '</ul>';
26    protected $before_val  = '<li class="tl">';
27    protected $after_val   = '</li>';
28
29    /**
30     * Create a weighted tag distribution
31     *
32     * @param &$tags  array The tags to weight ( tag => count)
33     * @param $min    int   The lowest count of a single tag
34     * @param $max    int   The highest count of a single tag
35     * @param $levels int   The number of levels you want. A 5 gives levels 0 to 4.
36     */
37    protected function _cloud_weight(&$tags, $min, $max, $levels) {
38        parent::_cloud_weight($tags, $min, $max, $levels);
39
40        // sort by values. Key is name of the single tag, value the count
41        arsort($tags);
42    }
43
44}
45
46