1<?php
2/**
3 * S5 Reloaded Plugin: Display a Wiki page as S5 reloaded slideshow presentation
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Tomas Alonso <t.alonso@oan.es>, Andreas Gohr <andi@splitbrain.org>
7 */
8// must be run within Dokuwiki
9if(!defined('DOKU_INC')) die();
10
11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
12require_once(DOKU_PLUGIN.'syntax.php');
13
14/**
15 * All DokuWiki plugins to extend the parser/rendering mechanism
16 * need to inherit from this class
17 */
18class syntax_plugin_s5reloaded extends DokuWiki_Syntax_Plugin {
19
20    /**
21     * What kind of syntax are we?
22     */
23    function getType(){
24        return 'substition';
25    }
26
27    /**
28     * What about paragraphs?
29     */
30    function getPType(){
31        return 'normal';
32    }
33
34    /**
35     * Where to sort in?
36     */
37    function getSort(){
38        return 800;
39    }
40
41
42    /**
43     * Connect pattern to lexer
44     */
45    function connectTo($mode) {
46        $this->Lexer->addSpecialPattern('~~SLIDESHOW[^~]*~~',$mode,'plugin_s5reloaded');
47    }
48
49
50    /**
51     * Handle the match
52     */
53    function handle($match, $state, $pos, &$handler){
54	if($match!='~~SLIDESHOW~~') return array(trim(substr($match,11,-2)));
55        return array();
56    }
57
58    /**
59     * Create output
60     */
61    function render($format, &$renderer, $data) {
62        global $ID;
63        if($format != 'xhtml') return false;
64
65	$renderer->doc .= '<a href="'.exportlink($ID, 's5reloaded',sizeof($data)?array('s5theme'=>$data[0]):null).'" title="'.$this->getLang('view').'">';
66        $renderer->doc .= '<img src="'.DOKU_BASE.'lib/plugins/s5reloaded/screen.gif" align="right" alt="'.$this->getLang('view').'" width="48" height="48" />';
67        $renderer->doc .= '</a>';
68        return true;
69    }
70}
71
72//Setup VIM: ex: et ts=4 enc=utf-8 :
73