Syntax adjustments

This commit is contained in:
Tobias Reich 2016-07-31 15:53:34 +02:00
parent 1020b0d1dc
commit 0c7d95fb15
9 changed files with 78 additions and 56 deletions

View File

@ -282,7 +282,7 @@ final class Album {
private function cleanZipName($name) { private function cleanZipName($name) {
// Illicit chars // Illicit chars
$badChars = array_merge( $badChars = array_merge(
array_map('chr', range(0,31)), array_map('chr', range(0,31)),
array("<", ">", ":", '"', "/", "\\", "|", "?", "*") array("<", ">", ":", '"', "/", "\\", "|", "?", "*")
); );

View File

@ -8,14 +8,19 @@ use Lychee\Modules\Database;
use Lychee\Modules\Response; use Lychee\Modules\Response;
// Add parent field to albums // Add parent field to albums
$query = Database::prepare($connection, "SELECT `parent` FROM `?` LIMIT 1", array(LYCHEE_TABLE_ALBUMS)); $query = Database::prepare($connection, "SELECT `parent` FROM `?` LIMIT 1", array(LYCHEE_TABLE_ALBUMS));
if (!Database::execute($connection, $query, "update_030103", __LINE__)) { $result = Database::execute($connection, $query, "update_030103", __LINE__);
$query = Database::prepare($connection, "ALTER TABLE `?` ADD `parent` BIGINT(14) NOT NULL DEFAULT 0", array(LYCHEE_TABLE_ALBUMS));
$result = Database::execute($connection, $query, "update_030103", __LINE__); if ($result===false) {
if (!$result) {
Log::error($database, 'update_030103', __LINE__, 'Could not update database (' . $database->error . ')'); $query = Database::prepare($connection, "ALTER TABLE `?` ADD `parent` BIGINT(14) NOT NULL DEFAULT 0", array(LYCHEE_TABLE_ALBUMS));
return false; $result = Database::execute($connection, $query, "update_030103", __LINE__);
}
if ($result===false) {
Log::error($database, 'update_030103', __LINE__, 'Could not update database (' . $database->error . ')');
return false;
}
} }
// Set version // Set version

View File

@ -12,7 +12,7 @@ album = {
album.isSmartID = function(id) { album.isSmartID = function(id) {
return id==='0' || id==='f' || id==='s' || id==='r' return (id==='0' || id==='f' || id==='s' || id==='r')
} }
@ -21,7 +21,7 @@ album.getID = function() {
let id = null let id = null
let isID = (id) => { let isID = (id) => {
if (album.isSmartID(id)) return true if (album.isSmartID(id)===true) return true
return $.isNumeric(id) return $.isNumeric(id)
} }
@ -35,19 +35,18 @@ album.getID = function() {
} }
if (isID(id)===true) return id if (isID(id)===true) return id
else return false
return false
} }
album.getParent = function () { album.getParent = function() {
let id = album.json.id; let id = album.json.id
if (album.isSmartID(id) || album.json.parent==0) { if (album.isSmartID(id)===true || album.json.parent==0) return ''
return ''
} else { return album.json.parent
return album.json.parent
}
} }
@ -109,7 +108,8 @@ album.load = function(albumID, refresh = false) {
} }
} }
if (!album.isSmartID(albumID)) { if (album.isSmartID(albumID)===false) {
params = { params = {
parent: albumID parent: albumID
} }
@ -125,14 +125,14 @@ album.load = function(albumID, refresh = false) {
if (durationTime>300) waitTime = 0 if (durationTime>300) waitTime = 0
else waitTime = 300 - durationTime else waitTime = 300 - durationTime
setTimeout(() => { setTimeout(finish, waitTime)
finish()
}, waitTime)
}) })
}
else { } else {
finish() finish()
} }
}, waitTime) }, waitTime)
@ -192,17 +192,22 @@ album.add = function(albumID = 0) {
} }
api.post('Albums::get', { api.post('Albums::get', { parent: -1 }, function(data) {
parent: -1
}, function (data) { let cmbxOptions = `
var cmbxOptions = `<select name='parent'>` <select name='parent'>
cmbxOptions += `<option value='0'>- None -</option>` <option value='0'>- None -</option>
cmbxOptions += buildAlbumOptions(data.albums, albumID) ${ buildAlbumOptions(data.albums, albumID) }
cmbxOptions += '</select>' </select>
`
let msg = `
<p>Enter a title for the new album: <input class='text' name='title' type='text' maxlength='50' placeholder='Title' value='Untitled'></p>
<p>Select the parent album:<br/> ${ cmbxOptions }</p>
`
basicModal.show({ basicModal.show({
body: `<p>Enter a title for the new album: <input class='text' name='title' type='text' maxlength='50' placeholder='Title' value='Untitled'></p>` body: msg,
+ `<p>Select the parent album:<br/>` + cmbxOptions + `</p>`,
buttons: { buttons: {
action: { action: {
title: 'Create Album', title: 'Create Album',
@ -214,6 +219,7 @@ album.add = function(albumID = 0) {
} }
} }
}) })
}) })
} }

View File

