Syntax adjustments

pull/584/head
Tobias Reich 8 years ago
parent 1020b0d1dc
commit 0c7d95fb15

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

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

@ -12,7 +12,7 @@ album = {
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 isID = (id) => {
if (album.isSmartID(id)) return true
if (album.isSmartID(id)===true) return true
return $.isNumeric(id)
}
@ -35,19 +35,18 @@ album.getID = function() {
}
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) {
return ''
} else {
return album.json.parent
}
if (album.isSmartID(id)===true || album.json.parent==0) return ''
return album.json.parent
}
@ -109,7 +108,8 @@ album.load = function(albumID, refresh = false) {
}
}
if (!album.isSmartID(albumID)) {
if (album.isSmartID(albumID)===false) {
params = {
parent: albumID
}
@ -125,14 +125,14 @@ album.load = function(albumID, refresh = false) {
if (durationTime>300) waitTime = 0
else waitTime = 300 - durationTime
setTimeout(() => {
finish()
}, waitTime)
setTimeout(finish, waitTime)
})
}
else {
} else {
finish()
}
}, waitTime)
@ -192,17 +192,22 @@ album.add = function(albumID = 0) {
}
api.post('Albums::get', {
parent: -1
}, function (data) {
var cmbxOptions = `<select name='parent'>`
cmbxOptions += `<option value='0'>- None -</option>`
cmbxOptions += buildAlbumOptions(data.albums, albumID)
cmbxOptions += '</select>'
api.post('Albums::get', { parent: -1 }, function(data) {
let cmbxOptions = `
<select name='parent'>
<option value='0'>- None -</option>
${ buildAlbumOptions(data.albums, albumID) }
</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({
body: `<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>`,
body: msg,
buttons: {
action: {
title: 'Create Album',
@ -214,6 +219,7 @@ album.add = function(albumID = 0) {
}
}
})
})
}

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

@ -134,7 +134,7 @@ contextMenu.albumTitle = function(albumID, e) {
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({ })
@ -168,14 +168,14 @@ contextMenu.mergeAlbum = function(albumID, e) {
let title = selalbum.title
// disable all parents; we cannot move them into us
let exclude = [albumID]
let exclude = [ albumID ]
let a = getAlbumFrom(data.albums, selalbum.parent)
while (a != null) {
exclude.push(a.id)
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) {
$('.photo.active, .album.active').removeClass('active')
multiselect.close()
lychee.error("Please select either albums or photos!")
lychee.error('Please select either albums or photos!')
return
}
if (subcount) {
@ -272,7 +272,7 @@ contextMenu.photoTitle = function(albumID, photoID, e) {
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 {
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
if (album.getID()!=='0') {

@ -199,7 +199,7 @@ multiselect.getSelection = function(e) {
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)
$(this).addClass('active')

@ -73,7 +73,7 @@ settings.createConfig = function() {
if (data==='Warning: Could not create file!') {
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: {
action: {
title: 'Retry',

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

@ -178,18 +178,25 @@ view.album = {
title: function(photoID) {
let ntitle = ''
let prefix = ''
if (album.json.content[photoID]) {
ntitle = album.json.content[photoID].title
prefix = '.photo'
}
else {
ntitle = album.json.content[photoID].title
} else {
prefix = '.album'
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
break
}
}
prefix = '.album'
}
ntitle = lychee.escapeHTML(ntitle)

Loading…
Cancel
Save