mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
Add a config page in admin for the search filters in the gallery. Privacy and default filters can be selected. Needs a database update.
This commit is contained in:
+15
-12
@@ -33,6 +33,8 @@ $(document).ready(function () {
|
||||
PS_params.search_id = search_id;
|
||||
empty_filters_list = [];
|
||||
|
||||
filters_to_remove = [];
|
||||
|
||||
// Setup word filter
|
||||
if (global_params.fields.allwords) {
|
||||
$(".filter-word").css("display", "flex");
|
||||
@@ -76,6 +78,7 @@ $(document).ready(function () {
|
||||
|
||||
empty_filters_list.push(PS_params.allwords);
|
||||
}
|
||||
|
||||
//Hide filter spinner
|
||||
$(".filter-spinner").hide();
|
||||
|
||||
@@ -87,7 +90,7 @@ $(document).ready(function () {
|
||||
items: global_params.fields.tags ? global_params.fields.tags.words : null,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
if (global_params.fields.tags) {
|
||||
$(".filter-tag").css("display", "flex");
|
||||
$(".filter-manager-controller.tags").prop("checked", true);
|
||||
@@ -569,17 +572,13 @@ $(document).ready(function () {
|
||||
|
||||
empty_filters_list.push(PS_params.ratings);
|
||||
}
|
||||
else if (!show_filter_ratings)
|
||||
{
|
||||
updateFilters('ratings', 'add');
|
||||
}
|
||||
|
||||
// Setup filesize filter
|
||||
if (global_params.fields.filesize_min != null && global_params.fields.filesize_max != null) {
|
||||
|
||||
$(".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);
|
||||
|
||||
@@ -594,7 +593,7 @@ $(document).ready(function () {
|
||||
|
||||
if( global_params.fields.filesize_min != null && global_params.fields.filesize_max > 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
|
||||
{
|
||||
@@ -622,13 +621,13 @@ $(document).ready(function () {
|
||||
if (global_params.fields.height_min != null && global_params.fields.height_max != null) {
|
||||
$(".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) {
|
||||
$(".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
|
||||
{
|
||||
@@ -656,13 +655,13 @@ $(document).ready(function () {
|
||||
if (global_params.fields.width_min != null && global_params.fields.width_max != null) {
|
||||
$(".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) {
|
||||
$(".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
|
||||
{
|
||||
@@ -686,6 +685,10 @@ $(document).ready(function () {
|
||||
empty_filters_list.push(PS_params.width_max);
|
||||
}
|
||||
|
||||
if(filters_to_remove.length > 0){
|
||||
filters_to_remove = [];
|
||||
performSearch(PS_params, true);
|
||||
}
|
||||
|
||||
// Adapt no result message
|
||||
if ($(".filter-filled").length === 0) {
|
||||
@@ -693,7 +696,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'];
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user