Skip to content

Commit

Permalink
提及置顶样式
Browse files Browse the repository at this point in the history
  • Loading branch information
nova2018 committed May 18, 2019
1 parent c1232c0 commit e4fa0da
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
9 changes: 8 additions & 1 deletion details.php
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,15 @@
'lastpagedefault' => 1
), "page");

$subres = sql_query("SELECT id, text, user, added, editedby, editdate FROM comments WHERE torrent = $id ORDER BY id $limit") or sqlerr(__FILE__, __LINE__);
$allrows = array();
// 取出置顶贴
$subres = sql_query("SELECT id, text, user, added, editedby, editdate FROM comments WHERE torrent = $id AND is_top > 0 ORDER BY is_top DESC, id ASC") or sqlerr(__FILE__, __LINE__);
while ($subrow = mysql_fetch_array($subres)) {
$allrows [] = $subrow;
}

// 取出非置顶
$subres = sql_query("SELECT id, text, user, added, editedby, editdate FROM comments WHERE torrent = $id AND is_top = 0 ORDER BY id $limit") or sqlerr(__FILE__, __LINE__);
while ($subrow = mysql_fetch_array($subres)) {
$allrows [] = $subrow;
}
Expand Down
4 changes: 3 additions & 1 deletion include/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3365,6 +3365,8 @@ function commenttable($rows, $type, $parent_id, $review = false)
begin_main_frame();
begin_frame();

$stickyicon = "<img class=\"sticky\" src=\"pic/trans.gif\" alt=\"Sticky\" title=\"" . $lang_functions ['title_sticky'] . "" . $row ['pos_state_until'] . "\" />";

$count = 0;
if ($Advertisement->enable_ad())
$commentad = $Advertisement->get_ad('comment');
Expand All @@ -3376,7 +3378,7 @@ function commenttable($rows, $type, $parent_id, $review = false)
echo "<div align=\"center\" style=\"margin-top: 10px\" id=\"ad_comment_" . $count . "\">" . $commentad [$count - 1] . "</div>";
}
}
print ("<div style=\"margin-top: 8pt; margin-bottom: 8pt;\"><table id=\"cid" . $row ["id"] . "\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr><td class=\"embedded\" width=\"99%\">#" . $row ["id"] . "&nbsp;&nbsp;<font color=\"gray\">" . $lang_functions ['text_by'] . "</font>");
print ("<div style=\"margin-top: 8pt; margin-bottom: 8pt;\"><table id=\"cid" . $row ["id"] . "\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr><td class=\"embedded\" width=\"99%\">" . ($row['is_top'] > 0 ? $stickyicon . "&nbsp;" : "") . "#" . $row ["id"] . "&nbsp;&nbsp;<font color=\"gray\">" . $lang_functions ['text_by'] . "</font>");
print (get_username($row ["user"], false, true, true, false, false, true));
print ("&nbsp;&nbsp;<font color=\"gray\">" . $lang_functions ['text_at'] . "</font>" . gettime($row ["added"]) . ($row ["editedby"] && get_user_class() >= $commanage_class ? " - [<a href=\"comment.php?action=vieworiginal&amp;cid=" . $row ['id'] . "&amp;type=" . $type . "\">" . $lang_functions ['text_view_original'] . "</a>]" : "") . "</td><td class=\"embedded nowrap\" width=\"1%\"><a href=\"#top\"><img class=\"top\" src=\"pic/trans.gif\" alt=\"Top\" title=\"Top\" /></a>&nbsp;&nbsp;</td></tr></table></div>");
$avatar = ($CURUSER ["avatars"] == "yes" ? htmlspecialchars(trim($userRow ["avatar"])) : "");
Expand Down
7 changes: 7 additions & 0 deletions sql/pt.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4378,6 +4378,13 @@ ALTER TABLE `usercss`
--
ALTER TABLE `users`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- 增加种子评论置顶功能
--
ALTER TABLE `comments` ADD COLUMN is_top tinyint(4) unsigned NOT NULL DEFAULT 0 COMMENT '评论置顶';
ALTER TABLE `comments` ADD INDEX idx_ttid(`torrent`,`is_top`,`id`);

COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
Expand Down
2 changes: 2 additions & 0 deletions sql/update_nova_v1.0.2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE comments ADD COLUMN is_top tinyint(4) unsigned NOT NULL DEFAULT 0 COMMENT '评论置顶';
ALTER TABLE comments ADD INDEX idx_ttid(`torrent`,`is_top`,`id`);

0 comments on commit e4fa0da

Please sign in to comment.