<% delete_allowed = User.current.allowed_to?(:manage_files, project) %>
<div class="re_con_top">
  <p class="f_l  c_blue f_b f_14">共有&nbsp;<%= all_attachments.count%>&nbsp;个资源</p>
  <p class="f_r" style="color: #808080">
    <% if order == "asc" %>
        按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %>&nbsp;/&nbsp;
        <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote  %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %>&nbsp;/&nbsp;
        <%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"quotes"} %>&nbsp;排序
    <% else %>
        按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %>&nbsp;/&nbsp;
        <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote  %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %>&nbsp; /&nbsp;
        <%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"quotes"} %>&nbsp;排序
    <% end %>
  </p>
</div>
<div class="cl"></div>
<div class="for_img_thumbnails">
  <% project_attachments.each do |file| %>
      <div class="re_con_box">
        <div class="">
          <%= link_to truncate(file.filename,length: 35, omission: '...'),
            download_named_attachment_path(file.id, file.filename),
            :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l"  %>
          <% if User.current.logged? %>
              <% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %>
                  <%= link_to(l(:label_slected_to_other_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %>
                  <% if authority_pubilic_for_files(project, file) && delete_allowed %>
                    <span id="is_public_<%= file.id %>">
                      <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post  %>
                    </span>
                  <% end %>
              <% else %>
                  <%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %>
              <% end %>
              <%= file_preview_tag(file, class: 'f_l re_open') %>
          <% end %>
        </div>
        <div class="cl"></div>
        <div class="">
          <p class="f_l c_grey02 font">文件大小：<%= number_to_human_size(file.filesize) %></p>
          <%= link_to( l(:button_delete), attachment_path(file),
                       :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if manage_allowed && file.container_id == project.id && file.container_type == "Project"%>
                       <p class="f_r c_grey02" ><%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>&nbsp;&nbsp;|&nbsp;&nbsp;下载<%= file.downloads %>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= file.quotes.nil? ? 0:file.quotes  %> </p>
        </div>
        <div class="cl"></div>
        <div class="tag_h">
          <!-- container_type = 2 代表是项目里的资源 -->
          <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6"} %>
          <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6"} %>
        </div>
        <div class="cl"></div>
      </div><!---re_con_box end-->
  <% end %>
</div>
<ul class="wlist">
  <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
</ul>
<div class="cl"></div>
