Merge pull request #771 from MicroWorldwide/master

Merging multiple PR's into master
This commit is contained in:
Fly Man 2018-04-25 13:57:15 +02:00 committed by GitHub
commit 9efb4ab038
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 94 additions and 6 deletions

BIN
dist/main.css vendored

Binary file not shown.

BIN
dist/main.js vendored

Binary file not shown.

BIN
dist/view.js vendored

Binary file not shown.

View File

@ -27,7 +27,7 @@ You can also use the [direct download](https://github.com/electerious/Lychee/arc
Change the permissions of `uploads/`, `data/` and all their subfolders. Sufficient read/write privileges are required. Change the permissions of `uploads/`, `data/` and all their subfolders. Sufficient read/write privileges are required.
chmod -R 777 uploads/ data/ chmod -R 750 uploads/ data/
### 4. Finish ### 4. Finish

View File

@ -26,6 +26,7 @@ final class Admin extends Access {
case 'Album::setTitle': self::setAlbumTitleAction(); break; case 'Album::setTitle': self::setAlbumTitleAction(); break;
case 'Album::setDescription': self::setAlbumDescriptionAction(); break; case 'Album::setDescription': self::setAlbumDescriptionAction(); break;
case 'Album::setPublic': self::setAlbumPublicAction(); break; case 'Album::setPublic': self::setAlbumPublicAction(); break;
case 'Album::setPosition': self::setPositionAction(); break;
case 'Album::delete': self::deleteAlbumAction(); break; case 'Album::delete': self::deleteAlbumAction(); break;
case 'Album::merge': self::mergeAlbumsAction(); break; case 'Album::merge': self::mergeAlbumsAction(); break;
@ -115,6 +116,15 @@ final class Admin extends Access {
} }
private static function setPositionAction() {
Validator::required(isset($_POST['albumID'],$_POST['photoOrder']), __METHOD__);
$album = new Album($_POST['albumID']);
Response::json($album->setPosition());
}
private static function setAlbumPublicAction() { private static function setAlbumPublicAction() {
Validator::required(isset($_POST['albumID'], $_POST['password'], $_POST['visible'], $_POST['downloadable']), __METHOD__); Validator::required(isset($_POST['albumID'], $_POST['password'], $_POST['visible'], $_POST['downloadable']), __METHOD__);

View File

@ -344,6 +344,41 @@ final class Album {
} }
public function setPosition(){
// Check dependencies
Validator::required(isset($_POST['photoOrder']), __METHOD__);
// Call plugins
Plugins::get()->activate(__METHOD__, 0, func_get_args());
$id_list = implode(',', $_POST['photoOrder']);
$indices = [];
$size = count(explode(',',$id_list));
for($i = 0; $i < $size; $i++){
$indices[$i] = $i;
}
$whens = implode(
" ",
array_map(
function ($id, $value) {
return "WHEN {$id} THEN {$value}";
},
explode(',',$id_list),
$indices
)
);
$query = Database::prepare(Database::get(), "UPDATE ? SET position = CASE id ? END WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $whens, $id_list));
$result = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
// Call plugins
Plugins::get()->activate(__METHOD__, 1, func_get_args());
if ($result===false) return false;
return true;
}
/** /**
* @return boolean Returns true when successful. * @return boolean Returns true when successful.
*/ */

View File

@ -208,7 +208,7 @@ final class Photo {
$info = $this->getInfo($path); $info = $this->getInfo($path);
// Use title of file if IPTC title missing // Use title of file if IPTC title missing
if ($info['title']==='') $info['title'] = substr(basename($file['name'], $extension), 0, 30); if ($info['title']==='') $info['title'] = substr(basename($file['name'], $extension), 0, 100);
if ($exists===false) { if ($exists===false) {
@ -709,7 +709,7 @@ final class Photo {
// Parse photo // Parse photo
$photo['sysdate'] = strftime('%d %b. %Y', substr($photo['id'], 0, -4)); $photo['sysdate'] = strftime('%d %b. %Y', substr($photo['id'], 0, -4));
if (strlen($photo['takestamp'])>1) $photo['takedate'] = strftime('%d %b. %Y', $photo['takestamp']); if (strlen($photo['takestamp'])>1) $photo['takedate'] = strftime('%d %b. %Y %T', $photo['takestamp']);
// Parse medium // Parse medium
if ($photo['medium']==='1') $photo['medium'] = LYCHEE_URL_UPLOADS_MEDIUM . $photo['url']; if ($photo['medium']==='1') $photo['medium'] = LYCHEE_URL_UPLOADS_MEDIUM . $photo['url'];
@ -832,7 +832,7 @@ final class Photo {
} }
// Read EXIF // Read EXIF
if ($info['mime']=='image/jpeg') $exif = @exif_read_data($url, 'EXIF', false, false); if ($info['mime']=='image/jpeg') $exif = @exif_read_data($url, 'EXIF, IFD0', false, false);
else $exif = false; else $exif = false;
// EXIF Metadata // EXIF Metadata

View File

@ -24,6 +24,7 @@ CREATE TABLE IF NOT EXISTS `?` (
`album` bigint(20) unsigned NOT NULL, `album` bigint(20) unsigned NOT NULL,
`checksum` char(40) DEFAULT NULL, `checksum` char(40) DEFAULT NULL,
`medium` tinyint(1) NOT NULL DEFAULT '0', `medium` tinyint(1) NOT NULL DEFAULT '0',
`position` tinyint(1) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `Index_album` (`album`), KEY `Index_album` (`album`),
KEY `Index_star` (`star`) KEY `Index_star` (`star`)

View File

@ -0,0 +1,25 @@
<?php
/**
* Update to version 3.1.7
*/
use Lychee\Modules\Database;
use Lychee\Modules\Response;
// Add position to photos
$query = Database::prepare($connection, "SELECT `position` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
$result = Database::execute($connection, $query, 'update_030107', __LINE__);
if ($result===false) {
$query = Database::prepare($connection, "ALTER TABLE `?` ADD `position` TINYINT(1) NOT NULL", array(LYCHEE_TABLE_PHOTOS));
$result = Database::execute($connection, $query, 'update_030107', __LINE__);
if ($result===false) Response::error('Could not add position to database!');
}
// Set version
if (Database::setVersion($connection, '030107')===false) Response::error('Could not update version of database!');
?>

View File

@ -83,6 +83,7 @@ paths.main = {
], ],
scripts: [ scripts: [
'node_modules/jquery/dist/jquery.min.js', 'node_modules/jquery/dist/jquery.min.js',
'node_modules/jquery-ui-dist/jquery-ui.min.js',
'node_modules/mousetrap/mousetrap.min.js', 'node_modules/mousetrap/mousetrap.min.js',
'node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.min.js', 'node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.min.js',
'node_modules/basiccontext/dist/basicContext.min.js', 'node_modules/basiccontext/dist/basicContext.min.js',

View File

@ -28,6 +28,7 @@
"gulp-sass": "^3.1.0", "gulp-sass": "^3.1.0",
"gulp-uglify": "^2.1.1", "gulp-uglify": "^2.1.1",
"jquery": "^3.2.0", "jquery": "^3.2.0",
"jquery-ui": "^1.12.1",
"mousetrap": "^1.6.0" "mousetrap": "^1.6.0"
} }
} }

View File

@ -30,6 +30,21 @@ album.getID = function() {
} }
album.load = function(albumID, refresh = false) { album.load = function(albumID, refresh = false) {
$('.content').sortable({
stop: function(event, ui){
let albumID = ui.item.data('album-id');
let photoOrder = $('.content').children().map(function(){
return $(this).data('id');
}).get();
let params = {
albumID: albumID,
photoOrder: photoOrder
};
api.post('Album::setPosition', params, function(data) {
if (data!==true) lychee.error(null, params, data)
})
}
});
password.get(albumID, function() { password.get(albumID, function() {

View File

@ -5,8 +5,8 @@
lychee = { lychee = {
title : document.title, title : document.title,
version : '3.1.6', version : '3.1.7',
versionCode : '030106', versionCode : '030107',
updatePath : '//update.electerious.com/index.json', updatePath : '//update.electerious.com/index.json',
updateURL : 'https://github.com/electerious/Lychee', updateURL : 'https://github.com/electerious/Lychee',