Commit eb5cf7a7b8fe3b0bcaee284e78d5c529d2da50a5
1 parent
314ef3ee
Added instaview link functionality for thumbnail display on preview pane and document details page
Story ID:1319317. Instant View should be triggered by click on thumbnail Fixed Committed by: Paul Barrett Reviewed by: Prince Mbekwa
Showing
3 changed files
with
47 additions
and
18 deletions
plugins/ktstandard/documentpreview/documentPreview.php
| ... | ... | @@ -280,12 +280,21 @@ class DocumentPreview { |
| 280 | 280 | $sInfo .= " </table></div>"; |
| 281 | 281 | |
| 282 | 282 | // Check for existence of thumbnail plugin |
| 283 | - if (KTPluginUtil::pluginIsActive('thumbnails.generator.processor.plugin')) { | |
| 283 | + if (KTPluginUtil::pluginIsActive('thumbnails.generator.processor.plugin')) | |
| 284 | + { | |
| 284 | 285 | // hook into thumbnail plugin to get display for thumbnail |
| 285 | 286 | include_once(KT_DIR . '/plugins/thumbnails/thumbnails.php'); |
| 286 | 287 | $thumbnailer = new ThumbnailViewlet(); |
| 287 | 288 | $thumbnailDisplay = $thumbnailer->display_viewlet($sId); |
| 288 | - if ($thumbnailDisplay != '') { | |
| 289 | + if ($thumbnailDisplay != '') | |
| 290 | + { | |
| 291 | + // check for existence and status of instant view plugin | |
| 292 | + if (KTPluginUtil::pluginIsActive('instaview.processor.plugin')) | |
| 293 | + { | |
| 294 | + require_once KTPluginUtil::getPluginPath('instaview.processor.plugin') . 'instaViewLinkAction.php'; | |
| 295 | + $ivLinkAction = new instaViewLinkAction(); | |
| 296 | + $thumbnailDisplay = '<a href="' . $ivLinkAction->getViewLink($sId, 'document') . '" target="_blank">' . $thumbnailDisplay . '</a>'; | |
| 297 | + } | |
| 289 | 298 | $sInfo .= "<div>$thumbnailDisplay</div>"; |
| 290 | 299 | } |
| 291 | 300 | } | ... | ... |
plugins/thumbnails/thumbnails.php
| ... | ... | @@ -28,8 +28,8 @@ require_once(KT_DIR . '/search2/documentProcessor/documentProcessor.inc.php'); |
| 28 | 28 | * Generates thumbnails of documents using the pdf converter output |
| 29 | 29 | * Dependent on the pdfConverter |
| 30 | 30 | */ |
| 31 | -class thumbnailGenerator extends BaseProcessor | |
| 32 | -{ | |
| 31 | +class thumbnailGenerator extends BaseProcessor { | |
| 32 | + | |
| 33 | 33 | public $order = 3; |
| 34 | 34 | protected $namespace = 'thumbnails.generator.processor'; |
| 35 | 35 | |
| ... | ... | @@ -38,9 +38,7 @@ class thumbnailGenerator extends BaseProcessor |
| 38 | 38 | * |
| 39 | 39 | * @return thumbnailGenerator |
| 40 | 40 | */ |
| 41 | - public function thumbnailGenerator() | |
| 42 | - { | |
| 43 | - } | |
| 41 | + public function thumbnailGenerator() { } | |
| 44 | 42 | |
| 45 | 43 | /** |
| 46 | 44 | * Gets the document path and calls the generator function |
| ... | ... | @@ -100,7 +98,6 @@ class thumbnailGenerator extends BaseProcessor |
| 100 | 98 | $mime_types[] = 'application/vnd.oasis.opendocument.spreadsheet'; |
| 101 | 99 | $mime_types[] = 'application/vnd.oasis.opendocument.spreadsheet-template'; |
| 102 | 100 | |
| 103 | - /* OO3 | |
| 104 | 101 | // Office 2007 |
| 105 | 102 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; |
| 106 | 103 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; |
| ... | ... | @@ -109,7 +106,6 @@ class thumbnailGenerator extends BaseProcessor |
| 109 | 106 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; |
| 110 | 107 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
| 111 | 108 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; |
| 112 | - */ | |
| 113 | 109 | |
| 114 | 110 | return $mime_types; |
| 115 | 111 | } |
| ... | ... | @@ -131,8 +127,10 @@ class thumbnailGenerator extends BaseProcessor |
| 131 | 127 | - check out ktcore/KTDocumentViewlets.php |
| 132 | 128 | - viewlet class is below |
| 133 | 129 | */ |
| 130 | + | |
| 134 | 131 | global $default; |
| 135 | - $pdfDir = $default->pdfDirectory; | |
| 132 | + | |
| 133 | + $pdfDir = $default->pdfDirectory; | |
| 136 | 134 | $pdfFile = $pdfDir .'/'. $this->document->iId.'.pdf'; |
| 137 | 135 | $thumbnaildir = $pdfDir."/thumbnails"; |
| 138 | 136 | $thumbnailfile = $thumbnaildir.'/'.$this->document->iId.'.jpg'; |
| ... | ... | @@ -162,33 +160,45 @@ class thumbnailGenerator extends BaseProcessor |
| 162 | 160 | } |
| 163 | 161 | |
| 164 | 162 | } |
| 163 | + | |
| 165 | 164 | } |
| 166 | 165 | |
| 167 | 166 | class ThumbnailViewlet extends KTDocumentViewlet { |
| 167 | + | |
| 168 | 168 | var $sName = 'thumbnail.viewlets'; |
| 169 | 169 | |
| 170 | - public function display_viewlet($documentId) { | |
| 170 | + public function display_viewlet($documentId) | |
| 171 | + { | |
| 171 | 172 | global $default; |
| 173 | + | |
| 172 | 174 | $oKTTemplating =& KTTemplating::getSingleton(); |
| 173 | 175 | $oTemplate =& $oKTTemplating->loadTemplate('thumbnail_viewlet'); |
| 176 | + | |
| 174 | 177 | if (is_null($oTemplate)) return ''; |
| 175 | - $pdfDir = $default->pdfDirectory; | |
| 178 | + | |
| 179 | + $pdfDir = $default->pdfDirectory; | |
| 176 | 180 | $thumbnailfile = $pdfDir . '/thumbnails/'.$documentId.'.jpg'; |
| 177 | - // check that file exists | |
| 181 | + | |
| 182 | + // check that file exists | |
| 178 | 183 | if (!file_exists($thumbnailfile)) return ''; |
| 179 | 184 | // NOTE this is to turn the config setting for the PDF directory into a proper URL and not a path |
| 180 | 185 | $thumbnailUrl = str_replace($default->varDirectory, 'var/', $thumbnailfile); |
| 181 | 186 | $oTemplate->setData(array('thumbnail' => $thumbnailUrl)); |
| 187 | + | |
| 182 | 188 | return $oTemplate->render(); |
| 183 | 189 | } |
| 184 | 190 | |
| 185 | - public function get_width($documentId){ | |
| 191 | + public function get_width($documentId) | |
| 192 | + { | |
| 186 | 193 | global $default; |
| 187 | - $pdfDir = $default->pdfDirectory; | |
| 194 | + | |
| 195 | + $pdfDir = $default->pdfDirectory; | |
| 188 | 196 | $thumbnailfile = $pdfDir . '/thumbnails/'.$documentId.'.jpg'; |
| 189 | 197 | $size = getimagesize($thumbnailfile); |
| 190 | - return $size[0]; | |
| 198 | + | |
| 199 | + return $size[0]; | |
| 191 | 200 | } |
| 201 | + | |
| 192 | 202 | } |
| 193 | 203 | |
| 194 | 204 | ?> |
| 195 | 205 | \ No newline at end of file | ... | ... |
view.php
| ... | ... | @@ -251,12 +251,22 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 251 | 251 | |
| 252 | 252 | // check for a thumbnail |
| 253 | 253 | $thumbnail = ''; |
| 254 | - if (KTPluginUtil::pluginIsActive('thumbnails.generator.processor.plugin')) { | |
| 254 | + if (KTPluginUtil::pluginIsActive('thumbnails.generator.processor.plugin')) | |
| 255 | + { | |
| 255 | 256 | // hook into thumbnail plugin to get display for thumbnail |
| 256 | 257 | include_once(KT_DIR . '/plugins/thumbnails/thumbnails.php'); |
| 257 | 258 | $thumbnailer = new ThumbnailViewlet(); |
| 258 | 259 | $thumbnailDisplay = $thumbnailer->display_viewlet($document_id); |
| 259 | - if ($thumbnailDisplay != '') { | |
| 260 | + if ($thumbnailDisplay != '') | |
| 261 | + { | |
| 262 | + // check for existence and status of instant view plugin | |
| 263 | + if (KTPluginUtil::pluginIsActive('instaview.processor.plugin')) | |
| 264 | + { | |
| 265 | + require_once KTPluginUtil::getPluginPath('instaview.processor.plugin') . 'instaViewLinkAction.php'; | |
| 266 | + $ivLinkAction = new instaViewLinkAction(); | |
| 267 | + $thumbnailDisplay = '<a href="' . $ivLinkAction->getViewLink($document_id, 'document') . '" target="_blank">' . $thumbnailDisplay . '</a>'; | |
| 268 | + } | |
| 269 | + | |
| 260 | 270 | $thumbnail = $thumbnailDisplay; |
| 261 | 271 | } |
| 262 | 272 | } | ... | ... |