<% @nav_dispaly_home_path_label = 1
   @nav_dispaly_main_course_label = 1
   @nav_dispaly_main_project_label = 1
   @nav_dispaly_main_contest_label = 1 %>
<% @nav_dispaly_forum_label = 1%>
<% @nav_dispaly_user_label = show_item_on_navbar(params) %>
<% @center_flag = (User.current == @user) %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title><%= h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'public_new', 'leftside_new','prettify','users', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "avatars",'prettify'%>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= yield :header_tags -%>



</head>
<body onload="prettyPrint();">
<div id="Container">
  <%= render :partial => 'layouts/base_header_new'%>
  <div id="TopBar">
    <div class="topbar_info02 fl">
      <h2><a href="javascript:void(0);" target="_blank" class="c_blue"><%= @center_flag ? '个人中心' : '个人主页' %></h2>
      <p>当前位置 :
        <%=link_to l(:field_homepage), home_path %> &gt; <%=link_to (@center_flag ? '个人中心' : '个人主页'), user_path(@user) %> &gt; <%=link_to @user.name, user_path(@user) %>
      </p>
    </div>
  </div><!--TopBar end-->
  <div class="cl"></div>

  <div id="content">
    <div id="LSide" class="fl">
      <div class="users_info">
        <div class="pic_head">
          <%= image_tag(url_to_avatar(@user), :id=>'nh_user_tx',:style=>"width:214px;height:214px;overflow:hidden",:alt=>"头像") %>
          <% if @center_flag %>
          <a href="<%= url_for(:controller => 'my', :action => 'clear_user_avatar_temp') %>" data-remote="true" class="pic_edit usersphoto_edit"></a>
          <% end %>
        </div><!--pic_head end-->
        <div class="users_name mt5">
          <%=link_to @user.name, user_path(@user),:class=>"fl c_dark fb f14" %>
          <% if (@user.user_extensions && (@user.user_extensions.identity != 2) ) %>
          <span class="<%= @user.user_extensions.gender==1?'icon_female':'icon_male' %> fl mt3 ml5"></span>
          <% end %>

          <%= render :partial => 'layouts/user_watch_btn', :locals => {:target => @user} %>
        </div>
        <div class="cl"></div>

        <div class="mt5 ">
          <%=l(:label_user_watcher)%>（<%= link_to User.watched_by(@user.id).count.to_s, {:controller=>"users", :action=>"user_watchlist",:id=>@user.id},:class=>"c_blue",:nh_name=>"watcher_count" %>）
          <span>|&nbsp;</span>
          <%=l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count)%>（<%= link_to @user.watcher_users.count.to_s, {:controller=>"users", :action=>"user_fanslist",:id=>@user.id},:class=>"c_blue",:nh_name=>"fans_count"%>）
          <span>|&nbsp;</span>积分（<%= link_to(format("%.2f" ,get_option_number(@user,1).total_score ).to_i,
                                             {:controller => 'users', :action => 'show_new_score', :remote => true, :id => @user.id }, :class => 'c_blue',:id => 'user_score') %>）
        </div>
        <div class="cl"></div>
        <% if (@user.user_extensions) %>
        <div class="pf_intro"><%= @user.user_extensions.brief_introduction %></div>
        <% end %>
      </div><!--uers_info end-->

      <div class="leftbox">
        <ul class="leftbox_ul_left">
          <li>最近登录&nbsp;:</li>   <!--加入时间修改为最近登录 -->
          <% if @user.user_extensions!=nil && @user.user_extensions.identity == 2 %>
            <li><%= l(:label_company_name) %>&nbsp;:</li>
          <% elsif !@user.firstname.empty? || !@user.lastname.empty? %>
              <% if @user.user_extensions.identity == 0 %>
                  <li>真实姓名&nbsp;:</li>
              <% end %>
          <% end %>
          <% unless @user.user_extensions.nil? %>
            <% if @user.user_extensions.identity == 0 %>
            <li>职称&nbsp;:</li>
            <% end %>
            <% if @user.user_extensions && @user.user_extensions.location && !@user.user_extensions.location.empty?%>
            <li>地区&nbsp;:</li>
            <% end %>
            <% if (@user.user_extensions.identity == 0 || @user.user_extensions.identity == 1) && !@user.user_extensions.school.nil? %>
              <li>工作单位&nbsp;:</li>
            <% elsif @user.user_extensions.identity == 3 && !@user.user_extensions.occupation.nil? && !@user.user_extensions.occupation.empty? %>
              <li>工作单位&nbsp;:</li>
            <% elsif @user.user_extensions.identity == 2 %>
              <li>工作单位&nbsp;:</li>
            <% end %>
            <% if (!@user.user_extensions.description.nil? && !@user.user_extensions.description.empty?) %>
            <li>个人简介&nbsp;:</li>
            <% end %>
          <% end %>
        </ul>
        <ul class="leftbox_ul_right c_dgrey">
          <li><%= format_date(@user.last_login_on) %></li>  <!-- 加入时间修改为最近登录时间-->
          <% if @user.user_extensions.identity == 0 %>
              <li style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="<%= @user.show_name %>"><%= @user.show_name %></li>
          <% end %>
          <% unless @user.user_extensions.nil? %>
            <% if @user.user_extensions.identity == 0 %>
            <li><%= get_technical_title @user %></li>
            <% end %>
            <% if @user.user_extensions && @user.user_extensions.location && !@user.user_extensions.location.empty?%>
            <li><%= @user.user_extensions.location %>&nbsp;&nbsp;<%= @user.user_extensions.location_city %></li>
            <% end %>

            <% if (@user.user_extensions.identity == 0 || @user.user_extensions.identity == 1) && !@user.user_extensions.school.nil? %>
              <li style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="<%= @user.user_extensions.school.name %>"><a href="<%= url_for(:controller=>'welcome',:action => 'course', :school_id => @user.user_extensions.school.id,:host=>Setting.host_course) %>"><%= @user.user_extensions.school.name  %></a></li>
            <% elsif @user.user_extensions.identity == 3 && !@user.user_extensions.occupation.nil? && !@user.user_extensions.occupation.empty? %>
              <li style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="<%= @user.user_extensions.occupation %>"><%= @user.user_extensions.occupation %></li>
            <% elsif @user.user_extensions.identity == 2 %>
              <li style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="<%= @user.show_name %>"><%= @user.show_name %></li>
            <% end %>
            <% if (!@user.user_extensions.description.nil? && !@user.user_extensions.description.empty?) %>
            <li style="word-break:break-all;"><%= @user.user_extensions.description %></li>
            <% end %>
          <% end %>
        </ul>
        <div class="cl"></div>
      </div>

      <div class="subNavBox ">
        <div class="subNav ">
          <a href="<%=url_for(:controller => 'users', :action => 'show',:id=>@user.id)%>" class=" f14 c_blue02">
            动态
          </a>
        </div>
      <% if @center_flag %>
            <div class="subNav">
            <a href="<%=url_for(:controller => 'users', :action => 'user_courses',:id=>@user.id)%>" class=" f14 c_blue02">
              我的课程
              <span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.courses.count%>)</span>
            </a>
          </div>
            <div class="subNav">
            <a href="<%=url_for(:controller => 'users', :action => 'user_projects',:id=>@user.id)%>" class=" f14 c_blue02">
              我的项目
              <span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.projects.count%>)</span>
            </a>
          </div>
            <div class="subNav">
              <a href="<%=url_for(:controller => 'users', :action => 'user_resource',:id=>@user.id,:type=>1)%>" class=" f14 c_blue02">
                我的资源库
                <span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=Attachment.where("(author_id = #{@user.id} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) or (container_type = 'Course'  and container_id in (#{@user.courses.map{|c| c.id}.empty? ? '0' : @user.courses.map{|c| c.id}.join(',')}))").count%>)</span>
              </a>
            </div>

        <% else%>
            <div class="subNav">
              <a href="<%=url_for(:controller => 'users', :action => 'user_courses',:id=>@user.id)%>" class=" f14 c_blue02">
                TA的课程
                <span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.courses.visible.count%>)</span>
              </a>
            </div>
            <div class="subNav">
              <a href="<%=url_for(:controller => 'users', :action => 'user_projects',:id=>@user.id)%>" class=" f14 c_blue02">
                TA的项目
                <span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.projects.visible.count%>)</span>
              </a>
            </div>
            <!--<div class="subNav">-->
              <!--<a href="<%#=url_for(:controller => 'users', :action => 'user_resource',:id=>@user.id,:type=>1)%>" class=" f14 c_blue02">-->
                <!--TA的资源库-->
                <!--<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%#=Attachment.where("(author_id = #{@user.id} and is_public = 1 and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) or (container_type = 'Course' and is_public = 1  and container_id in (#{@user.courses.visible.map{|c| c.id}.join(',')}))").count%>)</span>-->
              <!--</a>-->
            <!--</div>-->
        <% end %>
        <div class="subNav ">
          <%= link_to "留言",feedback_path(@user),:class => "f14 c_blue02"%>
        </div>
        </div><!--侧导航 end-->


      <div class="cl"></div>

      <div class="leftbox mt10">
        <ul class="leftbox_ul_left">
          <% if @user.user_extensions && @user.user_extensions.identity == 0 %>
            <% if(get_create_course_count(@user)) != 0 %>
                <li>创建课程&nbsp;:</li>
            <% end %>
            <% if(get_homework_commons_count(@user)) != 0 %>
                <li>发布作业&nbsp;:</li>
            <% end %>
          <% end %>
          <% if (get_join_course_count(@user) != 0) %>
              <li>加入课程&nbsp;:</li>
          <% end %>
          <% if @user.user_extensions.identity == 1 %>
            <li>参加匿评&nbsp;:</li>
          <% end %>
          <% if (get_projectandcourse_attachment_count(@user) != 0) %>
              <li>发布资源&nbsp;:</li>
          <% end %>
          <% if (get_create_project_count(@user) != 0) %>
              <li>创建项目&nbsp;:</li>
          <% end %>
          <% if (get_join_project_count(@user) != 0) %>
              <li>加入项目&nbsp;:</li>
          <% end %>
          <% if (get_create_issue_count(@user) != 0) %>
              <li>发布缺陷&nbsp;:</li>
          <% end %>
          <% if (get_resolve_issue_count(@user) != 0) %>
              <li>解决缺陷&nbsp;:</li>
          <% end %>
        </ul>
        <ul class="leftbox_ul_right c_dgrey">
          <% if @user.user_extensions && @user.user_extensions.identity == 0 %>
            <% if(get_create_course_count(@user)) != 0 %>
                <li><%= get_create_course_count(@user) %></li>
            <% end %>
            <% if(get_homework_commons_count(@user)) != 0 %>
                <li><%= get_homework_commons_count(@user) %></li>
            <% end %>
          <% end %>
          <% if (get_join_course_count(@user) != 0) %>
            <li><%= get_join_course_count(@user) %></li>
          <% end %>
          <% if @user.user_extensions.identity == 1 %>
            <li><%= get_anonymous_evaluation_count(@user) %></li>
          <% end %>
          <% if (get_projectandcourse_attachment_count(@user) != 0) %>
              <li><%= get_projectandcourse_attachment_count(@user) %></li>
          <% end %>
          <% if (get_create_project_count(@user) != 0) %>
              <li><%= get_create_project_count(@user) %></li>
          <% end %>
          <% if (get_join_project_count(@user) != 0) %>
              <li><%= get_join_project_count(@user) %></li>
          <% end %>
          <% if (get_create_issue_count(@user) != 0) %>
              <li><%= get_create_issue_count(@user) %></li>
          <% end %>
          <% if (get_resolve_issue_count(@user) != 0) %>
              <li><%= get_resolve_issue_count(@user) %></li>
          <% end %>
        </ul>
        <div class="cl"></div>
      </div>

      <!--<div class="cl"></div>-->

      <!-- tag模块 -->
      <div class="project_Label">
        <h4 class="mb5"><%= l(:label_tag)%>:</h4>
        <div class="tag_h">
          <div id="tags">
            <%= render :partial => 'tags/user_tag', :locals => {:obj => @user,:object_flag => "1"}%>
          </div>
        </div>
        <div class="cl"></div>
      </div><!--项目标签 end-->

      <%= render :partial => 'layouts/user_watch_list', :locals => {:user => @user} %>
      <%= render :partial => 'layouts/user_fans_list', :locals => {:user => @user} %>
      <% visitor_count,visitor_list = get_visitor_users(@user) %>
      <% if(User.current.admin?) %>
          <div class="leftbox" style="display:<%= visitor_count==0 ? 'none' : 'block' %>">
            <h4 class="fl">访客</h4><a href="<%=url_for(:controller => 'users', :action => 'user_visitorlist', :id=>@user.id)%>" data-count="<%= visitor_count %>" style="display:<%= visitor_count>10 ? 'block' : 'block' %>" class="more fr mr10">更多</a>
            <div class="cl"></div>
            <div class="mt5">
                  <% for visitor in visitor_list %>
                    <%= link_to image_tag(url_to_avatar(visitor.user), :style => "width:38px;height:38px;"), user_path(visitor.user), :class => "pic_members", :title => "#{visitor.user.name}" %>
                  <% end %>
              <div class="cl"></div>
            </div>
          </div>
      <% end %>

    </div><!--LSide end-->

    <%= yield %>

  </div><!--Content end-->
  <div class="cl"></div>

  <%= render :partial => 'layouts/new_footer'%>
  <div class="cl"></div>
