<% unless all_results.nil? || all_results.empty?%>
    <% all_results.each do |item|%>
        <% case item.type %>
<% when 'user'%>
            <ul class="searchContent">
              <li class="fl"></li>
              <li class="fl searchContentDes">
                <ul class="fl">
                  <li class="f16 mb5"><a href="<%= user_path(item.id)%>" class="fontGrey3 fl">
                    <%= item.try(:highlight).try(:login) ? item.highlight.login[0].html_safe : item.login  %>
                    <%if item.firstname.present? || item.lastname.present?%>
                        (<%= item.try(:highlight).try(:lastname) ? item.highlight.lastname[0].html_safe : item.lastname%>
                        <%= item.try(:highlight).try(:firstname) ? item.highlight.firstname[0].html_safe : item.firstname  %>)
                    <%end %>
                  </a>
                    <div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag"><%= get_user_identity(User.find(item.id).user_extensions.identity) %></span></div>
                    <div class="cl"></div>
                  </li>
                  <li class="fontGrey3 mb5"><%= User.find(item.id).user_extensions && User.find(item.id).user_extensions.brief_introduction.present? ? User.find(item.id).user_extensions.brief_introduction : '这位童鞋很懒，什么也没有留下～'%></li>
                  <li class="f12 fontGrey2">
                    <span class="mr30">加入时间：<%= format_date( User.find(item.id).created_on)%></span><span class="mr30">
                 最后登陆时间：<%= format_date( User.find(item.id).last_login_on)%></span><span class="mr30">
                <%= User.find(item.id).user_extensions.occupation.present? ? '单位：'+User.find(item.id).user_extensions.occupation : ''%></span></li>
                </ul>
              </li>
              <div class="cl"></div>
            </ul>
        <% when 'course'%>
            <ul class="searchContent">
              <li class="fl">
              </li>
              <li class="fl searchContentDes">
                <ul class="fl">
                  <li class="f16 mb5">
                    <a href="<%= course_path(item.id)%>" class="fontGrey3 fl"><%= item.try(:highlight).try(:name) ? item.highlight.name[0].html_safe : item.name  %></a>
                    <div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">课程</span></div>
                    <div class="cl"></div>
                  </li>
                  <li class="fontGrey3 mb5"><%= item.try(:highlight).try(:description) ? item.highlight.description[0].html_safe : item.description %></li>
                  <li class="f12 fontGrey2">
                    <span class="mr30">教师：<%= User.find(item.tea_id).realname %></span>
                    <span class="mr30">授课时间：<%= item.time.to_s + item.term%></span>
                    <span class="mr30">更新时间：<%= format_date(item.updated_at)%></span>
                    <span class="mr30"><%= User.find(item.tea_id).user_extensions.occupation.present? ? '单位：'+User.find(item.tea_id).user_extensions.occupation : ''%></span></li>
                </ul>
              </li>
              <div class="cl"></div>
            </ul>
        <% when 'attachment'%>
            <ul class="searchContent">
              <li class="fl">
              </li>
              <li class="fl searchContentDes">
                <ul class="fl">
                  <li class="f16 mb5 fontGrey3"><a href="<%= download_named_attachment_path(item.id,item.filename)%>" class="fontGrey3 mr10 fl"><%= item.try(:highlight).try(:filename) ? item.highlight.filename[0].html_safe : item.filename %></a><span class="f12 fl" style="padding-top: 5px">(<%=  number_to_human_size(item.filesize)%>)</span>
                    <div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">资源</span></div>
                    <div class="cl"></div>
                  </li>
                  <li class="f12 fontGrey2"><span class="mr30">发布者：<%= User.find(item.author_id).login%>（<%= User.find(item.author_id).realname%>）</span>
                    <!--<span class="mr30">职称：<%#= get_technical_title User.find(item.author_id) %></span>-->
                    <span class="mr30">发布时间：<%= format_date(item.created_on)%></span>
                    <span class="mr30">下载次数：<%= item.downloads%>次</span>
                  </li>
                </ul>
              </li>
              <div class="cl"></div>
            </ul>
        <% when 'project'%>
            <ul class="searchContent">
              <li class="fl">
              </li>
              <li class="fl searchContentDes">
                <ul class="fl">
                  <li class="f16 mb5"><a href="<%= project_path(item.id)%>" class="fontGrey3 fl"><%= item.try(:highlight).try(:name) ? item.highlight.name[0].html_safe : item.name  %></a>
                    <div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">项目</span></div>
                    <div class="cl"></div>
                  </li>
                  <li class="fontGrey3 mb5"><%= item.try(:highlight).try(:description) ? item.highlight.description[0].html_safe : item.description%></li>
                  <li class="f12 fontGrey2"><span class="mr30">管理人员：<%=  item.user_id ?  User.find(item.user_id).login : '无' %></span><span class="mr30">更新时间:<%= date_format_local( Project.find(item.id).updated_on) %></span></li>
                </ul>
              </li>
              <div class="cl"></div>
            </ul>
        <% when 'memo'%>
            <ul class="searchContent">
              <li class="fl">
              </li>
              <li class="fl searchContentDes">
                <ul class="fl">
                  <li class="f16 mb5"><a href="<%= forum_memo_path(:forum_id=>item.forum_id,:id=>item.id)%>" class="fontGrey3 fl"><%= item.try(:highlight).try(:subject) ? item.highlight.subject[0].html_safe : item.subject  %></a>
                    <div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">帖子</span></div>
                    <div class="cl"></div>
                  </li>
                  <li class="fontGrey3 mb5"><%= item.try(:highlight).try(:content) ? item.highlight.content[0].html_safe : item.content.html_safe%></li>
                  <li class="f12 fontGrey2"><span class="mr30">发帖人：<%=  item.author_id ?  User.find(item.author_id).login : '无' %></span><span class="mr30">更新时间:<%= format_date( item.updated_at) %></span></li>
                </ul>
              </li>
              <div class="cl"></div>
            </ul>
        <%end %>
    <% end %>
    <div class="pageRoll">
      <%= paginate all_results,:params => {:controller => 'welcome', :action => 'search',:search_type=>'all'}%>
    </div>
<% end %>
