xref: /plugin/bez/syntax/nav.php (revision ff14b1073c2dab2f863cab3b8baf8b1a01f7993a)
165cfcae3Sghi<?php
2de02284cSSzymon Olewniczak
3de02284cSSzymon Olewniczakuse \dokuwiki\plugin\bez;
465cfcae3Sghi
565cfcae3Sghi// must be run within DokuWiki
665cfcae3Sghiif(!defined('DOKU_INC')) die();
765cfcae3Sghi
865cfcae3Sghiclass syntax_plugin_bez_nav extends DokuWiki_Syntax_Plugin {
965cfcae3Sghi
10e8827d73SSzymon Olewniczak    public function getPType() { return 'block'; }
11e8827d73SSzymon Olewniczak    public function getType() { return 'substition'; }
12e8827d73SSzymon Olewniczak    public function getSort() { return 99; }
1365cfcae3Sghi
1465cfcae3Sghi
15e8827d73SSzymon Olewniczak    public function connectTo($mode) {
1665cfcae3Sghi		$this->Lexer->addSpecialPattern('~~BEZNAV~~',$mode,'plugin_bez_nav');
1765cfcae3Sghi    }
1865cfcae3Sghi
19e8827d73SSzymon Olewniczak    public function handle($match, $state, $pos, Doku_Handler $handler) {
2065cfcae3Sghi		return true;
2165cfcae3Sghi    }
2265cfcae3Sghi
23e8827d73SSzymon Olewniczak    public function render($mode, Doku_Renderer $r, $data) {
24e8827d73SSzymon Olewniczak        global $auth, $INFO, $conf;
25e8827d73SSzymon Olewniczak        if ($mode != 'xhtml') return;
2617f97301SSzymon Olewniczak
27e8827d73SSzymon Olewniczak        $r->info['cache'] = false;
2865cfcae3Sghi
29e8827d73SSzymon Olewniczak        $r->doc .= '<nav id="plugin__bez">';
30e8827d73SSzymon Olewniczak        $r->doc .= '<div style="background-color: #eee; color: #333; padding: 0 .3em;">' .
31e8827d73SSzymon Olewniczak            inlineSVG(DOKU_PLUGIN . 'bez/images/logo.svg') .
32e8827d73SSzymon Olewniczak            $this->getLang('bez') .
33e8827d73SSzymon Olewniczak            '</div>';
34e8827d73SSzymon Olewniczak        $r->doc .= '<ul>';
35e8827d73SSzymon Olewniczak        $actions = array(
36*ff14b107SSzymon Olewniczak            //'start' => $this->getLang('nav my_activities'),
37e8827d73SSzymon Olewniczak            'threads' => $this->getLang('issues'),
38e8827d73SSzymon Olewniczak            //'projects' => $this->getLang('nav projects'),
39e8827d73SSzymon Olewniczak            'tasks' => $this->getLang('tasks'),
40*ff14b107SSzymon Olewniczak            'activity_report' => $this->getLang('activity_report')
4108e8ea12Sghi        );
42e8827d73SSzymon Olewniczak        /** @var bez\mdl\Model $model */
43e8827d73SSzymon Olewniczak        $model = new bez\mdl\Model($auth, $INFO['client'], $this, $conf);
44e8827d73SSzymon Olewniczak        if ($model->acl->get_level() >= BEZ_AUTH_LEADER) {
45e8827d73SSzymon Olewniczak            $actions['types'] = $this->getLang('types_manage');
46e8827d73SSzymon Olewniczak            $actions['task_programs'] = $this->getLang('task_types');
476c94eb49Sghi        }
4860c2063dSSzymon Olewniczak
49e8827d73SSzymon Olewniczak        foreach ($actions as $action => $label) {
50e8827d73SSzymon Olewniczak            $r->doc .= $this->_list($action, $label);
516c94eb49Sghi        }
52e8827d73SSzymon Olewniczak        $r->doc .= '</ul>';
53e8827d73SSzymon Olewniczak        $r->doc .= '</nav>';
5427712358Sghi    }
55919e4830Sghi
56e8827d73SSzymon Olewniczak    protected function _list($action, $label) {
57e8827d73SSzymon Olewniczak        global $INFO;
58919e4830Sghi
59e8827d73SSzymon Olewniczak        $matches = array();
60e8827d73SSzymon Olewniczak        preg_match('/bez:([a-z_]*)/i', $INFO['id'], $matches);
61e8827d73SSzymon Olewniczak        $cur_action = '';
62e8827d73SSzymon Olewniczak        if (isset($matches[1])) {
63e8827d73SSzymon Olewniczak            $cur_action = $matches[1];
64168ecf58Sghi        }
65168ecf58Sghi
66e8827d73SSzymon Olewniczak        $ret = '<li>';
67e8827d73SSzymon Olewniczak        if ($cur_action == $action) $ret .= '<strong>';
68e8827d73SSzymon Olewniczak        $ret .= '<a href="' . action_plugin_bez_default::url($action) . '">' . $label . '</a>';
69e8827d73SSzymon Olewniczak        if ($cur_action == $action) $ret .= '</strong>';
70e8827d73SSzymon Olewniczak        $ret .= '</li>';
71168ecf58Sghi
72e8827d73SSzymon Olewniczak        return $ret;
7365cfcae3Sghi    }
7465cfcae3Sghi}
75