1<?php
2/**
3 *
4 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
5 * @author     Dan Kreiser <dan.kreiser@gmail.com>
6 */
7
8if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
9if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
10require_once(DOKU_PLUGIN.'syntax.php');
11
12
13/**
14 * All DokuWiki plugins to extend the parser/rendering mechanism
15 * need to inherit from this class
16 */
17class syntax_plugin_tline extends DokuWiki_Syntax_Plugin {
18
19    function getInfo() {
20        return array(
21            'author' => 'Dan Kreiser',
22            'email'  => 'dan.kreiser@gmail.com',
23            'date'   => '2011-03-01',
24            'name'   => 'tline',
25            'desc'   => 'Integrate charts with the google charts api',
26            'url'    => 'http://www.tux-tips.de/tux-wiki/doku.php?id=start:dokuwiki:plugins',
27        );
28    }
29    /**
30     * What kind of syntax are we?
31     */
32    function getType(){
33        return 'substition';
34    }
35
36    function getPType(){
37        return 'block';
38    }
39
40    /**
41     * Where to sort in?
42     */
43    function getSort(){
44        return 160;
45    }
46
47    /**
48     * Connect pattern to lexer
49     */
50    function connectTo($mode) {
51      $this->Lexer->addSpecialPattern('<tline>\n.*?\n</tline>',$mode,'plugin_tline');
52    }
53
54    /**
55     * Handle the match
56     */
57    function handle($match, $state, $pos, &$handler){
58
59        // prepare default data
60
61		$return=explode("\n",$match);
62        return $return;
63    }
64
65    /**
66     * Create output
67     */
68    function render($mode, &$R, $data) {
69        if($mode != 'xhtml') return false;
70
71	  //$R->doc .= '<img src="'.$url.'&.png" />';
72	  $R->doc .='<script src="data/pages/tline/'.$data[1].'.txt" type="text/javascript"></script>';
73	  $R->doc .='<div id="tl" class="timeline-default" style="height:'.$data[2].';"></div>';
74	  $R->doc .='<a title="tline:'.$data[1].'" class="wikilink1" href="doku.php?id=tline:'.$data[1].'" >Timeline bearbeiten</a>';
75  		if ($data[3]=="controls"){
76		$R->doc .='<div class="controls" id="controls"></div>';
77		}
78			return true;
79
80    }
81}
82