Updated Album::getAll
This commit is contained in:
parent
452a19254c
commit
67dce773e6
BIN
dist/main.css
vendored
BIN
dist/main.css
vendored
Binary file not shown.
BIN
dist/main.js
vendored
BIN
dist/main.js
vendored
Binary file not shown.
@ -154,8 +154,15 @@ class Album extends Module {
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Initialize return var
|
||||
$return = array(
|
||||
'smartalbums' => null,
|
||||
'albums' => null,
|
||||
'num' => 0
|
||||
);
|
||||
|
||||
# Get SmartAlbums
|
||||
if ($public===false) $return = $this->getSmartInfo();
|
||||
if ($public===false) $return['smartalbums'] = $this->getSmartInfo();
|
||||
|
||||
# Albums query
|
||||
$query = Database::prepare($this->database, 'SELECT id, title, public, sysstamp, password FROM ? WHERE public = 1 AND visible <> 0', array(LYCHEE_TABLE_ALBUMS));
|
||||
@ -192,7 +199,7 @@ class Album extends Module {
|
||||
}
|
||||
|
||||
# Add to return
|
||||
$return['content'][$album['id']] = $album;
|
||||
$return['albums'][$album['id']] = $album;
|
||||
|
||||
}
|
||||
|
||||
@ -211,29 +218,25 @@ class Album extends Module {
|
||||
# Check dependencies
|
||||
self::dependencies(isset($this->database, $this->settings));
|
||||
|
||||
# Initialize return var
|
||||
$return = array(
|
||||
'unsorted' => null,
|
||||
'public' => null,
|
||||
'starred' => null,
|
||||
'recent' => null
|
||||
);
|
||||
|
||||
# Unsorted
|
||||
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE album = 0 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
||||
$unsorted = $this->database->query($query);
|
||||
$i = 0;
|
||||
while($row = $unsorted->fetch_object()) {
|
||||
if ($i<3) {
|
||||
$return["unsortedThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row->thumbUrl;
|
||||
$return['unsorted']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row->thumbUrl;
|
||||
$i++;
|
||||
} else break;
|
||||
}
|
||||
$return['unsortedNum'] = $unsorted->num_rows;
|
||||
|
||||
# Public
|
||||
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE public = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
||||
$public = $this->database->query($query);
|
||||
$i = 0;
|
||||
while($row2 = $public->fetch_object()) {
|
||||
if ($i<3) {
|
||||
$return["publicThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row2->thumbUrl;
|
||||
$i++;
|
||||
} else break;
|
||||
}
|
||||
$return['publicNum'] = $public->num_rows;
|
||||
$return['unsorted']['num'] = $unsorted->num_rows;
|
||||
|
||||
# Starred
|
||||
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE star = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
||||
@ -241,11 +244,23 @@ class Album extends Module {
|
||||
$i = 0;
|
||||
while($row3 = $starred->fetch_object()) {
|
||||
if ($i<3) {
|
||||
$return["starredThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
|
||||
$return['starred']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
|
||||
$i++;
|
||||
} else break;
|
||||
}
|
||||
$return['starredNum'] = $starred->num_rows;
|
||||
$return['starred']['num'] = $starred->num_rows;
|
||||
|
||||
# Public
|
||||
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE public = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
||||
$public = $this->database->query($query);
|
||||
$i = 0;
|
||||
while($row2 = $public->fetch_object()) {
|
||||
if ($i<3) {
|
||||
$return['public']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row2->thumbUrl;
|
||||
$i++;
|
||||
} else break;
|
||||
}
|
||||
$return['public']['num'] = $public->num_rows;
|
||||
|
||||
# Recent
|
||||
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
||||
@ -253,11 +268,11 @@ class Album extends Module {
|
||||
$i = 0;
|
||||
while($row3 = $recent->fetch_object()) {
|
||||
if ($i<3) {
|
||||
$return["recentThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
|
||||
$return['recent']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
|
||||
$i++;
|
||||
} else break;
|
||||
}
|
||||
$return['recentNum'] = $recent->num_rows;
|
||||
$return['recent']['num'] = $recent->num_rows;
|
||||
|
||||
return $return;
|
||||
|
||||
|
@ -179,7 +179,7 @@ album.delete = function(albumIDs) {
|
||||
albumIDs.forEach(function(id) {
|
||||
albums.json.num--;
|
||||
view.albums.content.delete(id);
|
||||
delete albums.json.content[id];
|
||||
delete albums.json.albums[id];
|
||||
});
|
||||
|
||||
} else {
|
||||
@ -209,7 +209,7 @@ album.delete = function(albumIDs) {
|
||||
|
||||
// Get title
|
||||
if (album.json) albumTitle = album.json.title;
|
||||
else if (albums.json) albumTitle = albums.json.content[albumIDs].title;
|
||||
else if (albums.json) albumTitle = albums.json.albums[albumIDs].title;
|
||||
|
||||
msg = "<p>Are you sure you want to delete the album '" + albumTitle + "' and all of the photos it contains? This action can't be undone!</p>";
|
||||
|
||||
@ -253,7 +253,7 @@ album.setTitle = function(albumIDs) {
|
||||
|
||||
// Get old title if only one album is selected
|
||||
if (album.json) oldTitle = album.json.title;
|
||||
else if (albums.json) oldTitle = albums.json.content[albumIDs].title;
|
||||
else if (albums.json) oldTitle = albums.json.albums[albumIDs].title;
|
||||
|
||||
if (!oldTitle) oldTitle = '';
|
||||
oldTitle = oldTitle.replace("'", ''');
|
||||
@ -280,13 +280,13 @@ album.setTitle = function(albumIDs) {
|
||||
|
||||
if (albums.json) {
|
||||
var id = albumIDs[0];
|
||||
albums.json.content[id].title = newTitle;
|
||||
albums.json.albums[id].title = newTitle;
|
||||
}
|
||||
|
||||
} else if (visible.albums()) {
|
||||
|
||||
albumIDs.forEach(function(id) {
|
||||
albums.json.content[id].title = newTitle;
|
||||
albums.json.albums[id].title = newTitle;
|
||||
view.albums.content.title(id);
|
||||
});
|
||||
|
||||
|
@ -25,44 +25,44 @@ albums.load = function() {
|
||||
api.post('Album::getAll', {}, function(data) {
|
||||
|
||||
/* Smart Albums */
|
||||
data.unsortedAlbum = {
|
||||
data.smartalbums.unsorted = {
|
||||
id: 0,
|
||||
title: 'Unsorted',
|
||||
sysdate: data.unsortedNum + ' photos',
|
||||
sysdate: data.smartalbums.unsorted.num + ' photos',
|
||||
unsorted: '1',
|
||||
thumb0: data.unsortedThumb0,
|
||||
thumb1: data.unsortedThumb1,
|
||||
thumb2: data.unsortedThumb2
|
||||
thumb0: data.smartalbums.unsorted.thumb0,
|
||||
thumb1: data.smartalbums.unsorted.thumb1,
|
||||
thumb2: data.smartalbums.unsorted.thumb2
|
||||
};
|
||||
|
||||
data.starredAlbum = {
|
||||
data.smartalbums.starred = {
|
||||
id: 'f',
|
||||
title: 'Starred',
|
||||
sysdate: data.starredNum + ' photos',
|
||||
sysdate: data.smartalbums.starred.num + ' photos',
|
||||
star: '1',
|
||||
thumb0: data.starredThumb0,
|
||||
thumb1: data.starredThumb1,
|
||||
thumb2: data.starredThumb2
|
||||
thumb0: data.smartalbums.starred.thumb0,
|
||||
thumb1: data.smartalbums.starred.thumb1,
|
||||
thumb2: data.smartalbums.starred.thumb2
|
||||
};
|
||||
|
||||
data.publicAlbum = {
|
||||
data.smartalbums.public = {
|
||||
id: 's',
|
||||
title: 'Public',
|
||||
sysdate: data.publicNum + ' photos',
|
||||
sysdate: data.smartalbums.public.num + ' photos',
|
||||
public: '1',
|
||||
thumb0: data.publicThumb0,
|
||||
thumb1: data.publicThumb1,
|
||||
thumb2: data.publicThumb2
|
||||
thumb0: data.smartalbums.public.thumb0,
|
||||
thumb1: data.smartalbums.public.thumb1,
|
||||
thumb2: data.smartalbums.public.thumb2
|
||||
};
|
||||
|
||||
data.recentAlbum = {
|
||||
data.smartalbums.recent = {
|
||||
id: 'r',
|
||||
title: 'Recent',
|
||||
sysdate: data.recentNum + ' photos',
|
||||
sysdate: data.smartalbums.recent.num + ' photos',
|
||||
recent: '1',
|
||||
thumb0: data.recentThumb0,
|
||||
thumb1: data.recentThumb1,
|
||||
thumb2: data.recentThumb2
|
||||
thumb0: data.smartalbums.recent.thumb0,
|
||||
thumb1: data.smartalbums.recent.thumb1,
|
||||
thumb2: data.smartalbums.recent.thumb2
|
||||
};
|
||||
|
||||
albums.json = data;
|
||||
@ -79,7 +79,7 @@ albums.load = function() {
|
||||
setTimeout(function() {
|
||||
header.setMode('albums');
|
||||
view.albums.init();
|
||||
lychee.animate('.album, .photo', 'contentZoomIn');
|
||||
lychee.animate('.album', 'contentZoomIn');
|
||||
}, waitTime);
|
||||
});
|
||||
|
||||
|
@ -82,7 +82,7 @@ contextMenu.albumTitle = function(albumID, e) {
|
||||
items.push({ type: 'separator' });
|
||||
|
||||
// Generate list of albums
|
||||
$.each(data.content, function(index) {
|
||||
$.each(data.albums, function(index) {
|
||||
|
||||
var that = this,
|
||||
title = '';
|
||||
@ -220,7 +220,7 @@ contextMenu.move = function(photoIDs, e) {
|
||||
} else {
|
||||
|
||||
// Generate list of albums
|
||||
$.each(data.content, function(index) {
|
||||
$.each(data.albums, function(index) {
|
||||
|
||||
var that = this;
|
||||
|
||||
|
@ -16,7 +16,7 @@ password.get = function(albumID, callback) {
|
||||
|
||||
if (!lychee.publicMode) callback();
|
||||
else if (album.json&&album.json.password==false) callback();
|
||||
else if (albums.json&&albums.json.content[albumID].password==false) callback();
|
||||
else if (albums.json&&albums.json.albums[albumID].password==false) callback();
|
||||
else if (!albums.json&&!album.json) {
|
||||
|
||||
// Continue without password
|
||||
|
@ -49,16 +49,21 @@ view.albums = {
|
||||
albumsData = '';
|
||||
|
||||
/* Smart Albums */
|
||||
albums.parse(albums.json.unsortedAlbum);
|
||||
albums.parse(albums.json.publicAlbum);
|
||||
albums.parse(albums.json.starredAlbum);
|
||||
albums.parse(albums.json.recentAlbum);
|
||||
if (!lychee.publicMode) smartData = build.divider('Smart Albums') + build.album(albums.json.unsortedAlbum) + build.album(albums.json.starredAlbum) + build.album(albums.json.publicAlbum) + build.album(albums.json.recentAlbum);
|
||||
if (!lychee.publicMode) {
|
||||
|
||||
albums.parse(albums.json.smartalbums.unsorted);
|
||||
albums.parse(albums.json.smartalbums.public);
|
||||
albums.parse(albums.json.smartalbums.starred);
|
||||
albums.parse(albums.json.smartalbums.recent);
|
||||
|
||||
smartData = build.divider('Smart Albums') + build.album(albums.json.smartalbums.unsorted) + build.album(albums.json.smartalbums.public) + build.album(albums.json.smartalbums.starred) + build.album(albums.json.smartalbums.recent);
|
||||
|
||||
}
|
||||
|
||||
/* Albums */
|
||||
if (albums.json.content&&albums.json.num!==0) {
|
||||
if (albums.json.albums&&albums.json.num!==0) {
|
||||
|
||||
$.each(albums.json.content, function() {
|
||||
$.each(albums.json.albums, function() {
|
||||
albums.parse(this);
|
||||
|
||||
// Display albums in reverse order
|
||||
@ -88,7 +93,7 @@ view.albums = {
|
||||
title: function(albumID) {
|
||||
|
||||
var longTitle = '',
|
||||
title = albums.json.content[albumID].title;
|
||||
title = albums.json.albums[albumID].title;
|
||||
|
||||
if (title!==null&&title.length>18) {
|
||||
longTitle = title;
|
||||
|
Loading…
Reference in New Issue
Block a user