filters options implemented and connected to filtered search

This commit is contained in:
Perrom
2025-06-26 16:50:12 +02:00
parent 3b951a0e37
commit c2a46c449e
13 changed files with 608 additions and 108 deletions

View File

@@ -112,6 +112,22 @@ $display_info_checkboxes = array(
'rating_score',
);
$filters_names_checkboxes = array(
"words",
"tags",
"post_date",
"creation_date",
"album",
"author",
"added_by",
"file_type",
"ratio",
"rating",
"file_size",
"height",
"width"
);
// image order management
$sort_fields = array(
'' => '',
@@ -277,6 +293,23 @@ if (isset($_POST['submit']))
$_POST['picture_informations'] = addslashes(serialize($_POST['picture_informations']));
break;
}
case 'search' :
{
foreach( $filters_names_checkboxes as $checkbox)
{
if (empty($_POST['filters_views_box'][$checkbox])){
$_POST['filters_views'][$checkbox]['access'] = 'nobody';
$_POST['filters_views'][$checkbox]['default'] = false;
}
else{
$_POST['filters_views'][$checkbox]['default'] =
empty($_POST['filters_views'][$checkbox]['default'])? false : true;
}
}
$_POST['filters_views']['last_filters_conf'] =
empty($_POST['filters_views']['last_filters_conf'])? false : true;
$_POST['filters_views'] = addslashes(serialize($_POST['filters_views']));
}
}
// updating configuration if no error found
@@ -660,6 +693,18 @@ switch ($page['section'])
break;
}
case 'search':
{
$filters_names = $filters_names_checkboxes;
$template->assign(
'search',
array(
'filters_views' => unserialize($conf['filters_views']),
'filters_names' => $filters_names,
),
);
$template->assign('SHOW_FILTER_RATINGS', $conf['rate']);
}
}
$template->assign('isWebmaster', (is_webmaster()) ? 1 : 0);

View File

@@ -81,6 +81,7 @@ function add_core_tabs($sheets, $tab_id)
$sheets['watermark'] = array('caption' => '<span class="icon-file-image"></span>'.l10n('Watermark'), 'url' => $conf_link.'watermark');
$sheets['display'] = array('caption' => '<span class="icon-television"></span>'.l10n('Display'), 'url' => $conf_link.'display');
$sheets['comments'] = array('caption' => '<span class="icon-chat"></span>'.l10n('Comments'), 'url' => $conf_link.'comments');
$sheets['search'] = array('caption' => '<span class="icon-search"></span>'.l10n('Search'), 'url' => $conf_link.'search');
// $sheets['default'] = array('caption' => l10n('Guest Settings'), 'url' => $conf_link.'default');
break;

View File

