1<?php 2/** 3 * Panorama-Picture Plugin 4 * 5 * @license GPL 2 ( http://www.gnu.org/licenses/gpl.html ) 6 * @author jaloma.ac [at] googlemail [dot] com 7 * 8 * Description: 9 * Plugin to display Panorama-Pictures with Java-Applet http://www.tshsoft.de/panostudioapplet/index.html 10 * 11 * Acknowledgements: 12 * The java applet author(s) 13 */ 14 15if (!defined('DOKU_INC'))define('DOKU_INC', realpath(dirname( __FILE__ ).'/../../').'/'); 16if (!defined('DOKU_PLUGIN'))define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); 17require_once (DOKU_PLUGIN.'syntax.php'); 18require_once(DOKU_PLUGIN.'panorama/render_helper.php'); 19/** 20 * Panorama Plugin 21 */ 22class syntax_plugin_panorama_panorama extends DokuWiki_Syntax_Plugin 23{ 24 25 var $dflt = array ( 26 'width'=>800, 27 'height'=>400, 28 'name'=>'', 29 'mode'=>'java' 30 ); 31 /** 32 * Plugin Info 33 */ 34 function getInfo() 35 { 36 return array ( 37 'author'=>'Jürgen A. Lamers', 38 'email'=>'jaloma.ac [at] googlemail [dot] com', 39 'date'=>@file_get_contents(DOKU_PLUGIN . 'panorama/VERSION'), 40 'name'=>'panorama', 41 'desc'=>'Panorama-Picture Plugin <panorama name="" width="" height="" mode=""/>', 42 'url'=>'http://www.dokuwiki.org/plugin:panorama', 43 ); 44 } 45 46 /** 47 * Typology? 48 */ 49 function getType() 50 { 51 return 'substition'; 52 } 53 54 /** 55 * Sort Code? 56 */ 57 function getSort() 58 { 59 return 316; 60 } 61 62 /** 63 * Pattern Matching? 64 */ 65 function connectTo($mode) 66 { 67 $this->Lexer->addSpecialPattern('<panorama.*?/>', $mode, 'plugin_panorama_panorama'); 68 } 69 70 function matchLength() 71 { 72 return strlen("<panorama"); 73 } 74 /** 75 * Parsing 76 * 1. Very rough parsing involved 77 * 2. Applet parameters not included 78 */ 79 function handle($match, $state, $pos, & $handler) 80 { 81 $match = html_entity_decode(substr($match, $this->matchLength(), -2)); 82 $gmap = $this->_extract_params($match); 83 return $gmap; 84 } 85 /** 86 * extract parameters for the googlemap from the parameter string 87 * 88 * @param string $str_params string of key="value" pairs 89 * @return array associative array of parameters key=>value 90 */ 91 function _extract_params($str_params) 92 { 93 $param = array (); 94 preg_match_all('/(\w*)="(.*?)"/us', $str_params, $param, PREG_SET_ORDER); 95 if (sizeof($param) == 0) 96 { 97 preg_match_all("/(\w*)='(.*?)'/us", $str_params, $param, PREG_SET_ORDER); 98 } 99 // parse match for instructions, break into key value pairs 100 $gmap = $this->dflt; 101 foreach ($param as $kvpair) 102 { 103 list ($match, $key, $val) = $kvpair; 104 if ( isset ($gmap[$key]))$gmap[$key] = $val; 105 } 106 107 return $gmap; 108 } 109 110 /** 111 * Rendering 112 */ 113 function render($mode, & $renderer, $data) 114 { 115 if ($mode == 'xhtml') 116 { 117 global $conf; 118 $mode = $data['mode']; 119 $txt = ""; 120 if ($mode == null || $mode == 'java') 121 { 122 $txt = render_helper::_render_java($data); 123 } elseif ($mode == 'swf' || $mode == 'flash') 124 { 125 $txt = render_helper::_render_swf($data); 126 } 127 if ($this->getConf('showPanoramaUrl')) 128 { 129 $txt .= '<br />Powered by <a href="http://www.tshsoft.com/panostudioapplet/index.html">PanoramaStudio Viewer</a>'; 130 } 131 132 $renderer->doc .= $txt; 133 return true; 134 } else 135 { 136 return false; 137 } 138 } 139 140}// class 141