From 8bb89ecb6232ccfedeb26b62b1019357f38c645e Mon Sep 17 00:00:00 2001 From: Sergio Brighenti Date: Sun, 25 Nov 2018 16:16:43 +0100 Subject: [PATCH] Merge branch 'master' of C:\Users\Sergio\Documents\GitHub\XBackBone with conflicts. --- Gruntfile.js | 1 + app/Web/Lang.php | 62 +++++++------------ app/Web/Session.php | 3 +- resources/lang/en.lang.php | 82 ------------------------- resources/schemas/sqlite/sqlite.2.sql | 2 +- resources/templates/comp/footer.twig | 2 +- resources/templates/dashboard/home.twig | 36 ++++++----- 7 files changed, 46 insertions(+), 142 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 64c4f42..fd249e7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -73,6 +73,7 @@ module.exports = function (grunt) { 'resources/lang/**/*', 'resources/templates/**/*', 'resources/schemas/**/*', + 'resources/lang/**/*', 'static/**/*', 'vendor/**/*', '.htaccess', diff --git a/app/Web/Lang.php b/app/Web/Lang.php index bbf8074..d8e75b0 100644 --- a/app/Web/Lang.php +++ b/app/Web/Lang.php @@ -1,46 +1,34 @@ lang = $lang; - $this->path = $path; + /** @var array */ + protected $cache = []; - } /** * @return Lang */ - public static function getInstance() + public static function getInstance(): Lang { - if (self::$instance === null) { - self::$instance = self::build(); + self::$instance = new self(); } return self::$instance; @@ -48,22 +36,24 @@ class Lang /** * @param string $lang - * @param string $path + * @param string $langPath * @return Lang */ - public static function build($lang = self::DEFAULT_LANG, $path = null) + public static function build($lang = self::DEFAULT_LANG, $langPath = null): Lang { if (strlen($lang) !== 2) { - $lang = strtolower(substr($lang, 0, 2)); + self::$lang = strtolower(substr($lang, 0, 2)); + } else { + self::$lang = $lang; } - if (file_exists(($path ? $path : self::LANG_PATH) . $lang . '.lang.php')) { - self::$instance = new self($lang, $path); - } else { - self::$instance = new self(self::DEFAULT_LANG, $path); + if ($langPath !== null) { + self::$langPath = $langPath; } + self::$instance = new self(); + return self::$instance; } @@ -73,9 +63,9 @@ class Lang * @param array $args * @return string */ - public function get($key, $args = []) + public function get($key, $args = []): string { - return $this->getString($key, $this->lang, $args); + return $this->getString($key, self::$lang, $args); } /** @@ -84,13 +74,13 @@ class Lang * @param $args * @return string */ - private function getString($key, $lang, $args) + private function getString($key, $lang, $args): string { if (array_key_exists($lang, $this->cache)) { $transDict = $this->cache[$lang]; - } else if (file_exists($this->path . $lang . '.lang.php')) { - $transDict = include $this->path . $lang . '.lang.php'; + } elseif (file_exists(self::$langPath . $lang . '.lang.php')) { + $transDict = include self::$langPath . $lang . '.lang.php'; $this->cache[$lang] = $transDict; } else { $transDict = []; @@ -106,12 +96,4 @@ class Lang return $key; } - - /** - * @return string - */ - public function getLang(): string - { - return $this->lang; - } } \ No newline at end of file diff --git a/app/Web/Session.php b/app/Web/Session.php index f33962b..1fd58f3 100644 --- a/app/Web/Session.php +++ b/app/Web/Session.php @@ -16,7 +16,8 @@ class Session if (session_status() === PHP_SESSION_NONE) { session_start([ 'name' => $name, - 'save_path' => $path + 'save_path' => $path, + 'cookie_httponly' => true ]); } } diff --git a/resources/lang/en.lang.php b/resources/lang/en.lang.php index cd0f902..25058db 100644 --- a/resources/lang/en.lang.php +++ b/resources/lang/en.lang.php @@ -2,86 +2,4 @@ return [ - 'lang' => 'English', - - 'yes' => 'Yes', - 'no' => 'No', - 'send' => 'Send', - 'no_media' => 'No media found.', - - 'login.username' => 'Username or E-Mail', - 'password' => 'Password', - 'login' => 'Login', - 'username' => 'Username', - - 'home' => 'Home', - 'users' => 'Users', - 'system' => 'System', - 'profile' => 'Profile', - 'logout' => 'Logout', - - 'pager.next' => 'Next', - 'pager.previous' => 'Previous', - - 'copy_link' => 'Copy link', - 'public.telegram' => 'Share on Telegram', - 'public.delete_text' => 'Are you sure you want to delete this item? It will be gone forever!', - - 'preview' => 'Preview', - 'filename' => 'Filename', - 'size' => 'Size', - 'public' => 'Public', - 'owner' => 'Owner', - 'date' => 'Date', - 'raw' => 'Show raw', - 'download' => 'Download', - 'delete' => 'Delete', - 'publish' => 'Publish', - 'hide' => 'Hide', - - 'files' => 'Files', - 'orphaned_files' => 'Orphaned Files', - 'theme' => 'Theme', - 'click_to_load' => 'Click to load...', - 'apply' => 'Apply', - 'save' => 'Save', - 'used' => 'Used', - 'system_info' => 'System Information', - - 'user.create' => 'Create User', - 'user.edit' => 'Edit User', - 'is_active' => 'Is active', - 'is_admin' => 'Is administrator', - 'your_profile' => 'Your Profile', - 'token' => 'Token', - 'copy' => 'Copy', - 'update' => 'Update', - 'edit' => 'Edit', - 'client_config' => 'Client Configuration', - 'user_code' => 'User Code', - 'active' => 'Active', - 'admin' => 'Admin', - 'reg_date' => 'Registration Date', - 'none' => 'None', - 'open' => 'Open', - 'confirm' => 'Confirmation', - 'confirm_string' => 'Are you sure?', - - 'installed' => 'Installation completed successfully!', - 'bad_login' => 'Wrong credentials.', - 'account_disabled' => 'Your account is disabled.', - 'welcome' => 'Welcome, %s!', - 'goodbye' => 'Goodbye!', - 'token_not_found' => 'Token specified not found.', - 'email_required' => 'The email is required.', - 'email_taken' => 'The email is already taken.', - 'username_required' => 'The username is required.', - 'username_taken' => 'The username is already taken.', - 'password_required' => 'The password is required.', - 'user_created' => 'User "%s" created!', - 'user_updated' => 'User "%s" updated!', - 'profile_updated' => 'Profile updated successfully!', - 'user_deleted' => 'User deleted.', - 'cannot_delete' => 'You cannot delete yourself.', - 'cannot_demote' => 'You cannot demote yourself', ]; \ No newline at end of file diff --git a/resources/schemas/sqlite/sqlite.2.sql b/resources/schemas/sqlite/sqlite.2.sql index c1b3da6..955ec8d 100644 --- a/resources/schemas/sqlite/sqlite.2.sql +++ b/resources/schemas/sqlite/sqlite.2.sql @@ -1,2 +1,2 @@ -CREATE UNIQUE INDEX IF NOT EXISTS `username_email` +CREATE UNIQUE INDEX IF NOT EXISTS `email_index` ON `users` (`email`); \ No newline at end of file diff --git a/resources/templates/comp/footer.twig b/resources/templates/comp/footer.twig index 03293f3..199948a 100644 --- a/resources/templates/comp/footer.twig +++ b/resources/templates/comp/footer.twig @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/resources/templates/dashboard/home.twig b/resources/templates/dashboard/home.twig index 51bf97a..c2caf2c 100644 --- a/resources/templates/dashboard/home.twig +++ b/resources/templates/dashboard/home.twig @@ -1,6 +1,6 @@ {% extends 'base.twig' %} -{% block title %}{{ lang('home') }}{% endblock %} +{% block title %}Home{% endblock %} {% block content %} {% include 'comp/navbar.twig' %} @@ -13,40 +13,42 @@
{% if media.mimetype starts with 'image' %} - Card image + + {{ media.filename }} + {% else %} -
+ +
+
{% endif %} -
-
- {{ media.size }} -
- - {% if media.published %} - + {% else %} - + {% endif %} -
+ {{ media.timestamp|date("d/m/Y H:i:s") }}
-
{% endfor %} {% include 'comp/pager.twig' with {'path': 'home'} %} {% else %} -
{{ lang('no_media') }}
+
No medias found.
{% endif %} {% include 'comp/footer.twig' %}