@@ -629,7 +629,6 @@ table.dataTable thead th, table.dataTable.no-footer {
background: #3C3C3C;
}
.font-checkbox [class*=icon-check]:before { color:#444; }
#watermarkPositionBox {
border:2px solid #ccc;
@@ -651,7 +650,7 @@ FORM#categoryOrdering p.albumActions .userSeparator {border: 1px solid #E1E1E1;}
.afterUploadActions a.secondary_button {background-color: #ECECEC;}
.afterUploadActions a.secondary_button:hover {background-color: #FFA646;}
.font-checkbox:hover {color: #FFA844;}
.font-checkbox:hover {color: #3C3C3C;}
.font-checkbox.selected {color: #ffa646;}
LEGEND {color: #3C3C3C;}
@@ -910,4 +909,10 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important;
.RenameTagPopInContainer {
background-color:#fff;
}
/* Filters options */
label:has(> .filters-icon-check:disabled), span:has(+ .filters-icon-check:disabled){
color: #D5D5D5 !important;
cursor: not-allowed;
}

View File

@@ -0,0 +1,171 @@
{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'}
{footer_script}
filters_names = ["words","tags","post_date","creation_date","album","author","added_by","file_type","ratio","rating","file_size","height","width"];
for(const filter_name of filters_names){
if(!$("input#"+filter_name+"Filters").is(':checked')){
$("#f"+filter_name+"Select, #"+filter_name+"Arrow").hide();
$("#default_"+filter_name).parent().hide();
}
if($("#f"+filter_name+"Select").val()!="admins-only"){
$("#"+filter_name+"AdminIcon").hide();
}
if($("#default_"+filter_name).is(':checked')){
$("#default_"+filter_name).parent().addClass("selected-filter-container");
}
$("#"+filter_name+"Filters").on("click", function(){
if($("input#"+filter_name+"Filters").is(':checked')){
$("#f"+filter_name+"Select, #"+filter_name+"Arrow").show();
$("#default_"+filter_name).parent().show();
if($("#f"+filter_name+"Select").val()=="admins-only"){
$("#"+filter_name+"AdminIcon").show();
}
}
else{
$("#f"+filter_name+"Select, #"+filter_name+"Arrow, #"+filter_name+"AdminIcon").hide();
$("#default_"+filter_name).parent().hide();
}
})
$("#f"+filter_name+"Select").on("click", function(){
if($("#f"+filter_name+"Select").val()=="admins-only"){
$("#"+filter_name+"AdminIcon").show();
}
else{
$("#"+filter_name+"AdminIcon").hide();
}
})
$("#default_"+filter_name).on("click", function(){
if($("#default_"+filter_name).is(':checked')){
$("#default_"+filter_name).parent().addClass("selected-filter-container");
}
else{
$("#default_"+filter_name).parent().removeClass("selected-filter-container");
}
})
}
{/footer_script}
{combine_css path="themes/default/vendor/fontello/css/gallery-icon.css" order=-10}
<form method="post" action="{$F_ACTION}" class="properties">
<div id="configContent">
<fieldset class="searchConf">
<legend><span class="icon-equalizer icon-blue rotate-element"></span>{'Filters'|translate}</legend>
<ul>
{foreach from=$search.filters_names item=$filter_name}
<li class="filters-grid">
<label class="font-checkbox">
<span class="icon-check"></span>
<input type="checkbox" class="filters-icon-check" name="filters_views_box[{$filter_name}]" id="{$filter_name}Filters" {if ($search.filters_views.$filter_name.access != "nobody" and !($filter_name == "rating" and !$SHOW_FILTER_RATINGS))}checked="checked"{/if} {if ($filter_name == "rating" and !$SHOW_FILTER_RATINGS)}disabled{/if}>
{ucfirst(str_replace('_', ' ', $filter_name))|translate}
</label>
<div class='select-views-arrow icon-down-open' id="{$filter_name}Arrow"> </div>
<select name="filters_views[{$filter_name}][access]" id="f{$filter_name}Select" class="select-views">
<option value="everybody" {if ($search.filters_views.$filter_name.access == "everybody")}selected{/if}>{'Everybody'|translate}</option>
<option value="registered-users" {if ($search.filters_views.$filter_name.access == "registered-users")}selected{/if}>{'Registered users'|translate}</option>
<option value="admins-only" id="{$filter_name}Admin" {if ($search.filters_views.$filter_name.access == "admins-only")}selected{/if}>{'Admins only'|translate}</option>
</select>
<div class='icon-users select-views-admin' id="{$filter_name}AdminIcon"> </div>
</li>
{/foreach}
</ul>
</fieldset>
<fieldset class="searchConf">
<legend><span class="icon-equalizer icon-green rotate-element"></span>{'Default filters'|translate}</legend>
<div class="last-filters">
<label class="font-checkbox">
<span class="icon-check"></span>
<input type="checkbox" class="filters-icon-check" name="filters_views[last_filters_conf]" id="lastFilters" {if ($search.filters_views.last_filters_conf)}checked="checked"{/if}>
{'Set last used filters as default for each users'|translate}
</label>
<span class="icon-help-circled tiptip" title="{'This will be different for each user. Won\'t be applied for unregistered visitors'|translate}" style="cursor:help"></span>
</div>
<label class="filter-manager-options-container">
<span class="mcs-icon-options gallery-icon-search">{'Words'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[words][default]" id="default_words" {if ($search.filters_views.words.default)}checked="checked"{/if} hidden/>
</label>
<label class="filter-manager-options-container">
<span class="mcs-icon-options gallery-icon-tag">{'Tags'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[tags][default]" id="default_tags" {if ($search.filters_views.tags.default)}checked="checked"{/if} hidden/>
</label>
<label class="filter-manager-options-container">
<span class="mcs-icon-options gallery-icon-calendar-plus">{'Post date'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[post_date][default]" id="default_post_date" {if ($search.filters_views.post_date.default)}checked="checked"{/if} hidden/>
</label>
<label class="filter-manager-options-container">
<span class="mcs-icon-options gallery-icon-calendar">{'Creation date'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[creation_date][default]" id="default_creation_date" {if ($search.filters_views.creation_date.default)}checked="checked"{/if} hidden/>
</label>
<label class="filter-manager-options-container">
<span class="mcs-icon-options gallery-icon-album">{'Album'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[album][default]" id="default_album" {if ($search.filters_views.album.default)}checked="checked"{/if} hidden/>
</label>
<label class="filter-manager-options-container">
<span class="mcs-icon-options gallery-icon-user-edit">{'Author'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[author][default]" id="default_author" {if ($search.filters_views.author.default)}checked="checked"{/if} hidden/>
</label>
<label class="filter-manager-options-container">
<span class="mcs-icon-options icon-user-1">{'Added by'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[added_by][default]" id="default_added_by" {if ($search.filters_views.added_by.default)}checked="checked"{/if} hidden/>
</label>
<label class="filter-manager-options-container">
<span class="mcs-icon-options icon-file-image">{'File type'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[file_type][default]" id="default_file_type" {if ($search.filters_views.file_type.default)}checked="checked"{/if} hidden/>
</label>
<label class="filter-manager-options-container">
<span class="mcs-icon-options icon-crop">{'Ratio'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[ratio][default]" id="default_ratio" {if ($search.filters_views.ratio.default)}checked="checked"{/if} hidden/>
</label>
<label class="filter-manager-options-container">
<span class="mcs-icon-options icon-star">{'Rating'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[rating][default]" id="default_rating" {if ($search.filters_views.rating.default)}checked="checked"{/if} hidden/>
</label>
<label class="filter-manager-options-container">
<span class="mcs-icon-options icon-hdd">{'Filesize'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[file_size][default]" id="default_file_size" {if ($search.filters_views.file_size.default)}checked="checked"{/if} hidden/>
</label>
<label class="filter-manager-options-container">
<span class="mcs-icon-options gallery-icon-height">{'Height'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[height][default]" id="default_height" {if ($search.filters_views.height.default)}checked="checked"{/if} hidden/>
</label>
<label class="filter-manager-options-container">
<span class="mcs-icon-options gallery-icon-width">{'Width'|translate}</span>
<input type="checkbox" class="filter-manager-options-check" name="filters_views[width][default]" id="default_width" {if ($search.filters_views.width.default)}checked="checked"{/if} hidden/>
</label>
</fieldset>
</div>
<div class="savebar-footer">
<div class="savebar-footer-start">
</div>
<div class="savebar-footer-end">
{if isset($save_success)}
<div class="savebar-footer-block">
<div class="badge info-message">
<i class="icon-ok"></i>{$save_success}
</div>
</div>
{/if}
<div class="savebar-footer-block">
<button class="buttonLike" type="submit" name="submit" {if $isWebmaster != 1}disabled{/if}><i class="icon-floppy"></i> {'Save Settings'|@translate}</button>
</div>
</div>
<input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
</div>
</form>

View File

@@ -6374,13 +6374,23 @@ table.qsearch_help_table td {
.font-checkbox [class*=icon-check]:before {
font-size:16px;
line-height:16px;
margin-right:0;
margin-right:5px;
margin-left:0;
font-size: 145%;
}
.font-checkbox .icon-check-empty {
position:relative;
left:-1px;
}
.font-checkbox:hover .icon-check-empty, .font-checkbox:hover .icon-check {
color: #FF7700;
}
.font-checkbox .icon-check {
color: #FFA646;
}
.font-checkbox input[type=checkbox], .font-checkbox input[type=radio] {
display:none;
}
@@ -7758,3 +7768,73 @@ color:#FF7B00;
box-shadow: 0px 4px 4px 0px #00000040;
font-size: 10px;
}
/* Filters options */
.filters-check::before{
margin-right: 5px !important;
font-size: 145% !important;
}
.filters-checked-orange::before{
margin-right: 5px !important;
color: #ffa646 !important;
font-size: 145% !important;
}
.filters-grid{
display: grid;
grid-template-columns: 150px 118px 25px;
margin-bottom: 0px !important;
}
.select-views{
background-color: #f3f3f3;
font-size: 11px;
border: none;
height: 16px;
margin-top: 4.5px;
padding-left: 10px;
}
.select-views-arrow{
display: flex;
position: absolute;
margin-left: 249.9px;
margin-top: 5px;
pointer-events: none;
}
.select-views-admin{
margin-left: 3px;
}
.last-filters{
display: block;
margin-bottom: 15px;
font-weight: bold;
}
.filter-manager-options-container{
display: inline-block;
font-size: 11px;
font-weight: normal !important;
color: #474747;
border: 1px solid #777;
border-radius: 20px;
padding: 4px 10px;
cursor: pointer;
margin-right: 7.5px;
margin-bottom: 7.5px;
}
.filter-manager-options-container:hover{
background-color: #EDEDED;
}
.filter-manager-options-container.selected-filter-container{
background-color: #777777;
color: #FFFFFF;
}
.filter-manager-options-container.selected-filter-container:hover{
background-color: #5D5D5D;
}
.mcs-icon-options::before{
margin-right: 5px;
}

View File

@@ -224,7 +224,7 @@ body .ui-resizable-autohide .ui-resizable-handle { display: none; } /* use 'body
#ui-datepicker-div .ui-datepicker-buttonpane .ui-state-error:hover { background: #7e3030;}
INPUT[type="text"].large { width: 317px; }
.buttonLike:disabled, input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled {
.buttonLike:disabled, .filters-icon-check:disabled, input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled {
color:#555;
border-color:#666;
cursor:not-allowed;
@@ -2381,4 +2381,26 @@ ul.jqtree-tree li.jqtree-ghost span.jqtree-line {
.RenameTagPopInContainer {
background-color:#444;
}
/* Filters options */
.select-views{
background-color: #444444;
color: #898888;
border: 1px solid #666;
}
.filter-manager-options-container{
background-color: #333;
color: #aaa;
border-color: #333;
}
.filter-manager-options-container.selected-filter-container{
background-color: #777777;
color: #FFFFFF;
}
label:has(> .filters-icon-check:disabled){
color:#555;
}

View File

@@ -119,10 +119,12 @@ function get_regular_search_results($search, $images_where='')
$image_ids_for_filter = array();
$display_filters = unserialize($conf["filters_views"]);
//
// allwords
//
if (isset($search['fields']['allwords']) and !empty($search['fields']['allwords']['words']) and count($search['fields']['allwords']['fields']) > 0)
if (isset($search['fields']['allwords']) and !empty($search['fields']['allwords']['words']) and count($search['fields']['allwords']['fields']) > 0 and ($display_filters["words"]["access"] == "everybody" or ($display_filters["words"]["access"] == "admins-only" and is_admin()) or ($display_filters["words"]["access"] == "registered-users" and is_classic_user())))
{
$has_filters_filled = true;
@@ -327,12 +329,12 @@ SELECT
//
// filetypes
//
if (!empty($search['fields']['filetypes']))
if (!empty($search['fields']['filetypes']['data']))
{
$has_filters_filled = true;
$filetypes_clauses = array();
foreach ($search['fields']['filetypes'] as $ext)
foreach ($search['fields']['filetypes']['data'] as $ext)
{
$filetypes_clauses[] = 'path LIKE \'%.'.$ext.'\'';
}
@@ -351,7 +353,7 @@ SELECT
//
// added_by
//
if (!empty($search['fields']['added_by']))
if (!empty($search['fields']['added_by']['data']))
{
$has_filters_filled = true;
@@ -360,7 +362,7 @@ SELECT
DISTINCT(id)
FROM '.IMAGES_TABLE.' AS i
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE added_by IN ('.implode(',', $search['fields']['added_by']).')
WHERE added_by IN ('.implode(',', $search['fields']['added_by']['data']).')
'.$forbidden.'
;';
$image_ids_for_filter['added_by'] = query2array($query, null, 'id');
@@ -567,7 +569,7 @@ SELECT
//
// ratios
//
if (!empty($search['fields']['ratios']))
if (!empty($search['fields']['ratios']['data']))
{
$has_filters_filled = true;
@@ -579,7 +581,7 @@ SELECT
);
$ratios_clauses = array();
foreach ($search['fields']['ratios'] as $r)
foreach ($search['fields']['ratios']['data'] as $r)
{
$ratios_clauses[] = $clause_for_ratio[$r];
}
@@ -598,12 +600,12 @@ SELECT
//
// ratings
//
if ($conf['rate'] and !empty($search['fields']['ratings']))
if ($conf['rate'] and !empty($search['fields']['ratings']['data']))
{
$has_filters_filled = true;
$filter_clauses = array();
foreach ($search['fields']['ratings'] as $r)
foreach ($search['fields']['ratings']['data'] as $r)
{
if (0 == $r)
{
@@ -629,7 +631,7 @@ SELECT
//
// filesize
//
if (!empty($search['fields']['filesize_min']) and !empty($search['fields']['filesize_max']))
if (!empty($search['fields']['filesize_min']['data']) and !empty($search['fields']['filesize_max']['data']))
{
$has_filters_filled = true;
@@ -640,7 +642,7 @@ SELECT
DISTINCT(id)
FROM '.IMAGES_TABLE.' AS i
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE filesize BETWEEN '.($search['fields']['filesize_min']-100).' AND '.($search['fields']['filesize_max']+100).'
WHERE filesize BETWEEN '.($search['fields']['filesize_min']['data']-100).' AND '.($search['fields']['filesize_max']['data']+100).'
'.$forbidden.'
;';
$image_ids_for_filter['filesize'] = query2array($query, null, 'id');
@@ -649,7 +651,7 @@ SELECT
//
// height
//
if (!empty($search['fields']['height_min']) and !empty($search['fields']['height_max']))
if (!empty($search['fields']['height_min']['data']) and !empty($search['fields']['height_max']['data']))
{
$has_filters_filled = true;
@@ -658,7 +660,7 @@ SELECT
DISTINCT(id)
FROM '.IMAGES_TABLE.' AS i
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE height BETWEEN '.$search['fields']['height_min'].' AND '.$search['fields']['height_max'].'
WHERE height BETWEEN '.$search['fields']['height_min']['data'].' AND '.$search['fields']['height_max']['data'].'
'.$forbidden.'
;';
$image_ids_for_filter['height'] = query2array($query, null, 'id');
@@ -667,7 +669,7 @@ SELECT
//
// width
//
if (!empty($search['fields']['width_min']) and !empty($search['fields']['width_max']))
if (!empty($search['fields']['width_min']['data']) and !empty($search['fields']['width_max']['data']))
{
$has_filters_filled = true;
@@ -676,7 +678,7 @@ SELECT
DISTINCT(id)
FROM '.IMAGES_TABLE.' AS i
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE width BETWEEN '.$search['fields']['width_min'].' AND '.$search['fields']['width_max'].'
WHERE width BETWEEN '.$search['fields']['width_min']['data'].' AND '.$search['fields']['width_max']['data'].'
'.$forbidden.'
;';
$image_ids_for_filter['width'] = query2array($query, null, 'id');

View File

@@ -6,6 +6,9 @@
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
$filters_views = unserialize($conf['filters_views']);
$template->assign('display_filter', $filters_views);
// we add isset($page['search_details']) in this condition because it only
// applies to regular search, not the legacy qsearch. As Piwigo 14 will still
// be able to show an old quicksearch result, we must check this condtion too.
@@ -40,8 +43,14 @@ if ('search' == $page['section'] and isset($page['search_details']))
$search_items_clause = '1=1';
}
if (isset($my_search['fields']['allwords']))
{
$my_search['fields']['allwords']["access"] = $filters_views["words"]["access"];
}
if (isset($my_search['fields']['tags']))
{
$my_search['fields']['tags']["access"] = $filters_views["tags"]["access"];
$filter_tags = array();
// TODO calling get_available_tags(), with lots of photos/albums/tags may cost time,
@@ -79,6 +88,7 @@ if ('search' == $page['section'] and isset($page['search_details']))
if (isset($my_search['fields']['author']))
{
$my_search['fields']['author']["access"] = $filters_views["author"]["access"];
$filter_clause = get_clause_for_filter('author');
$query = '
@@ -120,6 +130,7 @@ SELECT
if (isset($my_search['fields']['date_posted']))
{
$my_search['fields']['date_posted']["access"] = $filters_views["post_date"]["access"];
$filter_clause = get_clause_for_filter('date_posted');
$cache_key = $persistent_cache->make_key('filter_date_posted'.$user['id'].$user['cache_update_time']);
$set_persistent_cache = !preg_match('/^image_id IN/', $filter_clause) and !$persistent_cache->get($cache_key, $date_posted);
@@ -222,6 +233,7 @@ SELECT
if (isset($my_search['fields']['date_created']))
{
$my_search['fields']['date_created']["access"] = $filters_views["creation_date"]["access"];
$filter_clause = get_clause_for_filter('date_created');
$cache_key = $persistent_cache->make_key('filter_date_created'.$user['id'].$user['cache_update_time']);
$set_persistent_cache = !preg_match('/^image_id IN/', $filter_clause) and !$persistent_cache->get($cache_key, $date_created);
@@ -327,6 +339,7 @@ SELECT
if (isset($my_search['fields']['added_by']))
{
$my_search['fields']['added_by']["access"] = $filters_views["added_by"]["access"];
$filter_clause = get_clause_for_filter('added_by');
$query = '
@@ -385,14 +398,19 @@ SELECT
$template->assign('ADDED_BY', $added_by);
// in case the search has forbidden added_by users for current user, we need to filter the search rule
$my_search['fields']['added_by'] = array_intersect($my_search['fields']['added_by'], $user_ids);
$my_search['fields']['added_by']['data'] = array_intersect($my_search['fields']['added_by']['data'], $user_ids);
}
if (isset($my_search['fields']['cat']) and !empty($my_search['fields']['cat']['words']))
if (isset($my_search['fields']['cat']))
{
$fullname_of = array();
$my_search['fields']['cat']["access"] = $filters_views["album"]["access"];
if (!empty($my_search['fields']['cat']['words']))
{
$my_search['fields']['cat']["access"] = "hahaha";
$fullname_of = array();
$query = '
$query = '
SELECT
id,
uppercats
@@ -400,27 +418,29 @@ SELECT
INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON id = cat_id AND user_id = '.$user['id'].'
WHERE id IN ('.implode(',', $my_search['fields']['cat']['words']).')
;';
$result = pwg_query($query);
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
$cat_display_name = get_cat_display_name_cache(
$row['uppercats'],
'admin.php?page=album-' // TODO not sure it's relevant to link to admin pages
);
$row['fullname'] = strip_tags($cat_display_name);
while ($row = pwg_db_fetch_assoc($result))
{
$cat_display_name = get_cat_display_name_cache(
$row['uppercats'],
'admin.php?page=album-' // TODO not sure it's relevant to link to admin pages
);
$row['fullname'] = strip_tags($cat_display_name);
$fullname_of[$row['id']] = $row['fullname'];
$fullname_of[$row['id']] = $row['fullname'];
}
$template->assign('fullname_of', json_encode($fullname_of));
// in case the search has forbidden albums for current user, we need to filter the search rule
$my_search['fields']['cat']['words'] = array_intersect($my_search['fields']['cat']['words'], array_keys($fullname_of));
}
$template->assign('fullname_of', json_encode($fullname_of));
// in case the search has forbidden albums for current user, we need to filter the search rule
$my_search['fields']['cat']['words'] = array_intersect($my_search['fields']['cat']['words'], array_keys($fullname_of));
}
if (isset($my_search['fields']['filetypes']))
{
$my_search['fields']['filetypes']["access"] = $filters_views["file_type"]["access"];
$filter_clause = get_clause_for_filter('filetypes');
// get all file extensions for this user in the gallery, whatever the current filters
@@ -476,6 +496,7 @@ SELECT
if (isset($my_search['fields']['ratings']))
{
$my_search['fields']['ratings']["access"] = $filters_views["rating"]["access"];
$filter_clause = get_clause_for_filter('ratings');
$cache_key = $persistent_cache->make_key('filter_ratings'.$user['id'].$user['cache_update_time']);
@@ -538,6 +559,8 @@ SELECT
// For filesize
if (isset($my_search['fields']['filesize_min']) && isset($my_search['fields']['filesize_max']))
{
$my_search['fields']['filesize_min']["access"] = $filters_views["file_size"]["access"];
$my_search['fields']['filesize_max']["access"] = $filters_views["file_size"]["access"];
$filter_clause = get_clause_for_filter('filesize');
$filesizes = array();
@@ -576,8 +599,8 @@ SELECT
// current search won't always be the first/last values found. It's going to be a
// problem with this way to select selected values
$filesize['selected'] = array(
'min' => !empty($my_search['fields']['filesize_min']) ? sprintf('%.1f', $my_search['fields']['filesize_min']/1024) : $unique_filesizes[0],
'max' => !empty($my_search['fields']['filesize_max']) ? sprintf('%.1f', $my_search['fields']['filesize_max']/1024) : end($unique_filesizes),
'min' => !empty($my_search['fields']['filesize_min']['data']) ? sprintf('%.1f', $my_search['fields']['filesize_min']['data']/1024) : $unique_filesizes[0],
'max' => !empty($my_search['fields']['filesize_max']['data']) ? sprintf('%.1f', $my_search['fields']['filesize_max']['data']/1024) : end($unique_filesizes),
);
$template->assign('FILESIZE', $filesize );
@@ -585,6 +608,7 @@ SELECT
if (isset($my_search['fields']['ratios']))
{
$my_search['fields']['ratios']["access"] = $filters_views["ratio"]["access"];
$filter_clause = get_clause_for_filter('ratios');
$cache_key = $persistent_cache->make_key('filter_ratios'.$user['id'].$user['cache_update_time']);
@@ -654,6 +678,8 @@ SELECT
if (isset($my_search['fields']['height_min']) and isset($my_search['fields']['height_max']))
{
$my_search['fields']['height_min']["access"] = $filters_views["height"]["access"];
$my_search['fields']['height_max']["access"] = $filters_views["height"]["access"];
$filter_clause = get_clause_for_filter('height');
$query = '
@@ -691,8 +717,8 @@ SELECT
'max' => end($heights),
),
'selected' => array(
'min' => !empty($my_search['fields']['height_min']) ? $my_search['fields']['height_min'] : $heights[0],
'max' => !empty($my_search['fields']['height_max']) ? $my_search['fields']['height_max'] : end($heights),
'min' => !empty($my_search['fields']['height_min']['data']) ? $my_search['fields']['height_min']['data'] : $heights[0],
'max' => !empty($my_search['fields']['height_max']['data']) ? $my_search['fields']['height_max']['data'] : end($heights),
)
);
@@ -701,6 +727,8 @@ SELECT
if (isset($my_search['fields']['width_min']) and isset($my_search['fields']['width_max']))
{
$my_search['fields']['width_min']["access"] = $filters_views["width"]["access"];
$my_search['fields']['width_max']["access"] = $filters_views["width"]["access"];
$filter_clause = get_clause_for_filter('width');
$query = '
@@ -738,8 +766,8 @@ SELECT
'max' => end($widths),
),
'selected' => array(
'min' => !empty($my_search['fields']['width_min']) ? $my_search['fields']['width_min'] : $widths[0],
'max' => !empty($my_search['fields']['width_max']) ? $my_search['fields']['width_max'] : end($widths),
'min' => !empty($my_search['fields']['width_min']['data']) ? $my_search['fields']['width_min']['data'] : $widths[0],
'max' => !empty($my_search['fields']['width_max']['data']) ? $my_search['fields']['width_max']['data'] : end($widths),
)
);

View File

@@ -843,7 +843,7 @@ function ws_images_filteredSearch_create($params, $service)
}
}
$search['fields']['filetypes'] = $params['filetypes'];
$search['fields']['filetypes']['data'] = $params['filetypes'];
}
if (isset($params['added_by']))
@@ -856,7 +856,7 @@ function ws_images_filteredSearch_create($params, $service)
}
}
$search['fields']['added_by'] = $params['added_by'];
$search['fields']['added_by']['data'] = $params['added_by'];
}
if (isset($params['date_posted_preset']))
@@ -1001,42 +1001,42 @@ function ws_images_filteredSearch_create($params, $service)
}
}
$search['fields']['ratios'] = $params['ratios'];
$search['fields']['ratios']['data'] = $params['ratios'];
}
if ($conf['rate'] and isset($params['ratings']))
{
$search['fields']['ratings'] = $params['ratings'];
$search['fields']['ratings']['data'] = $params['ratings'];
}
if (isset($params['filesize_min']))
{
$search['fields']['filesize_min'] = $params['filesize_min'];
$search['fields']['filesize_min']['data'] = $params['filesize_min'];
}
if (isset($params['filesize_max']))
{
$search['fields']['filesize_max'] = $params['filesize_max'];
$search['fields']['filesize_max']['data'] = $params['filesize_max'];
}
if (isset($params['width_min']))
{
$search['fields']['width_min'] = $params['width_min'];
$search['fields']['width_min']['data'] = $params['width_min'];
}
if (isset($params['width_max']))
{
$search['fields']['width_max'] = $params['width_max'];
$search['fields']['width_max']['data'] = $params['width_max'];
}
if (isset($params['height_min']))
{
$search['fields']['height_min'] = $params['height_min'];
$search['fields']['height_min']['data'] = $params['height_min'];
}
if (isset($params['height_max']))
{
$search['fields']['height_max'] = $params['height_max'];
$search['fields']['height_max']['data'] = $params['height_max'];
}
list($search_uuid, $search_url) = save_search($search, $search_info['id'] ?? null);

View File

@@ -80,3 +80,4 @@ INSERT INTO piwigo_config (param,value) VALUES ('index_search_in_set_action','tr
INSERT INTO piwigo_config (param,value) VALUES ('upload_detect_duplicate','true');
INSERT INTO piwigo_config (param,value) VALUES ('webmaster_id','1');
INSERT INTO piwigo_config (param,value) VALUES ('use_standard_pages','true');
INSERT INTO piwigo_config (param,value,comment) VALUES ('filters_views','a:14:{s:5:"words";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:1;}s:4:"tags";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:9:"post_date";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:13:"creation_date";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:1;}s:5:"album";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:1;}s:6:"author";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:8:"added_by";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:9:"file_type";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:5:"ratio";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:6:"rating";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:9:"file_size";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:6:"height";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:5:"width";a:2:{s:6:"access";s:9:"everybody";s:7:"default";b:0;}s:17:"last_filters_conf";b:1;}','Filters displays configuration');

View File

@@ -28,9 +28,23 @@ $search = array(
);
// list of filters in user preferences
// allwords, cat, tags, author, added_by, filetypes, date_posted
$default_fields = array('allwords', 'cat', 'tags', 'author');
if (is_a_guest() or is_generic())
// allwords, cat, tags, author, added_by, filetypes, date_posted, date_created, ratios, ratings (if rating is allowed in this Piwigo), height, width
//import the conf for the filters
$filters_conf = unserialize($conf['filters_views']);
//change the name of the keys so that they can be used with this part of the program
$filters_conf = array_combine(array("allwords", "tags", "date_posted", "date_created", "cat", "author", "added_by", "filetypes", "ratios", "ratings", "filesize", "height", "width", "last_filters_conf"), $filters_conf);
//get all default filters
$default_fields = array();
foreach($filters_conf as $filt_name => $filt_conf){
if(isset($filt_conf["default"])){
if($filt_conf["default"] == true){
$default_fields[] = $filt_name;
}
}
}
if (is_a_guest() or is_generic() or $filters_conf["last_filters_conf"]==false)
{
$fields = $default_fields;
}
@@ -131,11 +145,28 @@ SELECT
}
}
foreach (array('added_by', 'filetypes', 'date_posted') as $field)
foreach (array('added_by', 'filetypes', 'ratios', 'ratings') as $field)
{
if (in_array($field, $fields))
{
$search['fields'][$field] = array();
$search['fields'][$field]["data"] = array();
}
}
foreach (array('date_posted', 'date_created') as $field){
if (in_array($field, $fields))
{
$search['fields'][$field] = array(
'preset' => ''
);
}
}
foreach (array('filesize_min', 'filesize_max', 'width_min', 'width_max', 'height_min', 'height_max') as $field)
{
if (in_array($field, $fields))
{
$search['fields'][$field]["data"] = '';
}
}

View File

@@ -33,8 +33,10 @@ $(document).ready(function () {
PS_params.search_id = search_id;
empty_filters_list = [];
filters_to_remove = [];
// Setup word filter
if (global_params.fields.allwords) {
if (global_params.fields.allwords && (global_params.fields.allwords.access == "everybody" || (global_params.fields.allwords.access == "admins-only" && user_rank == "admin") || (global_params.fields.allwords.access == "registered-users" && user_rank == "user"))) {
$(".filter-word").css("display", "flex");
$(".filter-manager-controller.word").prop("checked", true);
@@ -76,6 +78,13 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.allwords);
}
else if (global_params.fields.allwords && !(global_params.fields.allwords.access == "everybody" || (global_params.fields.allwords.access == "admins-only" && user_rank == "admin") || (global_params.fields.allwords.access == "registered-users" && user_rank == "user")))
{
updateFilters('word', 'del');
filters_to_remove.push("allwords");
}
//Hide filter spinner
$(".filter-spinner").hide();
@@ -87,8 +96,8 @@ $(document).ready(function () {
items: global_params.fields.tags ? global_params.fields.tags.words : null,
});
});
if (global_params.fields.tags) {
if (global_params.fields.tags && (global_params.fields.tags.access == "everybody" || (global_params.fields.tags.access == "admins-only" && user_rank == "admin") || (global_params.fields.tags.access == "registered-users" && user_rank == "user"))) {
$(".filter-tag").css("display", "flex");
$(".filter-manager-controller.tags").prop("checked", true);
$(".filter-tag-form .search-params input[value=" + global_params.fields.tags.mode + "]").prop("checked", true);
@@ -115,8 +124,14 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.tags);
}
else if (global_params.fields.tags && !(global_params.fields.tags.access == "everybody" || (global_params.fields.tags.access == "admins-only" && user_rank == "admin") || (global_params.fields.tags.access == "registered-users" && user_rank == "user")))
{
updateFilters('tag', 'del');
filters_to_remove.push("tags");
}
// Setup Date post filter
if (global_params.fields.date_posted) {
if (global_params.fields.date_posted && (global_params.fields.date_posted.access == "everybody" || (global_params.fields.date_posted.access == "admins-only" && user_rank == "admin") || (global_params.fields.date_posted.access == "registered-users" && user_rank == "user"))) {
$(".filter-date_posted").css("display", "flex");
$(".filter-manager-controller.date_posted").prop("checked", true);
@@ -226,9 +241,15 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.date_posted_custom);
}
else if (global_params.fields.date_posted && !(global_params.fields.date_posted.access == "everybody" || (global_params.fields.date_posted.access == "admins-only" && user_rank == "admin") || (global_params.fields.date_posted.access == "registered-users" && user_rank == "user")))
{
updateFilters('date_posted', 'del');
filters_to_remove.push("date_posted");
}
// Setup Date creation filter
if (global_params.fields.date_created) {
if (global_params.fields.date_created && (global_params.fields.date_created.access == "everybody" || (global_params.fields.date_created.access == "admins-only" && user_rank == "admin") || (global_params.fields.date_created.access == "registered-users" && user_rank == "user"))) {
$(".filter-date_created").css("display", "flex");
$(".filter-manager-controller.date_created").prop("checked", true);
@@ -336,8 +357,14 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.date_created_custom);
}
else if (global_params.fields.date_created && !(global_params.fields.date_created.access == "everybody" || (global_params.fields.date_created.access == "admins-only" && user_rank == "admin") || (global_params.fields.date_created.access == "registered-users" && user_rank == "user")))
{
updateFilters('date_created', 'del');
filters_to_remove.push("date_created");
}
// Setup album filter
if (global_params.fields.cat) {
if (global_params.fields.cat && (global_params.fields.cat.access == "everybody" || (global_params.fields.cat.access == "admins-only" && user_rank == "admin") || (global_params.fields.cat.access == "registered-users" && user_rank == "user"))) {
$(".filter-album").css("display", "flex");
$(".filter-manager-controller.album").prop("checked", true);
@@ -388,6 +415,12 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.categories);
}
else if (global_params.fields.cat && !(global_params.fields.cat.access == "everybody" || (global_params.fields.cat.access == "admins-only" && user_rank == "admin") || (global_params.fields.cat.access == "registered-users" && user_rank == "user")))
{
updateFilters('album', 'del');
filters_to_remove.push("cat");
}
// Setup author filter
$("#authors").each(function() {
@@ -396,7 +429,7 @@ $(document).ready(function () {
maxOptions:$(this).find("option").length,
items: global_params.fields.author ? global_params.fields.author.words : null,
});
if (global_params.fields.author) {
if (global_params.fields.author && (global_params.fields.author.access == "everybody" || (global_params.fields.author.access == "admins-only" && user_rank == "admin") || (global_params.fields.author.access == "registered-users" && user_rank == "user"))) {
$(".filter-authors").css("display", "flex");
$(".filter-manager-controller.author").prop("checked", true);
@@ -420,14 +453,20 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.authors);
}
else if (global_params.fields.author && !(global_params.fields.author.access == "everybody" || (global_params.fields.author.access == "admins-only" && user_rank == "admin") || (global_params.fields.author.access == "registered-users" && user_rank == "user")))
{
updateFilters('author', 'del');
filters_to_remove.push("author");
}
});
// Setup added_by filter
if (global_params.fields.added_by) {
if (global_params.fields.added_by && (global_params.fields.added_by.access == "everybody" || (global_params.fields.added_by.access == "admins-only" && user_rank == "admin") || (global_params.fields.added_by.access == "registered-users" && user_rank == "user"))) {
$(".filter-added_by").css("display", "flex");
$(".filter-manager-controller.added_by").prop("checked", true);
if (global_params.fields.added_by && global_params.fields.added_by.length > 0) {
if (global_params.fields.added_by && global_params.fields.added_by.data.length > 0) {
$(".filter-added_by").addClass("filter-filled");
added_by_names = [];
@@ -436,7 +475,7 @@ $(document).ready(function () {
input = $(this).find('input');
added_by_id = parseInt(input.attr('name'));
if (jQuery.inArray(added_by_id, global_params.fields.added_by) >= 0) {
if (jQuery.inArray(added_by_id, global_params.fields.added_by.data) >= 0) {
input.prop('checked', true);
added_by_names.push($(this).find('.added_by-name').text());
}
@@ -452,27 +491,33 @@ $(document).ready(function () {
$(".filter-added_by .added_by-option input").prop("checked", false);
});
PS_params.added_by = global_params.fields.added_by.length > 0 ? global_params.fields.added_by : '';
PS_params.added_by = global_params.fields.added_by.data.length > 0 ? global_params.fields.added_by.data : '';
empty_filters_list.push(PS_params.added_by);
}
else if (global_params.fields.added_by && !(global_params.fields.added_by.access == "everybody" || (global_params.fields.added_by.access == "admins-only" && user_rank == "admin") || (global_params.fields.added_by.access == "registered-users" && user_rank == "user")))
{
updateFilters('added_by', 'del');
filters_to_remove.push("added_by");
}
// Setup filetypes filter
if (global_params.fields.filetypes) {
if (global_params.fields.filetypes && (global_params.fields.filetypes.access == "everybody" || (global_params.fields.filetypes.access == "admins-only" && user_rank == "admin") || (global_params.fields.filetypes.access == "registered-users" && user_rank == "user"))) {
$(".filter-filetypes").css("display", "flex");
$(".filter-manager-controller.filetypes").prop("checked", true);
filetypes_search_str = "";
global_params.fields.filetypes.forEach(ft => {
global_params.fields.filetypes.data.forEach(ft => {
filetypes_search_str += ft + ", ";
});
if (global_params.fields.filetypes && global_params.fields.filetypes.length > 0) {
if (global_params.fields.filetypes && global_params.fields.filetypes.data.length > 0) {
$(".filter-filetypes").addClass("filter-filled");
$(".filter.filter-filetypes .search-words").text(filetypes_search_str.toUpperCase().slice(0, -2));
$(".filetypes-option input").each(function () {
if (global_params.fields.filetypes.includes($(this).attr('name'))) {
if (global_params.fields.filetypes.data.includes($(this).attr('name'))) {
$(this).prop('checked', true);
}
});
@@ -484,27 +529,33 @@ $(document).ready(function () {
$(".filter-filetypes .filetypes-option input").prop("checked", false);
});
PS_params.filetypes = global_params.fields.filetypes.length > 0 ? global_params.fields.filetypes : '';
PS_params.filetypes = global_params.fields.filetypes.data.length > 0 ? global_params.fields.filetypes.data : '';
empty_filters_list.push(PS_params.filetypes);
}
else if (global_params.fields.filetypes && !(global_params.fields.filetypes.access == "everybody" || (global_params.fields.filetypes.access == "admins-only" && user_rank == "admin") || (global_params.fields.filetypes.access == "registered-users" && user_rank == "user")))
{
updateFilters('filetypes', 'del');
filters_to_remove.push("filetypes");
}
// Setup Ratio filter
if (global_params.fields.ratios) {
if (global_params.fields.ratios && (global_params.fields.ratios.access == "everybody" || (global_params.fields.ratios.access == "admins-only" && user_rank == "admin") || (global_params.fields.ratios.access == "registered-users" && user_rank == "user"))) {
$(".filter-ratios").css("display", "flex");
$(".filter-manager-controller.ratios").prop("checked", true);
ratios_search_str = "";
global_params.fields.ratios.forEach(ft => {
global_params.fields.ratios.data.forEach(ft => {
ratios_search_str += str_ratios_label[ft] + ", ";
});
if (global_params.fields.ratios && global_params.fields.ratios.length > 0) {
if (global_params.fields.ratios && global_params.fields.ratios.data.length > 0) {
$(".filter-ratios").addClass("filter-filled");
$(".filter.filter-ratios .search-words").text(ratios_search_str.slice(0, -2));
$(".ratios-option input").each(function () {
if (global_params.fields.ratios.includes($(this).attr('name'))) {
if (global_params.fields.ratios.data.includes($(this).attr('name'))) {
$(this).prop('checked', true);
}
});
@@ -516,23 +567,29 @@ $(document).ready(function () {
$(".filter-ratios .ratios-option input").prop("checked", false);
});
PS_params.ratios = global_params.fields.ratios.length > 0 ? global_params.fields.ratios : '';
PS_params.ratios = global_params.fields.ratios.data.length > 0 ? global_params.fields.ratios.data : '';
empty_filters_list.push(PS_params.ratios);
}
else if (global_params.fields.ratios && !(global_params.fields.ratios.access == "everybody" || (global_params.fields.ratios.access == "admins-only" && user_rank == "admin") || (global_params.fields.ratios.access == "registered-users" && user_rank == "user")))
{
updateFilters('ratios', 'del');
filters_to_remove.push("ratios");
}
// Setup rating filter
if (global_params.fields.ratings && show_filter_ratings) {
if (global_params.fields.ratings && show_filter_ratings && (global_params.fields.ratings.access == "everybody" || (global_params.fields.ratings.access == "admins-only" && user_rank == "admin") || (global_params.fields.ratings.access == "registered-users" && user_rank == "user"))) {
$(".filter-ratings").css("display", "flex");
$(".filter-manager-controller.ratings").prop("checked", true);
ratings_search_str = "";
global_params.fields.ratings.forEach(function(ft, i){
global_params.fields.ratings.data.forEach(function(ft, i){
if(0 == ft )
{
ratings_search_str += str_no_rating
if(global_params.fields.ratings.length > 1)
if(global_params.fields.ratings.data.length > 1)
{
ratings_search_str += ", ";
}
@@ -541,19 +598,19 @@ $(document).ready(function () {
{
str_between = str_between_rating.split("%d");
ratings_search_str += str_between[0] + (ft-1) + str_between[1] + ft + str_between[2];
if(global_params.fields.ratings.length-1 != i)
if(global_params.fields.ratings.data.length-1 != i)
{
ratings_search_str += ", ";
}
}
});
if (global_params.fields.ratings && global_params.fields.ratings.length > 0) {
if (global_params.fields.ratings && global_params.fields.ratings.data.length > 0) {
$(".filter-ratings").addClass("filter-filled");
$(".filter.filter-ratings .search-words").text(ratings_search_str);
$(".ratings-option input").each(function () {
if (global_params.fields.ratings.includes($(this).attr('name'))) {
if (global_params.fields.ratings.data.includes($(this).attr('name'))) {
$(this).prop('checked', true);
}
});
@@ -565,21 +622,22 @@ $(document).ready(function () {
$(".filter-ratings .ratings-option input").prop("checked", false);
});
PS_params.ratings = global_params.fields.ratings.length > 0 ? global_params.fields.ratings : '';
PS_params.ratings = global_params.fields.ratings.data.length > 0 ? global_params.fields.ratings.data : '';
empty_filters_list.push(PS_params.ratings);
}
else if (!show_filter_ratings)
else if (global_params.fields.ratings && (!show_filter_ratings || global_params.fields.ratings && !(global_params.fields.ratings.access == "everybody" || (global_params.fields.ratings.access == "admins-only" && user_rank == "admin") || (global_params.fields.ratings.access == "registered-users" && user_rank == "user"))))
{
updateFilters('ratings', 'add');
updateFilters('ratings', 'del');
filters_to_remove.push("ratings");
}
// Setup filesize filter
if (global_params.fields.filesize_min != null && global_params.fields.filesize_max != null) {
if (global_params.fields.filesize_min != null && global_params.fields.filesize_max != null && (global_params.fields.filesize_min.access == "everybody" || (global_params.fields.filesize_min.access == "admins-only" && user_rank == "admin") || (global_params.fields.filesize_min.access == "registered-users" && user_rank == "user"))) {
$(".filter-filesize").css("display", "flex");
$(".filter-manager-controller.filesize").prop("checked", true);
$(".filter.filter-filesize .slider-info").html(sprintf(sliders.filesizes.text,sliders.filesizes.selected.min,sliders.filesizes.selected.max,));
$(".filter.filter-filesize .slider-info").html(sprintf(sliders.filesizes.text,sliders.filesizes.selected.min,sliders.filesizes.selected.max));
$('[data-slider=filesizes]').pwgDoubleSlider(sliders.filesizes);
@@ -592,9 +650,9 @@ $(document).ready(function () {
});
if( global_params.fields.filesize_min != null && global_params.fields.filesize_max > 0) {
if( global_params.fields.filesize_min.data != null && global_params.fields.filesize_max.data > 0) {
$(".filter-filesize").addClass("filter-filled");
$(".filter.filter-filesize .search-words").html(sprintf(sliders.filesizes.text,sliders.filesizes.selected.min,sliders.filesizes.selected.max,));
$(".filter.filter-filesize .search-words").html(sprintf(sliders.filesizes.text,sliders.filesizes.selected.min,sliders.filesizes.selected.max));
}
else
{
@@ -611,24 +669,30 @@ $(document).ready(function () {
}
});
PS_params.filesize_min = global_params.fields.filesize_min != null ? global_params.fields.filesize_min : '';
PS_params.filesize_max = global_params.fields.filesize_max != null ? global_params.fields.filesize_max : '';
PS_params.filesize_min = global_params.fields.filesize_min.data != null ? global_params.fields.filesize_min.data : '';
PS_params.filesize_max = global_params.fields.filesize_max.data != null ? global_params.fields.filesize_max.data : '';
empty_filters_list.push(PS_params.filesize_min);
empty_filters_list.push(PS_params.filesize_max);
}
else if (global_params.fields.filesize_min != null && global_params.fields.filesize_max != null && !(global_params.fields.filesize_min.access == "everybody" || (global_params.fields.filesize_min.access == "admins-only" && user_rank == "admin") || (global_params.fields.filesize_min.access == "registered-users" && user_rank == "user")))
{
updateFilters('filesize', 'del');
filters_to_remove.push("filesize");
}
// Setup Height filter
if (global_params.fields.height_min != null && global_params.fields.height_max != null) {
if (global_params.fields.height_min != null && global_params.fields.height_max != null && (global_params.fields.height_min.access == "everybody" || (global_params.fields.height_min.access == "admins-only" && user_rank == "admin") || (global_params.fields.height_min.access == "registered-users" && user_rank == "user"))) {
$(".filter-height").css("display", "flex");
$(".filter-manager-controller.height").prop("checked", true);
$(".filter.filter-height .slider-info").html(sprintf(sliders.heights.text,sliders.heights.selected.min,sliders.heights.selected.max,));
$(".filter.filter-height .slider-info").html(sprintf(sliders.heights.text,sliders.heights.selected.min,sliders.heights.selected.max));
$('[data-slider=heights]').pwgDoubleSlider(sliders.heights);
if( global_params.fields.height_min > 0 && global_params.fields.height_max > 0) {
if( global_params.fields.height_min.data > 0 && global_params.fields.height_max.data > 0) {
$(".filter-height").addClass("filter-filled");
$(".filter.filter-height .search-words").html(sprintf(sliders.heights.text,sliders.heights.selected.min,sliders.heights.selected.max,));
$(".filter.filter-height .search-words").html(sprintf(sliders.heights.text,sliders.heights.selected.min,sliders.heights.selected.max));
}
else
{
@@ -645,24 +709,30 @@ $(document).ready(function () {
}
});
PS_params.height_min = global_params.fields.height_min != null ? global_params.fields.height_min : '';
PS_params.height_max = global_params.fields.height_max != null ? global_params.fields.height_max : '';
PS_params.height_min = global_params.fields.height_min.data != null ? global_params.fields.height_min.data : '';
PS_params.height_max = global_params.fields.height_max.data != null ? global_params.fields.height_max.data : '';
empty_filters_list.push(PS_params.height_min);
empty_filters_list.push(PS_params.height_max);
}
else if (global_params.fields.height_min != null && global_params.fields.height_max != null && !(global_params.fields.height_min.access == "everybody" || (global_params.fields.height_min.access == "admins-only" && user_rank == "admin") || (global_params.fields.height_min.access == "registered-users" && user_rank == "user")))
{
updateFilters('height', 'del');
filters_to_remove.push("height");
}
// Setup Width filter
if (global_params.fields.width_min != null && global_params.fields.width_max != null) {
if (global_params.fields.width_min != null && global_params.fields.width_max != null && (global_params.fields.width_min.access == "everybody" || (global_params.fields.width_min.access == "admins-only" && user_rank == "admin") || (global_params.fields.width_min.access == "registered-users" && user_rank == "user"))) {
$(".filter-width").css("display", "flex");
$(".filter-manager-controller.width").prop("checked", true);
$(".filter.filter-width .slider-info").html(sprintf(sliders.widths.text,sliders.widths.selected.min,sliders.widths.selected.max,));
$(".filter.filter-width .slider-info").html(sprintf(sliders.widths.text,sliders.widths.selected.min,sliders.widths.selected.max));
$('[data-slider=widths]').pwgDoubleSlider(sliders.widths);
if( global_params.fields.width_min > 0 && global_params.fields.width_max > 0) {
if( global_params.fields.width_min.data > 0 && global_params.fields.width_max.data > 0) {
$(".filter-width").addClass("filter-filled");
$(".filter.filter-width .search-words").html(sprintf(sliders.widths.text,sliders.widths.selected.min,sliders.widths.selected.max,));
$(".filter.filter-width .search-words").html(sprintf(sliders.widths.text,sliders.widths.selected.min,sliders.widths.selected.max));
}
else
{
@@ -679,13 +749,23 @@ $(document).ready(function () {
}
});
PS_params.width_min = global_params.fields.width_min != null ? global_params.fields.width_min : '';
PS_params.width_max = global_params.fields.width_max != null ? global_params.fields.width_max : '';
PS_params.width_min = global_params.fields.width_min.data != null ? global_params.fields.width_min.data : '';
PS_params.width_max = global_params.fields.width_max.data != null ? global_params.fields.width_max.data : '';
empty_filters_list.push(PS_params.width_min);
empty_filters_list.push(PS_params.width_max);
}
else if (global_params.fields.width_min != null && global_params.fields.width_max != null && !(global_params.fields.width_min.access == "everybody" || (global_params.fields.width_min.access == "admins-only" && user_rank == "admin") || (global_params.fields.width_min.access == "registered-users" && user_rank == "user")))
{
updateFilters('width', 'del');
filters_to_remove.push("width");
}
if(filters_to_remove.length > 0){
filters_to_remove = [];
performSearch(PS_params, true);
}
// Adapt no result message
if ($(".filter-filled").length === 0) {
@@ -693,7 +773,7 @@ $(document).ready(function () {
$(".mcs-no-result .text .bot").html(str_empty_search_bot_alt);
}
if (!empty_filters_list.every(param => param === "" || param === null)) {
if (!empty_filters_list.every(param => param === "" || param === null || (typeof param == 'undefined'))) {
$(".clear-all").addClass("clickable");
$(".clear-all.clickable").on('click', function () {
exclude_params = ['search_id', 'allwords_mode', 'allwords_fields', 'tags_mode', 'categories_withsubs'];
@@ -1173,7 +1253,7 @@ $(document).ready(function () {
ratios_array.push($(this).attr('name'));
});
global_params.fields.ratios = ratios_array;
global_params.fields.ratios.data = ratios_array;
PS_params.ratios = ratios_array.length > 0 ? ratios_array : '';
}

View File

@@ -23,6 +23,14 @@ fullname_of_cat = {$fullname_of};
search_id = '{$SEARCH_ID}';
{/if}
{if is_admin()}
user_rank = "admin";
{elseif is_classic_user()}
user_rank = "user";
{else}
user_rank = "none";
{/if}
str_word_widget_label = "{'Search for words'|@translate|escape:javascript}";
str_tags_widget_label = "{'Tag'|@translate|escape:javascript}";
str_album_widget_label = "{'Album'|@translate|escape:javascript}";
@@ -101,60 +109,86 @@ const prefix_icon = 'gallery-icon-';
<div class="mcs-popin-title">{'Choose filters'|@translate}</div>
<div class="filter-manager-controller-container">
{if $display_filter.words.access == "everybody" or ($display_filter.words.access == "admins-only" and is_admin()) or ($display_filter.words.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='word' class="filter-manager-controller word" type="checkbox"/>
<span class="mcs-icon gallery-icon-search">{'Search for words'|@translate}</span>
</label>
{/if}
{if $display_filter.tags.access == "everybody" or ($display_filter.tags.access == "admins-only" and is_admin()) or ($display_filter.tags.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='tag' class="filter-manager-controller tags" type="checkbox"/>
<span class="mcs-icon gallery-icon-tag">{'Tag'|@translate}</span>
</label>
{/if}
{if $display_filter.post_date.access == "everybody" or ($display_filter.post_date.access == "admins-only" and is_admin()) or ($display_filter.post_date.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='date_posted' class="filter-manager-controller date_posted" type="checkbox"/>
<span class="mcs-icon gallery-icon-calendar-plus">{'Post date'|@translate}</span>
</label>
{/if}
{if $display_filter.creation_date.access == "everybody" or ($display_filter.creation_date.access == "admins-only" and is_admin()) or ($display_filter.creation_date.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='date_created' class="filter-manager-controller date_created" type="checkbox"/>
<span class="mcs-icon gallery-icon-calendar">{'Creation date'|@translate}</span>
</label>
{/if}
{if $display_filter.album.access == "everybody" or ($display_filter.album.access == "admins-only" and is_admin()) or ($display_filter.album.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='album' class="filter-manager-controller album" type="checkbox"/>
<span class="mcs-icon gallery-icon-album">{'Album'|@translate}</span>
</label>
{/if}
{if $display_filter.author.access == "everybody" or ($display_filter.author.access == "admins-only" and is_admin()) or ($display_filter.author.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='authors' class="filter-manager-controller author" type="checkbox"/>
<span class="mcs-icon gallery-icon-user-edit">{'Author'|@translate}</span>
</label>
{/if}
{if $display_filter.added_by.access == "everybody" or ($display_filter.added_by.access == "admins-only" and is_admin()) or ($display_filter.added_by.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='added_by' class="filter-manager-controller added_by" type="checkbox"/>
<span class="mcs-icon gallery-icon-user">{'Added by'|@translate}</span>
</label>
{/if}
{if $display_filter.file_type.access == "everybody" or ($display_filter.file_type.access == "admins-only" and is_admin()) or ($display_filter.file_type.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='filetypes' class="filter-manager-controller filetypes" type="checkbox"/>
<span class="mcs-icon gallery-icon-file-image">{'File type'|@translate}</span>
</label>
{/if}
{if $display_filter.ratio.access == "everybody" or ($display_filter.ratio.access == "admins-only" and is_admin()) or ($display_filter.ratio.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='ratios' class="filter-manager-controller ratios" type="checkbox"/>
<span class="mcs-icon gallery-icon-crop">{'Ratio'|@translate}</span>
</label>
{/if}
{if $SHOW_FILTER_RATINGS and isset($SHOW_FILTER_RATINGS)}
{if $display_filter.rating.access == "everybody" or ($display_filter.rating.access == "admins-only" and is_admin()) or ($display_filter.rating.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='ratings' class="filter-manager-controller ratings" type="checkbox"/>
<span class="mcs-icon gallery-icon-star-1">{'Rating'|@translate}</span>
</label>
{/if}
{/if}
{if $display_filter.file_size.access == "everybody" or ($display_filter.file_size.access == "admins-only" and is_admin()) or ($display_filter.file_size.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='filesize' class="filter-manager-controller filesize" type="checkbox"/>
<span class="mcs-icon gallery-icon-hdd">{'Filesize'|@translate}</span>
</label>
{/if}
{if $display_filter.height.access == "everybody" or ($display_filter.height.access == "admins-only" and is_admin()) or ($display_filter.height.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='height' class="filter-manager-controller height" type="checkbox"/>
<span class="mcs-icon gallery-icon-height">{'Height'|@translate}</span>
</label>
{/if}
{if $display_filter.width.access == "everybody" or ($display_filter.width.access == "admins-only" and is_admin()) or ($display_filter.width.access == "registered-users" and is_classic_user())}
<label>
<input data-wid='width' class="filter-manager-controller width" type="checkbox"/>
<span class="mcs-icon gallery-icon-width">{'Width'|@translate}</span>
</label>
{/if}
</div>
<div class="filter-manager-actions">