{% extends 'TopxiaWebBundle:Settings:layout.html.twig' %}

{% block title %}头像 - {{ parent() }}{% endblock %}
{% set side_nav = 'avatar' %}
{% set script_controller = 'settings/avatar' %}

{% block main %}
  {% embed "TopxiaWebBundle:Bootstrap:panel.html.twig" with {class:'panel-col'} %}
    {% block heading %}头像{% endblock %}
    {% block body %}
      
      {% if fromCourse %}
      <div class="alert alert-info">请设置自定义头像。</div>
      {% endif %}

      <form id="settings-avatar-form" class="form-horizontal" method="post" enctype="multipart/form-data">

        {{ web_macro.flash_messages() }}

        <div class="form-group">
          <div class="col-md-2 control-label"><b>当前头像</b></div>
          <div class="controls col-md-8 controls">
          	<img src="{{ default_path('avatar',user.largeAvatar, '') }}">
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label">
          {{ form_label(form.avatar, '新头像') }}
          </div>
          <div class="controls col-md-8 controls">
            {{ form_widget(form.avatar,{'attr' : { 'accept': 'image/gif,image/jpeg,image/png'}}) }}
            <p class="help-block">你可以上传JPG、GIF或PNG格式的文件，文件大小不能超过<strong>{{ upload_max_filesize() }}</strong>。</p>
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label"></div>
          <div class="controls col-md-8 controls">
            {{ form_rest(form) }}
            <button type="submit" class="btn btn-primary">上传</button>
            <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
          </div>
        </div>

        {% if partnerAvatar %}
          <div class="form-group">
            <div class="col-md-2 control-label"><b>论坛头像</b></div>
            <div class="controls col-md-8 controls">
              <img src="{{ partnerAvatar }}" class="mrm">
              <button class="btn btn-default use-partner-avatar" type="button" data-url="{{ path('settings_avatar_fetch_partner') }}" data-goto="{{ path('settings_avatar') }}">使用该头像</button>
            </div>
          </div>
        {% endif %}

      </form>

















    {% endblock %}
  {% endembed %}
{% endblock %}