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
|
# Call plugins
|
||||||
$this->plugins(__METHOD__, 0, func_get_args());
|
$this->plugins(__METHOD__, 0, func_get_args());
|
||||||
|
|
||||||
|
# Initialize return var
|
||||||
|
$return = array(
|
||||||
|
'smartalbums' => null,
|
||||||
|
'albums' => null,
|
||||||
|
'num' => 0
|
||||||
|
);
|
||||||
|
|
||||||
# Get SmartAlbums
|
# Get SmartAlbums
|
||||||
if ($public===false) $return = $this->getSmartInfo();
|
if ($public===false) $return['smartalbums'] = $this->getSmartInfo();
|
||||||
|
|
||||||
# Albums query
|
# Albums query
|
||||||
$query = Database::prepare($this->database, 'SELECT id, title, public, sysstamp, password FROM ? WHERE public = 1 AND visible <> 0', array(LYCHEE_TABLE_ALBUMS));
|
$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
|
# Add to return
|
||||||
$return['content'][$album['id']] = $album;
|
$return['albums'][$album['id']] = $album;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,29 +218,25 @@ class Album extends Module {
|
|||||||
# Check dependencies
|
# Check dependencies
|
||||||
self::dependencies(isset($this->database, $this->settings));
|
self::dependencies(isset($this->database, $this->settings));
|
||||||
|
|
||||||
|
# Initialize return var
|
||||||
|
$return = array(
|
||||||
|
'unsorted' => null,
|
||||||
|
'public' => null,
|
||||||
|
'starred' => null,
|
||||||
|
'recent' => null
|
||||||
|
);
|
||||||
|
|
||||||
# Unsorted
|
# Unsorted
|
||||||
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE album = 0 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE album = 0 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
||||||
$unsorted = $this->database->query($query);
|
$unsorted = $this->database->query($query);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while($row = $unsorted->fetch_object()) {
|
while($row = $unsorted->fetch_object()) {
|
||||||
if ($i<3) {
|
if ($i<3) {
|
||||||
$return["unsortedThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row->thumbUrl;
|
$return['unsorted']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row->thumbUrl;
|
||||||
$i++;
|
$i++;
|
||||||
} else break;
|
} else break;
|
||||||
}
|
}
|
||||||
$return['unsortedNum'] = $unsorted->num_rows;
|
$return['unsorted']['num'] = $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;
|
|
||||||
|
|
||||||
# Starred
|
# Starred
|
||||||
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE star = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
$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;
|
$i = 0;
|
||||||
while($row3 = $starred->fetch_object()) {
|
while($row3 = $starred->fetch_object()) {
|
||||||
if ($i<3) {
|
if ($i<3) {
|
||||||
$return["starredThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
|
$return['starred']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
|
||||||
$i++;
|
$i++;
|
||||||
} else break;
|
} 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
|
# 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));
|
$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;
|
$i = 0;
|
||||||
while($row3 = $recent->fetch_object()) {
|
while($row3 = $recent->fetch_object()) {
|
||||||
if ($i<3) {
|
if ($i<3) {
|
||||||
$return["recentThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
|
$return['recent']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
|
||||||
$i++;
|
$i++;
|
||||||
} else break;
|
} else break;
|
||||||
}
|
}
|
||||||
$return['recentNum'] = $recent->num_rows;
|
$return['recent']['num'] = $recent->num_rows;
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ album.delete = function(albumIDs) {
|
|||||||
albumIDs.forEach(function(id) {
|
albumIDs.forEach(function(id) {
|
||||||
albums.json.num--;
|
albums.json.num--;
|
||||||
view.albums.content.delete(id);
|
view.albums.content.delete(id);
|
||||||
delete albums.json.content[id];
|
delete albums.json.albums[id];
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -209,7 +209,7 @@ album.delete = function(albumIDs) {
|
|||||||
|
|
||||||
// Get title
|
// Get title
|
||||||
if (album.json) albumTitle = album.json.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>";
|
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
|
// Get old title if only one album is selected
|
||||||
if (album.json) oldTitle = album.json.title;
|
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 = '';
|
if (!oldTitle) oldTitle = '';
|
||||||
oldTitle = oldTitle.replace("'", ''');
|
oldTitle = oldTitle.replace("'", ''');
|
||||||
@ -280,13 +280,13 @@ album.setTitle = function(albumIDs) {
|
|||||||
|
|
||||||
if (albums.json) {
|
if (albums.json) {
|
||||||
var id = albumIDs[0];
|
var id = albumIDs[0];
|
||||||
albums.json.content[id].title = newTitle;
|
albums.json.albums[id].title = newTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (visible.albums()) {
|
} else if (visible.albums()) {
|
||||||
|
|
||||||
albumIDs.forEach(function(id) {
|
albumIDs.forEach(function(id) {
|
||||||
albums.json.content[id].title = newTitle;
|
albums.json.albums[id].title = newTitle;
|
||||||
view.albums.content.title(id);
|
view.albums.content.title(id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -25,44 +25,44 @@ albums.load = function() {
|
|||||||
api.post('Album::getAll', {}, function(data) {
|
api.post('Album::getAll', {}, function(data) {
|
||||||
|
|
||||||
/* Smart Albums */
|
/* Smart Albums */
|
||||||
data.unsortedAlbum = {
|
data.smartalbums.unsorted = {
|
||||||
id: 0,
|
id: 0,
|
||||||
title: 'Unsorted',
|
title: 'Unsorted',
|
||||||
sysdate: data.unsortedNum + ' photos',
|
sysdate: data.smartalbums.unsorted.num + ' photos',
|
||||||
unsorted: '1',
|
unsorted: '1',
|
||||||
thumb0: data.unsortedThumb0,
|
thumb0: data.smartalbums.unsorted.thumb0,
|
||||||
thumb1: data.unsortedThumb1,
|
thumb1: data.smartalbums.unsorted.thumb1,
|
||||||
thumb2: data.unsortedThumb2
|
thumb2: data.smartalbums.unsorted.thumb2
|
||||||
};
|
};
|
||||||
|
|
||||||
data.starredAlbum = {
|
data.smartalbums.starred = {
|
||||||
id: 'f',
|
id: 'f',
|
||||||
title: 'Starred',
|
title: 'Starred',
|
||||||
sysdate: data.starredNum + ' photos',
|
sysdate: data.smartalbums.starred.num + ' photos',
|
||||||
star: '1',
|
star: '1',
|
||||||
thumb0: data.starredThumb0,
|
thumb0: data.smartalbums.starred.thumb0,
|
||||||
thumb1: data.starredThumb1,
|
thumb1: data.smartalbums.starred.thumb1,
|
||||||
thumb2: data.starredThumb2
|
thumb2: data.smartalbums.starred.thumb2
|
||||||
};
|
};
|
||||||
|
|
||||||
data.publicAlbum = {
|
data.smartalbums.public = {
|
||||||
id: 's',
|
id: 's',
|
||||||
title: 'Public',
|
title: 'Public',
|
||||||
sysdate: data.publicNum + ' photos',
|
sysdate: data.smartalbums.public.num + ' photos',
|
||||||
public: '1',
|
public: '1',
|
||||||
thumb0: data.publicThumb0,
|
thumb0: data.smartalbums.public.thumb0,
|
||||||
thumb1: data.publicThumb1,
|
thumb1: data.smartalbums.public.thumb1,
|
||||||
thumb2: data.publicThumb2
|
thumb2: data.smartalbums.public.thumb2
|
||||||
};
|
};
|
||||||
|
|
||||||
data.recentAlbum = {
|
data.smartalbums.recent = {
|
||||||
id: 'r',
|
id: 'r',
|
||||||
title: 'Recent',
|
title: 'Recent',
|
||||||
sysdate: data.recentNum + ' photos',
|
sysdate: data.smartalbums.recent.num + ' photos',
|
||||||
recent: '1',
|
recent: '1',
|
||||||
thumb0: data.recentThumb0,
|
thumb0: data.smartalbums.recent.thumb0,
|
||||||
thumb1: data.recentThumb1,
|
thumb1: data.smartalbums.recent.thumb1,
|
||||||
thumb2: data.recentThumb2
|
thumb2: data.smartalbums.recent.thumb2
|
||||||
};
|
};
|
||||||
|
|
||||||
albums.json = data;
|
albums.json = data;
|
||||||
@ -79,7 +79,7 @@ albums.load = function() {
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
header.setMode('albums');
|
header.setMode('albums');
|
||||||
view.albums.init();
|
view.albums.init();
|
||||||
lychee.animate('.album, .photo', 'contentZoomIn');
|
lychee.animate('.album', 'contentZoomIn');
|
||||||
}, waitTime);
|
}, waitTime);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ contextMenu.albumTitle = function(albumID, e) {
|
|||||||
items.push({ type: 'separator' });
|
items.push({ type: 'separator' });
|
||||||
|
|
||||||
// Generate list of albums
|
// Generate list of albums
|
||||||
$.each(data.content, function(index) {
|
$.each(data.albums, function(index) {
|
||||||
|
|
||||||
var that = this,
|
var that = this,
|
||||||
title = '';
|
title = '';
|
||||||
@ -220,7 +220,7 @@ contextMenu.move = function(photoIDs, e) {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Generate list of albums
|
// Generate list of albums
|
||||||
$.each(data.content, function(index) {
|
$.each(data.albums, function(index) {
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ password.get = function(albumID, callback) {
|
|||||||
|
|
||||||
if (!lychee.publicMode) callback();
|
if (!lychee.publicMode) callback();
|
||||||
else if (album.json&&album.json.password==false) 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) {
|
else if (!albums.json&&!album.json) {
|
||||||
|
|
||||||
// Continue without password
|
// Continue without password
|
||||||
|
@ -49,16 +49,21 @@ view.albums = {
|
|||||||
albumsData = '';
|
albumsData = '';
|
||||||
|
|
||||||
/* Smart Albums */
|
/* Smart Albums */
|
||||||
albums.parse(albums.json.unsortedAlbum);
|
if (!lychee.publicMode) {
|
||||||
albums.parse(albums.json.publicAlbum);
|
|
||||||
albums.parse(albums.json.starredAlbum);
|
albums.parse(albums.json.smartalbums.unsorted);
|
||||||
albums.parse(albums.json.recentAlbum);
|
albums.parse(albums.json.smartalbums.public);
|
||||||
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);
|
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 */
|
/* 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);
|
albums.parse(this);
|
||||||
|
|
||||||
// Display albums in reverse order
|
// Display albums in reverse order
|
||||||
@ -88,7 +93,7 @@ view.albums = {
|
|||||||
title: function(albumID) {
|
title: function(albumID) {
|
||||||
|
|
||||||
var longTitle = '',
|
var longTitle = '',
|
||||||
title = albums.json.content[albumID].title;
|
title = albums.json.albums[albumID].title;
|
||||||
|
|
||||||
if (title!==null&&title.length>18) {
|
if (title!==null&&title.length>18) {
|
||||||
longTitle = title;
|
longTitle = title;
|
||||||
|
Loading…
Reference in New Issue
Block a user