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

{% block title %}{{ group.name }}{% endblock %}

{% block content %}

  <div class="show_options">
    
    {% if his_group %}
      <a class="button" href="{{ path('group_edit', { 'slug': group.slug }) }}" >
        {{ 'group.edit'|trans({}, 'groups') }}
      </a>
    {% endif %}
      
    <a href="{{ path('follow', { 'type': 'group', 'id': group.id, 'token': user.personalHash }) }}" 
       class="follow_link button {% if following %}following{% else %}notfollowing{% endif %}">
      {% if following %}
        {{ 'group.following'|trans({}, 'groups') }}
      {% else %}
        {{ 'group.follow'|trans({}, 'groups') }}
      {% endif %}
    </a>
    
  </div>
    
  <h2>{{ group.name }}</h2>
  
  <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%':group.name }, 'elements') }}
    {% elseif count_followers == 0 %}
      {{ 'show.user.followers.zero_count'|trans({'%name%':group.name }, 'elements') }}
    {% else %}
      {{ 'show.user.followers.one_count'|trans({'%count%':count_followers, '%name%':group.name }, 'elements') }}
    {% endif %}
  </p>
  
  <p class="group_description">
    {{ group.description }}
  </p>

  {% include "MuzichCoreBundle:Tag:tagsList.show.html.twig" with {
    'object_id'   : group.id,
    'object_type' : 'group'
  } %}
  
  {% if his_group or group.open %}
  
    <div id="element_add_box" style="display: none;">
  
      <a href="#" id="element_add_close_link" class="button">
        &lt;&lt; {{ 'group.add_element_box.close'|trans({}, 'navigationui') }}
      </a>
      
      <form novalidate name="{{ add_form_name }}" action="{{ path('element_add', {'group_slug' : group.slug}) }}" method="post" {{ form_enctype(add_form) }}>

        {% include "MuzichCoreBundle:Element:form.add.html.twig" with { 'form': add_form, 'form_name': add_form_name } %}

        <input type="submit" class="button" >
      </form>
      
    </div>
  
    <a href="#" id="element_add_link" class="button">
      {{ 'group.add_element'|trans({}, 'navigationui') }} &gt;&gt;
    </a>
    <br />
  
  {% endif %}
  
  {% include "MuzichCoreBundle:SearchElement:default.html.twig" with {'no_group_name' : true} %}
    
  <div class="elements_loader_div">
    <img class="elements_more_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
  </div>
    
  {% if more_count is defined %} 
  {% if elements|length %}
   <span class="elements_more">
     <input type="hidden" id="more_elements_url" value="{{ path('show_elements_get', {
        'type'          : 'group',
        'object_id'     : group.id, 
        'tags_ids_json' : ''
      }) }}" />
     <a href="{{ path('show_elements_get', {
        'type'          : 'group',
        'object_id'     : group.id, 
        'tags_ids_json' : tags_id_json
      }) }}" class="elements_more button" >
       {{ 'more'|trans({}, 'userui') }}
     </a>
   </span>
  {% endif %}
  {% endif %}
  
{% endblock %}