@ -17,7 +17,7 @@ albums.load = function() {
if (albums.json===null) { if (albums.json===null) {
params = { let params = {
parent: 0 parent: 0
} }

View File

@ -134,7 +134,7 @@ contextMenu.albumTitle = function(albumID, e) {
if (data.albums && data.num>1) { if (data.albums && data.num>1) {
items = buildAlbumList(data.albums, [albumID], (a) => lychee.goto(a.id)) items = buildAlbumList(data.albums, [ albumID ], (a) => lychee.goto(a.id))
items.unshift({ }) items.unshift({ })
@ -168,14 +168,14 @@ contextMenu.mergeAlbum = function(albumID, e) {
let title = selalbum.title let title = selalbum.title
// disable all parents; we cannot move them into us // disable all parents; we cannot move them into us
let exclude = [albumID] let exclude = [ albumID ]
let a = getAlbumFrom(data.albums, selalbum.parent) let a = getAlbumFrom(data.albums, selalbum.parent)
while (a != null) { while (a != null) {
exclude.push(a.id) exclude.push(a.id)
a = getAlbumFrom(data.albums, a.parent) a = getAlbumFrom(data.albums, a.parent)
} }
items = buildAlbumList(data.albums, exclude, (a) => album.merge([ albumID, a.id ], [title, a.title])) items = buildAlbumList(data.albums, exclude, (a) => album.merge([ albumID, a.id ], [ title, a.title ]))
} }
@ -232,7 +232,7 @@ contextMenu.photoMulti = function(photoIDs, e) {
if (subcount && photocount) { if (subcount && photocount) {
$('.photo.active, .album.active').removeClass('active') $('.photo.active, .album.active').removeClass('active')
multiselect.close() multiselect.close()
lychee.error("Please select either albums or photos!") lychee.error('Please select either albums or photos!')
return return
} }
if (subcount) { if (subcount) {
@ -272,7 +272,7 @@ contextMenu.photoTitle = function(albumID, photoID, e) {
items.push({ }) items.push({ })
items = items.concat(buildAlbumList(data.content, [photoID], (a) => lychee.goto(albumID + '/' + a.id))) items = items.concat(buildAlbumList(data.content, [ photoID ], (a) => lychee.goto(albumID + '/' + a.id)))
} }
@ -311,7 +311,7 @@ contextMenu.move = function(photoIDs, e) {
} else { } else {
items = buildAlbumList(data.albums, [album.getID()], (a) => photo.setAlbum(photoIDs, a.id)) items = buildAlbumList(data.albums, [ album.getID() ], (a) => photo.setAlbum(photoIDs, a.id))
// Show Unsorted when unsorted is not the current album // Show Unsorted when unsorted is not the current album
if (album.getID()!=='0') { if (album.getID()!=='0') {

View File

@ -199,7 +199,7 @@ multiselect.getSelection = function(e) {
let id = $(this).data('id') let id = $(this).data('id')
if (id!=null && id!==0 && !album.isSmartID(id)) { if (id!=null && id!==0 && album.isSmartID(id)===false) {
ids.push(id) ids.push(id)
$(this).addClass('active') $(this).addClass('active')

View File

@ -73,7 +73,7 @@ settings.createConfig = function() {
if (data==='Warning: Could not create file!') { if (data==='Warning: Could not create file!') {
basicModal.show({ basicModal.show({
body: "<p>Unable to save this configuration. Permission denied in <b>'data/'</b>. Please set the read, write and execute rights for others in <b>'data/'</b> and <b>'uploads/'</b>. Take a look at the readme for more information.</p>", body: `<p>Unable to save this configuration. Permission denied in <b>'data/'</b>. Please set the read, write and execute rights for others in <b>'data/'</b> and <b>'uploads/'</b>. Take a look at the readme for more information.</p>`,
buttons: { buttons: {
action: { action: {
title: 'Retry', title: 'Retry',

View File

@ -125,14 +125,18 @@ sidebar.createStructure.photo = function(data) {
// Set value for public // Set value for public
switch (data.public) { switch (data.public) {
case '0' : _public = 'No' case '0':
break _public = 'No'
case '1' : _public = 'Yes' break
break case '1':
case '2' : _public = 'Yes (Album)' _public = 'Yes'
break break
default : _public = '-' case '2':
break _public = 'Yes (Album)'
break
default:
_public = '-'
break
} }

View File

@ -178,18 +178,25 @@ view.album = {
title: function(photoID) { title: function(photoID) {
let ntitle = ''
let prefix = ''
if (album.json.content[photoID]) { if (album.json.content[photoID]) {
ntitle = album.json.content[photoID].title
prefix = '.photo' prefix = '.photo'
} ntitle = album.json.content[photoID].title
else {
} else {
prefix = '.album'
for (i in album.subjson.albums) { for (i in album.subjson.albums) {
if (album.subjson.albums[i].id == photoID) { if (album.subjson.albums[i].id==photoID) {
ntitle = album.subjson.albums[i].title ntitle = album.subjson.albums[i].title
break break
} }
} }
prefix = '.album'
} }
ntitle = lychee.escapeHTML(ntitle) ntitle = lychee.escapeHTML(ntitle)