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,12 +280,21 @@ class DocumentPreview { | ||
| 280 | $sInfo .= " </table></div>"; | 280 | $sInfo .= " </table></div>"; |
| 281 | 281 | ||
| 282 | // Check for existence of thumbnail plugin | 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 | // hook into thumbnail plugin to get display for thumbnail | 285 | // hook into thumbnail plugin to get display for thumbnail |
| 285 | include_once(KT_DIR . '/plugins/thumbnails/thumbnails.php'); | 286 | include_once(KT_DIR . '/plugins/thumbnails/thumbnails.php'); |
| 286 | $thumbnailer = new ThumbnailViewlet(); | 287 | $thumbnailer = new ThumbnailViewlet(); |
| 287 | $thumbnailDisplay = $thumbnailer->display_viewlet($sId); | 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 | $sInfo .= "<div>$thumbnailDisplay</div>"; | 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,8 +28,8 @@ require_once(KT_DIR . '/search2/documentProcessor/documentProcessor.inc.php'); | ||
| 28 | * Generates thumbnails of documents using the pdf converter output | 28 | * Generates thumbnails of documents using the pdf converter output |
| 29 | * Dependent on the pdfConverter | 29 | * Dependent on the pdfConverter |
| 30 | */ | 30 | */ |
| 31 | -class thumbnailGenerator extends BaseProcessor | ||
| 32 | -{ | 31 | +class thumbnailGenerator extends BaseProcessor { |
| 32 | + | ||
| 33 | public $order = 3; | 33 | public $order = 3; |
| 34 | protected $namespace = 'thumbnails.generator.processor'; | 34 | protected $namespace = 'thumbnails.generator.processor'; |
| 35 | 35 | ||
| @@ -38,9 +38,7 @@ class thumbnailGenerator extends BaseProcessor | @@ -38,9 +38,7 @@ class thumbnailGenerator extends BaseProcessor | ||
| 38 | * | 38 | * |
| 39 | * @return thumbnailGenerator | 39 | * @return thumbnailGenerator |
| 40 | */ | 40 | */ |
| 41 | - public function thumbnailGenerator() | ||
| 42 | - { | ||
| 43 | - } | 41 | + public function thumbnailGenerator() { } |
| 44 | 42 | ||
| 45 | /** | 43 | /** |
| 46 | * Gets the document path and calls the generator function | 44 | * Gets the document path and calls the generator function |
| @@ -100,7 +98,6 @@ class thumbnailGenerator extends BaseProcessor | @@ -100,7 +98,6 @@ class thumbnailGenerator extends BaseProcessor | ||
| 100 | $mime_types[] = 'application/vnd.oasis.opendocument.spreadsheet'; | 98 | $mime_types[] = 'application/vnd.oasis.opendocument.spreadsheet'; |
| 101 | $mime_types[] = 'application/vnd.oasis.opendocument.spreadsheet-template'; | 99 | $mime_types[] = 'application/vnd.oasis.opendocument.spreadsheet-template'; |
| 102 | 100 | ||
| 103 | - /* OO3 | ||
| 104 | // Office 2007 | 101 | // Office 2007 |
| 105 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; | 102 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; |
| 106 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; | 103 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; |
| @@ -109,7 +106,6 @@ class thumbnailGenerator extends BaseProcessor | @@ -109,7 +106,6 @@ class thumbnailGenerator extends BaseProcessor | ||
| 109 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; | 106 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; |
| 110 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; | 107 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
| 111 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; | 108 | $mime_types[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; |
| 112 | - */ | ||
| 113 | 109 | ||
| 114 | return $mime_types; | 110 | return $mime_types; |
| 115 | } | 111 | } |
| @@ -131,8 +127,10 @@ class thumbnailGenerator extends BaseProcessor | @@ -131,8 +127,10 @@ class thumbnailGenerator extends BaseProcessor | ||
| 131 | - check out ktcore/KTDocumentViewlets.php | 127 | - check out ktcore/KTDocumentViewlets.php |
| 132 | - viewlet class is below | 128 | - viewlet class is below |
| 133 | */ | 129 | */ |
| 130 | + | ||
| 134 | global $default; | 131 | global $default; |
| 135 | - $pdfDir = $default->pdfDirectory; | 132 | + |
| 133 | + $pdfDir = $default->pdfDirectory; | ||
| 136 | $pdfFile = $pdfDir .'/'. $this->document->iId.'.pdf'; | 134 | $pdfFile = $pdfDir .'/'. $this->document->iId.'.pdf'; |
| 137 | $thumbnaildir = $pdfDir."/thumbnails"; | 135 | $thumbnaildir = $pdfDir."/thumbnails"; |
| 138 | $thumbnailfile = $thumbnaildir.'/'.$this->document->iId.'.jpg'; | 136 | $thumbnailfile = $thumbnaildir.'/'.$this->document->iId.'.jpg'; |
| @@ -162,33 +160,45 @@ class thumbnailGenerator extends BaseProcessor | @@ -162,33 +160,45 @@ class thumbnailGenerator extends BaseProcessor | ||
| 162 | } | 160 | } |
| 163 | 161 | ||
| 164 | } | 162 | } |
| 163 | + | ||
| 165 | } | 164 | } |
| 166 | 165 | ||
| 167 | class ThumbnailViewlet extends KTDocumentViewlet { | 166 | class ThumbnailViewlet extends KTDocumentViewlet { |
| 167 | + | ||
| 168 | var $sName = 'thumbnail.viewlets'; | 168 | var $sName = 'thumbnail.viewlets'; |
| 169 | 169 | ||
| 170 | - public function display_viewlet($documentId) { | 170 | + public function display_viewlet($documentId) |
| 171 | + { | ||
| 171 | global $default; | 172 | global $default; |
| 173 | + | ||
| 172 | $oKTTemplating =& KTTemplating::getSingleton(); | 174 | $oKTTemplating =& KTTemplating::getSingleton(); |
| 173 | $oTemplate =& $oKTTemplating->loadTemplate('thumbnail_viewlet'); | 175 | $oTemplate =& $oKTTemplating->loadTemplate('thumbnail_viewlet'); |
| 176 | + | ||
| 174 | if (is_null($oTemplate)) return ''; | 177 | if (is_null($oTemplate)) return ''; |
| 175 | - $pdfDir = $default->pdfDirectory; | 178 | + |
| 179 | + $pdfDir = $default->pdfDirectory; | ||
| 176 | $thumbnailfile = $pdfDir . '/thumbnails/'.$documentId.'.jpg'; | 180 | $thumbnailfile = $pdfDir . '/thumbnails/'.$documentId.'.jpg'; |
| 177 | - // check that file exists | 181 | + |
| 182 | + // check that file exists | ||
| 178 | if (!file_exists($thumbnailfile)) return ''; | 183 | if (!file_exists($thumbnailfile)) return ''; |
| 179 | // NOTE this is to turn the config setting for the PDF directory into a proper URL and not a path | 184 | // NOTE this is to turn the config setting for the PDF directory into a proper URL and not a path |
| 180 | $thumbnailUrl = str_replace($default->varDirectory, 'var/', $thumbnailfile); | 185 | $thumbnailUrl = str_replace($default->varDirectory, 'var/', $thumbnailfile); |
| 181 | $oTemplate->setData(array('thumbnail' => $thumbnailUrl)); | 186 | $oTemplate->setData(array('thumbnail' => $thumbnailUrl)); |
| 187 | + | ||
| 182 | return $oTemplate->render(); | 188 | return $oTemplate->render(); |
| 183 | } | 189 | } |
| 184 | 190 | ||
| 185 | - public function get_width($documentId){ | 191 | + public function get_width($documentId) |
| 192 | + { | ||
| 186 | global $default; | 193 | global $default; |
| 187 | - $pdfDir = $default->pdfDirectory; | 194 | + |
| 195 | + $pdfDir = $default->pdfDirectory; | ||
| 188 | $thumbnailfile = $pdfDir . '/thumbnails/'.$documentId.'.jpg'; | 196 | $thumbnailfile = $pdfDir . '/thumbnails/'.$documentId.'.jpg'; |
| 189 | $size = getimagesize($thumbnailfile); | 197 | $size = getimagesize($thumbnailfile); |
| 190 | - return $size[0]; | 198 | + |
| 199 | + return $size[0]; | ||
| 191 | } | 200 | } |
| 201 | + | ||
| 192 | } | 202 | } |
| 193 | 203 | ||
| 194 | ?> | 204 | ?> |
| 195 | \ No newline at end of file | 205 | \ No newline at end of file |
view.php
| @@ -251,12 +251,22 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { | @@ -251,12 +251,22 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { | ||
| 251 | 251 | ||
| 252 | // check for a thumbnail | 252 | // check for a thumbnail |
| 253 | $thumbnail = ''; | 253 | $thumbnail = ''; |
| 254 | - if (KTPluginUtil::pluginIsActive('thumbnails.generator.processor.plugin')) { | 254 | + if (KTPluginUtil::pluginIsActive('thumbnails.generator.processor.plugin')) |
| 255 | + { | ||
| 255 | // hook into thumbnail plugin to get display for thumbnail | 256 | // hook into thumbnail plugin to get display for thumbnail |
| 256 | include_once(KT_DIR . '/plugins/thumbnails/thumbnails.php'); | 257 | include_once(KT_DIR . '/plugins/thumbnails/thumbnails.php'); |
| 257 | $thumbnailer = new ThumbnailViewlet(); | 258 | $thumbnailer = new ThumbnailViewlet(); |
| 258 | $thumbnailDisplay = $thumbnailer->display_viewlet($document_id); | 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 | $thumbnail = $thumbnailDisplay; | 270 | $thumbnail = $thumbnailDisplay; |
| 261 | } | 271 | } |
| 262 | } | 272 | } |