<?php if (!defined('PmWiki')) exit(); define('X-PTVIEWER_VERSION', '0.1.1'); /*--------------------------------------------------------------- * Copyright / Warranty * This PmWiki addon was written on November 18, 2004 by Chris Drew (web@cdrew.co.uk). The same terms and conditions that apply to PmWiki also apply to this script. There's no warranty what-so-ever with this script. Use at your own risk. /*--------------------------------------------------------------- * Special Thanks * Thanks to Pm (Patrick Michaud, www.pmichaud.com), for creating PmWiki, and for sharing his knowledge and insightfulness which is what made this script possible. Also thanks for Steven Leite for his plugin addons which I have used as templates. Also thanks to Helmut Dersch for making the excellent java panorama viewer. /*--------------------------------------------------------------- * Description * This add-on allows a PmWiki user to insert the PTViewer java applet into a WikiPage that will view a panorama of the users choice stored on the server. /*--------------------------------------------------------------- * Features * X-ptviewer variables are packed away in functions which are only called when the [[x-ptviewer:]] directive is executed. /*--------------------------------------------------------------- * Installation * 1. Create a new folder: /local/scripts. 2. Save this file (x-ptviewer.php) in the new directory. 3. Add this one line to your config.php file: ptviewer_once("local/scripts/x-ptviewer.php"); 4. Put the ptviewer.jar file in the your pub directory (or change the jarurl variable, see below) /*--------------------------------------------------------------- * Usage Instructions * Using this script is easy and intuitive, and as similar to the direct usage of the ptviewer applet as possible: Example: [[x-ptviewer: file=pano.jpg]] Optional fields include: width = Width of the view in the PmWiki page (default 320) height = Height of the view in the PmWiki page (default 200) pfov = 0..360 Horizontal field of view of panorama (default 360) auto = -360..360 (fractional values allowed) Auto pan speed (default 0) fov = 5..165 Initial horizontal field of view (default 70) fovmin = 5..165 Minimum field of view (default 12) fovmax = 5..165 Maximum field of view (default 165) If the fields are not specified, the script/ptviewer defaults will be used. You can set these defaults in the script (see below). /*--------------------------------------------------------------- * History * Nov 18, 2004 - Beta Release. Nov 19, 2004 - Any parameter can now be passed to ptviewer. /*-------------------------------------------------------------*/ $DoubleBrackets["/\\[\\[x-ptviewer:(.*?)\\]\\]/e"] = 'xptviewer("$1");'; //--------------------------------------------------------------- function xptviewerInit($user_input, & $xptviewerParams, & $xptviewerVars) { //--------------------------------------------------------------- global $PubDirUrl; $xptviewerVars = array ( 'show_errors' => 'false', //TODO may need to impliment error checking 'filename_filtering' => 'false', //TODO need to do some formating of the picture URL 'jarurl' => $PubDirUrl."/ptviewer.jar"); //URL to ptviewer.jar file //Deal with the user input and put it into xptviewerParams $pieces = explode(" ", $user_input); foreach($pieces as $apart){ list($key,$value) = explode("=", $apart); $xptviewerParams["$key"] = $value; } //Defaults SDVA($xptviewerParams, array( 'width' => '320', // width of panorama 'height' => '200', // height of panorama )); return; } //--------------------------------------------------------------- function xptviewer($user_input) { //--------------------------------------------------------------- xptviewerInit($user_input, $xptviewerParams, $xptviewerVars); $html .= "\n\n<!-- X-ptviewer -->\n"; $html .= "<applet archive=\"{$xptviewerVars['jarurl']}\" code=\"ptviewer.class\" height={$xptviewerParams[height]} width={$xptviewerParams[width]}>\n"; // $html .= "<applet archive=\"{$xptviewerVars['jarurl']}\" code=\"ptviewer.class\">\n"; while ($PtvParam = current($xptviewerParams)) { if (key($xptviewerParams) != 'width' && key($xptviewerParams) != 'height'){ $html .= '<param name='.key($xptviewerParams)." value=".$PtvParam.">\n"; } next($xptviewerParams); } $html.="</applet>"; $html .= "\n<!--/ X-ptviewer -->\n\n"; return Keep($html); } ?>