mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
issue #2202 search filter, always display all filetypes
This commit is contained in:
@@ -433,7 +433,27 @@ SELECT
|
||||
{
|
||||
$filter_clause = get_clause_for_filter('filetypes');
|
||||
|
||||
$query = '
|
||||
// get all file extensions for this user in the gallery, whatever the current filters
|
||||
$cache_key = $persistent_cache->make_key('file_exts'.$user['id'].$user['cache_update_time']);
|
||||
if (!$persistent_cache->get($cache_key, $all_exts))
|
||||
{
|
||||
$query = '
|
||||
SELECT
|
||||
SUBSTRING_INDEX(path, ".", -1) AS ext,
|
||||
COUNT(DISTINCT(id)) AS counter
|
||||
FROM '.IMAGES_TABLE.' AS i
|
||||
JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.image_id = i.id
|
||||
WHERE 1=1'.$page['search_details']['forbidden'].'
|
||||
GROUP BY ext
|
||||
ORDER BY counter DESC
|
||||
;';
|
||||
$all_exts = query2array($query, 'ext', 'counter');
|
||||
$persistent_cache->set($cache_key, $all_exts);
|
||||
}
|
||||
|
||||
if (preg_match('/^image_id IN/', $filter_clause))
|
||||
{
|
||||
$query = '
|
||||
SELECT
|
||||
SUBSTRING_INDEX(path, ".", -1) AS ext,
|
||||
COUNT(DISTINCT(id)) AS counter
|
||||
@@ -443,7 +463,20 @@ SELECT
|
||||
GROUP BY ext
|
||||
ORDER BY counter DESC
|
||||
;';
|
||||
$template->assign('FILETYPES', query2array($query, 'ext', 'counter'));
|
||||
$filtered_exts = query2array($query, 'ext', 'counter');
|
||||
|
||||
$exts = array();
|
||||
foreach ($all_exts as $ext => $counter)
|
||||
{
|
||||
$exts[$ext] = $filtered_exts[$ext] ?? 0;
|
||||
}
|
||||
|
||||
$template->assign('FILETYPES', $exts);
|
||||
}
|
||||
else
|
||||
{
|
||||
$template->assign('FILETYPES', $all_exts);
|
||||
}
|
||||
}
|
||||
|
||||
// For rating
|
||||
|
||||
@@ -136,11 +136,13 @@
|
||||
}
|
||||
|
||||
.ratios-option.disabled label .ratio-badge,
|
||||
.filetypes-option.disabled label .ext-badge,
|
||||
.ratings-option.disabled label .ratings-badge{
|
||||
background-color: #888;
|
||||
}
|
||||
|
||||
.ratios-option.disabled label .ratio-name,
|
||||
.filetypes-option.disabled label .ext-name,
|
||||
.ratings-option.disabled label .ratings-name{
|
||||
color:#888
|
||||
}
|
||||
|
||||
@@ -136,11 +136,13 @@
|
||||
}
|
||||
|
||||
.ratios-option.disabled label .ratio-badge,
|
||||
.filetypes-option.disabled label .ext-badge,
|
||||
.ratings-option.disabled label .ratings-badge{
|
||||
background-color: #888;
|
||||
}
|
||||
|
||||
.ratios-option.disabled label .ratio-name,
|
||||
.filetypes-option.disabled label .ext-name,
|
||||
.ratings-option.disabled label .ratings-name{
|
||||
color:#888
|
||||
}
|
||||
|
||||
@@ -401,12 +401,12 @@ const prefix_icon = 'gallery-icon-';
|
||||
<div class="form-container">
|
||||
<div class="filetypes-option-container">
|
||||
{foreach from=$FILETYPES item=filetypes key=k}
|
||||
<div class="filetypes-option">
|
||||
<input type="checkbox" id="filetype-{$k}" name="{$k}">
|
||||
<div class="filetypes-option {if 0 == $filetypes}disabled{/if}"">
|
||||
<input type="checkbox" id="filetype-{$k}" name="{$k}" {if 0 == $filetypes}disabled{/if}>
|
||||
<label for="filetype-{$k}">
|
||||
<span class="mcs-icon gallery-icon-checkmark checked-icon"></span>
|
||||
<span class="ext-name">{$k}</span>
|
||||
<span class="ext-badge">{$filetypes}</span>
|
||||
{if 0 != $filetypes}<span class="ext-badge">{$filetypes}</span>{/if}
|
||||
</label>
|
||||
</div>
|
||||
{/foreach}
|
||||
|
||||
Reference in New Issue
Block a user