diff --git a/plugins/thumbnails/resources/thumbnails.css b/plugins/thumbnails/resources/thumbnails.css new file mode 100644 index 0000000..15d9ed5 --- /dev/null +++ b/plugins/thumbnails/resources/thumbnails.css @@ -0,0 +1,16 @@ +.thumb-shadow { + float:left; + background: url(plugins/thumbnails/templates/shadowAlpha.png) no-repeat bottom right !important; + background: url(plugins/thumbnails/templates/shadow.gif) no-repeat bottom right; + margin: 10px 0 0 10px !important; + margin: 10px 0 0 5px; +} + +.thumb-shadow img { + display: block; + position: relative; + background-color: #fff; + border: 1px solid #a9a9a9; + margin: -6px 6px 6px -6px; + padding: 4px; +} \ No newline at end of file diff --git a/plugins/thumbnails/thumbnails.php b/plugins/thumbnails/thumbnails.php index 99b8a03..7f89bad 100755 --- a/plugins/thumbnails/thumbnails.php +++ b/plugins/thumbnails/thumbnails.php @@ -36,6 +36,7 @@ */ require_once(KT_LIB_DIR . "/actions/documentviewlet.inc.php"); +require_once(KT_LIB_DIR . '/browse/advancedcolumns.inc.php'); require_once(KT_DIR . '/search2/documentProcessor/documentProcessor.inc.php'); /** @@ -134,14 +135,14 @@ class thumbnailGenerator extends BaseProcessor // In addition PDF and (standard) Image files are also supported $mime_types[] = 'application/pdf'; - + $sQuery = "SELECT DISTINCT mimetypes FROM mime_types WHERE mimetypes LIKE 'image/%'"; $aTempRes = DBUtil::getResultArray($sQuery); $count =count($aTempRes); for($i = 0; $i < $count; $i++ ) { $mime_types[] = $aTempRes[$i]['mimetypes']; } - + return $mime_types; } @@ -218,7 +219,7 @@ class thumbnailGenerator extends BaseProcessor else { $cmd = "{$pathConvert} {$srcFile}" . $pageNumber . " -resize 200x200 $thumbnailfile"; } - + $result = KTUtil::pexec($cmd); return true; } @@ -304,4 +305,76 @@ class ThumbnailViewlet extends KTDocumentViewlet { } } +/** + * Displays a column in the Browse view of the document thumbnail + */ +class ThumbnailColumn extends AdvancedColumn { + var $name = 'thumnailcolumn'; + var $namespace = 'thumbnails.generator.column'; + + function ThumbnailColumn() { + $this->label = _kt('Thumbnail'); + } + + function renderHeader($sReturnURL) { + global $main; + + $path = dirname(__FILE__); + + // Get the CSS to render the thumbnail + $main->requireCSSResource('plugins/thumbnails/resources/thumbnails.css'); + return ' '; + } + + /** + * Render the thumbnail for the given document + * + * @param array $aDataRow + * @return string HTML + */ + function renderData($aDataRow) { + if ($aDataRow["type"] == "document") { + $docid = $aDataRow['docid']; + $oDoc = $aDataRow['document']; + + $config = KTConfig::getSingleton(); + $height = $config->get('browse/thumbnail_height', 75); + $rootUrl = $config->get('KnowledgeTree/rootUrl'); + + // Check if the thumbnail exists + global $default; + $varDir = $default->varDirectory; + $thumbnailCheck = $varDir . '/thumbnails/'.$docid.'.jpg'; + + // Use correct slashes for windows + if (strpos(PHP_OS, 'WIN') !== false) { + $thumbnailCheck = str_replace('/', '\\', $thumbnailCheck); + } + + // We won't try generate one - will slow down browsing too much + if (!file_exists($thumbnailCheck)){ + $tag = " +
+