From f3aa01dc051713f0cefb5b758cc99054a5e51fd4 Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Fri, 31 Jan 2014 20:11:28 +0100 Subject: [PATCH] ids -> photoIDs --- assets/js/modules/contextMenu.js | 16 +++++----- assets/js/modules/multiselect.js | 8 ++--- assets/js/modules/photo.js | 52 ++++++++++++++++---------------- php/api.php | 16 +++++----- php/modules/photo.php | 16 +++++----- 5 files changed, 54 insertions(+), 54 deletions(-) diff --git a/assets/js/modules/contextMenu.js b/assets/js/modules/contextMenu.js index 7c8d8aa..7ca5c30 100644 --- a/assets/js/modules/contextMenu.js +++ b/assets/js/modules/contextMenu.js @@ -140,7 +140,7 @@ contextMenu = { }, - photoMulti: function(ids, e) { + photoMulti: function(photoIDs, e) { var mouse_x = e.pageX, mouse_y = e.pageY - $(document).scrollTop(), @@ -149,10 +149,10 @@ contextMenu = { multiselect.stopResize(); contextMenu.fns = [ - function() { photo.setStar(ids) }, - function() { photo.setTitle(ids) }, - function() { contextMenu.move(ids, e, "right") }, - function() { photo.delete(ids) } + function() { photo.setStar(photoIDs) }, + function() { photo.setTitle(photoIDs) }, + function() { contextMenu.move(photoIDs, e, "right") }, + function() { photo.delete(photoIDs) } ]; items = [ @@ -167,7 +167,7 @@ contextMenu = { }, - move: function(ids, e, orientation) { + move: function(photoIDs, e, orientation) { var mouse_x = e.pageX, mouse_y = e.pageY - $(document).scrollTop(), @@ -177,7 +177,7 @@ contextMenu = { if (album.getID()!=="0") { items = [ - ["Unsorted", 0, "photo.setAlbum([" + ids + "], 0)"], + ["Unsorted", 0, "photo.setAlbum([" + photoIDs + "], 0)"], ["separator", -1] ]; } @@ -188,7 +188,7 @@ contextMenu = { items = [["New Album", 0, "album.add()"]]; } else { $.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 + ")"]); }); } diff --git a/assets/js/modules/multiselect.js b/assets/js/modules/multiselect.js index d4263c3..8f9cd31 100644 --- a/assets/js/modules/multiselect.js +++ b/assets/js/modules/multiselect.js @@ -112,7 +112,7 @@ multiselect = { getSelection: function(e) { - var ids = [], + var photoIDs = [], offset, size = multiselect.getSize(); @@ -127,14 +127,14 @@ multiselect = { offset.left>=size.left&& (offset.top+206)<=(size.top+size.height)&& (offset.left+206)<=(size.left+size.width)) { - ids.push($(this).data('id')); + photoIDs.push($(this).data('id')); $(this).addClass('active'); } }); - if (ids.length!=0&&visible.album()) contextMenu.photoMulti(ids, e); - else if (ids.length!=0&&visible.albums()) contextMenu.albumMulti(ids, e); + if (photoIDs.length!=0&&visible.album()) contextMenu.photoMulti(photoIDs, e); + else if (photoIDs.length!=0&&visible.albums()) contextMenu.albumMulti(photoIDs, e); else multiselect.close(); }, diff --git a/assets/js/modules/photo.js b/assets/js/modules/photo.js index 175707c..3e0a5e9 100644 --- a/assets/js/modules/photo.js +++ b/assets/js/modules/photo.js @@ -56,26 +56,26 @@ photo = { }, - delete: function(ids) { + delete: function(photoIDs) { var params, buttons, photoTitle; - if (!ids) return false; - if (ids instanceof Array===false) ids = [ids]; + if (!photoIDs) return false; + if (photoIDs instanceof Array===false) photoIDs = [photoIDs]; - if (ids.length===1) { + if (photoIDs.length===1) { // Get title if only one photo is selected 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"; } buttons = [ ["Delete", function() { - ids.forEach(function(id, index, array) { + photoIDs.forEach(function(id, index, array) { // Change reference for the next and previous photo if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") { @@ -96,7 +96,7 @@ photo = { // Only when search is not active if (!visible.albums()) lychee.goto(album.getID()); - params = "deletePhoto&ids=" + ids; + params = "deletePhoto&photoIDs=" + photoIDs; lychee.api(params, function(data) { if (data!==true) lychee.error(null, params, data); @@ -107,25 +107,25 @@ photo = { ["Cancel", function() {}] ]; - if (ids.length===1) modal.show("Delete Photo", "Are you sure you want to delete the photo '" + photoTitle + "'?
This action can't be undone!", buttons); - else modal.show("Delete Photos", "Are you sure you want to delete all " + ids.length + " selected photo?
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 + "'?
This action can't be undone!", buttons); + else modal.show("Delete Photos", "Are you sure you want to delete all " + photoIDs.length + " selected photo?
This action can't be undone!", buttons); }, - setTitle: function(ids) { + setTitle: function(photoIDs) { var oldTitle = "", newTitle, params, buttons; - if (!ids) return false; - if (ids instanceof Array===false) ids = [ids]; + if (!photoIDs) return false; + if (photoIDs instanceof Array===false) photoIDs = [photoIDs]; - if (ids.length===1) { + if (photoIDs.length===1) { // Get old title if only one photo is selected 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 = [ @@ -140,12 +140,12 @@ photo = { view.photo.title(oldTitle); } - ids.forEach(function(id, index, array) { + photoIDs.forEach(function(id, index, array) { album.json.content[id].title = newTitle; 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) { if (data!==true) lychee.error(null, params, data); @@ -158,22 +158,22 @@ photo = { ["Cancel", function() {}] ]; - if (ids.length===1) modal.show("Set Title", "Please enter a new title for this photo: ", buttons); + if (photoIDs.length===1) modal.show("Set Title", "Please enter a new title for this photo: ", buttons); else modal.show("Set Titles", "Please enter a title for all selected photos: ", buttons); }, - setAlbum: function(ids, albumID) { + setAlbum: function(photoIDs, albumID) { var params, nextPhoto, previousPhoto; - if (!ids) return false; + if (!photoIDs) return false; 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 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) { if (data!==true) lychee.error(null, params, data); @@ -200,22 +200,22 @@ photo = { }, - setStar: function(ids) { + setStar: function(photoIDs) { var params; - if (!ids) return false; + if (!photoIDs) return false; if (visible.photo()) { photo.json.star = (photo.json.star==0) ? 1 : 0; 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; view.album.content.star(id); }); - params = "setPhotoStar&ids=" + ids; + params = "setPhotoStar&photoIDs=" + photoIDs; lychee.api(params, function(data) { if (data!==true) lychee.error(null, params, data); diff --git a/php/api.php b/php/api.php index f57a237..cff6b6f 100755 --- a/php/api.php +++ b/php/api.php @@ -110,20 +110,20 @@ if (!empty($_POST['function'])||!empty($_GET['function'])) { echo json_encode(getPhoto($_POST['photoID'], $_POST['albumID'])); break; - case 'deletePhoto': if (isset($_POST['ids'])) - echo deletePhoto($_POST['ids']); + case 'deletePhoto': if (isset($_POST['photoIDs'])) + echo deletePhoto($_POST['photoIDs']); break; - case 'setAlbum': if (isset($_POST['ids'])&&isset($_POST['albumID'])) - echo setAlbum($_POST['ids'], $_POST['albumID']); + case 'setAlbum': if (isset($_POST['photoIDs'])&&isset($_POST['albumID'])) + echo setAlbum($_POST['photoIDs'], $_POST['albumID']); break; - case 'setPhotoTitle': if (isset($_POST['ids'])&&isset($_POST['title'])) - echo setPhotoTitle($_POST['ids'], $_POST['title']); + case 'setPhotoTitle': if (isset($_POST['photoIDs'])&&isset($_POST['title'])) + echo setPhotoTitle($_POST['photoIDs'], $_POST['title']); break; - case 'setPhotoStar': if (isset($_POST['ids'])) - echo setPhotoStar($_POST['ids']); + case 'setPhotoStar': if (isset($_POST['photoIDs'])) + echo setPhotoStar($_POST['photoIDs']); break; case 'setPhotoPublic': if (isset($_POST['photoID'])&&isset($_POST['url'])) diff --git a/php/modules/photo.php b/php/modules/photo.php index d78a20c..40f4d2a 100755 --- a/php/modules/photo.php +++ b/php/modules/photo.php @@ -71,12 +71,12 @@ function setPhotoPublic($photoID, $url) { } -function setPhotoStar($ids) { +function setPhotoStar($photoIDs) { global $database; $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()) { @@ -93,23 +93,23 @@ function setPhotoStar($ids) { } -function setAlbum($ids, $albumID) { +function setAlbum($photoIDs, $albumID) { 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; return true; } -function setPhotoTitle($ids, $title) { +function setPhotoTitle($photoIDs, $title) { global $database; 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; return true; @@ -129,11 +129,11 @@ function setPhotoDescription($photoID, $description) { } -function deletePhoto($ids) { +function deletePhoto($photoIDs) { 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()) {