1<?php
2/**
3 * DokuWiki Plugin workflow (Syntax Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Ryan Boder <ryan.boder@suretycam.com>
7 */
8
9// must be run within Dokuwiki
10if (!defined('DOKU_INC')) die();
11
12class syntax_plugin_workflow_box extends DokuWiki_Syntax_Plugin {
13
14    function getType(){ return 'formatting';}
15    function getAllowedTypes() { return array('container', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs'); }
16    function getPType(){ return 'block';}
17    function getSort(){ return 197; }
18
19    public function connectTo($mode) {
20      $this->Lexer->addEntryPattern('<box.*?>(?=.*?</box>)', $mode, 'plugin_workflow_box');
21    }
22
23    public function postConnect() {
24      $this->Lexer->addExitPattern('</box>', 'plugin_workflow_box');
25    }
26
27    public function handle($match, $state, $pos, &$handler){
28      $data = array($state, $match);
29      return $data;
30    }
31
32    public function render($mode, &$renderer, $indata) {
33      if($mode != 'xhtml') return false;
34
35      if (empty($indata)) return false;
36      list($state, $data) = $indata;
37
38      switch ($state) {
39      case DOKU_LEXER_ENTER:
40	$renderer->doc .= '<div class="box">';
41	break;
42      case DOKU_LEXER_UNMATCHED:
43	$renderer->doc .= $data;
44	break;
45      case DOKU_LEXER_EXIT:
46	$renderer->doc .= '</div><br/>';
47	break;
48      }
49
50      return true;
51    }
52
53}
54