1<?php 2/** 3 * Plugin orgapp: OrgApp applet integration - GPL>=3 - See licence COPYING file 4 * 5 * @author Enrico Croce & Simona Burzio (staff@eiroca.net) 6 * @copyright Copyright (C) 2009-2019 eIrOcA - Enrico Croce & Simona Burzio 7 * @license GPL >=3 (http://www.gnu.org/licenses/) 8 * @version 19.02 9 * @link http://www.eiroca.net/doku_orgapp 10 */ 11if (!defined('DOKU_INC')) die(); 12if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); 13if (!defined('DOKU_PLUGIN_ORGAPP')) define('DOKU_PLUGIN_ORGAPP', DOKU_PLUGIN . 'orgapp/'); 14require_once (DOKU_PLUGIN . 'syntax.php'); 15 16class syntax_plugin_orgapp extends DokuWiki_Syntax_Plugin { 17 18 function getType() { 19 return 'disabled'; 20 } 21 22 function getSort() { 23 return 150; 24 } 25 26 function connectTo($mode) { 27 $this->Lexer->addEntryPattern('<orgapp.*?>(?=.*?</orgapp>)', $mode, 'plugin_orgapp'); 28 } 29 30 function postConnect() { 31 $this->Lexer->addExitPattern('</orgapp>', 'plugin_orgapp'); 32 } 33 34 function handle($match, $state, $pos, Doku_Handler $handler) { 35 $out = [ ]; 36 switch ($state) { 37 case DOKU_LEXER_ENTER : 38 $out['width'] = $this->getConf('width'); 39 $out['height'] = $this->getConf('height'); 40 $out['name'] = $this->getConf('name'); 41 $out['code'] = $this->getConf('code'); 42 $out['archive'] = $this->getConf('archive'); 43 $out['target'] = $this->getConf('target'); 44 $out['type'] = $this->getConf('type'); 45 $matches = ''; 46 $found = preg_match_all('#([^\s=]+)\s*=\s*(\'[^<\']*\'|"[^<"]*"|[\d\w]+)#', $match, $matches, PREG_SET_ORDER); 47 if ($found != 0) { 48 foreach ($matches as $attribute) { 49 if ($attribute[2][0] == '"') { 50 $out[$attribute[1]] = substr($attribute[2], 1, -1); 51 } 52 else { 53 $out[$attribute[1]] = $attribute[2]; 54 } 55 } 56 } 57 return array ( 58 $state, $out 59 ); 60 case DOKU_LEXER_UNMATCHED : 61 return array ( 62 $state, $match 63 ); 64 case DOKU_LEXER_EXIT : 65 return array ( 66 $state, '' 67 ); 68 } 69 } 70 71 var $data; 72 73 function render($mode, Doku_Renderer $renderer, $data) { 74 $renderer->info['cache'] = false; 75 if ($mode == 'xhtml') { 76 list ($state, $match) = $data; 77 switch ($state) { 78 case DOKU_LEXER_ENTER : 79 $code = $match['code']; 80 $renderer->doc .= '<applet name="' . $match['name'] . '" code="' . $code . '" archive="' . $match['archive'] . '" width="' . $match['width'] . '" height="' . $match['height'] . '">'; 81 if ($match['target'] != '') { 82 $renderer->doc .= '<param name="Target" value="' . $match['target'] . '" />'; 83 } 84 $renderer->doc .= '<param name="DataType" value="' . $match['type'] . '" />'; 85 if ($match['url'] != '') { 86 $renderer->doc .= '<param name="DataSource" value="' . $match['url'] . '" />'; 87 } 88 $this->data = ''; 89 break; 90 case DOKU_LEXER_UNMATCHED : 91 $this->data .= $match; 92 break; 93 case DOKU_LEXER_EXIT : 94 if ($this->data != '') { 95 $renderer->doc .= '<param name="Data" value="' . $renderer->_xmlEntities($this->data) . '" />'; 96 } 97 $renderer->doc .= '</applet>'; 98 break; 99 } 100 return true; 101 } 102 return false; 103 } 104 105} 106?>