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