From 1468d22c9cce7ad6ffff0eb4a36d5fb8efd7885b Mon Sep 17 00:00:00 2001 From: flashwave Date: Fri, 21 Sep 2018 11:28:22 +0200 Subject: [PATCH] Added styling to about editor. --- .../less/mio/classes/profile/container.less | 30 --------------- assets/less/mio/classes/profile/profile.less | 17 +++++++++ assets/less/mio/classes/settings/about.less | 19 ++++++++++ assets/less/mio/classes/warning.less | 16 ++++++++ assets/less/mio/main.less | 3 +- public/settings.php | 37 ++++++------------- src/Parsers/parse.php | 11 ++++++ templates/settings/account.twig | 36 +++++++++++------- templates/user/profile.twig | 4 +- 9 files changed, 102 insertions(+), 71 deletions(-) delete mode 100644 assets/less/mio/classes/profile/container.less create mode 100644 assets/less/mio/classes/settings/about.less create mode 100644 assets/less/mio/classes/warning.less diff --git a/assets/less/mio/classes/profile/container.less b/assets/less/mio/classes/profile/container.less deleted file mode 100644 index a2c437bb..00000000 --- a/assets/less/mio/classes/profile/container.less +++ /dev/null @@ -1,30 +0,0 @@ -.profile__container { - display: flex; - - &__main { - flex: 1 1 auto; - word-wrap: break-word; - overflow: hidden; - } - - &__side { - flex: 0 0 auto; - width: 100%; - max-width: 300px; - margin-right: 2px; - } - - &__placeholder { - background-image: repeating-linear-gradient(-45deg, yellow, yellow 10px, black 10px, black 20px); - box-shadow: 0 1px 4px #111; - margin: 2px 0; - padding: 2px; - color: #fff; - text-align: center; - - &__content { - background-color: rgba(17, 17, 17, .9); - padding: 2px 5px; - } - } -} diff --git a/assets/less/mio/classes/profile/profile.less b/assets/less/mio/classes/profile/profile.less index 437621dc..e559db30 100644 --- a/assets/less/mio/classes/profile/profile.less +++ b/assets/less/mio/classes/profile/profile.less @@ -1,3 +1,20 @@ .profile { margin-top: 10px; + + &__container { + display: flex; + + &__main { + flex: 1 1 auto; + word-wrap: break-word; + overflow: hidden; + } + + &__side { + flex: 0 0 auto; + width: 100%; + max-width: 300px; + margin-right: 2px; + } + } } diff --git a/assets/less/mio/classes/settings/about.less b/assets/less/mio/classes/settings/about.less new file mode 100644 index 00000000..2e441d8c --- /dev/null +++ b/assets/less/mio/classes/settings/about.less @@ -0,0 +1,19 @@ +.settings__about { + display: flex; + flex-direction: column; + padding: 2px; + + &__text { + min-height: 400px; + + // prevents resizing horizontally + max-width: 100%; + min-width: 100%; + } + + &__options { + margin-top: 2px; + display: flex; + justify-content: space-between; + } +} diff --git a/assets/less/mio/classes/warning.less b/assets/less/mio/classes/warning.less new file mode 100644 index 00000000..414189ba --- /dev/null +++ b/assets/less/mio/classes/warning.less @@ -0,0 +1,16 @@ +.warning { + --start-colour: yellow; + --end-colour: black; + + background-image: repeating-linear-gradient(-45deg, var(--start-colour), var(--start-colour) 10px, var(--end-colour) 10px, var(--end-colour) 20px); + box-shadow: 0 1px 4px #111; + margin: 2px 0; + padding: 2px; + color: #fff; + text-align: center; + + &__content { + background-color: rgba(17, 17, 17, .9); + padding: 2px 5px; + } +} diff --git a/assets/less/mio/main.less b/assets/less/mio/main.less index 5d6a7fc0..cabe4c7c 100644 --- a/assets/less/mio/main.less +++ b/assets/less/mio/main.less @@ -75,11 +75,11 @@ body { @import "classes/header"; @import "classes/index"; @import "classes/permissions"; +@import "classes/warning"; // Profile @import "classes/profile/profile"; @import "classes/profile/header"; -@import "classes/profile/container"; @import "classes/profile/accounts"; @import "classes/profile/about"; @@ -97,6 +97,7 @@ body { @import "classes/settings/log"; @import "classes/settings/login-history"; @import "classes/settings/sessions"; +@import "classes/settings/about"; // News @import "classes/news/container"; diff --git a/public/settings.php b/public/settings.php index 261721a3..81eab67f 100644 --- a/public/settings.php +++ b/public/settings.php @@ -386,42 +386,29 @@ tpl_vars([ switch ($settingsMode) { case 'account': // TODO: FIX THIS GARBAGE HOLY HELL $profileFields = user_profile_fields_get(); - $getUserFields = Database::prepare(' - SELECT ' . pdo_prepare_array($profileFields, true, '`user_%s`') . ' - FROM `msz_users` - WHERE `user_id` = :user_id - '); - $getUserFields->bindValue('user_id', $app->getUserId()); - $userFields = $getUserFields->execute() ? $getUserFields->fetch() : []; - $getMail = Database::prepare(' - SELECT `email` - FROM `msz_users` - WHERE `user_id` = :user_id - '); - $getMail->bindValue('user_id', $app->getUserId()); - $currentEmail = $getMail->execute() ? $getMail->fetchColumn() : 'Failed to fetch e-mail address.'; + $getAccountInfo = Database::prepare(sprintf( + ' + SELECT %s, `email`, `user_about_content`, `user_about_parser` + FROM `msz_users` + WHERE `user_id` = :user_id + ', + pdo_prepare_array($profileFields, true, '`user_%s`') + )); + $getAccountInfo->bindValue('user_id', $app->getUserId()); + $accountInfo = $getAccountInfo->execute() ? $getAccountInfo->fetch(PDO::FETCH_ASSOC) : []; + $userHasAvatar = is_file(build_path($app->getStoragePath(), 'avatars/original', $avatarFileName)); $userHasBackground = is_file(build_path($app->getStoragePath(), 'backgrounds/original', $avatarFileName)); - $getAboutInfo = Database::prepare(' - SELECT `user_about_content`, `user_about_parser` - FROM `msz_users` - WHERE `user_id` = :user_id - '); - $getAboutInfo->bindValue('user_id', $app->getUserId()); - $aboutInfo = $getAboutInfo->execute() ? $getAboutInfo->fetch(PDO::FETCH_ASSOC) : []; - tpl_vars([ 'avatar' => $avatarProps, 'background' => $backgroundProps, 'user_has_avatar' => $userHasAvatar, 'user_has_background' => $userHasBackground, 'settings_profile_fields' => $profileFields, - 'settings_profile_values' => $userFields, 'settings_disable_account_options' => $disableAccountOptions, - 'settings_email' => $currentEmail, - 'about_info' => $aboutInfo, + 'account_info' => $accountInfo, ]); break; diff --git a/src/Parsers/parse.php b/src/Parsers/parse.php index 7b0fdd66..734a9d0c 100644 --- a/src/Parsers/parse.php +++ b/src/Parsers/parse.php @@ -11,11 +11,22 @@ define('MSZ_PARSERS', [ MSZ_PARSER_MARKDOWN, ]); +define('MSZ_PARSERS_NAMES', [ + MSZ_PARSER_PLAIN => 'Plain text', + MSZ_PARSER_BBCODE => 'BB Code', + MSZ_PARSER_MARKDOWN => 'Markdown', +]); + function parser_is_valid(int $parser): bool { return in_array($parser, MSZ_PARSERS, true); } +function parser_name(int $parser): string +{ + return parser_is_valid($parser) ? MSZ_PARSERS_NAMES[$parser] : ''; +} + function parse_text(string $text, int $parser): string { if (!parser_is_valid($parser)) { diff --git a/templates/settings/account.twig b/templates/settings/account.twig index e81fef0f..315e2f96 100644 --- a/templates/settings/account.twig +++ b/templates/settings/account.twig @@ -21,7 +21,7 @@ {{ props.name }}
- +
{% endfor %} @@ -50,7 +50,7 @@ Current e-mail address
- +
@@ -265,24 +265,34 @@ {% if settings_perms.edit_about %}
- About you + About
-
+ - + - +
+ - - +
+ + + +
+
+ + {% endif %} {% endblock %} diff --git a/templates/user/profile.twig b/templates/user/profile.twig index df527112..e37bac01 100644 --- a/templates/user/profile.twig +++ b/templates/user/profile.twig @@ -132,8 +132,8 @@ -
-
+
+
The profile pages are still under much construction, more things will eventually populate the area where this container current exists.