pull/655/merge
Jason Priebe 6 years ago committed by GitHub
commit dad7adb265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

File diff suppressed because one or more lines are too long

@ -74,8 +74,14 @@ final class Admin extends Access {
private static function getAlbumsAction() {
$albums = new Albums();
Response::json($albums->get(false));
if (isset ($_POST['filterParams']))
{
Response::json($albums->get(false, $_POST['filterParams']));
}
else
{
Response::json($albums->get(false));
}
}
// Album functions
@ -351,4 +357,4 @@ final class Admin extends Access {
}
?>
?>

@ -16,7 +16,7 @@ final class Albums {
/**
* @return array|false Returns an array of albums or false on failure.
*/
public function get($public = true) {
public function get($public = true, $filter_params = null) {
// Call plugins
Plugins::get()->activate(__METHOD__, 0, func_get_args());
@ -32,8 +32,47 @@ final class Albums {
if ($public===false) $return['smartalbums'] = $this->getSmartAlbums();
// Albums query
if ($public===false) $query = Database::prepare(Database::get(), 'SELECT id, title, public, sysstamp, password FROM ? ' . Settings::get()['sortingAlbums'], array(LYCHEE_TABLE_ALBUMS));
else $query = Database::prepare(Database::get(), 'SELECT id, title, public, sysstamp, password FROM ? WHERE public = 1 AND visible <> 0 ' . Settings::get()['sortingAlbums'], array(LYCHEE_TABLE_ALBUMS));
if ($public===false) $sql = 'SELECT id, title, public, sysstamp, password FROM ? ';
else $sql = 'SELECT id, title, public, sysstamp, password FROM ? WHERE public = 1 AND visible <> 0 ';
$query_params1 = array (LYCHEE_TABLE_ALBUMS);
$query_params2 = array ();
$filter_where1 = '';
$filter_where2 = '';
if ($filter_params !== null)
{
$query_params1[] = LYCHEE_TABLE_PHOTOS;
$xary = array ();
if (isset ($filter_params['star']) && $filter_params['star'])
{
$xary[] = 'star = 1';
}
if (isset ($filter_params['tags']) && $filter_params['tags'])
{
$xary[] = "tags LIKE '%?%'";
$query_params1[] = $filter_params['tags'];
$query_params2[] = $filter_params['tags'];
}
$filter_where1 = join (" AND ", $xary);
$filter_where2 = "AND " . join (" AND ", $xary);
if ($public)
{
$sql .= "AND ";
}
else
{
$sql .= "WHERE ";
}
$sql .= "id IN (SELECT DISTINCT album FROM ? WHERE $filter_where1) ";
}
$sql .= Settings::get()['sortingAlbums'];
$query = Database::prepare (Database::get (), $sql, $query_params1);
// Execute query
$albums = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
@ -51,7 +90,11 @@ final class Albums {
($public===false)) {
// Execute query
$query = Database::prepare(Database::get(), "SELECT thumbUrl FROM ? WHERE album = '?' ORDER BY star DESC, " . substr(Settings::get()['sortingPhotos'], 9) . " LIMIT 3", array(LYCHEE_TABLE_PHOTOS, $album['id']));
$query = Database::prepare(Database::get(), "SELECT thumbUrl FROM ? WHERE album = '?' "
. $filter_where2
. " ORDER BY star DESC, "
. substr(Settings::get()['sortingPhotos'], 9)
. " LIMIT 3", array_merge (array(LYCHEE_TABLE_PHOTOS, $album['id']), $query_params2));
$thumbs = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
if ($thumbs===false) return false;
@ -188,4 +231,4 @@ final class Albums {
}
?>
?>

@ -1 +1 @@
<svg class="svgsprite" version="1.1" xmlns="http://www.w3.org/2000/svg"><symbol id="twitter" viewBox="0 0 512 512"><path d="M492 109.5c-17.4 7.7-36 12.9-55.6 15.3 20-12 35.4-31 42.6-53.6-18.7 11.1-39.4 19.2-61.5 23.5C399.8 75.8 374.6 64 346.8 64c-53.5 0-96.8 43.4-96.8 96.9 0 7.6.8 15 2.5 22.1-80.5-4-151.9-42.6-199.6-101.3-8.3 14.3-13.1 31-13.1 48.7 0 33.6 17.2 63.3 43.2 80.7-16-.4-31-4.8-44-12.1v1.2c0 47 33.4 86.1 77.7 95-8.1 2.2-16.7 3.4-25.5 3.4-6.2 0-12.3-.6-18.2-1.8 12.3 38.5 48.1 66.5 90.5 67.3-33.1 26-74.9 41.5-120.3 41.5-7.8 0-15.5-.5-23.1-1.4C62.8 432 113.7 448 168.3 448 346.6 448 444 300.3 444 172.2c0-4.2-.1-8.4-.3-12.5C462.6 146 479 129 492 109.5z"/></symbol><symbol id="facebook" viewBox="0 0 512 512"><path d="M288 192v-38.1c0-17.2 3.8-25.9 30.5-25.9H352V64h-55.9c-68.5 0-91.1 31.4-91.1 85.3V192h-45v64h45v192h83V256h56.4l7.6-64h-64z"/></symbol><symbol id="dropbox" viewBox="0 0 512 512"><path d="M177 77L64 150.9l78.1 62.7L256 143.1zM64 276.3l113 73.9 79-66.1-113.9-70.5zM256 284.1l79 66.1 113-73.9-78.1-62.7zM448 150.9L335 77l-79 66.1 113.9 70.5zM256.2 298.3l-79.8 66-34.4-22.2V367l114 68 114-68v-24.9l-34.2 22.2z"/></symbol></svg>
<svg class="svgsprite" version="1.1" xmlns="http://www.w3.org/2000/svg"><symbol id="twitter" viewBox="0 0 512 512"><path d="M492 109.5c-17.4 7.7-36 12.9-55.6 15.3 20-12 35.4-31 42.6-53.6-18.7 11.1-39.4 19.2-61.5 23.5C399.8 75.8 374.6 64 346.8 64c-53.5 0-96.8 43.4-96.8 96.9 0 7.6.8 15 2.5 22.1-80.5-4-151.9-42.6-199.6-101.3-8.3 14.3-13.1 31-13.1 48.7 0 33.6 17.2 63.3 43.2 80.7-16-.4-31-4.8-44-12.1v1.2c0 47 33.4 86.1 77.7 95-8.1 2.2-16.7 3.4-25.5 3.4-6.2 0-12.3-.6-18.2-1.8 12.3 38.5 48.1 66.5 90.5 67.3-33.1 26-74.9 41.5-120.3 41.5-7.8 0-15.5-.5-23.1-1.4C62.8 432 113.7 448 168.3 448 346.6 448 444 300.3 444 172.2c0-4.2-.1-8.4-.3-12.5C462.6 146 479 129 492 109.5z"/></symbol><symbol id="facebook" viewBox="0 0 512 512"><path d="M288 192v-38.1c0-17.2 3.8-25.9 30.5-25.9H352V64h-55.9c-68.5 0-91.1 31.4-91.1 85.3V192h-45v64h45v192h83V256h56.4l7.6-64h-64z"/></symbol><symbol id="dropbox" viewBox="0 0 512 512"><path d="M177 77L64 150.9l78.1 62.7L256 143.1zM64 276.3l113 73.9 79-66.1-113.9-70.5zM256 284.1l79 66.1 113-73.9-78.1-62.7zM448 150.9L335 77l-79 66.1 113.9 70.5zM256.2 298.3l-79.8 66-34.4-22.2V367l114 68 114-68v-24.9l-34.2 22.2z"/></symbol><symbol id="funnel" viewBox="0 0 512 512"><path d="M256.085,32c-123.79,0-224.096,35.817-224.096,80c0,8.476,3.729,16.642,10.573,24.309l-0.061,0.008 C74.408,175.213,192,313,192,352v87l0,0c0,22.688,28.891,41,64,41s64-18.312,64-41l0,0v-83.088c0-1.241,0.008-2.54,0.008-3.912 C320.008,313,436,177.432,471,134.062v-0.002c6-7.007,8.977-14.408,8.977-22.06C479.977,67.817,379.875,32,256.085,32z M256.178,160c-92.058,0-176.112-22-176.112-48s83.053-48,176.112-48c93.06,0,176.111,22.413,176.111,48S348.236,160,256.178,160z"/></symbol></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

@ -16,7 +16,14 @@ albums.load = function() {
if (albums.json===null) {
api.post('Albums::get', {}, function(data) {
params = {}
filterParams = filter.getFilterParams ()
if (filterParams !== null)
{
params.filterParams = filterParams;
}
api.post('Albums::get', params, function(data) {
let waitTime = 0
@ -153,4 +160,4 @@ albums.refresh = function() {
albums.json = null
}
}

@ -0,0 +1,120 @@
/**
* @description Applies filters to album
*/
var filter = {};
filter.currentState = {
star: 0,
tags: ''
};
filter.setFilter = function() {
const action = function() {
filter.currentState.star = 0;
if ($('#filter_star').prop('checked'))
{
filter.currentState.star = 1;
}
filter.currentState.tags = '';
if ($('#filter_tags').val() !== 'undefined')
{
filter.currentState.tags = $('#filter_tags').val().trim();
}
basicModal.close();
albums.refresh();
if (album.json !== null)
{
album.load(album.json.id, true);
}
else
{
albums.load();
}
};
let msg = `
<p>
<span style="width: 33%">Starred:</span>
<input type="checkbox" class="checkbox" id="filter_star">
</p>
<p>
<span style="width: 33%">Tags match:</span>
<input type="text" class="text" id="filter_tags">
</p>
`;
basicModal.show({
body: msg,
buttons: {
action: {
title: 'Apply Filter',
fn: action
},
cancel: {
title: 'Cancel',
fn: basicModal.close
}
}
});
if (filter.currentState.star)
{
$('#filter_star').prop ('checked', true);
}
$('#filter_tags').val(filter.currentState.tags);
}
filter.checkPhoto = function(p)
{
if (filter.currentState.star === 1)
{
if (p.star !== "1")
{
return false;
}
}
if (filter.currentState.tags !== '')
{
if (!p.tags.includes (filter.currentState.tags))
{
return false;
}
}
return true;
}
filter.isFilterActive = function ()
{
if (filter.currentState.star)
{
return true;
}
if (filter.currentState.tags !== '')
{
return true;
}
return false;
}
filter.getFilterParams = function ()
{
if (!filter.isFilterActive())
{
return null;
}
return filter.currentState;
}

@ -49,6 +49,7 @@ header.bind = function() {
header.dom('.header__hostedwith') .on(eventName, function() { window.open(lychee.website) })
header.dom('#button_trash_album') .on(eventName, function() { album.delete([ album.getID() ]) })
header.dom('#button_trash') .on(eventName, function() { photo.delete([ photo.getID() ]) })
header.dom('.button_filter') .on(eventName, function() { filter.setFilter () })
header.dom('#button_archive') .on(eventName, function() { album.getArchive(album.getID()) })
header.dom('#button_star') .on(eventName, function() { photo.setStar([ photo.getID() ]) })
header.dom('#button_back_home') .on(eventName, function() { lychee.goto() })
@ -177,4 +178,4 @@ header.setEditable = function(editable) {
return true
}
}

@ -15,7 +15,14 @@ view.albums = {
title: function() {
lychee.setTitle('Albums', false)
if (filter.isFilterActive())
{
lychee.setTitle('Albums (filtered)', false)
}
else
{
lychee.setTitle('Albums', false)
}
},
@ -114,25 +121,36 @@ view.album = {
if ((visible.album() || !album.json.init) && !visible.photo()) {
title = '';
editable = false;
switch (album.getID()) {
case 'f':
lychee.setTitle('Starred', false)
title = 'Starred'
break
case 's':
lychee.setTitle('Public', false)
title = 'Public'
break
case 'r':
lychee.setTitle('Recent', false)
title = 'Recent'
break
case '0':
lychee.setTitle('Unsorted', false)
title = 'Unsorted'
break
default:
if (album.json.init) sidebar.changeAttr('title', album.json.title)
lychee.setTitle(album.json.title, true)
title = album.json.title
editable = true
break
}
if (filter.isFilterActive())
{
title += " (filtered)"
}
if (editable && album.json.init) sidebar.changeAttr('title', title)
lychee.setTitle(title, editable)
}
},
@ -147,7 +165,10 @@ view.album = {
// Build photos
$.each(album.json.content, function() {
photosData += build.photo(this)
if (filter.checkPhoto (this))
{
photosData += build.photo(this)
}
})
}
@ -452,4 +473,4 @@ view.photo = {
}
}
}

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save