1<?php
2/**
3 * Embed an guestbook
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Gerry Weißbach <gerry.w@gammaproduction.de>
7 */
8
9if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11require_once(DOKU_PLUGIN.'syntax.php');
12
13require_once(dirname(__FILE__).'/'.'basic.class.php');   // settings classes specific to these settings
14
15class syntax_plugin_guestbook extends DokuWiki_Syntax_Plugin {
16    /**
17     * return some info
18     */
19    function getInfo(){
20        return array(
21            'author' => 'Gerry Wei&szlig;bach',
22            'email'  => 'gerry.w@gammaproduction.de',
23            'date'   => '2006-01-28',
24            'name'   => 'guestbook Plugin',
25            'desc'   => 'Shows up a guestbook, editable from adminarea
26            			Syntax: {{guestbook}}',
27            'url'    => 'http://wiki.gammaproduction.de/dokuwiki/plugins/guestbook',
28        );
29    }
30
31    /**
32     * What kind of syntax are we?
33     */
34    function getType(){
35        return 'disabled'; //substition';
36    }
37
38    /**
39     * What about paragraphs?
40     */
41    function getPType(){
42        return 'block'; //container';
43    }
44
45    /**
46     * Where to sort in?
47     */
48    function getSort(){
49        return 301;
50    }
51
52
53    /**
54     * Connect pattern to lexer
55     */
56    function connectTo($mode) {
57        $this->Lexer->addSpecialPattern('\{\{guestbook\}\}',$mode, 'plugin_guestbook');
58    }
59
60
61    /**
62     * Handle the match
63     */
64    function handle($match, $state, $pos, &$handler){
65
66			return 1;
67    }
68
69    /**
70     * Create output
71     */
72    function render($mode, &$renderer, $data) {
73
74       	$renderer->info['cache'] = FALSE;
75        if($mode == 'xhtml'){
76						$guestbook = new guestbook();
77
78		      	$renderer->doc .= '<div id="guestbook">';
79
80						if (!empty($_POST['newEntry']))
81						{
82							$renderer->doc .= $guestbook->newEntry($this);
83						}
84		    		if(!empty($_POST['createEntry']))
85							$renderer->doc .= $guestbook->form($this, intval($_POST['guestEdit']));
86						else
87						{
88            	$renderer->doc .= $guestbook->html($this);
89            }
90
91					  $renderer->doc .= '</div>';
92
93            return true;
94        }
95        return false;
96    }
97
98}
99
100//Setup VIM: ex: et ts=4 enc=utf-8 :
101