From ae66ec223cd86a51df80636eb09e70b00371f4f0 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 24 Apr 2025 16:31:27 +0200 Subject: [PATCH] add searching for mime types --- out/out.Search.php | 16 ++++++++++++++++ views/bootstrap/class.Search.php | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/out/out.Search.php b/out/out.Search.php index 09c079f50..cae2b796f 100644 --- a/out/out.Search.php +++ b/out/out.Search.php @@ -574,6 +574,21 @@ if($fullsearch) { } /* }}} */ + // Check to see if the search has been restricted to a particular + // mimetype. {{{ + $mimetype = []; + if (isset($_GET["mimetype"])) { + if (!is_array($_GET['mimetype'])) { + if(!empty($_GET['mimetype'])) + $mimetype[] = $_GET['mimetype']; + } else { + foreach($_GET["mimetype"] as $l) { + if($l) + $mimetype[] = $l; + } + } + } /* }}} */ + // status $status = isset($_GET['status']) ? $_GET['status'] : array(); /* @@ -661,6 +676,7 @@ if($fullsearch) { 'startFolder'=>$startFolder, 'owner'=>$ownerobjs, 'status'=>$status, + 'mimetype'=>$mimetype, 'creationstartdate'=>$created['from'], //$createstartdate ? $createstartdate : array(), 'creationenddate'=>$created['to'], //$createenddate ? $createenddate : array(), 'modificationstartdate'=>$modified['from'], diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index 7df547f82..fa6a97844 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -707,6 +707,8 @@ $(document).ready(function() { $openfilterdlg = true; if($status) $openfilterdlg = true; + if($mimetype) + $openfilterdlg = true; if($modifyenddate || $modifystartdate) $openfilterdlg = true; if($expenddate || $expstartdate) @@ -761,6 +763,22 @@ $(document).ready(function() { 'options'=>$options ) ); + $options = []; + foreach($dms->getMimeTypes() as $m) { + $options[] = array($m['mimeType'], $m['mimeType'], in_array($m['mimeType'], $mimetype)/*, array(array('data-subtitle', htmlspecialchars($m['c'].' ×')))*/); + } + $this->formField( + getMLText("mimetype"), + array( + 'element'=>'select', + 'class'=>'chzn-select', + 'name'=>'mimetype[]', + 'multiple'=>true, + 'attributes'=>array(array('data-placeholder', getMLText('select_mimetype')), array('data-no_results_text', getMLText('unknown_mimetype'))), + 'options'=>$options + ) + ); + $this->formField( getMLText("modified")." (".getMLText('from').")", $this->getDateChooser(!empty($modifystartdate) ? getReadableDate($modifystartdate) : null, "modified[from]", $this->params['session']->getLanguage())