1<?php 2/** 3 * Plugin Now: Inserts a timestamp. 4 * 5 * @license GPL 3 (http://www.gnu.org/licenses/gpl.html) 6 * @author Szymon Olewniczak <szymon.olewniczak@rid.pl> 7 */ 8 9// must be run within DokuWiki 10if(!defined('DOKU_INC')) die(); 11 12if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 13require_once DOKU_PLUGIN.'syntax.php'; 14 15/** 16 * All DokuWiki plugins to extend the parser/rendering mechanism 17 * need to inherit from this class 18 */ 19class syntax_plugin_bez_nav extends DokuWiki_Syntax_Plugin { 20 21 function getPType(){ 22 return 'block'; 23 } 24 25 function getType() { return 'substition'; } 26 function getSort() { return 99; } 27 28 29 function connectTo($mode) { 30 $this->Lexer->addSpecialPattern('~~BEZNAV~~',$mode,'plugin_bez_nav'); 31 } 32 33 function handle($match, $state, $pos, &$handler) 34 { 35 return true; 36 } 37 38 private function user_can_edit() { 39 global $INFO; 40 global $auth; 41 42 if ($auth->getUserData($INFO['client']) == true) { 43 return true; 44 } else { 45 return false; 46 } 47 } 48 private function user_can_view() { 49 global $INFO; 50 global $auth; 51 52 if ($auth->getUserData($INFO['client']) == true) { 53 return true; 54 } else { 55 return false; 56 } 57 } 58 59 function render($mode, &$renderer, $data) { 60 if($mode == 'xhtml') { 61 62 if ( ! $this->user_can_view()) { 63 return false; 64 } 65 66 $renderer->doc .= '<ul>'; 67 $renderer->doc .= '<li><a href="?id=bez:timeline">'.$this->getLang('bds_timeline').'</a></li>'; 68 $renderer->doc .= '<li><a href="?id=bez:issues">'.$this->getLang('bds_issues').'</a></li>'; 69 70 if ($this->user_can_edit()) { 71 $renderer->doc .= '<li><a href="?id=bez:issue_report">'.$this->getLang('bds_issue_report').'</a></li>'; 72 } 73 $renderer->doc .= '</ul>'; 74 75 } 76 } 77} 78