2019-02-27 17:26:49 +01:00
{% extends 'profile/master.twig' %}
2018-10-22 21:53:21 +02:00
{% from 'macros.twig' import container_title %}
2018-12-27 00:21:44 +01:00
{% from 'user/macros.twig' import user_profile_warning %}
2018-10-27 23:38:01 +02:00
{% from '_layout/input.twig' import input_hidden , input_csrf , input_text , input_checkbox , input_file , input_file_raw , input_select %}
2018-03-22 02:56:41 +00:00
2019-02-27 15:46:18 +01:00
{% set canonical_url = url ( 'user-profile' , { 'user' : profile .user_id } ) %}
2019-02-27 17:26:49 +01:00
{% set title = profile .username %}
2018-09-23 16:04:48 +02:00
2018-03-22 02:56:41 +00:00
{% block content %}
2019-02-27 16:32:13 +01:00
{% if profile_is_editing %}
<form class="profile" method="post" action=" {{ url ( 'user-profile' , { 'user' : profile .user_id } ) }} " enctype="multipart/form-data">
2018-10-27 03:20:27 +02:00
{{ input_csrf ( 'profile' ) }}
2018-09-26 11:23:36 +02:00
{% if perms .edit_avatar %}
2018-10-27 20:50:34 +02:00
{{ input_file_raw ( 'avatar[file]' , 'profile__hidden' , [ 'image/png' , 'image/jpeg' , 'image/gif' ] , { 'id' :'avatar-selection' } ) }}
2018-09-26 11:23:36 +02:00
<script>
function updateAvatarPreview(name, url, preview) {
2019-02-27 15:46:18 +01:00
url = url || " {{ url ( 'user-avatar' , { 'user' : profile .user_id } ) | raw }} ";
2018-09-26 11:23:36 +02:00
preview = preview || document.getElementById('avatar-preview');
preview.style.backgroundImage = 'url(\' { 0}\')'.replace(' { 0}', url);
preview.title = name;
}
document.getElementById('avatar-selection').addEventListener('change', function (ev) {
updateAvatarPreview(ev.target.files[0].name, URL.createObjectURL(ev.target.files[0]));
});
</script>
{% endif %}
2018-09-23 21:12:40 +02:00
{% else %}
<div class="profile">
{% endif %}
2018-08-12 15:35:50 +02:00
2019-02-27 17:26:49 +01:00
{% include 'profile/_layout/header.twig' %}
2018-09-23 21:12:40 +02:00
2019-02-27 16:32:13 +01:00
{% if profile_is_editing %}
2019-01-18 15:11:15 +01:00
<div class="container profile__container profile__guidelines">
2018-09-27 22:02:24 +02:00
<ul class="profile__guidelines__section">
<li class="profile__guidelines__line profile__guidelines__line--header">General</li>
<li class="profile__guidelines__line">Keep things sane and generally suitable for all ages.</li>
2019-01-24 21:54:24 +01:00
<li class="profile__guidelines__line">Make sure to adhere to the <a href=" {{ url ( 'info' , { 'title' : 'rules' } ) }} " class="profile__guidelines__link">rules</a>.</li>
2018-09-27 22:02:24 +02:00
</ul>
2018-09-27 08:39:49 +02:00
2018-09-27 22:02:24 +02:00
{% if perms .edit_avatar %}
2018-09-27 08:39:49 +02:00
<ul class="profile__guidelines__section">
2018-09-27 22:02:24 +02:00
<li class="profile__guidelines__line profile__guidelines__line--header">Avatar</li>
<li class="profile__guidelines__line">May not exceed the <span class="profile__guidelines__emphasis"> {{ guidelines .avatar .max_size | byte_symbol ( true ) }} </span> file size limit.</li>
<li class="profile__guidelines__line">May not be larger than <span class="profile__guidelines__emphasis"> {{ guidelines .avatar .max_width }} x {{ guidelines .avatar .max_height }} </span>.</li>
<li class="profile__guidelines__line">Will be centre cropped and scaled to <span class="profile__guidelines__emphasis">200x200</span>.</li>
<li class="profile__guidelines__line">Animated gif images are allowed.</li>
2018-09-27 08:39:49 +02:00
</ul>
2018-09-27 22:02:24 +02:00
{% endif %}
2018-09-27 08:39:49 +02:00
2018-09-27 22:02:24 +02:00
{% if perms .edit_background %}
<ul class="profile__guidelines__section">
<li class="profile__guidelines__line profile__guidelines__line--header">Background</li>
<li class="profile__guidelines__line">May not exceed the <span class="profile__guidelines__emphasis"> {{ guidelines .background .max_size | byte_symbol ( true ) }} </span> file size limit.</li>
<li class="profile__guidelines__line">May not be larger than <span class="profile__guidelines__emphasis"> {{ guidelines .background .max_width }} x {{ guidelines .background .max_height }} </span>.</li>
<li class="profile__guidelines__line">Gif images, in general, are only allowed when tiling.</li>
</ul>
{% endif %}
2018-09-23 21:12:40 +02:00
</div>
2018-09-28 00:03:43 +02:00
{% endif %}
2018-10-27 03:20:27 +02:00
{% if profile_notices | length > 0 %}
2018-09-27 08:39:49 +02:00
<div class="warning">
<div class="warning__content">
2018-09-28 00:03:43 +02:00
{% for notice in profile_notices %}
{{ notice }}
{% endfor %}
2018-09-27 08:39:49 +02:00
</div>
</div>
{% endif %}
2018-09-17 00:36:46 +02:00
2019-01-18 15:11:15 +01:00
<div class="profile__content">
2019-02-27 16:32:13 +01:00
{% set show_profile_fields = profile_is_editing ? perms .edit_profile : profile_fields | default ( [ ] ) | length > 0 %}
{% set show_background_settings = profile_is_editing and perms .edit_background %}
{% set show_birthdate = profile_is_editing and perms .edit_birthdate %}
2018-12-28 17:52:15 +01:00
{% set show_sidebar = current_user is not defined or show_profile_fields or show_background_settings %}
{% if show_sidebar %}
2019-01-18 15:11:15 +01:00
<div class="profile__content__side">
2018-12-28 17:52:15 +01:00
{% if show_background_settings %}
2019-01-18 15:11:15 +01:00
<div class="container profile__container profile__background-settings">
2018-12-28 17:52:15 +01:00
{{ container_title ( 'Background' ) }}
<div class="profile__background-settings__content">
{{ input_file ( 'background[file]' , '' , [ 'image/png' , 'image/jpeg' , 'image/gif' ] , { 'id' :'background-selection' } ) }}
{{ input_checkbox ( 'background[attach]' , 'None' , true , '' , 0 , true , { 'onchange' :'profileChangeBackgroundAttach(this.value)' } ) }}
{% for key , value in background_attachments %}
{{ input_checkbox ( 'background[attach]' , value | capitalize , key == profile .user_background_attachment , '' , key , true , { 'onchange' :'profileChangeBackgroundAttach(this.value)' } ) }}
{% endfor %}
{{ input_checkbox ( 'background[attr][blend]' , 'Blend' , profile .user_background_blend , '' , '' , false , { 'onchange' :'profileToggleBackgroundAttr(\'blend\', this.checked)' } ) }}
{{ input_checkbox ( 'background[attr][slide]' , 'Slide' , profile .user_background_slide , '' , '' , false , { 'onchange' :'profileToggleBackgroundAttr(\'slide\', this.checked)' } ) }}
</div>
2018-10-27 03:20:27 +02:00
</div>
2018-12-28 17:52:15 +01:00
{% endif %}
{% if current_user is not defined %}
2019-01-18 15:11:15 +01:00
<div class="container profile__container">
2018-12-28 17:52:15 +01:00
<div class="profile__accounts__notice">
2019-01-24 21:54:24 +01:00
You must <a href=" {{ url ( 'auth-login' ) }} " class="profile__accounts__link">log in</a> to view full profiles!
2018-12-28 17:52:15 +01:00
</div>
2018-10-27 14:45:51 +02:00
</div>
2018-12-28 17:52:15 +01:00
{% elseif show_profile_fields %}
2019-01-18 15:11:15 +01:00
<div class="container profile__container profile__accounts">
2018-12-28 17:52:15 +01:00
{{ container_title ( 'Elsewhere' ) }}
<div class="profile__accounts__content">
{% for name , data in profile_fields %}
<label class="profile__accounts__item">
<div class="profile__accounts__title">
{{ data .name }}
2018-10-27 14:45:51 +02:00
</div>
2018-12-28 17:52:15 +01:00
2019-02-27 16:32:13 +01:00
{% if profile_is_editing %}
2018-12-28 17:52:15 +01:00
{{ input_text ( 'profile[' ~ name ~ ']' , 'profile__accounts__input' , profile [ 'user_' ~ name ] , data .type | default ( 'text' ) ) }}
{% else %}
<div class="profile__accounts__value"
{% if data .tooltip is defined %} title=" {{ data .tooltip | format ( data .value ) | raw }} " {% endif %} >
{% set profile_field_value = ( data .format is defined ? data .format : '%s' ) | format ( data .value ) %}
{% if data .link is defined %}
{{ data .link | format ( data .value ) | html_link ( profile_field_value , 'profile__accounts__link' ) | raw }}
{% else %}
{{ profile_field_value }}
{% endif %}
</div>
{% endif %}
</label>
{% endfor %}
</div>
2018-10-27 14:45:51 +02:00
</div>
2018-12-28 17:52:15 +01:00
{% endif %}
2019-01-18 15:11:15 +01:00
{% if show_birthdate %}
<div class="container profile__container profile__birthdate">
{{ container_title ( 'Birthdate' ) }}
{% set birthdate = profile .user_birthdate | split ( '-' ) %}
<div class="profile__birthdate__content">
<div class="profile__birthdate__date">
<label class="profile__birthdate__label">
<div class="profile__birthdate__title">
Day
</div>
2019-02-01 09:27:06 +01:00
{{ input_select ( 'birthdate[day]' , [ '-' ] | merge ( range ( 1 , 3 1 ) ) , birthdate [ 2 ] | default ( 0 ) | trim ( '0' , 'left' ) , '' , '' , true , 'profile__birthdate__select profile__birthdate__select--day' ) }}
2019-01-18 15:11:15 +01:00
</label>
<label class="profile__birthdate__label">
<div class="profile__birthdate__title">
Month
</div>
2019-02-01 09:27:06 +01:00
{{ input_select ( 'birthdate[month]' , [ '-' ] | merge ( range ( 1 , 1 2 ) ) , birthdate [ 1 ] | default ( 0 ) | trim ( '0' , 'left' ) , '' , '' , true , 'profile__birthdate__select profile__birthdate__select--month' ) }}
2019-01-18 15:11:15 +01:00
</label>
</div>
<div class="profile__birthdate__year">
<label class="profile__birthdate__label">
<div class="profile__birthdate__title">
Year (may be left empty)
</div>
2019-02-01 09:27:06 +01:00
{{ input_select ( 'birthdate[year]' , [ '-' ] | merge ( range ( null | date ( 'Y' ) , null | date ( 'Y' ) - 1 0 0 ) ) , birthdate [ 0 ] | default ( 0 ) | trim ( '0' , 'left' ) , '' , '' , true , 'profile__birthdate__select profile__birthdate__select--year' ) }}
2019-01-18 15:11:15 +01:00
</label>
</div>
</div>
</div>
{% endif %}
2018-12-28 17:52:15 +01:00
</div>
{% endif %}
2018-09-17 20:39:46 +02:00
2019-01-18 15:11:15 +01:00
<div class="profile__content__main">
2019-02-27 16:32:13 +01:00
{% if ( profile_is_editing and perms .edit_about ) or profile .user_about_content | length > 0 %}
2019-01-18 15:11:15 +01:00
<div class="container profile__container profile__about" id="about">
2018-10-22 21:53:21 +02:00
{{ container_title ( 'About ' ~ profile .username ) }}
2019-02-27 16:32:13 +01:00
{% if profile_is_editing %}
2019-01-18 23:24:37 +01:00
<div class="profile__signature__editor">
2018-10-27 23:38:01 +02:00
{{ input_select ( 'about[parser]' , constant ( 'MSZ_PARSERS_NAMES' ) , profile .user_about_parser , '' , '' , false , 'profile__about__select' ) }}
2019-01-18 23:24:37 +01:00
<textarea name="about[text]" class="input__textarea profile__about__text" id="about-textarea"> {{ profile .user_about_content | escape }} </textarea>
</div>
{% else %}
2019-02-27 16:32:13 +01:00
<div class="profile__about__content {% if profile_is_editing %} profile__about__content--edit {% elseif profile .user_about_parser == constant ( 'MSZ_PARSER_MARKDOWN' ) %} markdown {% endif %} ">
2018-09-23 21:12:40 +02:00
{{ profile .user_about_content | escape | parse_text ( profile .user_about_parser ) | raw }}
2019-01-18 23:24:37 +01:00
</div>
{% endif %}
</div>
{% endif %}
2019-02-27 16:32:13 +01:00
{% if ( profile_is_editing and perms .edit_signature ) or profile .user_signature_content | length > 0 %}
2019-01-18 23:24:37 +01:00
<div class="container profile__container profile__signature" id="signature">
{{ container_title ( 'Signature' ) }}
2019-02-27 16:32:13 +01:00
{% if profile_is_editing %}
2019-01-18 23:24:37 +01:00
<div class="profile__signature__editor">
{{ input_select ( 'signature[parser]' , constant ( 'MSZ_PARSERS_NAMES' ) , profile .user_signature_parser , '' , '' , false , 'profile__signature__select' ) }}
<textarea name="signature[text]" class="input__textarea profile__signature__text" id="signature-textarea"> {{ profile .user_signature_content | escape }} </textarea>
</div>
{% else %}
2019-02-27 16:32:13 +01:00
<div class="profile__signature__content {% if profile_is_editing %} profile__signature__content--edit {% elseif profile .user_signature_parser == constant ( 'MSZ_PARSER_MARKDOWN' ) %} markdown {% endif %} ">
2019-01-18 23:24:37 +01:00
{{ profile .user_signature_content | escape | parse_text ( profile .user_signature_parser ) | raw }}
</div>
{% endif %}
2018-09-19 20:58:13 +02:00
</div>
2018-09-23 21:12:40 +02:00
{% endif %}
2018-09-19 20:58:13 +02:00
2019-02-27 16:32:13 +01:00
{% if profile_warnings | length > 0 %}
2019-01-18 15:11:15 +01:00
<div class="container profile__container profile__warning__container" id="account-standing">
2019-02-27 16:32:13 +01:00
{{ container_title ( 'Account Standing' , false , profile_warnings_can_manage ? '/manage/users.php?v=warnings&u=' ~ profile .user_id : '' ) }}
2018-12-25 22:41:28 +01:00
<div class="profile__warning">
<div class="profile__warning__background"></div>
2019-02-27 16:32:13 +01:00
{% if profile_warnings_can_manage %}
2018-12-28 06:03:42 +01:00
<div class="profile__warning__tools">
<div class="profile__warning__user">
<div class="profile__warning__user__ip">
User IP
</div>
</div>
<div class="profile__warning__user">
<div class="profile__warning__user__username">
Issuer
</div>
<div class="profile__warning__user__ip">
Issuer IP
</div>
</div>
</div>
{% endif %}
2018-12-25 22:41:28 +01:00
<div class="profile__warning__content">
<div class="profile__warning__type">
Type
</div>
<div class="profile__warning__created">
Created
</div>
<div class="profile__warning__duration">
Expires
</div>
<div class="profile__warning__note">
Note
</div>
</div>
</div>
2019-02-27 16:32:13 +01:00
{% for warning in profile_warnings %}
{{ user_profile_warning ( warning , prpfile_warnings_view_private , profile_warnings_can_manage , profile_warnings_can_manage ? csrf_token ( 'warning-delete[%d]' | format ( warning .warning_id ) ) : '' ) }}
2018-12-25 22:41:28 +01:00
{% endfor %}
</div>
{% endif %}
2018-09-23 21:12:40 +02:00
</div>
2018-09-17 20:39:46 +02:00
</div>
2019-02-27 16:32:13 +01:00
{% if profile_is_editing %}
2018-09-23 21:12:40 +02:00
</form>
2018-10-27 20:50:34 +02:00
<script>
let profilePreviousBackground = null;
function profileToggleBackground(checked) {
let currentBg = document.body.style.getPropertyValue('--background-image');
if (currentBg != 'initial' && checked) {
profilePreviousBackground = currentBg;
currentBg = 'initial';
2018-10-27 23:38:01 +02:00
} else if (currentBg == 'initial' && !checked) {
2018-10-27 20:50:34 +02:00
currentBg = profilePreviousBackground;
}
document.body.style.setProperty('--background-image', currentBg);
}
function profileChangeBackgroundAttach(mode) {
2018-10-27 23:38:01 +02:00
const modes = {
1: 'cover',
2: 'stretch',
3: 'tile',
4: 'contain',
};
profileToggleBackground(mode == 0);
2018-10-27 20:50:34 +02:00
2018-10-27 23:38:01 +02:00
for (let i = 1; i <= Object.keys(modes).length; i++)
2018-10-27 20:50:34 +02:00
document.body.classList.remove('main--bg-' + modes[i]);
2018-10-27 23:38:01 +02:00
if (!modes[mode])
return;
document.body.classList.add('main--bg-' + modes[mode]);
2018-10-27 20:50:34 +02:00
}
function profileToggleBackgroundAttr(attr, mode) {
let className = '';
switch (attr) {
case 'blend':
className = 'main--bg-blend';
break;
case 'slide':
className = 'main--bg-slide';
break;
}
if (className) {
if (mode)
document.body.classList.add(className);
else
document.body.classList.remove(className);
}
}
document.getElementById('background-selection').addEventListener('change', ev => {
const image = new Image();
image.src = URL.createObjectURL(ev.target.files[0]);
image.addEventListener('load', () => {
document.body.style.setProperty('--background-image', 'url(%)'.replace('%', image.src));
document.body.style.setProperty('--background-width', '%px'.replace('%', image.width));
document.body.style.setProperty('--background-height', '%px'.replace('%', image.height));
});
});
</script>
2018-09-23 21:12:40 +02:00
{% else %}
2018-09-17 20:39:46 +02:00
</div>
2018-09-23 21:12:40 +02:00
{% endif %}
2018-03-22 02:56:41 +00:00
{% endblock %}