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