{% extends "MuzichHomeBundle::layout.html.twig" %}

{% block title %}{{ viewed_user.name }}{% endblock %}
{% block mainbox_classes %}mainbox_nopadding{% endblock %}

{% block content %}

  <div class="top_tools">
    
    <div class="show_options">
            
      {% if app.user %}
        {% if app.user.id != viewed_user.id %}
          <a href="{{ path('follow', { 'type': 'user', 'id': viewed_user.id, 'token': user.personalHash(viewed_user.id) }) }}" 
             class="follow_link button darkbutton {% if following %}following{% else %}notfollowing{% endif %}" >
            {% if following %}
              {{ 'user.following'|trans({}, 'users') }}
            {% else %}
              {{ 'user.follow'|trans({}, 'users') }}
            {% endif %}
          </a>
        {% endif %}
      {% endif %}
      
      <a class="button darkbutton" href="{{ path('favorite_user_list', {'slug' : viewed_user.slug}) }}" >
        {{ 'user.view_favorites'|trans({}, 'users') }}
      </a>
      
      <a class="button darkbutton" href="{{ path('playlists_user', {'user_slug' : viewed_user.slug}) }}" >
        {{ 'user.view_playlists'|trans({}, 'users') }}
      </a>
      
    </div>
    
    <h1>{{ 'user.show.title'|trans({'%name%' : viewed_user.name}, 'users') }}</h1>
  
    {% if app.user %}
      {% if app.user.id == viewed_user.id %}
        {% include 'MuzichCoreBundle:Component:element_add_box.html.twig'  %}
      {% endif %}
    {% endif  %}
    
    <div class="reputation">
      
      {% if viewed_user.avatar_path %}
        <img alt="avatar" src="{{ image(viewed_user.avatarWebPath).resize(48,50,'#000000') }}" />
      {% else %}
        <img alt="default_avatar" src="{{ asset('/img/1360770994_user_48_50.png') }}" />
      {% endif %}
      
      {{ 'user.reputation.name'|trans({}, 'users') }}: 
      <span class="score">{{ viewed_user.reputation|format_score }}</span>
      {{ 'user.reputation.txt'|trans({}, 'users') }}
    </div>
    
    <p class="show_info">
      {% if count_owned != 0 %}
      {{ 'show.user.elements.count'|trans({
        '%count_owned%' : count_owned,
        '%count_favorited%': count_favorited,
        '%count_favorited_users%': count_favorited_users
      }, 'elements') }}
      {% else %}
        {{ 'show.user.elements.no_count'|trans({}, 'elements') }}
      {% endif %}
      <br />
      {% if count_followers > 1 %}
        {{ 'show.user.followers.x_count'|trans({'%count%':count_followers, '%name%':viewed_user.name }, 'elements') }}
      {% elseif count_followers == 0 %}
        {{ 'show.user.followers.zero_count'|trans({'%name%':viewed_user.name }, 'elements') }}
      {% else %}
        {{ 'show.user.followers.one_count'|trans({'%count%':count_followers, '%name%':viewed_user.name }, 'elements') }}
      {% endif %}
    </p>
      
    {% include "MuzichCoreBundle:Tag:tagsList.show.html.twig" with {
      'object_id'   : viewed_user.id,
      'object_type' : 'user'
    } %}
  
  </div>
  
  {% include "MuzichCoreBundle:SearchElement:default.html.twig" with {
    'display_autoplay'     : true,
    'autoplay_context'     : 'show_user'
  } %}
  
  {% if more_count is defined %} 
    {% if elements|length %}
      {% include "MuzichCoreBundle:SearchElement:more_button.html.twig" with {
        'more_path'     : path('show_elements_get', {
          'type'          : 'user',
          'object_id'     : viewed_user.id, 
          'tags_ids_json' : '[]'
        }),
        'more_url_path' : path('show_elements_get', {
          'type'          : 'user',
          'object_id'     : viewed_user.id, 
          'tags_ids_json' : ''
        })
      }%}
    {% endif %}
  {% endif %}

{% endblock %}