1<?php
2/**
3 * Plugin for making callflow diagrams
4 *
5 * @note the js uses SVG/VXML from Raphaël.js @link:raphaeljs.com
6 *
7 * @author Bojidar Marinov <bojidar.marinov.bg@gmail.com>
8 */
9class syntax_plugin_callflow extends DokuWiki_Syntax_Plugin {
10
11	function getType(){return "protected";}
12
13	function getSort(){return 151;}
14
15	function connectTo($mode){$this->Lexer->addEntryPattern('<callflow>(?=.*?</callflow>)',$mode,'plugin_callflow');}
16
17	function postConnect() { $this->Lexer->addExitPattern('</callflow>','plugin_callflow'); }
18	/**
19	* Handle the match
20	*/
21	function handle($match, $state, $pos, Doku_Handler $handler)
22	{
23		switch ($state) {
24			case DOKU_LEXER_ENTER :
25			return array($state, array($state, $match));
26			case DOKU_LEXER_UNMATCHED :  return array($state, $match);
27			case DOKU_LEXER_EXIT :       return array($state, '');
28		}
29		return array();
30	}
31
32	/**
33	* Create output
34	*/
35	function render($mode, Doku_Renderer $renderer, $data)
36	{
37	// $data is what the function handle return'ed.
38		if($mode == 'xhtml'){
39			list($state,$match) = $data;
40			switch ($state) {
41				case DOKU_LEXER_ENTER :      $renderer->doc .= "<pre callflow='true' style='border: none; box-shadow: none;background-color: #fff;'>"; break;
42				case DOKU_LEXER_UNMATCHED :  $renderer->doc .= $renderer->_xmlEntities($match); break;
43				case DOKU_LEXER_EXIT :       $renderer->doc .= "</pre>"; break;
44			}
45			return true;
46		}
47		return false;
48	}
49
50}
51