mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-05-18 07:16:11 +02:00
fixes #2417 ability to hide the new filter "expert mode"
... and removes 2 other duplicates of the filters_views configuration
This commit is contained in:
@@ -117,7 +117,7 @@ if (!isset($conf['filters_views']))
|
||||
conf_update_param('filters_views', $conf['default_filters_views'], true);
|
||||
}
|
||||
|
||||
$filters_names_checkboxes = array_diff(array_keys(safe_unserialize($conf['filters_views'])), array('last_filters_conf'));
|
||||
$filters_names_checkboxes = array_values(array_diff(array_keys(safe_unserialize($conf['filters_views'])), array('last_filters_conf')));
|
||||
|
||||
// image order management
|
||||
$sort_fields = array(
|
||||
@@ -688,12 +688,11 @@ switch ($page['section'])
|
||||
}
|
||||
case 'search':
|
||||
{
|
||||
$filters_names = $filters_names_checkboxes;
|
||||
$template->assign(
|
||||
'search',
|
||||
array(
|
||||
'filters_views' => safe_unserialize($conf['filters_views']),
|
||||
'filters_names' => $filters_names,
|
||||
'filters_names' => $filters_names_checkboxes,
|
||||
),
|
||||
);
|
||||
$template->assign('SHOW_FILTER_RATINGS', $conf['rate']);
|
||||
|
||||
@@ -2,22 +2,7 @@
|
||||
|
||||
{footer_script}
|
||||
|
||||
filters_names =
|
||||
[
|
||||
'words',
|
||||
'tags',
|
||||
'post_date',
|
||||
'creation_date',
|
||||
'album',
|
||||
'author',
|
||||
'added_by',
|
||||
'file_type',
|
||||
'ratio',
|
||||
'rating',
|
||||
'file_size',
|
||||
'height',
|
||||
'width'
|
||||
];
|
||||
const filters_names = {$search.filters_names|json_encode};
|
||||
|
||||
for(const filter_name of filters_names){
|
||||
if(!$("input#"+filter_name+"Filters").is(':checked')){
|
||||
@@ -91,6 +76,8 @@ for(const filter_name of filters_names){
|
||||
>
|
||||
{if $filter_name == 'words'}
|
||||
{'Search for words'|translate}
|
||||
{else if $filter_name == 'expert'}
|
||||
{'Expert mode'|translate}
|
||||
{else if $filter_name == 'file_size'}
|
||||
{'Filesize'|translate}
|
||||
{else}
|
||||
@@ -100,7 +87,7 @@ for(const filter_name of filters_names){
|
||||
<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="registered-users" {if ($search.filters_views.$filter_name.access == "registered-users")}selected{/if}>{'registered users'|translate|ucfirst}</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>
|
||||
@@ -225,7 +212,14 @@ for(const filter_name of filters_names){
|
||||
{/if}
|
||||
hidden/>
|
||||
</label>
|
||||
|
||||
<label class="filter-manager-options-container">
|
||||
<span class="mcs-icon-options gallery-icon-chemistry">{'Expert mode'|translate}</span>
|
||||
<input type="checkbox" class="filter-manager-options-check" name="filters_views[expert][default]" id="default_expert"
|
||||
{if ($search.filters_views.expert.default)}
|
||||
checked="checked"
|
||||
{/if}
|
||||
hidden/>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -8454,7 +8454,7 @@ color:#FF7B00;
|
||||
/* Filters options */
|
||||
.filters-grid{
|
||||
display: grid;
|
||||
grid-template-columns: 200px 118px 25px;
|
||||
grid-template-columns: 200px 150px 25px;
|
||||
margin-bottom: 0px !important;
|
||||
}
|
||||
.select-views{
|
||||
@@ -8468,7 +8468,7 @@ color:#FF7B00;
|
||||
.select-views-arrow{
|
||||
display: flex;
|
||||
position: absolute;
|
||||
margin-left: 299.9px;
|
||||
margin-left: 333px;
|
||||
margin-top: 5px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@@ -1054,6 +1054,7 @@ $conf['default_filters_views'] = array(
|
||||
'file_size' => ['access'=>'everybody', 'default'=>false],
|
||||
'height' => ['access'=>'everybody', 'default'=>false],
|
||||
'width' => ['access'=>'everybody', 'default'=>false],
|
||||
'expert' => ['access'=>'everybody', 'default'=>false],
|
||||
|
||||
'last_filters_conf' => true,
|
||||
);
|
||||
|
||||
@@ -119,15 +119,7 @@ function get_regular_search_results($search, $images_where='')
|
||||
|
||||
$image_ids_for_filter = array();
|
||||
|
||||
if (isset($conf['filters_views']))
|
||||
{
|
||||
$display_filters = unserialize($conf['filters_views']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$display_filters = unserialize('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;}');
|
||||
}
|
||||
|
||||
$display_filters = safe_unserialize(conf_get_param('filters_views', $conf['default_filters_views']));
|
||||
|
||||
foreach($display_filters as $filt_name => $filt_conf){
|
||||
if(isset($filt_conf['access']))
|
||||
@@ -146,7 +138,7 @@ function get_regular_search_results($search, $images_where='')
|
||||
//
|
||||
// expert
|
||||
//
|
||||
if (isset($search['fields']['expert']) and !empty($search['fields']['expert']['string']))
|
||||
if (isset($search['fields']['expert']) and !empty($search['fields']['expert']['string']) and $display_filters['expert']['access'])
|
||||
{
|
||||
$has_filters_filled = true;
|
||||
|
||||
|
||||
@@ -109,7 +109,14 @@ if ('search' == $page['section'] and isset($page['search_details']))
|
||||
|
||||
if (isset($my_search['fields']['expert']))
|
||||
{
|
||||
load_language('help_quick_search.lang');
|
||||
if (!$display_filters['expert']['access'])
|
||||
{
|
||||
unset($my_search['fields']['expert']);
|
||||
}
|
||||
else
|
||||
{
|
||||
load_language('help_quick_search.lang');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($my_search['fields']['author']) and $display_filters['author']['access'])
|
||||
|
||||
@@ -13,7 +13,9 @@ if (!defined('PHPWG_ROOT_PATH'))
|
||||
|
||||
$upgrade_description = 'add config parameters to the gallery filters';
|
||||
|
||||
conf_update_param('filters_views', $conf['default_filters_views']);
|
||||
// let the $conf['filters_views'] be written in config table when the admin will change settings in administration.
|
||||
//
|
||||
// conf_update_param('filters_views', $conf['default_filters_views']);
|
||||
|
||||
echo "\n".$upgrade_description."\n";
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This file is part of Piwigo. |
|
||||
// | |
|
||||
// | For copyright and license information, please view the COPYING.txt |
|
||||
// | file that was distributed with this source code. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if (!defined('PHPWG_ROOT_PATH'))
|
||||
{
|
||||
die('Hacking attempt!');
|
||||
}
|
||||
|
||||
$upgrade_description = 'add "expert mode" in filters_views for gallery search';
|
||||
|
||||
load_conf_from_db();
|
||||
|
||||
// if the filters_views is not already registered in the config table, no need
|
||||
// to update it because it will be initialized with all filters
|
||||
if (isset($conf['filters_views']))
|
||||
{
|
||||
$conf['filters_views'] = safe_unserialize($conf['filters_views']);
|
||||
|
||||
if (!isset($conf['filters_views']['expert']))
|
||||
{
|
||||
$conf['filters_views']['expert'] = $conf['default_filters_views']['expert'];
|
||||
conf_update_param('filters_views', $conf['filters_views']);
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n".$upgrade_description."\n";
|
||||
|
||||
?>
|
||||
@@ -1420,5 +1420,6 @@ $lang['If a photo in this album has the same filename, update the file without c
|
||||
$lang['Empty lounge'] = 'Empty lounge';
|
||||
$lang['There is currently %d photos in the lounge (upload buffer)'] = 'There is currently %d photos in the lounge (upload buffer)';
|
||||
$lang['%d photos were moved from the upload lounge to their albums'] = '%d photos were moved from the upload lounge to their albums';
|
||||
$lang['Admins only'] = 'Admins only';
|
||||
|
||||
// Leave this line empty
|
||||
@@ -1422,4 +1422,5 @@ $lang['If a photo in this album has the same filename, update the file without c
|
||||
$lang['Empty lounge'] = 'Vider le lounge';
|
||||
$lang['There is currently %d photos in the lounge (upload buffer)'] = 'Il y a actuellement %d photos dans le lounge (salle d\'attente des transferts)';
|
||||
$lang['%d photos were moved from the upload lounge to their albums'] = '%d photos ont été déplacées du lounge vers leurs albums respectifs';
|
||||
$lang['Admins only'] = 'Admins uniquement';
|
||||
// Leave this line empty
|
||||
|
||||
+18
-28
@@ -28,38 +28,28 @@ $search = array(
|
||||
);
|
||||
|
||||
// list of filters in user preferences
|
||||
// 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
|
||||
if (isset($conf['filters_views']))
|
||||
{
|
||||
$filters_conf = unserialize($conf['filters_views']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$filters_conf = unserialize('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_views = safe_unserialize(conf_get_param('filters_views', $conf['default_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
|
||||
$filter_rename_for = array(
|
||||
'words' => 'allwords',
|
||||
'post_date' => 'date_posted',
|
||||
'creation_date' => 'date_created',
|
||||
'album' => 'cat',
|
||||
'file_type' => 'filetypes',
|
||||
'ratio' => 'ratios',
|
||||
'rating' => 'ratings',
|
||||
'file_size' => 'filesize',
|
||||
);
|
||||
|
||||
$filters_conf = array();
|
||||
foreach ($filters_views as $filter_name => $filter_value)
|
||||
{
|
||||
$key = isset($filter_rename_for[$filter_name]) ? $filter_rename_for[$filter_name] : $filter_name;
|
||||
|
||||
$filters_conf[$key] = $filter_value;
|
||||
}
|
||||
|
||||
//get all default filters
|
||||
$default_fields = array();
|
||||
foreach($filters_conf as $filt_name => $filt_conf){
|
||||
|
||||
@@ -191,11 +191,12 @@ const prefix_icon = 'gallery-icon-';
|
||||
</label>
|
||||
{/if}
|
||||
|
||||
{if $display_filter.expert.access == 'everybody' or ($display_filter.expert.access == 'admins-only' and is_admin()) or ($display_filter.expert.access == 'registered-users' and is_classic_user())}
|
||||
<label>
|
||||
<input data-wid='expert' class="filter-manager-controller expert" type="checkbox"/>
|
||||
<span class="mcs-icon gallery-icon-chemistry">{'Expert mode'|translate}</span>
|
||||
</label>
|
||||
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="filter-manager-actions">
|
||||
|
||||
Reference in New Issue
Block a user