Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

Commit

Permalink
V3.2.11 candidate (#183)
Browse files Browse the repository at this point in the history
* Setting for image overlay type
* Create update file to insert `image_overlay_type` field in settings.
* Write the data display type to the settings table when submitted by the user.
* Include 24-hour timestamp in `photo.json`
* Add setting for php_script_limit. Fixes #177
* Update English locale with new Setting button
* Validate image overlay type default from Settings
* Write image_overlay_type keys to lychee_settings table
  • Loading branch information
ildyria authored Feb 2, 2019
1 parent 65ef6ed commit 5711d20
Show file tree
Hide file tree
Showing 13 changed files with 327 additions and 119 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ uploads/small/*
uploads/thumb/*

dist/user.css
dist/frame.js

!uploads/big/index.html
!uploads/import/index.html
Expand Down
2 changes: 1 addition & 1 deletion dist/main.css

Large diffs are not rendered by default.

266 changes: 187 additions & 79 deletions dist/main.js

Large diffs are not rendered by default.

86 changes: 51 additions & 35 deletions dist/view.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions php/Access/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static function init($fn) {

// Settings functions
case 'Settings::setImageOverlay': self::setImageOverlay(); break;
case 'Settings::setOverlayType': self::setOverlayType(); break;
case 'Settings::setLayout': self::setLayoutAction(); break;
case 'Settings::setLang': self::setLangAction(); break;
case 'Settings::setDefaultLicense': self::setDefaultLicenseAction(); break;
Expand Down Expand Up @@ -355,6 +356,13 @@ private static function setImageOverlay() {
Response::json(Settings::setImageOverlay($_POST['image_overlay']));
}

private static function setOverlayType() {

Validator::required(isset($_POST['image_overlay_type']), __METHOD__);

Response::json(Settings::setOverlayType($_POST['image_overlay_type']));
}

private static function setSortingAction() {

Validator::required(isset($_POST['typeAlbums'], $_POST['orderAlbums'], $_POST['typePhotos'], $_POST['orderPhotos']), __METHOD__);
Expand Down
8 changes: 7 additions & 1 deletion php/Locale/English.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static public function get_locale()
'UPDATE_AVAILABLE' => 'Update available!',
'DEFAULT_LICENSE' => 'Default license for new uploads:',
'SET_LICENSE' => 'Set License',
'SET_OVERLAY_TYPE' => 'Set Overlay',

'SMART_ALBUMS' => 'Smart albums',
'SHARED_ALBUMS' => 'Shared albums',
Expand Down Expand Up @@ -277,7 +278,12 @@ static public function get_locale()
'LANG_TITLE' => 'Change Language',

'LAYOUT_TEXT' => 'Use justified layout:',
'IMAGE_OVERLAY_TEXT' => 'Display EXIF data overlay by default:',
'IMAGE_OVERLAY_TEXT' => 'Display data overlay by default:',

'LAYOUT_TYPE' => 'Data to use in image overlay:',
'OVERLAY_EXIF' => 'Photo EXIF data',
'OVERLAY_DESCRIPTION' => 'Photo description',
'OVERLAY_DATE' => 'Photo date taken',

'VIEW_NO_RESULT' => 'No results',
'VIEW_NO_PUBLIC_ALBUMS' => 'No public albums',
Expand Down
7 changes: 7 additions & 0 deletions php/Modules/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ public function url($urls, $albumID = 0) {
*/
public function server($path, $albumID = 0) {

// Fixes #177
$php_script_limit = Settings::get()['php_script_limit'];
if ($php_script_limit == 1) {
set_time_limit(0);
Log::notice(Database::get(), __METHOD__, __LINE__, 'Importing using unlimited execution time');
}

// Parse path
if (!isset($path)) $path = LYCHEE_UPLOADS_IMPORT;
if (substr($path, -1)==='/') $path = substr($path, 0, -1);
Expand Down
2 changes: 1 addition & 1 deletion php/Modules/Photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ public static function prepareData(array $data) {
// Use takestamp
$photo['cameraDate'] = '1';
$photo['sysdate'] = strftime('%d %B %Y', substr($data['id'], 0, -4));
$photo['takedate'] = strftime('%d %B %Y', $data['takestamp']);
$photo['takedate'] = strftime('%d %B %Y - %k:%M', $data['takestamp']);

} else {

Expand Down
1 change: 1 addition & 0 deletions php/Modules/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function init($public = true) {
unset($return['config']['location']);
unset($return['config']['imagick']);
unset($return['config']['plugins']);
unset($return['config']['php_script_limit']);

}

Expand Down
20 changes: 20 additions & 0 deletions php/Modules/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,26 @@ public static function setImageOverlay($imageOverlay) {
return true;
}

public static function setOverlayType($imageOverlayType) {
$overlays = [ 'exif', 'desc', 'takedate' ];

$found = false;
$i = 0;

while(!$found && $i < count($overlays)) {
if ($overlays[$i] === $imageOverlayType) $found = true;
$i++;
}

if(!$found) {
Log::error(Database::get(), __METHOD__, __LINE__, 'Cound not find the submitted overlay type');
Response::error(Database::get(), __METHOD__, __LINE__, 'Cound not find the submitted overlay type');
}
else {
if (self::set('image_overlay_type', $imageOverlayType, true)===false) return false;
return true;
}
}

/**
* Sets a new sorting for the photos.
Expand Down
41 changes: 41 additions & 0 deletions php/database/update_030211.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* Update to version 3.2.11
*/

use Lychee\Modules\Database;
use Lychee\Modules\Response;

// Add image_overlay_type to settings
$query = Database::prepare($connection, "SELECT `key` FROM `?` WHERE `key` = 'image_overlay_type' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
$result = Database::execute($connection, $query, 'update_030211', __LINE__);

if ($result===false) Response::error('Could not get current image_overlay_type from database!');

if ($result->num_rows===0) {

$query = Database::prepare($connection, "INSERT INTO `?` (`key`, `value`) VALUES ('image_overlay_type', 'exif')", array(LYCHEE_TABLE_SETTINGS));
$result = Database::execute($connection, $query, 'update_030211', __LINE__);

if ($result===false) Response::error('Could not add image_overlay_type to database!');

}

// Add php_script_limit to settings
$query = Database::prepare($connection, "SELECT `key` FROM `?` WHERE `key` = 'php_script_limit' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
$result = Database::execute($connection, $query, 'update_030211', __LINE__);

if ($result===false) Response::error('Could not get current php_script_limit from database!');

if ($result->num_rows===0) {

$query = Database::prepare($connection, "INSERT INTO `?` (`key`, `value`) VALUES ('php_script_limit', '0')", array(LYCHEE_TABLE_SETTINGS));
$result = Database::execute($connection, $query, 'update_030211', __LINE__);

if ($result===false) Response::error('Could not add php_script_limit to database!');
}


// Set version
if (Database::setVersion($connection, 'update_030211')===false) Response::error('Could not update version of database!');
2 changes: 1 addition & 1 deletion version.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.10
3.2.11

0 comments on commit 5711d20

Please sign in to comment.