From 5f281a1e99ce3f9525d2cbef6b836dee007d9ac9 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 24 Apr 2026 08:10:16 +0200 Subject: [PATCH] number of files listed in drop folder can be configured --- inc/inc.ClassSettings.php | 10 ++++ op/op.Settings.php | 2 + out/out.DropFolderChooser.php | 2 + views/bootstrap/class.DropFolderChooser.php | 59 ++++++++++++++------- views/bootstrap/class.Settings.php | 4 +- 5 files changed, 57 insertions(+), 20 deletions(-) diff --git a/inc/inc.ClassSettings.php b/inc/inc.ClassSettings.php index 53de7d8e7..a5b688b31 100644 --- a/inc/inc.ClassSettings.php +++ b/inc/inc.ClassSettings.php @@ -347,6 +347,10 @@ class Settings { /* {{{ */ var $_maxItemsPerPage = 0; // number of documents/folders fetched when scrolling to bottom of ViewFolder page var $_incItemsPerPage = 0; + // maximum number of documents/folders in drop folder menu + var $_maxItemsInDropFolderMenu = 10; + // maximum number of documents/folders in drop folder list + var $_maxItemsInDropFolderList = 30; // parse comments of folders and documents as markdown var $_markdownComments = false; // show dropdown menu for actions on folders/documents @@ -569,6 +573,10 @@ class Settings { /* {{{ */ $this->_maxItemsPerPage = intval($tab["maxItemsPerPage"]); if(isset($tab["incItemsPerPage"])) $this->_incItemsPerPage = intval($tab["incItemsPerPage"]); + if(isset($tab["maxItemsInDropFolderMenu"])) + $this->_maxItemsInDropFolderMenu = intval($tab["maxItemsInDropFolderMenu"]); + if(isset($tab["maxItemsInDropFolderList"])) + $this->_maxItemsInDropFolderList = intval($tab["maxItemsInDropFolderList"]); $this->_markdownComments = Settings::boolVal($tab["markdownComments"]); $this->_actiondropdown = Settings::boolVal($tab["actiondropdown"]); @@ -995,6 +1003,8 @@ class Settings { /* {{{ */ $this->setXMLAttributValue($node, "convertToPdf", $this->_convertToPdf); $this->setXMLAttributValue($node, "maxItemsPerPage", $this->_maxItemsPerPage); $this->setXMLAttributValue($node, "incItemsPerPage", $this->_incItemsPerPage); + $this->setXMLAttributValue($node, "maxItemsInDropFolderMenu", $this->_maxItemsInDropFolderMenu); + $this->setXMLAttributValue($node, "maxItemsInDropFolderList", $this->_maxItemsInDropFolderList); $this->setXMLAttributValue($node, "markdownComments", $this->_markdownComments); $this->setXMLAttributValue($node, "actiondropdown", $this->_actiondropdown); diff --git a/op/op.Settings.php b/op/op.Settings.php index cd68e4e99..4d4e4e5d9 100644 --- a/op/op.Settings.php +++ b/op/op.Settings.php @@ -109,6 +109,8 @@ if ($action == "saveSettings") setBoolValue('convertToPdf'); setIntValue('maxItemsPerPage'); setIntValue('incItemsPerPage'); + setIntValue('maxItemsInDropFolderMenu'); + setIntValue('maxItemsInDropFolderList'); setBoolValue('markdownComments'); setBoolValue('actiondropdown'); diff --git a/out/out.DropFolderChooser.php b/out/out.DropFolderChooser.php index f153830f1..f564e050f 100644 --- a/out/out.DropFolderChooser.php +++ b/out/out.DropFolderChooser.php @@ -66,6 +66,8 @@ if($view) { $view->setParam('cachedir', $settings->_cacheDir); $view->setParam('previewWidthMenuList', $settings->_previewWidthMenuList); $view->setParam('previewWidthList', $settings->_previewWidthDropFolderList); + $view->setParam('maxItemsInDropFolderMenu', $settings->_maxItemsInDropFolderMenu); + $view->setParam('maxItemsInDropFolderList', $settings->_maxItemsInDropFolderList); $view->setParam('convertToPdf', $settings->_convertToPdf); $view->setParam('previewConverters', isset($settings->_converters['preview']) ? $settings->_converters['preview'] : array()); $view->setParam('timeout', $settings->_cmdTimeout); diff --git a/views/bootstrap/class.DropFolderChooser.php b/views/bootstrap/class.DropFolderChooser.php index 84f279ee7..46fa6bcc2 100644 --- a/views/bootstrap/class.DropFolderChooser.php +++ b/views/bootstrap/class.DropFolderChooser.php @@ -47,7 +47,7 @@ $('.folderselect').click(function(ev) { isDir()) - $files[] = [substr($file->getPath(), strlen($path)+1), $file->getFilename()]; - if(count($files) > 20) + if (!$file->isDir()) { + $filesize = filesize($file->getPath().DIRECTORY_SEPARATOR.$file->getFilename()); + $filedate = filectime($file->getPath().DIRECTORY_SEPARATOR.$file->getFilename()); + $files[] = [substr($file->getPath(), strlen($path)+1), $file->getFilename(), $filesize, $filedate]; + } + if(count($files) > ($maxfiles-1)) return $files; } return $files; } - private function getFolders($path, $recursive=false) { + private function getFolders($path, $recursive=false, $maxfiles=20) { if($recursive) $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); else @@ -76,7 +79,7 @@ $('.folderselect').click(function(ev) { if(($t = substr($file->getPath(), strlen($path)+1)) && ($file->getFilename() == '.')) $files[] = $t; } - if(count($files) > 20) + if(count($files) > ($maxfiles-1)) return $files; } @@ -93,6 +96,7 @@ $('.folderselect').click(function(ev) { $cachedir = $this->params['cachedir']; $conversionmgr = $this->params['conversionmgr']; $previewwidth = $this->params['previewWidthMenuList']; + $maxItemsInDropFolderMenu = $this->params['maxItemsInDropFolderMenu']; $previewconverters = $this->params['previewConverters']; $timeout = $this->params['timeout']; $xsendfile = $this->params['xsendfile']; @@ -113,8 +117,10 @@ $('.folderselect').click(function(ev) { */ if(dirname($dir) == $dropfolderdir) { if(is_dir($dir)) { - $files = $this->getFiles($dir, $recursive); - + $files = $this->getFiles($dir, $recursive, $maxItemsInDropFolderMenu); + usort($files, function($a, $b) { + return $a[3] < $b[3]; + }); $finfo = finfo_open(FILEINFO_MIME_TYPE); foreach($files as $file) { $entry = $file[1]; @@ -130,7 +136,7 @@ $('.folderselect').click(function(ev) { $subitem['label'] .= "
_httpRoot."op/op.DropFolderPreview.php?filename=".urlencode($path.DIRECTORY_SEPARATOR.$entry)."&width=".$previewwidth."\" title=\"".htmlspecialchars($mimetype)."\">
"; } } - $subitem['label'] .= "
".htmlspecialchars($path.DIRECTORY_SEPARATOR.$entry)."
".SeedDMS_Core_File::format_filesize(filesize($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry)).", ".date('Y-m-d H:i:s', filectime($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry))."
"; + $subitem['label'] .= "
".htmlspecialchars($path.DIRECTORY_SEPARATOR.$entry)."
".SeedDMS_Core_File::format_filesize($file[2]).", ".getLongReadableDate($file[3])."
"; $menuitems['dropfolder']['children'][] = $subitem; } } @@ -150,6 +156,7 @@ $('.folderselect').click(function(ev) { $cachedir = $this->params['cachedir']; $conversionmgr = $this->params['conversionmgr']; $previewwidth = $this->params['previewWidthList']; + $maxItemsInDropFolderList = $this->params['maxItemsInDropFolderList']; $previewconverters = $this->params['previewConverters']; $timeout = $this->params['timeout']; $xsendfile = $this->params['xsendfile']; @@ -168,9 +175,13 @@ $('.folderselect').click(function(ev) { */ if(dirname($dir) == $dropfolderdir) { if(is_dir($dir)) { - echo "\n"; + echo "
\n"; echo "\n"; - echo "\n"; + echo ""; + if($previewwidth) { + echo ""; + } + echo "\n"; echo "\n"; echo "\n"; $finfo = finfo_open(FILEINFO_MIME_TYPE); @@ -178,24 +189,34 @@ $('.folderselect').click(function(ev) { $folders = $this->getFolders($dir, $recursive); foreach($folders as $entry) { echo ""; - echo ''; + if($previewwidth) { + echo ''; + } echo ""; echo "\n"; } } else { - $files = $this->getFiles($dir, $recursive); + $files = $this->getFiles($dir, $recursive, $maxItemsInDropFolderList); + usort($files, function($a, $b) { + return $a[3] < $b[3]; + }); foreach($files as $file) { $entry = $file[1]; $path = $file[0]; $mimetype = finfo_file($finfo, $dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry); + echo ""; if($previewwidth) { - $previewer->createRawPreview($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry, 'dropfolder'.DIRECTORY_SEPARATOR, $mimetype); - echo "\n"; + $previewer->createRawPreview($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry, 'dropfolder'.DIRECTORY_SEPARATOR, $mimetype); + echo ""; + } } + echo ""; + echo ""; + echo ""; + echo "\n"; } } echo "\n"; diff --git a/views/bootstrap/class.Settings.php b/views/bootstrap/class.Settings.php index b7bd39f7a..a05489e03 100644 --- a/views/bootstrap/class.Settings.php +++ b/views/bootstrap/class.Settings.php @@ -652,6 +652,8 @@ $this->showStartPaneContent('site', (!$currenttab || $currenttab == 'site')); showConfigCheckbox('settings_convertToPdf', 'convertToPdf'); ?> showConfigText('settings_maxItemsPerPage', 'maxItemsPerPage'); ?> showConfigText('settings_incItemsPerPage', 'incItemsPerPage'); ?> +showConfigText('settings_maxItemsInDropFolderMenu', 'maxItemsInDropFolderMenu'); ?> +showConfigText('settings_maxItemsInDropFolderList', 'maxItemsInDropFolderList'); ?> showConfigCheckbox('settings_markdownComments', 'markdownComments'); ?> showConfigCheckbox('settings_actiondropdown', 'actiondropdown'); ?> @@ -737,7 +739,7 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk)) --> showConfigHeadline('settings_Server'); ?> showConfigText('settings_rootDir', 'rootDir'); ?> -showConfigText('settings_baseUrl', 'baseUrl', '', getBaseUrl()); ?> +showConfigText('settings_baseUrl', 'baseUrl', '', $settings->getBaseUrl()); ?> showConfigText('settings_httpRoot', 'httpRoot'); ?> showConfigText('settings_contentDir', 'contentDir'); ?> showConfigText('settings_backupDir', 'backupDir'); ?>
".getMLText('name')."".getMLText('filesize')."".getMLText('date')."
".getMLText('name')."".getMLText('filesize')."".getMLText('date')."
".$entry."
"; - if($previewer->hasRawPreview($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry, 'dropfolder'.DIRECTORY_SEPARATOR)) { - echo ""; - } - echo "".htmlspecialchars($path.DIRECTORY_SEPARATOR.$entry)."".SeedDMS_Core_File::format_filesize(filesize($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry))."".date('Y-m-d H:i:s', filectime($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry))."
"; + if($previewer->hasRawPreview($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry, 'dropfolder'.DIRECTORY_SEPARATOR)) { + echo ""; + echo "".htmlspecialchars($path.DIRECTORY_SEPARATOR.$entry)."".SeedDMS_Core_File::format_filesize($file[2])."".getLongReadableDate($file[3])."