// 生成删除文章的文章html代码 public String generateAdminArticleDelHtml(List<TArticle> articles) { String listHtml = ""; int size = articles.size(); for (int i = 0; i < size; i++) { TArticle article = articles.get(i); String item = ""; item += "<tr id='" + article.getArticle_ID() + "' class='noteItem'>"; item += " <td>"; item += " <div class='checker'>"; item += " <span>"; item += " <input class='checkboxes' type='checkbox' value='1'>"; item += " </span>"; item += " </div>"; item += " </td>"; item += " <td>" + article.getArticle_ID() + "</td>"; item += " <td>" + article.getArticle_Title() + "</td>"; item += " <td>" + article.getSort_Name() + "</td>"; item += " <td>" + article.getRecommend_Num() + "</td>"; item += " <td>" + article.getRead_Num() + "</td>"; item += " <td>" + article.getArticle_Date() + "</td>"; item += " <td>"; item += " <a class='delete' onclick='oneDel(" + article.getArticle_ID() + ")' href='javascript:void(0)'>删除</a>"; item += " </td>"; item += "</tr>"; listHtml += item; } return listHtml; }
// 生成修改文章的文章html代码 public String generateAdminArticleUpdateHtml(List<TArticle> articles) { String listHtml = ""; int size = articles.size(); for (int i = 0; i < size; i++) { TArticle article = articles.get(i); String item = ""; item += "<tr id='" + article.getArticle_ID() + "' class='noteItem'>"; item += " <td>" + article.getArticle_ID() + "</td>"; item += " <td>" + article.getArticle_Title() + "</td>"; item += " <td>" + article.getSort_Name() + "</td>"; item += " <td>" + article.getRecommend_Num() + "</td>"; item += " <td>" + article.getRead_Num() + "</td>"; item += " <td>" + article.getArticle_Date() + "</td>"; item += " <td>"; item += " <a class='update' onclick='update(" + article.getArticle_ID() + ")' href='javascript:void(0)'>修改</a>"; item += " </td>"; item += "</tr>"; listHtml += item; } return listHtml; }
// 生成个人作品页面的作品列表html代码 public String generateWorksMainHtml(List<TArticle> articles) throws UnsupportedEncodingException { String listHtml = ""; if (articles != null) { int size = articles.size(); for (int i = 0; i < size; i++) { if (i % 2 != 0) { // 奇数 TArticle prevArticle = articles.get(i - 1); // 获得这一行的第一个 TArticle nowArticle = articles.get(i); // 获得这一行的第二个 // 获取封面 String prevCoverHtml = ""; String nowCoverHtml = ""; if (prevArticle.getArticle_Cover() == "") { prevCoverHtml = "/doit/common/images/cover_default.png"; } else { prevCoverHtml = prevArticle.getArticle_Cover(); } if (nowArticle.getArticle_Cover() == "") { nowCoverHtml = "/doit/common/images/cover_default.png"; } else { nowCoverHtml = nowArticle.getArticle_Cover(); } // 组织html String rowItem = ""; rowItem += "<div class='row'>"; rowItem += " <div class='col-md-6'>"; rowItem += " <a class='works_item' href='/doit/show/" + prevArticle.getArticle_ID() + "'>"; rowItem += " <div class='works_pic'>"; rowItem += " <img class='img-responsive' xsalt='Responsive image' src='" + prevCoverHtml + "' />"; rowItem += " </div>"; rowItem += " <div class='works_info'>"; rowItem += " <div class='works_name'>" + prevArticle.getArticle_Title() + "</div>"; rowItem += " <div class='works_others'>"; rowItem += " <span class='works_others_guide'>"; rowItem += " <span>" + prevArticle.getArticle_Tag() + "</span>"; rowItem += " </span>"; rowItem += " <span class='works_others_info'>"; rowItem += " <i class='unhide icon' style='margin:0 2px 0 20px;'></i>" + prevArticle.getRead_Num() + ""; rowItem += " <i class='heart icon' style='margin:0 2px 0 10px;'></i>" + prevArticle.getRecommend_Num() + ""; rowItem += " </span>"; rowItem += " </div>"; rowItem += " </div>"; rowItem += " </a>"; rowItem += " </div>"; rowItem += " <div class='col-md-6'>"; rowItem += " <a class='works_item' href='/doit/show/" + nowArticle.getArticle_ID() + "'>"; rowItem += " <div class='works_pic'>"; rowItem += " <img class='img-responsive' xsalt='Responsive image' src='" + nowCoverHtml + "' />"; rowItem += " </div>"; rowItem += " <div class='works_info'>"; rowItem += " <div class='works_name'>" + nowArticle.getArticle_Title() + "</div>"; rowItem += " <div class='works_others'>"; rowItem += " <span class='works_others_guide'>"; rowItem += " <span>" + nowArticle.getArticle_Tag() + "</span>"; rowItem += " </span>"; rowItem += " <span class='works_others_info'>"; rowItem += " <i class='unhide icon' style='margin:0 2px 0 20px;'></i>" + nowArticle.getRead_Num() + ""; rowItem += " <i class='heart icon' style='margin:0 2px 0 10px;'></i>" + nowArticle.getRecommend_Num() + ""; rowItem += " </span>"; rowItem += " </div>"; rowItem += " </div>"; rowItem += " </a>"; rowItem += " </div>"; rowItem += "</div>"; listHtml += rowItem; } else { // 偶数 if (i + 1 == size) { // 最后一个 TArticle nowArticle = articles.get(i); // 获得这一行的第二个 // 获取封面 String nowCoverHtml = ""; if (nowArticle.getArticle_Cover() == "") { nowCoverHtml = "/doit/common/images/cover_default.png"; } else { nowCoverHtml = nowArticle.getArticle_Cover(); } // 组织html String rowItem = ""; rowItem += "<div class='row'>"; rowItem += " <div class='col-md-6'>"; rowItem += " <a class='works_item' href='/doit/show/" + nowArticle.getArticle_ID() + "'>"; rowItem += " <div class='works_pic'>"; rowItem += " <img class='img-responsive' xsalt='Responsive image' src='" + nowCoverHtml + "' />"; rowItem += " </div>"; rowItem += " <div class='works_info'>"; rowItem += " <div class='works_name'>" + nowArticle.getArticle_Title() + "</div>"; rowItem += " <div class='works_others'>"; rowItem += " <span class='works_others_guide'>"; rowItem += " <span>" + nowArticle.getArticle_Tag() + "</span>"; rowItem += " </span>"; rowItem += " <span class='works_others_info'>"; rowItem += " <i class='unhide icon' style='margin:0 2px 0 20px;'></i>" + nowArticle.getRead_Num() + ""; rowItem += " <i class='heart icon' style='margin:0 2px 0 10px;'></i>" + nowArticle.getRecommend_Num() + ""; rowItem += " </span>"; rowItem += " </div>"; rowItem += " </div>"; rowItem += " </a>"; rowItem += " </div>"; rowItem += "</div>"; listHtml += rowItem; } } } } return listHtml; }