</div><!--Container end-->

<%= render :partial => 'layouts/new_feedback' %>

<div id="ajax-modal" style="display:none;"></div>
<div id="ajax-indicator" style="display:none;">
  <span><%= l(:label_loading) %></span>
</div>
<div id="nh_tx_dialog_html" class="white_content" style="display:none;">
  <div>
    <div><a href="javascript:hideModal();" class="box_close"></a></div>
    <div class="cl"></div>
    <div class="pro_new">
      <h3 class="box_h3 mb10">头像设置</h3>
      <div class="uppicBox">
        <%= file_field_tag 'avatar[image]',
                           :id => nil,
                           :class => 'uppic_btn',
                           :style => 'width:70px;',#added by young
                           :size => "1",
                           :multiple => false,
                           :onchange => 'addInputAvatar(this);',
                           :data => {
                             :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
                             :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
                             :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
                             :file_type => Redmine::Configuration['pic_types'].to_s,
                             :type_support_message => l(:error_pic_type),
                             :upload_path => upload_avatar_path(:format => 'js'),
                             :description_placeholder => nil ,# l(:label_optional_description)
                             :source_type => @user.class.to_s,
                             :source_id => @user.id.to_s
                           } %>
        <!--<br/>-->
        <!--<span>只支持jpg,png,gif,大小不超过5M</span>-->
      </div>
      <div class="showpicBox">
        <p>预览</p>
        <%= image_tag(url_to_avatar(@user), :style=>"width:96px;height:96px;",:class=>"mb5 mt10",:nhname=>'avatar_image') %>
        <span >96px*96px</span> <br />
        <div class="mb20"></div>
        <%= image_tag(url_to_avatar(@user), :style=>"width:48px;height:48px;",:class=>"mb5",:nhname=>'avatar_image') %>
        <br />
        <span>48px*48px</span> <br />
      </div>
      <div class="cl mb10"></div>
      <a href="javascript:hideModal();" class=" fr grey_btn mr15 f14"> 取&nbsp;&nbsp;消</a>
      <a href="<%= url_for(:controller => 'my', :action => 'save_user_avatar') %>" data-remote="true" class="blue_btn fr mr10 f14">确&nbsp;&nbsp;定</a>

    </div><!--talknew end-->
    <div class="cl"></div>
  </div><!--floatbox end-->
</div>

<script type="text/javascript">
    $(function(){
        if($(".top_new").length==0){
            $("#RSide").css("min-height",$("#LSide").height()-30);
        }
        else{
            $("#RSide").css("min-height",$("#LSide").height()-87);
        }

    });
</script>

</body>
</html>
