1<?php 2 3use \dokuwiki\plugin\bez; 4 5// must be run within DokuWiki 6if(!defined('DOKU_INC')) die(); 7 8class syntax_plugin_bez_nav extends DokuWiki_Syntax_Plugin { 9 10 public function getPType() { return 'block'; } 11 public function getType() { return 'substition'; } 12 public function getSort() { return 99; } 13 14 15 public function connectTo($mode) { 16 $this->Lexer->addSpecialPattern('~~BEZNAV~~',$mode,'plugin_bez_nav'); 17 } 18 19 public function handle($match, $state, $pos, Doku_Handler $handler) { 20 return true; 21 } 22 23 public function render($mode, Doku_Renderer $r, $data) { 24 global $auth, $INFO, $conf; 25 if ($mode != 'xhtml') return; 26 27 $r->info['cache'] = false; 28 29 $r->doc .= '<nav id="plugin__bez">'; 30 $r->doc .= '<div style="background-color: #eee; color: #333; padding: 0 .3em;">' . 31 inlineSVG(DOKU_PLUGIN . 'bez/images/logo.svg') . 32 $this->getLang('bez') . 33 '</div>'; 34 $r->doc .= '<ul>'; 35 $actions = array( 36 //'start' => $this->getLang('nav my_activities'), 37 'threads' => $this->getLang('issues'), 38 //'projects' => $this->getLang('nav projects'), 39 'tasks' => $this->getLang('tasks'), 40 'activity_report' => $this->getLang('activity_report') 41 ); 42 /** @var bez\mdl\Model $model */ 43 $model = new bez\mdl\Model($auth, $INFO['client'], $this, $conf); 44 if ($model->acl->get_level() >= BEZ_AUTH_LEADER) { 45 $actions['types'] = $this->getLang('types_manage'); 46 $actions['task_programs'] = $this->getLang('task_types'); 47 } 48 49 foreach ($actions as $action => $label) { 50 $r->doc .= $this->_list($action, $label); 51 } 52 $r->doc .= '</ul>'; 53 $r->doc .= '</nav>'; 54 } 55 56 protected function _list($action, $label) { 57 global $INFO; 58 59 $matches = array(); 60 preg_match('/bez:([a-z_]*)/i', $INFO['id'], $matches); 61 $cur_action = ''; 62 if (isset($matches[1])) { 63 $cur_action = $matches[1]; 64 } 65 66 $ret = '<li>'; 67 if ($cur_action == $action) $ret .= '<strong>'; 68 $ret .= '<a href="' . action_plugin_bez_default::url($action) . '">' . $label . '</a>'; 69 if ($cur_action == $action) $ret .= '</strong>'; 70 $ret .= '</li>'; 71 72 return $ret; 73 } 74} 75