From 712979ba898f39fe0901edd8cfa92839052d8685 Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 6 Jun 2019 22:18:31 +0200 Subject: [PATCH] Updated user not found page. --- public/profile.php | 4 +- templates/profile/_layout/header.twig | 75 +++++++------ templates/profile/index.twig | 156 +++++++++++++------------- templates/profile/master.twig | 99 ++++++++-------- templates/user/notfound.twig | 14 --- 5 files changed, 179 insertions(+), 169 deletions(-) delete mode 100644 templates/user/notfound.twig diff --git a/public/profile.php b/public/profile.php index 7c3de385..3cf69c20 100644 --- a/public/profile.php +++ b/public/profile.php @@ -7,9 +7,9 @@ $isEditing = !empty($_GET['edit']) && is_string($_GET['edit']) ? (bool)$_GET['ed $userId = user_find_for_profile($userId); -if ($userId < 1) { +if($userId < 1) { http_response_code(404); - echo tpl_render('user.notfound'); + echo tpl_render('profile.index'); return; } diff --git a/templates/profile/_layout/header.twig b/templates/profile/_layout/header.twig index 406c4415..ddc0dd87 100644 --- a/templates/profile/_layout/header.twig +++ b/templates/profile/_layout/header.twig @@ -28,25 +28,34 @@
-
- {{ profile.username }} -
+ {% if profile is defined %} +
+ {{ profile.username }} +
- {% if profile.user_title is not empty %} + {% if profile.user_title is not empty %} +
+ {{ profile.user_title }} +
+ {% endif %} + +
+
+
+ {{ profile.user_country|country_name }} +
+
+ {% else %} +
+ User not found! +
- {{ profile.user_title }} + Check the link and try again.
{% endif %} - -
-
-
- {{ profile.user_country|country_name }} -
-
- {% if profile_relation_info|length > 0 and (profile_relation_info.subject_relation is not null or profile_relation_info.user_relation is not null) %} + {% if profile is defined and profile_relation_info|length > 0 and (profile_relation_info.subject_relation is not null or profile_relation_info.user_relation is not null) %}
{% if profile_relation_info.subject_relation and profile_relation_info.user_relation %} Mutual Friends @@ -60,27 +69,29 @@
-
- {% if profile_mode is empty %} - {% if profile_is_editing %} - - Discard - Settings - {% elseif profile_can_edit %} - Edit Profile - {% endif %} - - {% if current_user is defined and current_user.user_id != profile.user_id and not profile_is_editing %} - {% if profile_relation_info.user_relation == constant('MSZ_USER_RELATION_FOLLOW') %} - Unfollow - {% else %} - Follow + {% if profile is defined %} +
+ {% if profile_mode is empty %} + {% if profile_is_editing %} + + Discard + Settings + {% elseif profile_can_edit %} + Edit Profile {% endif %} + + {% if current_user is defined and current_user.user_id != profile.user_id and not profile_is_editing %} + {% if profile_relation_info.user_relation == constant('MSZ_USER_RELATION_FOLLOW') %} + Unfollow + {% else %} + Follow + {% endif %} + {% endif %} + {% else %} + Return {% endif %} - {% else %} - Return - {% endif %} -
+
+ {% endif %} {% if stats is defined %}
diff --git a/templates/profile/index.twig b/templates/profile/index.twig index 46762375..b2dcf622 100644 --- a/templates/profile/index.twig +++ b/templates/profile/index.twig @@ -3,8 +3,12 @@ {% from 'user/macros.twig' import user_profile_warning %} {% from '_layout/input.twig' import input_hidden, input_csrf, input_text, input_checkbox, input_file, input_file_raw, input_select %} -{% set canonical_url = url('user-profile', {'user': profile.user_id}) %} -{% set title = profile.username %} +{% if profile is defined %} + {% set canonical_url = url('user-profile', {'user': profile.user_id}) %} + {% set title = profile.username %} +{% else %} + {% set title = 'User not found!' %} +{% endif %} {% block content %} {% if profile_is_editing %} @@ -169,90 +173,92 @@
{% endif %} -
- {% if (profile_is_editing and perms.edit_about) or profile.user_about_content|length > 0 %} -
- {{ container_title('About ' ~ profile.username) }} + {% if profile is defined %} +
+ {% if (profile_is_editing and perms.edit_about) or profile.user_about_content|length > 0 %} +
+ {{ container_title('About ' ~ profile.username) }} - {% if profile_is_editing %} -
- {{ input_select('about[parser]', constant('MSZ_PARSERS_NAMES'), profile.user_about_parser, '', '', false, 'profile__about__select') }} - -
- {% else %} -
- {{ profile.user_about_content|escape|parse_text(profile.user_about_parser)|raw }} -
- {% endif %} -
- {% endif %} - - {% if (profile_is_editing and perms.edit_signature) or profile.user_signature_content|length > 0 %} -
- {{ container_title('Signature') }} - - {% if profile_is_editing %} -
- {{ input_select('signature[parser]', constant('MSZ_PARSERS_NAMES'), profile.user_signature_parser, '', '', false, 'profile__signature__select') }} - -
- {% else %} -
- {{ profile.user_signature_content|escape|parse_text(profile.user_signature_parser)|raw }} -
- {% endif %} -
- {% endif %} - - {% if profile_warnings|length > 0 %} -
- {{ container_title('Account Standing', false, profile_warnings_can_manage ? '/manage/users.php?v=warnings&u=' ~ profile.user_id : '') }} - -
-
- - {% if profile_warnings_can_manage %} -
-
-
- User IP -
-
- -
-
- Issuer -
-
- Issuer IP -
-
+ {% if profile_is_editing %} +
+ {{ input_select('about[parser]', constant('MSZ_PARSERS_NAMES'), profile.user_about_parser, '', '', false, 'profile__about__select') }} + +
+ {% else %} +
+ {{ profile.user_about_content|escape|parse_text(profile.user_about_parser)|raw }}
{% endif %} +
+ {% endif %} -
-
- Type + {% if (profile_is_editing and perms.edit_signature) or profile.user_signature_content|length > 0 %} +
+ {{ container_title('Signature') }} + + {% if profile_is_editing %} +
+ {{ input_select('signature[parser]', constant('MSZ_PARSERS_NAMES'), profile.user_signature_parser, '', '', false, 'profile__signature__select') }} +
- -
- Created + {% else %} +
+ {{ profile.user_signature_content|escape|parse_text(profile.user_signature_parser)|raw }}
+ {% endif %} +
+ {% endif %} -
- Expires -
+ {% if profile_warnings|length > 0 %} +
+ {{ container_title('Account Standing', false, profile_warnings_can_manage ? '/manage/users.php?v=warnings&u=' ~ profile.user_id : '') }} -
- Note +
+
+ + {% if profile_warnings_can_manage %} +
+
+
+ User IP +
+
+ +
+
+ Issuer +
+
+ Issuer IP +
+
+
+ {% endif %} + +
+
+ Type +
+ +
+ Created +
+ +
+ Expires +
+ +
+ Note +
-
- {% for warning in profile_warnings %} - {{ user_profile_warning(warning, profile_warnings_view_private, profile_warnings_can_manage, profile_warnings_can_manage ? csrf_token('warning-delete[%d]'|format(warning.warning_id)) : '') }} - {% endfor %} -
+ {% for warning in profile_warnings %} + {{ user_profile_warning(warning, profile_warnings_view_private, profile_warnings_can_manage, profile_warnings_can_manage ? csrf_token('warning-delete[%d]'|format(warning.warning_id)) : '') }} + {% endfor %} +
+ {% endif %} {% endif %}
diff --git a/templates/profile/master.twig b/templates/profile/master.twig index ec5fb59c..73dfb81f 100644 --- a/templates/profile/master.twig +++ b/templates/profile/master.twig @@ -1,48 +1,55 @@ {% extends 'master.twig' %} -{% set image = url('user-avatar', {'user': profile.user_id, 'res': 240}) %} -{% set manage_link = '/manage/users.php?v=view&u=' ~ profile.user_id %} -{% set stats = [ - { - 'title': 'Joined', - 'is_date': true, - 'value': profile.user_created, - }, - { - 'title': 'Last seen', - 'is_date': true, - 'value': profile.user_active, - }, - { - 'title': 'Following', - 'value': profile.following_count, - 'url': url('user-profile-following', {'user': profile.user_id}), - 'active': profile_mode == 'following', - }, - { - 'title': 'Followers', - 'value': profile.followers_count, - 'url': url('user-profile-followers', {'user': profile.user_id}), - 'active': profile_mode == 'followers', - }, - { - 'title': 'Topics', - 'value': profile.forum_topic_count, - 'url': url('user-profile-forum-topics', {'user': profile.user_id}), - 'active': profile_mode == 'forum-topics', - }, - { - 'title': 'Posts', - 'value': profile.forum_post_count, - 'url': url('user-profile-forum-posts', {'user': profile.user_id}), - 'active': profile_mode == 'forum-posts', - }, - { - 'title': 'Comments', - 'value': profile.comments_count, - }, - { - 'title': 'Changes', - 'value': profile.changelog_count, - }, -] %} +{% if profile is defined %} + {% set image = url('user-avatar', {'user': profile.user_id, 'res': 240}) %} + {% set manage_link = '/manage/users.php?v=view&u=' ~ profile.user_id %} + {% set stats = [ + { + 'title': 'Joined', + 'is_date': true, + 'value': profile.user_created, + }, + { + 'title': 'Last seen', + 'is_date': true, + 'value': profile.user_active, + }, + { + 'title': 'Following', + 'value': profile.following_count, + 'url': url('user-profile-following', {'user': profile.user_id}), + 'active': profile_mode == 'following', + }, + { + 'title': 'Followers', + 'value': profile.followers_count, + 'url': url('user-profile-followers', {'user': profile.user_id}), + 'active': profile_mode == 'followers', + }, + { + 'title': 'Topics', + 'value': profile.forum_topic_count, + 'url': url('user-profile-forum-topics', {'user': profile.user_id}), + 'active': profile_mode == 'forum-topics', + }, + { + 'title': 'Posts', + 'value': profile.forum_post_count, + 'url': url('user-profile-forum-posts', {'user': profile.user_id}), + 'active': profile_mode == 'forum-posts', + }, + { + 'title': 'Comments', + 'value': profile.comments_count, + }, + { + 'title': 'Changes', + 'value': profile.changelog_count, + }, + ] %} +{% else %} + {% set image = url('user-avatar', {'user': 0, 'res': 240}) %} + {% set manage_link = '/manage/users.php?v=listing' %} + {% set profile_is_editing = false %} + {% set profile_notices = [] %} +{% endif %} diff --git a/templates/user/notfound.twig b/templates/user/notfound.twig deleted file mode 100644 index 4e2c1301..00000000 --- a/templates/user/notfound.twig +++ /dev/null @@ -1,14 +0,0 @@ -{% extends 'user/master.twig' %} -{% from 'macros.twig' import container_title %} - -{% set title = 'User not found!' %} - -{% block content %} -
- {{ container_title('User not found!') }} - -
-

Check the url and try again.

-
-
-{% endblock %}