1<?php 2/** 3 * Embed an image gallery 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once(DOKU_PLUGIN.'syntax.php'); 12require_once(DOKU_INC.'inc/search.php'); 13require_once(DOKU_INC.'inc/JpegMeta.php'); 14 15class syntax_plugin_panoview extends DokuWiki_Syntax_Plugin { 16 /** 17 * return some info 18 */ 19 function getInfo(){ 20 return confToHash(dirname(__FILE__).'/info.txt'); 21 } 22 23 /** 24 * What kind of syntax are we? 25 */ 26 function getType(){ 27 return 'substition'; 28 } 29 30 /** 31 * What about paragraphs? 32 */ 33 function getPType(){ 34 return 'block'; 35 } 36 37 /** 38 * Where to sort in? 39 */ 40 function getSort(){ 41 return 301; 42 } 43 44 45 /** 46 * Connect pattern to lexer 47 */ 48 function connectTo($mode) { 49 $this->Lexer->addSpecialPattern('\{\{panoview>[^}]*\}\}',$mode,'plugin_panoview'); 50 } 51 52 /** 53 * Handle the match 54 */ 55 function handle($match, $state, $pos, &$handler){ 56 global $ID; 57 58 $options = array( 59 'width' => 500, 60 'height' => 250, 61 'align' => 'center', 62 63 64 'image' => 'zoom:greetsiel.jpg', 65 'imageWidth' => 7672, 66 'imageHeight' => 1624, 67 'initialZoom' => 2, 68 69 'tileBaseUri' => DOKU_BASE.'lib/plugins/panoview/tiles.php', 70 'tileSize' => 256, 71 'maxZoom' => 10, 72 'blankTile' => DOKU_BASE.'lib/plugins/panoview/gfx/blank.gif', 73 'loadingTile' => DOKU_BASE.'lib/plugins/panoview/gfx/progress.gif', 74 75 ); 76 77 78 return $options; 79 } 80 81 /** 82 * Create output 83 */ 84 function render($mode, &$R, $data) { 85 if($mode != 'xhtml') return false; 86 87 require_once(DOKU_INC.'inc/JSON.php'); 88 $json = new JSON(); 89 90 $img = '<img src="'.ml($data['image'],array('w'=>$data['width'],'h'=>$data['height'])).'" width="'.$data['width'].'" height="'.$data['height'].'" alt="" />'; 91 92 93 $R->doc .= ' 94<div class="panoview_plugin" style="width: '.$data['width'].'px; height: '.$data['height'].'px;"> 95 <div class="well">'.$img.'</div> 96 <div class="surface"><!-- --></div> 97 <p class="controls" style="display: none"> 98 <span class="zoomIn" title="Zoom In">+</span> 99 <span class="zoomOut" title="Zoom Out">-</span> 100 </p> 101 <div class="options" style="display:none">'.hsc($json->encode($data)).'</div> 102</div> 103 104'; 105 106 107 return true; 108 } 109 110 111} 112 113//Setup VIM: ex: et ts=4 enc=utf-8 : 114