more security improvement and code reorganization

This commit is contained in:
Perrom
2025-07-08 16:58:13 +02:00
parent e85ecfe252
commit 12c532deb3
8 changed files with 204 additions and 229 deletions
+23
View File
@@ -652,6 +652,8 @@ FORM#categoryOrdering p.albumActions .userSeparator {border: 1px solid #E1E1E1;}
.font-checkbox:hover {color: #3C3C3C;}
.font-checkbox.selected {color: #ffa646;}
.font-checkbox:hover .icon-check-empty, .font-checkbox:hover .icon-check {color: #FF7700;}
.font-checkbox .icon-check {color: #FFA646;}
LEGEND {color: #3C3C3C;}
a#showPermissions {color: #5B5B5B; border: 1px solid #D6D6D6; background-color: #FAFAFA;}
@@ -915,4 +917,25 @@ li.plupload_delete a:hover {background: url("images/cancelhover.svg")!important;
label:has(> .filters-icon-check:disabled), span:has(+ .filters-icon-check:disabled){
color: #D5D5D5 !important;
cursor: not-allowed;
}
.select-views{
background-color: #f3f3f3;
}
.filter-manager-options-container{
color: #474747;
}
.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;
}
-31
View File
@@ -6452,14 +6452,6 @@ table.qsearch_help_table td {
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;
}
@@ -7941,15 +7933,6 @@ color:#FF7B00;
}
/* 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;
@@ -7984,7 +7967,6 @@ color:#FF7B00;
display: inline-block;
font-size: 11px;
font-weight: normal !important;
color: #474747;
border: 1px solid #777;
border-radius: 20px;
padding: 4px 10px;
@@ -7993,19 +7975,6 @@ color:#FF7B00;
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;
}
+11 -3
View File
@@ -961,8 +961,6 @@ table.qsearch_help_table td {
border-color: #444;
}
.font-checkbox [class*=icon-check]:before { color:#aaa; }
#cboxLoadedContent { background-color:#333 !important; }
#watermarkPositionBox {
@@ -983,6 +981,8 @@ table.qsearch_help_table td {
.font-checkbox {color: #898888;}
.font-checkbox:hover {color: #ededed;}
.font-checkbox:hover .icon-check-empty, .font-checkbox:hover .icon-check {color: #FF7700;}
.font-checkbox .icon-check {color: #FFA646;}
.with-border legend, .with-border strong {color: #c0c0c0;}
.font-checkbox.selected {color: #ffa646;}
@@ -2396,9 +2396,17 @@ ul.jqtree-tree li.jqtree-ghost span.jqtree-line {
border-color: #333;
}
.filter-manager-options-container:hover{
background-color: #5D5D5D;
}
.filter-manager-options-container.selected-filter-container{
background-color: #777777;
color: #FFFFFF;
color: #ddd;
}
.filter-manager-options-container.selected-filter-container:hover{
background-color: #aaa;
}
label:has(> .filters-icon-check:disabled){
+14 -14
View File
@@ -342,12 +342,12 @@ SELECT
//
// filetypes
//
if (!empty($search['fields']['filetypes']['data']) and $display_filters['file_type']['access'])
if (!empty($search['fields']['filetypes']) and $display_filters['file_type']['access'])
{
$has_filters_filled = true;
$filetypes_clauses = array();
foreach ($search['fields']['filetypes']['data'] as $ext)
foreach ($search['fields']['filetypes'] as $ext)
{
$filetypes_clauses[] = 'path LIKE \'%.'.$ext.'\'';
}
@@ -366,7 +366,7 @@ SELECT
//
// added_by
//
if (!empty($search['fields']['added_by']['data']) and $display_filters['added_by']['access'])
if (!empty($search['fields']['added_by']) and $display_filters['added_by']['access'])
{
$has_filters_filled = true;
@@ -375,7 +375,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']['data']).')
WHERE added_by IN ('.implode(',', $search['fields']['added_by']).')
'.$forbidden.'
;';
$image_ids_for_filter['added_by'] = query2array($query, null, 'id');
@@ -582,7 +582,7 @@ SELECT
//
// ratios
//
if (!empty($search['fields']['ratios']['data']) and $display_filters['ratio']['access'])
if (!empty($search['fields']['ratios']) and $display_filters['ratio']['access'])
{
$has_filters_filled = true;
@@ -594,7 +594,7 @@ SELECT
);
$ratios_clauses = array();
foreach ($search['fields']['ratios']['data'] as $r)
foreach ($search['fields']['ratios'] as $r)
{
$ratios_clauses[] = $clause_for_ratio[$r];
}
@@ -613,12 +613,12 @@ SELECT
//
// ratings
//
if ($conf['rate'] and !empty($search['fields']['ratings']['data']) and $display_filters['rating']['access'])
if ($conf['rate'] and !empty($search['fields']['ratings']) and $display_filters['rating']['access'])
{
$has_filters_filled = true;
$filter_clauses = array();
foreach ($search['fields']['ratings']['data'] as $r)
foreach ($search['fields']['ratings'] as $r)
{
if (0 == $r)
{
@@ -644,7 +644,7 @@ SELECT
//
// filesize
//
if (!empty($search['fields']['filesize_min']['data']) and !empty($search['fields']['filesize_max']['data']) and $display_filters['file_size']['access'])
if (!empty($search['fields']['filesize_min']) and !empty($search['fields']['filesize_max']) and $display_filters['file_size']['access'])
{
$has_filters_filled = true;
@@ -655,7 +655,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']['data']-100).' AND '.($search['fields']['filesize_max']['data']+100).'
WHERE filesize BETWEEN '.($search['fields']['filesize_min']-100).' AND '.($search['fields']['filesize_max']+100).'
'.$forbidden.'
;';
$image_ids_for_filter['filesize'] = query2array($query, null, 'id');
@@ -664,7 +664,7 @@ SELECT
//
// height
//
if (!empty($search['fields']['height_min']['data']) and !empty($search['fields']['height_max']['data']) and $display_filters['height']['access'])
if (!empty($search['fields']['height_min']) and !empty($search['fields']['height_max']) and $display_filters['height']['access'])
{
$has_filters_filled = true;
@@ -673,7 +673,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']['data'].' AND '.$search['fields']['height_max']['data'].'
WHERE height BETWEEN '.$search['fields']['height_min'].' AND '.$search['fields']['height_max'].'
'.$forbidden.'
;';
$image_ids_for_filter['height'] = query2array($query, null, 'id');
@@ -682,7 +682,7 @@ SELECT
//
// width
//
if (!empty($search['fields']['width_min']['data']) and !empty($search['fields']['width_max']['data']) and $display_filters['width']['access'])
if (!empty($search['fields']['width_min']) and !empty($search['fields']['width_max']) and $display_filters['width']['access'])
{
$has_filters_filled = true;
@@ -691,7 +691,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']['data'].' AND '.$search['fields']['width_max']['data'].'
WHERE width BETWEEN '.$search['fields']['width_min'].' AND '.$search['fields']['width_max'].'
'.$forbidden.'
;';
$image_ids_for_filter['width'] = query2array($query, null, 'id');
+104 -40
View File
@@ -14,6 +14,22 @@ $template->assign('display_filter', $filters_views);
// be able to show an old quicksearch result, we must check this condtion too.
if ('search' == $page['section'] and isset($page['search_details']))
{
$display_filters = $filters_views;
foreach($filters_views as $filt_name => $filt_conf){
if(isset($filt_conf['access']))
{
if ($filt_conf['access'] == 'everybody' or ($filt_conf['access'] == 'admins-only' and is_admin()) or ($filt_conf['access'] == 'registered-users' and is_classic_user()))
{
$display_filters[$filt_name]['access'] = true;
}
else
{
$display_filters[$filt_name]['access'] = false;
}
}
}
include_once(PHPWG_ROOT_PATH.'include/functions_search.inc.php');
$my_search = get_search_array($page['search']);
@@ -43,14 +59,13 @@ if ('search' == $page['section'] and isset($page['search_details']))
$search_items_clause = '1=1';
}
if (isset($my_search['fields']['allwords']))
if (isset($my_search['fields']['allwords']) and !($display_filters['words']['access']))
{
$my_search['fields']['allwords']['access'] = $filters_views['words']['access'];
unset($my_search['fields']['allwords']);
}
if (isset($my_search['fields']['tags']))
if (isset($my_search['fields']['tags']) and $display_filters['tags']['access'])
{
$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,
@@ -86,9 +101,13 @@ if ('search' == $page['section'] and isset($page['search_details']))
$my_search['fields']['tags']['words'] = array_intersect($my_search['fields']['tags']['words'], $filter_tag_ids);
}
if (isset($my_search['fields']['author']))
else if (isset($my_search['fields']['tags']) and !($display_filters['tags']['access']))
{
unset($my_search['fields']['tags']);
}
if (isset($my_search['fields']['author']) and $display_filters['author']['access'])
{
$my_search['fields']['author']['access'] = $filters_views['author']['access'];
$filter_clause = get_clause_for_filter('author');
$query = '
@@ -128,9 +147,13 @@ SELECT
$my_search['fields']['author']['words'] = array_intersect($my_search['fields']['author']['words'], $author_names);
}
if (isset($my_search['fields']['date_posted']))
else if (isset($my_search['fields']['author']) and !($display_filters['author']['access']))
{
unset($my_search['fields']['author']);
}
if (isset($my_search['fields']['date_posted']) and $display_filters['post_date']['access'])
{
$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);
@@ -231,9 +254,13 @@ SELECT
$template->assign('DATE_POSTED', $counters);
}
if (isset($my_search['fields']['date_created']))
else if (isset($my_search['fields']['date_posted']) and !($display_filters['post_date']['access']))
{
unset($my_search['fields']['date_posted']);
}
if (isset($my_search['fields']['date_created']) and $display_filters['creation_date']['access'])
{
$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);
@@ -336,10 +363,13 @@ SELECT
$template->assign('DATE_CREATED', $counters);
}
if (isset($my_search['fields']['added_by']))
else if (isset($my_search['fields']['date_created']) and !($display_filters['creation_date']['access']))
{
unset($my_search['fields']['date_created']);
}
if (isset($my_search['fields']['added_by']) and $display_filters['added_by']['access'])
{
$my_search['fields']['added_by']['access'] = $filters_views['added_by']['access'];
$filter_clause = get_clause_for_filter('added_by');
$query = '
@@ -398,13 +428,16 @@ 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']['data'] = array_intersect($my_search['fields']['added_by']['data'], $user_ids);
$my_search['fields']['added_by'] = array_intersect($my_search['fields']['added_by'], $user_ids);
}
if (isset($my_search['fields']['cat']))
else if (isset($my_search['fields']['added_by']) and !($display_filters['added_by']['access']))
{
unset($my_search['fields']['added_by']);
}
if (isset($my_search['fields']['cat']) and $display_filters['album']['access'])
{
$my_search['fields']['cat']['access'] = $filters_views['album']['access'];
if (!empty($my_search['fields']['cat']['words']))
{
$fullname_of = array();
@@ -437,9 +470,13 @@ SELECT
}
}
if (isset($my_search['fields']['filetypes']))
else if (isset($my_search['fields']['cat']) and !($display_filters['album']['access']))
{
unset($my_search['fields']['cat']);
}
if (isset($my_search['fields']['filetypes']) and $display_filters['file_type']['access'])
{
$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
@@ -488,14 +525,18 @@ SELECT
}
}
else if (isset($my_search['fields']['filetypes']) and !($display_filters['file_type']['access']))
{
unset($my_search['fields']['filetypes']);
}
// For rating
if ($conf['rate'])
{
$template->assign('SHOW_FILTER_RATINGS', true);
if (isset($my_search['fields']['ratings']))
if (isset($my_search['fields']['ratings']) and $display_filters['rating']['access'])
{
$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']);
@@ -549,17 +590,23 @@ SELECT
}
$template->assign('RATING', $ratings);
}
else if (isset($my_search['fields']['ratings']) and !($display_filters['rating']['access']))
{
unset($my_search['fields']['ratings']);
}
}
else
{
$template->assign('SHOW_FILTER_RATINGS', false);
if (isset($my_search['fields']['ratings']))
{
unset($my_search['fields']['ratings']);
}
}
// For filesize
if (isset($my_search['fields']['filesize_min']) && isset($my_search['fields']['filesize_max']))
if (isset($my_search['fields']['filesize_min']) && isset($my_search['fields']['filesize_max']) and $display_filters['file_size']['access'])
{
$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();
@@ -598,16 +645,21 @@ 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']['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),
'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),
);
$template->assign('FILESIZE', $filesize );
}
if (isset($my_search['fields']['ratios']))
else if (isset($my_search['fields']['filesize_min']) && isset($my_search['fields']['filesize_max']) and !($display_filters['file_size']['access']))
{
unset($my_search['fields']['filesize_min']);
unset($my_search['fields']['filesize_max']);
}
if (isset($my_search['fields']['ratios']) and $display_filters['ratio']['access'])
{
$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']);
@@ -671,14 +723,16 @@ SELECT
$persistent_cache->set($cache_key, $ratios);
}
}
$template->assign('RATIOS', $ratios);
}
if (isset($my_search['fields']['height_min']) and isset($my_search['fields']['height_max']))
else if (isset($my_search['fields']['ratios']) and !($display_filters['ratio']['access']))
{
unset($my_search['fields']['ratios']);
}
if (isset($my_search['fields']['height_min']) and isset($my_search['fields']['height_max']) and $display_filters['height']['access'])
{
$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 = '
@@ -716,18 +770,22 @@ SELECT
'max' => end($heights),
),
'selected' => array(
'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),
'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),
)
);
$template->assign('HEIGHT', $height);
}
if (isset($my_search['fields']['width_min']) and isset($my_search['fields']['width_max']))
else if (isset($my_search['fields']['height_min']) && isset($my_search['fields']['height_max']) and !($display_filters['height']['access']))
{
unset($my_search['fields']['height_min']);
unset($my_search['fields']['height_max']);
}
if (isset($my_search['fields']['width_min']) and isset($my_search['fields']['width_max']) and $display_filters['width']['access'])
{
$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 = '
@@ -765,14 +823,20 @@ SELECT
'max' => end($widths),
),
'selected' => array(
'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),
'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),
)
);
$template->assign('WIDTH', $width);
}
else if (isset($my_search['fields']['width_min']) && isset($my_search['fields']['width_max']) and !($display_filters['width']['access']))
{
unset($my_search['fields']['width_min']);
unset($my_search['fields']['width_max']);
}
$template->assign(
array(
'GP' => json_encode($my_search),
+10 -10
View File
@@ -843,7 +843,7 @@ function ws_images_filteredSearch_create($params, $service)
}
}
$search['fields']['filetypes']['data'] = $params['filetypes'];
$search['fields']['filetypes'] = $params['filetypes'];
}
if (isset($params['added_by']))
@@ -856,7 +856,7 @@ function ws_images_filteredSearch_create($params, $service)
}
}
$search['fields']['added_by']['data'] = $params['added_by'];
$search['fields']['added_by'] = $params['added_by'];
}
if (isset($params['date_posted_preset']))
@@ -1001,42 +1001,42 @@ function ws_images_filteredSearch_create($params, $service)
}
}
$search['fields']['ratios']['data'] = $params['ratios'];
$search['fields']['ratios'] = $params['ratios'];
}
if ($conf['rate'] and isset($params['ratings']))
{
$search['fields']['ratings']['data'] = $params['ratings'];
$search['fields']['ratings'] = $params['ratings'];
}
if (isset($params['filesize_min']))
{
$search['fields']['filesize_min']['data'] = $params['filesize_min'];
$search['fields']['filesize_min'] = $params['filesize_min'];
}
if (isset($params['filesize_max']))
{
$search['fields']['filesize_max']['data'] = $params['filesize_max'];
$search['fields']['filesize_max'] = $params['filesize_max'];
}
if (isset($params['width_min']))
{
$search['fields']['width_min']['data'] = $params['width_min'];
$search['fields']['width_min'] = $params['width_min'];
}
if (isset($params['width_max']))
{
$search['fields']['width_max']['data'] = $params['width_max'];
$search['fields']['width_max'] = $params['width_max'];
}
if (isset($params['height_min']))
{
$search['fields']['height_min']['data'] = $params['height_min'];
$search['fields']['height_min'] = $params['height_min'];
}
if (isset($params['height_max']))
{
$search['fields']['height_max']['data'] = $params['height_max'];
$search['fields']['height_max'] = $params['height_max'];
}
list($search_uuid, $search_url) = save_search($search, $search_info['id'] ?? null);
+2 -2
View File
@@ -167,7 +167,7 @@ foreach (array('added_by', 'filetypes', 'ratios', 'ratings') as $field)
{
if (in_array($field, $fields))
{
$search['fields'][$field]['data'] = array();
$search['fields'][$field] = array();
}
}
@@ -184,7 +184,7 @@ foreach (array('filesize_min', 'filesize_max', 'width_min', 'width_max', 'height
{
if (in_array($field, $fields))
{
$search['fields'][$field]['data'] = '';
$search['fields'][$field] = '';
}
}
+40 -129
View File
@@ -22,22 +22,10 @@ $(document).ready(function () {
});
global_params.search_id = search_id;
filt_perms = {};
if (!global_params.fields) {
global_params.fields = {};
}
else{
for(var filter_name in global_params.fields){
if (global_params.fields[filter_name]['access'] == 'everybody' || (global_params.fields[filter_name]['access'] == 'admins-only' && user_rank == 'admin') || (global_params.fields[filter_name]['access'] == 'registered-users' && user_rank == 'user'))
{
filt_perms[filter_name] = true;
}
else{
filt_perms[filter_name] = false;
}
}
}
// Declare params sent to pwg.images.filteredSearch.update
// PS for performSearch()
@@ -48,7 +36,7 @@ $(document).ready(function () {
filters_to_remove = [];
// Setup word filter
if (global_params.fields.allwords && filt_perms['allwords']) {
if (global_params.fields.allwords) {
$(".filter-word").css("display", "flex");
$(".filter-manager-controller.word").prop("checked", true);
@@ -91,12 +79,6 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.allwords);
}
else if (global_params.fields.allwords && !(filt_perms['allwords']))
{
updateFilters('word', 'del');
filters_to_remove.push('allwords');
}
//Hide filter spinner
$(".filter-spinner").hide();
@@ -109,7 +91,7 @@ $(document).ready(function () {
});
});
if (global_params.fields.tags && filt_perms['tags']) {
if (global_params.fields.tags) {
$(".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);
@@ -136,14 +118,8 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.tags);
}
else if (global_params.fields.tags && !(filt_perms['tags']))
{
updateFilters('tag', 'del');
filters_to_remove.push('tags');
}
// Setup Date post filter
if (global_params.fields.date_posted && filt_perms['date_posted']) {
if (global_params.fields.date_posted) {
$(".filter-date_posted").css("display", "flex");
$(".filter-manager-controller.date_posted").prop("checked", true);
@@ -253,15 +229,9 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.date_posted_custom);
}
else if (global_params.fields.date_posted && !(filt_perms['date_posted']))
{
updateFilters('date_posted', 'del');
filters_to_remove.push('date_posted');
}
// Setup Date creation filter
if (global_params.fields.date_created && filt_perms['date_created']) {
if (global_params.fields.date_created) {
$(".filter-date_created").css("display", "flex");
$(".filter-manager-controller.date_created").prop("checked", true);
@@ -369,14 +339,8 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.date_created_custom);
}
else if (global_params.fields.date_created && !(filt_perms['date_created']))
{
updateFilters('date_created', 'del');
filters_to_remove.push('date_created');
}
// Setup album filter
if (global_params.fields.cat && filt_perms['cat']) {
if (global_params.fields.cat) {
$(".filter-album").css("display", "flex");
$(".filter-manager-controller.album").prop("checked", true);
@@ -427,12 +391,6 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.categories);
}
else if (global_params.fields.cat && !(filt_perms['cat']))
{
updateFilters('album', 'del');
filters_to_remove.push('cat');
}
// Setup author filter
$("#authors").each(function() {
@@ -441,7 +399,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 && filt_perms['author']) {
if (global_params.fields.author) {
$(".filter-authors").css("display", "flex");
$(".filter-manager-controller.author").prop("checked", true);
@@ -465,20 +423,14 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.authors);
}
else if (global_params.fields.author && !(filt_perms['author']))
{
updateFilters('author', 'del');
filters_to_remove.push('author');
}
});
// Setup added_by filter
if (global_params.fields.added_by && filt_perms['added_by']) {
if (global_params.fields.added_by) {
$(".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.data.length > 0) {
if (global_params.fields.added_by && global_params.fields.added_by.length > 0) {
$(".filter-added_by").addClass("filter-filled");
added_by_names = [];
@@ -487,7 +439,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.data) >= 0) {
if (jQuery.inArray(added_by_id, global_params.fields.added_by) >= 0) {
input.prop('checked', true);
added_by_names.push($(this).find('.added_by-name').text());
}
@@ -503,33 +455,27 @@ $(document).ready(function () {
$(".filter-added_by .added_by-option input").prop("checked", false);
});
PS_params.added_by = global_params.fields.added_by.data.length > 0 ? global_params.fields.added_by.data : '';
PS_params.added_by = global_params.fields.added_by.length > 0 ? global_params.fields.added_by : '';
empty_filters_list.push(PS_params.added_by);
}
else if (global_params.fields.added_by && !(filt_perms['added_by']))
{
updateFilters('added_by', 'del');
filters_to_remove.push('added_by');
}
// Setup filetypes filter
if (global_params.fields.filetypes && filt_perms['filetypes']) {
if (global_params.fields.filetypes) {
$(".filter-filetypes").css("display", "flex");
$(".filter-manager-controller.filetypes").prop("checked", true);
filetypes_search_str = "";
global_params.fields.filetypes.data.forEach(ft => {
global_params.fields.filetypes.forEach(ft => {
filetypes_search_str += ft + ", ";
});
if (global_params.fields.filetypes && global_params.fields.filetypes.data.length > 0) {
if (global_params.fields.filetypes && global_params.fields.filetypes.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.data.includes($(this).attr('name'))) {
if (global_params.fields.filetypes.includes($(this).attr('name'))) {
$(this).prop('checked', true);
}
});
@@ -541,33 +487,27 @@ $(document).ready(function () {
$(".filter-filetypes .filetypes-option input").prop("checked", false);
});
PS_params.filetypes = global_params.fields.filetypes.data.length > 0 ? global_params.fields.filetypes.data : '';
PS_params.filetypes = global_params.fields.filetypes.length > 0 ? global_params.fields.filetypes : '';
empty_filters_list.push(PS_params.filetypes);
}
else if (global_params.fields.filetypes && !(filt_perms['filetypes']))
{
updateFilters('filetypes', 'del');
filters_to_remove.push('filetypes');
}
// Setup Ratio filter
if (global_params.fields.ratios && filt_perms['ratios']) {
if (global_params.fields.ratios) {
$(".filter-ratios").css("display", "flex");
$(".filter-manager-controller.ratios").prop("checked", true);
ratios_search_str = "";
global_params.fields.ratios.data.forEach(ft => {
global_params.fields.ratios.forEach(ft => {
ratios_search_str += str_ratios_label[ft] + ", ";
});
if (global_params.fields.ratios && global_params.fields.ratios.data.length > 0) {
if (global_params.fields.ratios && global_params.fields.ratios.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.data.includes($(this).attr('name'))) {
if (global_params.fields.ratios.includes($(this).attr('name'))) {
$(this).prop('checked', true);
}
});
@@ -579,29 +519,23 @@ $(document).ready(function () {
$(".filter-ratios .ratios-option input").prop("checked", false);
});
PS_params.ratios = global_params.fields.ratios.data.length > 0 ? global_params.fields.ratios.data : '';
PS_params.ratios = global_params.fields.ratios.length > 0 ? global_params.fields.ratios : '';
empty_filters_list.push(PS_params.ratios);
}
else if (global_params.fields.ratios && !(filt_perms['ratios']))
{
updateFilters('ratios', 'del');
filters_to_remove.push('ratios');
}
// Setup rating filter
if (global_params.fields.ratings && show_filter_ratings && filt_perms['ratings']) {
if (global_params.fields.ratings && show_filter_ratings) {
$(".filter-ratings").css("display", "flex");
$(".filter-manager-controller.ratings").prop("checked", true);
ratings_search_str = "";
global_params.fields.ratings.data.forEach(function(ft, i){
global_params.fields.ratings.forEach(function(ft, i){
if(0 == ft )
{
ratings_search_str += str_no_rating
if(global_params.fields.ratings.data.length > 1)
if(global_params.fields.ratings.length > 1)
{
ratings_search_str += ", ";
}
@@ -610,19 +544,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.data.length-1 != i)
if(global_params.fields.ratings.length-1 != i)
{
ratings_search_str += ", ";
}
}
});
if (global_params.fields.ratings && global_params.fields.ratings.data.length > 0) {
if (global_params.fields.ratings && global_params.fields.ratings.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.data.includes($(this).attr('name'))) {
if (global_params.fields.ratings.includes($(this).attr('name'))) {
$(this).prop('checked', true);
}
});
@@ -634,18 +568,13 @@ $(document).ready(function () {
$(".filter-ratings .ratings-option input").prop("checked", false);
});
PS_params.ratings = global_params.fields.ratings.data.length > 0 ? global_params.fields.ratings.data : '';
PS_params.ratings = global_params.fields.ratings.length > 0 ? global_params.fields.ratings : '';
empty_filters_list.push(PS_params.ratings);
}
else if (global_params.fields.ratings && (!show_filter_ratings || global_params.fields.ratings && !(filt_perms['ratings'])))
{
updateFilters('ratings', 'del');
filters_to_remove.push('ratings');
}
// Setup filesize filter
if (global_params.fields.filesize_min != null && global_params.fields.filesize_max != null && filt_perms['filesize_min']) {
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);
@@ -662,7 +591,7 @@ $(document).ready(function () {
});
if( global_params.fields.filesize_min.data != null && global_params.fields.filesize_max.data > 0) {
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));
}
@@ -681,28 +610,22 @@ $(document).ready(function () {
}
});
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 : '';
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 : '';
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 && !(filt_perms['filesize_min']))
{
updateFilters('filesize', 'del');
filters_to_remove.push('filesize');
}
// Setup Height filter
if (global_params.fields.height_min != null && global_params.fields.height_max != null && filt_perms['height_min']) {
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));
$('[data-slider=heights]').pwgDoubleSlider(sliders.heights);
if( global_params.fields.height_min.data > 0 && global_params.fields.height_max.data > 0) {
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));
}
@@ -721,28 +644,22 @@ $(document).ready(function () {
}
});
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 : '';
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 : '';
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 && !(filt_perms['height_min']))
{
updateFilters('height', 'del');
filters_to_remove.push('height');
}
// Setup Width filter
if (global_params.fields.width_min != null && global_params.fields.width_max != null && filt_perms['width_min']) {
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));
$('[data-slider=widths]').pwgDoubleSlider(sliders.widths);
if( global_params.fields.width_min.data > 0 && global_params.fields.width_max.data > 0) {
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));
}
@@ -761,19 +678,13 @@ $(document).ready(function () {
}
});
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 : '';
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 : '';
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 && !(filt_perms['width_min']))
{
updateFilters('width', 'del');
filters_to_remove.push('width');
}
if(filters_to_remove.length > 0){
filters_to_remove = [];
performSearch(PS_params, true);
@@ -1265,7 +1176,7 @@ $(document).ready(function () {
ratios_array.push($(this).attr('name'));
});
global_params.fields.ratios.data = ratios_array;
global_params.fields.ratios = ratios_array;
PS_params.ratios = ratios_array.length > 0 ? ratios_array : '';
}