diff --git a/plugins/instaView/instaView.php b/plugins/instaView/instaView.php new file mode 100755 index 0000000..08ad01d --- /dev/null +++ b/plugins/instaView/instaView.php @@ -0,0 +1,148 @@ +generateFlash(); + return $res; + } + + /** + * The supported mime types for the converter. + * + * @return array + */ + public function getSupportedMimeTypes() + { +// $aAcceptedMimeTypes = array('doc', 'ods', 'odt', 'ott', 'txt', 'rtf', 'sxw', 'stw', +// // 'html', 'htm', +// 'xml' , 'pdb', 'psw', 'ods', 'ots', 'sxc', +// 'stc', 'dif', 'dbf', 'xls', 'xlt', 'slk', 'csv', 'pxl', +// 'odp', 'otp', 'sxi', 'sti', 'ppt', 'pot', 'sxd', 'odg', +// 'otg', 'std', 'asc'); + + // taken from the original list of accepted types in the pdf generator action + $mime_types = array(); + $mime_types[] = 'text/plain'; + $mime_types[] = 'text/html'; + $mime_types[] = 'text/csv'; + $mime_types[] = 'text/rtf'; + + // Office OLE2 - 2003, XP, etc + $mime_types[] = 'application/msword'; + $mime_types[] = 'application/vnd.ms-powerpoint'; + $mime_types[] = 'application/vnd.ms-excel'; + + // Star Office + $mime_types[] = 'application/vnd.sun.xml.writer'; + $mime_types[] = 'application/vnd.sun.xml.writer.template'; + $mime_types[] = 'application/vnd.sun.xml.calc'; + $mime_types[] = 'application/vnd.sun.xml.calc.template'; + $mime_types[] = 'application/vnd.sun.xml.draw'; + $mime_types[] = 'application/vnd.sun.xml.draw.template'; + $mime_types[] = 'application/vnd.sun.xml.impress'; + $mime_types[] = 'application/vnd.sun.xml.impress.template'; + + // Open Office + $mime_types[] = 'application/vnd.oasis.opendocument.text'; + $mime_types[] = 'application/vnd.oasis.opendocument.text-template'; + $mime_types[] = 'application/vnd.oasis.opendocument.graphics'; + $mime_types[] = 'application/vnd.oasis.opendocument.graphics-template'; + $mime_types[] = 'application/vnd.oasis.opendocument.presentation'; + $mime_types[] = 'application/vnd.oasis.opendocument.presentation-template'; + $mime_types[] = 'application/vnd.oasis.opendocument.spreadsheet'; + $mime_types[] = 'application/vnd.oasis.opendocument.spreadsheet-template'; + + /* OO3 + // Office 2007 + $mime_types[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; + $mime_types[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; + $mime_types[] = 'application/vnd.openxmlformats-officedocument.presentationml.template'; + $mime_types[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'; + $mime_types[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; + $mime_types[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; + $mime_types[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; + */ + + return $mime_types; + } + + /** + * Merges the flash template with the pdf of the document + * + * @return boolean + */ + private function generateFlash() + { + /* + The template can be stored in a resources folder under the plugin and merged in with the pdf below. + */ + global $default; + + $pdfDir = $default->pdfDirectory; + $pdfFile = $pdfDir .'/'. $this->document->iId.'.pdf'; + $swfFile = $pdfDir .'/'. $this->document->iId.'.swf'; + + // if a previous version of the swf file exists - delete it + if(file_exists($swfFile)){ + @unlink($swfFile); + } + //check if the pdf exists + if(!file_exists($pdfFile)){ + global $default; + $default->log->debug('InstaView Plugin: PDF file does not exist, cannot generate the flash view'); + return false; + } + + // do merge + $output = shell_exec("pdf2swf $pdfFile -o $swfFile"); + return true; + } +} +?> \ No newline at end of file diff --git a/plugins/instaView/instaViewLinkAction.php b/plugins/instaView/instaViewLinkAction.php new file mode 100755 index 0000000..b043abf --- /dev/null +++ b/plugins/instaView/instaViewLinkAction.php @@ -0,0 +1,151 @@ +. + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * California 94120-7775, or email info@knowledgetree.com. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "Powered by + * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. + * Contributor( s): ______________________________________ + * + */ + +require_once(KT_LIB_DIR . '/actions/documentaction.inc.php'); +require_once(KT_LIB_DIR . '/permissions/permission.inc.php'); +require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php'); +require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); +require_once(KT_LIB_DIR . "/actions/documentviewlet.inc.php"); +require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); +require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); + +require_once(KT_LIB_DIR . '/roles/Role.inc'); + +class instaViewLinkAction extends KTDocumentAction { + var $sName = 'instaview.processor.link'; + var $_sShowPermission = "ktcore.permissions.read"; + var $sDisplayName = "Instant View"; + var $pluginDir; + + function getDisplayName() { + //get document object + $oDocument = $this->oDocument; + + // get document id + if(!isset($oDocument)){ + return 'Instant View'; + } + $iFId = $oDocument->getID(); + + // return link... + return "InstaView ".$this->getImageLink($iFId, 'document'); + } + + function do_main() { + //get document object + $oDocument = $this->oDocument; + global $default; + // get document id + $iDId = $oDocument->getID(); + $oUser = User::get($_SESSION['userID']); + if(Pear::isError($oUser)){ + die("Invalid user"); + } + $dir = KTPlugin::_fixFilename(__FILE__); + $this->pluginDir = dirname($dir) . '/'; + + //check permissions on the document + if(KTPermissionUtil::userHasPermissionOnItem($oUser,'ktcore.permissions.read',$oDocument) == true){ + // NOTE this is to turn the config setting for the PDF directory into a proper URL and not a path + $pdfDir = str_replace($default->varDirectory, 'var/', $default->pdfDirectory); + $swfFile = $pdfDir .'/'. $iDId.'.swf'; + return instaViewlet::display_viewlet($swfFile,$this->pluginDir); + }else{ + die("You don't have permission to view this document."); + } + + } + // get instaView link for a document + function getViewLink($iItemId, $sItemType){ + $item = strToLower($sItemType); + if($item == 'folder'){ + $sItemParameter = '?folderId'; + }else if($item == 'document'){ + $sItemParameter = '?instaview.processor.link&fDocumentId'; + } + + // built server path + global $default; + $sHostPath = "http" . ($default->sslEnabled ? "s" : "") . "://" . $_SERVER['HTTP_HOST']; + + // build link + $sLink = $sHostPath.KTBrowseUtil::buildBaseUrl('action.php?kt_path_info').$sItemParameter.'='.$iItemId; + + return $sLink; + } + + // get rss icon link + function getImageLink($iItemId, $sItemType){ + return "".$this->getIcon().""; + } + // get icon for instaView + function getIcon(){ + // built server path + global $default; + $sHostPath = "http" . ($default->sslEnabled ? "s" : "") . "://".$_SERVER['HTTP_HOST']."/".$GLOBALS['KTRootUrl']."/"; + + // create image + $icon = "InstaView"; + + return $icon; + } +} + +/** + * Main display class for instantView + * + */ +class instaViewlet extends KTDocumentViewlet { + var $sName = 'instaView.viewlets'; + + function display_viewlet($flashdocument,$plugin) { + global $main; + + $main->requireJSResource($plugin."/resources/swfobject.js"); + $oKTTemplating =& KTTemplating::getSingleton(); + $oTemplate =& $oKTTemplating->loadTemplate('instaview_viewlet'); + if (is_null($oTemplate)) return ''; + + $aTemplatesetData =array('document' =>$flashdocument, + 'mainobject' => $plugin."/resources/zviewer.swf", + 'defaultobject' => $plugin."/resources/expressinstall.swf"); + $output = $oTemplate->render($aTemplatesetData); + return $output; + } +} +?> diff --git a/plugins/instaView/instaViewPlugin.php b/plugins/instaView/instaViewPlugin.php new file mode 100755 index 0000000..b4f088f --- /dev/null +++ b/plugins/instaView/instaViewPlugin.php @@ -0,0 +1,63 @@ +sFriendlyName = _kt('InstaView Document Viewer'); + return $res; + } + + function setup() { + $plugin_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR; + $dir = $plugin_dir . 'instaView.php'; + $this->registerProcessor('InstaView', 'instaview.generator.processor', $dir); + $this->registerAction('documentaction', 'instaViewLinkAction', 'instaview.processor.link', 'instaViewLinkAction.php'); + require_once(KT_LIB_DIR . '/templating/templating.inc.php'); + $oTemplating =& KTTemplating::getSingleton(); + $oTemplating->addLocation('InstaView', $plugin_dir.'templates', 'instaview.processor.plugin'); + } + + function run_setup() { + // Check that the license is valid + if (BaobabKeyUtil::getLicenseCount() < MIN_LICENSES) { + return false; + } + return true; + } +} + +$oPluginRegistry =& KTPluginRegistry::getSingleton(); +$oPluginRegistry->registerPlugin('instaViewPlugin', 'instaview.processor.plugin', __FILE__); +?> \ No newline at end of file diff --git a/plugins/instaView/resources/expressinstall.swf b/plugins/instaView/resources/expressinstall.swf new file mode 100755 index 0000000..86958bf --- /dev/null +++ b/plugins/instaView/resources/expressinstall.swf diff --git a/plugins/instaView/resources/swfobject.js b/plugins/instaView/resources/swfobject.js new file mode 100755 index 0000000..c383123 --- /dev/null +++ b/plugins/instaView/resources/swfobject.js @@ -0,0 +1,5 @@ +/* SWFObject v2.0 + Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis + This software is released under the MIT License +*/ +var swfobject=function(){var Z="undefined",P="object",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",W="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,T=null,S=false,C=false;var a=function(){var l=typeof g.getElementById!=Z&&typeof g.getElementsByTagName!=Z&&typeof g.createElement!=Z&&typeof g.appendChild!=Z&&typeof g.replaceChild!=Z&&typeof g.removeChild!=Z&&typeof g.cloneNode!=Z,t=[0,0,0],n=null;if(typeof N.plugins!=Z&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=Z){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var e=function(){if(!a.w3cdom){return }J(I);if(a.ie&&a.win){try{g.write(" +
+

In order to view this page you need Flash Player 9+ support!

+

+ + Get Adobe Flash player

+
+ + {/literal} +{/if} \ No newline at end of file diff --git a/resources/graphics/edit-find.png b/resources/graphics/edit-find.png new file mode 100644 index 0000000..d072d3c --- /dev/null +++ b/resources/graphics/edit-find.png