ids -> photoIDs

This commit is contained in:
Tobias Reich 2014-01-31 20:11:28 +01:00
parent 458d4ad98e
commit f3aa01dc05
5 changed files with 54 additions and 54 deletions

View File

@ -140,7 +140,7 @@ contextMenu = {
}, },
photoMulti: function(ids, e) { photoMulti: function(photoIDs, e) {
var mouse_x = e.pageX, var mouse_x = e.pageX,
mouse_y = e.pageY - $(document).scrollTop(), mouse_y = e.pageY - $(document).scrollTop(),
@ -149,10 +149,10 @@ contextMenu = {
multiselect.stopResize(); multiselect.stopResize();
contextMenu.fns = [ contextMenu.fns = [
function() { photo.setStar(ids) }, function() { photo.setStar(photoIDs) },
function() { photo.setTitle(ids) }, function() { photo.setTitle(photoIDs) },
function() { contextMenu.move(ids, e, "right") }, function() { contextMenu.move(photoIDs, e, "right") },
function() { photo.delete(ids) } function() { photo.delete(photoIDs) }
]; ];
items = [ items = [
@ -167,7 +167,7 @@ contextMenu = {
}, },
move: function(ids, e, orientation) { move: function(photoIDs, e, orientation) {
var mouse_x = e.pageX, var mouse_x = e.pageX,
mouse_y = e.pageY - $(document).scrollTop(), mouse_y = e.pageY - $(document).scrollTop(),
@ -177,7 +177,7 @@ contextMenu = {
if (album.getID()!=="0") { if (album.getID()!=="0") {
items = [ items = [
["Unsorted", 0, "photo.setAlbum([" + ids + "], 0)"], ["Unsorted", 0, "photo.setAlbum([" + photoIDs + "], 0)"],
["separator", -1] ["separator", -1]
]; ];
} }
@ -188,7 +188,7 @@ contextMenu = {
items = [["New Album", 0, "album.add()"]]; items = [["New Album", 0, "album.add()"]];
} else { } else {
$.each(data.content, function(index) { $.each(data.content, function(index) {
if (this.id!=album.getID()) items.push([this.title, 0, "photo.setAlbum([" + ids + "], " + this.id + ")"]); if (this.id!=album.getID()) items.push([this.title, 0, "photo.setAlbum([" + photoIDs + "], " + this.id + ")"]);
}); });
} }

View File

@ -112,7 +112,7 @@ multiselect = {
getSelection: function(e) { getSelection: function(e) {
var ids = [], var photoIDs = [],
offset, offset,
size = multiselect.getSize(); size = multiselect.getSize();
@ -127,14 +127,14 @@ multiselect = {
offset.left>=size.left&& offset.left>=size.left&&
(offset.top+206)<=(size.top+size.height)&& (offset.top+206)<=(size.top+size.height)&&
(offset.left+206)<=(size.left+size.width)) { (offset.left+206)<=(size.left+size.width)) {
ids.push($(this).data('id')); photoIDs.push($(this).data('id'));
$(this).addClass('active'); $(this).addClass('active');
} }
}); });
if (ids.length!=0&&visible.album()) contextMenu.photoMulti(ids, e); if (photoIDs.length!=0&&visible.album()) contextMenu.photoMulti(photoIDs, e);
else if (ids.length!=0&&visible.albums()) contextMenu.albumMulti(ids, e); else if (photoIDs.length!=0&&visible.albums()) contextMenu.albumMulti(photoIDs, e);
else multiselect.close(); else multiselect.close();
}, },

View File

@ -56,26 +56,26 @@ photo = {
}, },
delete: function(ids) { delete: function(photoIDs) {
var params, var params,
buttons, buttons,
photoTitle; photoTitle;
if (!ids) return false; if (!photoIDs) return false;
if (ids instanceof Array===false) ids = [ids]; if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
if (ids.length===1) { if (photoIDs.length===1) {
// Get title if only one photo is selected // Get title if only one photo is selected
if (visible.photo()) photoTitle = photo.json.title; if (visible.photo()) photoTitle = photo.json.title;
else photoTitle = album.json.content[ids].title; else photoTitle = album.json.content[photoIDs].title;
if (photoTitle=="") photoTitle = "Untitled"; if (photoTitle=="") photoTitle = "Untitled";
} }
buttons = [ buttons = [
["Delete", function() { ["Delete", function() {
ids.forEach(function(id, index, array) { photoIDs.forEach(function(id, index, array) {
// Change reference for the next and previous photo // Change reference for the next and previous photo
if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") { if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") {
@ -96,7 +96,7 @@ photo = {
// Only when search is not active // Only when search is not active
if (!visible.albums()) lychee.goto(album.getID()); if (!visible.albums()) lychee.goto(album.getID());
params = "deletePhoto&ids=" + ids; params = "deletePhoto&photoIDs=" + photoIDs;
lychee.api(params, function(data) { lychee.api(params, function(data) {
if (data!==true) lychee.error(null, params, data); if (data!==true) lychee.error(null, params, data);
@ -107,25 +107,25 @@ photo = {
["Cancel", function() {}] ["Cancel", function() {}]
]; ];
if (ids.length===1) modal.show("Delete Photo", "Are you sure you want to delete the photo '" + photoTitle + "'?<br>This action can't be undone!", buttons); if (photoIDs.length===1) modal.show("Delete Photo", "Are you sure you want to delete the photo '" + photoTitle + "'?<br>This action can't be undone!", buttons);
else modal.show("Delete Photos", "Are you sure you want to delete all " + ids.length + " selected photo?<br>This action can't be undone!", buttons); else modal.show("Delete Photos", "Are you sure you want to delete all " + photoIDs.length + " selected photo?<br>This action can't be undone!", buttons);
}, },
setTitle: function(ids) { setTitle: function(photoIDs) {
var oldTitle = "", var oldTitle = "",
newTitle, newTitle,
params, params,
buttons; buttons;
if (!ids) return false; if (!photoIDs) return false;
if (ids instanceof Array===false) ids = [ids]; if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
if (ids.length===1) { if (photoIDs.length===1) {
// Get old title if only one photo is selected // Get old title if only one photo is selected
if (photo.json) oldTitle = photo.json.title; if (photo.json) oldTitle = photo.json.title;
else if (album.json) oldTitle = album.json.content[ids].title; else if (album.json) oldTitle = album.json.content[photoIDs].title;
} }
buttons = [ buttons = [
@ -140,12 +140,12 @@ photo = {
view.photo.title(oldTitle); view.photo.title(oldTitle);
} }
ids.forEach(function(id, index, array) { photoIDs.forEach(function(id, index, array) {
album.json.content[id].title = newTitle; album.json.content[id].title = newTitle;
view.album.content.title(id); view.album.content.title(id);
}); });
params = "setPhotoTitle&ids=" + ids + "&title=" + escape(encodeURI(newTitle)); params = "setPhotoTitle&photoIDs=" + photoIDs + "&title=" + escape(encodeURI(newTitle));
lychee.api(params, function(data) { lychee.api(params, function(data) {
if (data!==true) lychee.error(null, params, data); if (data!==true) lychee.error(null, params, data);
@ -158,22 +158,22 @@ photo = {
["Cancel", function() {}] ["Cancel", function() {}]
]; ];
if (ids.length===1) modal.show("Set Title", "Please enter a new title for this photo: <input class='text' type='text' placeholder='Title' value='" + oldTitle + "'>", buttons); if (photoIDs.length===1) modal.show("Set Title", "Please enter a new title for this photo: <input class='text' type='text' placeholder='Title' value='" + oldTitle + "'>", buttons);
else modal.show("Set Titles", "Please enter a title for all selected photos: <input class='text' type='text' placeholder='Title' value=''>", buttons); else modal.show("Set Titles", "Please enter a title for all selected photos: <input class='text' type='text' placeholder='Title' value=''>", buttons);
}, },
setAlbum: function(ids, albumID) { setAlbum: function(photoIDs, albumID) {
var params, var params,
nextPhoto, nextPhoto,
previousPhoto; previousPhoto;
if (!ids) return false; if (!photoIDs) return false;
if (visible.photo) lychee.goto(album.getID()); if (visible.photo) lychee.goto(album.getID());
if (ids instanceof Array===false) ids = [ids]; if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
ids.forEach(function(id, index, array) { photoIDs.forEach(function(id, index, array) {
// Change reference for the next and previous photo // Change reference for the next and previous photo
if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") { if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") {
@ -191,7 +191,7 @@ photo = {
}); });
params = "setAlbum&ids=" + ids + "&albumID=" + albumID; params = "setAlbum&photoIDs=" + photoIDs + "&albumID=" + albumID;
lychee.api(params, function(data) { lychee.api(params, function(data) {
if (data!==true) lychee.error(null, params, data); if (data!==true) lychee.error(null, params, data);
@ -200,22 +200,22 @@ photo = {
}, },
setStar: function(ids) { setStar: function(photoIDs) {
var params; var params;
if (!ids) return false; if (!photoIDs) return false;
if (visible.photo()) { if (visible.photo()) {
photo.json.star = (photo.json.star==0) ? 1 : 0; photo.json.star = (photo.json.star==0) ? 1 : 0;
view.photo.star(); view.photo.star();
} }
ids.forEach(function(id, index, array) { photoIDs.forEach(function(id, index, array) {
album.json.content[id].star = (album.json.content[id].star==0) ? 1 : 0; album.json.content[id].star = (album.json.content[id].star==0) ? 1 : 0;
view.album.content.star(id); view.album.content.star(id);
}); });
params = "setPhotoStar&ids=" + ids; params = "setPhotoStar&photoIDs=" + photoIDs;
lychee.api(params, function(data) { lychee.api(params, function(data) {
if (data!==true) lychee.error(null, params, data); if (data!==true) lychee.error(null, params, data);

View File

@ -110,20 +110,20 @@ if (!empty($_POST['function'])||!empty($_GET['function'])) {
echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID'])); echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID']));
break; break;
case 'deletePhoto': if (isset($_POST['ids'])) case 'deletePhoto': if (isset($_POST['photoIDs']))
echo deletePhoto($_POST['ids']); echo deletePhoto($_POST['photoIDs']);
break; break;
case 'setAlbum': if (isset($_POST['ids'])&&isset($_POST['albumID'])) case 'setAlbum': if (isset($_POST['photoIDs'])&&isset($_POST['albumID']))
echo setAlbum($_POST['ids'], $_POST['albumID']); echo setAlbum($_POST['photoIDs'], $_POST['albumID']);
break; break;
case 'setPhotoTitle': if (isset($_POST['ids'])&&isset($_POST['title'])) case 'setPhotoTitle': if (isset($_POST['photoIDs'])&&isset($_POST['title']))
echo setPhotoTitle($_POST['ids'], $_POST['title']); echo setPhotoTitle($_POST['photoIDs'], $_POST['title']);
break; break;
case 'setPhotoStar': if (isset($_POST['ids'])) case 'setPhotoStar': if (isset($_POST['photoIDs']))
echo setPhotoStar($_POST['ids']); echo setPhotoStar($_POST['photoIDs']);
break; break;
case 'setPhotoPublic': if (isset($_POST['photoID'])&&isset($_POST['url'])) case 'setPhotoPublic': if (isset($_POST['photoID'])&&isset($_POST['url']))

View File

@ -71,12 +71,12 @@ function setPhotoPublic($photoID, $url) {
} }
function setPhotoStar($ids) { function setPhotoStar($photoIDs) {
global $database; global $database;
$error = false; $error = false;
$result = $database->query("SELECT id, star FROM lychee_photos WHERE id IN ($ids);"); $result = $database->query("SELECT id, star FROM lychee_photos WHERE id IN ($photoIDs);");
while ($row = $result->fetch_object()) { while ($row = $result->fetch_object()) {
@ -93,23 +93,23 @@ function setPhotoStar($ids) {
} }
function setAlbum($ids, $albumID) { function setAlbum($photoIDs, $albumID) {
global $database; global $database;
$result = $database->query("UPDATE lychee_photos SET album = '$albumID' WHERE id IN ($ids);"); $result = $database->query("UPDATE lychee_photos SET album = '$albumID' WHERE id IN ($photoIDs);");
if (!$result) return false; if (!$result) return false;
return true; return true;
} }
function setPhotoTitle($ids, $title) { function setPhotoTitle($photoIDs, $title) {
global $database; global $database;
if (strlen($title)>30) return false; if (strlen($title)>30) return false;
$result = $database->query("UPDATE lychee_photos SET title = '$title' WHERE id IN ($ids);"); $result = $database->query("UPDATE lychee_photos SET title = '$title' WHERE id IN ($photoIDs);");
if (!$result) return false; if (!$result) return false;
return true; return true;
@ -129,11 +129,11 @@ function setPhotoDescription($photoID, $description) {
} }
function deletePhoto($ids) { function deletePhoto($photoIDs) {
global $database; global $database;
$result = $database->query("SELECT * FROM lychee_photos WHERE id IN ($ids);"); $result = $database->query("SELECT * FROM lychee_photos WHERE id IN ($photoIDs);");
while ($row = $result->fetch_object()) { while ($row = $result->fetch_object()) {