1<?php
2/**
3 * Table2csv Plugin
4 *
5 * Provides tag for table to export.
6 *
7 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
8 * @author  Tom Cafferty <tcafferty@glocalfocal.com>
9 */
10
11// must be run within Dokuwiki
12if(!defined('DOKU_INC')) die();
13
14if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
15require_once(DOKU_PLUGIN.'syntax.php');
16
17/**
18 * All DokuWiki plugins to extend the parser/rendering mechanism
19 * need to inherit from this class
20 */
21class syntax_plugin_table2csv extends DokuWiki_Syntax_Plugin {
22
23  /**
24   * return some info
25   */
26  function getInfo(){
27    return array (
28      'author' => 'Tom Cafferty',
29      'email' => 'tcafferty@glocalfocal.com',
30      'date' => '2012-07-08',
31      'name' => 'Table2csv plugin (syntax component)',
32      'desc' => 'Provide table identification',
33      'url' => 'http://www.dokuwiki.org/plugin:table2csv',
34    );
35  }
36
37  function getType(){
38      return 'substition';
39  }
40
41  function getPType(){
42      return 'block';
43  }
44
45  function getSort(){
46      return 160;
47  }
48
49  /**
50   * Connect pattern to lexer
51   */
52  function connectTo($mode) {
53      $this->Lexer->addSpecialPattern('<table2csv>.*?</table2csv>',$mode,'plugin_table2csv');
54  }
55
56  /**
57   * Handle the match
58   */
59  function handle($match, $state, $pos, &$handler){
60      parse_str($match, $return);
61      return $return;
62  }
63
64  /**
65   *  Render output
66   */
67  function render($mode, &$renderer, $data) {
68      global $INFO;
69      global $ID;
70      global $conf;
71      if ($mode == 'metadata') {
72          $renderer->meta ['table2csv'] = $data['startMarker'];
73          return true;
74      }
75      else
76          return false;
77  }
78
79}
80