From c09e0a84ed2bffaece55d628383053ac22e760ff Mon Sep 17 00:00:00 2001 From: spiritree Date: Mon, 20 Nov 2017 10:07:54 +0800 Subject: [PATCH] fix comments --- comments.php | 161 +++++++++++++++++++++++++++++++++++--------------- functions.php | 17 ++++++ 2 files changed, 132 insertions(+), 46 deletions(-) diff --git a/comments.php b/comments.php index 47bd1ac..e6f7c00 100644 --- a/comments.php +++ b/comments.php @@ -1,51 +1,120 @@ -
- comments()->to($comments); ?> - have()): ?> -

commentsNum(_t('暂无评论'), _t('仅有一条评论'), _t('已有 %d 条评论')); ?>

- - listComments(); ?> - pageNav('« 前一页', '后一页 »'); ?> - - +authorId) { + if ($comments->authorId == $comments->ownerId) { + $commentClass .= ' comment-by-author'; + } else { + $commentClass .= ' comment-by-user'; + } + } + $commentLevelClass = $comments->levels > 0 ? ' comment-child' : ' comment-parent'; + $depth = $comments->levels +1; + if ($comments->url) { + $author = '' . $comments->author . ''; + } else { + $author = $comments->author; + } +?> - allow('comment')): ?> -
-
- cancelReply(); ?> +
  • +
    + commentsAvatarRating; + $hash = md5(strtolower($comments->mail)); + $avatar = $host . $url . $hash . '?s=' . $size . '&r=' . $rating . '&d=' . $default; + ?> +
    +
    + + +
    +
    + coid); ?> content(); ?>

    +
    +
    + + reply('Reply'); ?> +
    - -

    -
    - user->hasLogin()): ?> -

    user->screenName(); ?>. »

    - -
    - - - - - - - options->commentsRequireMail): ?> required /> - - - - options->commentsRequireURL): ?> required /> - -
    - -

    - - -

    -

    - -

    -
    - -

    - -
  • + children) { ?> +
    + threadedComments($options); ?> +
    + + + + +
    +
    + comments()->to($comments); ?> + allow('comment')): ?> +
    +
    + cancelReply(); ?> +
    + +

    +
    + user->hasLogin()): ?> +

    user->screenName(); ?>. »

    + +
    + + + + + + + options->commentsRequireMail): ?> required /> + + + + options->commentsRequireURL): ?> required /> + +
    + +

    + + +

    +

    + +

    +
    +
    + +

    + + + have()): ?> + + listComments(); ?> + +
    + pageNav('←','→','2','...'); ?> +
    + + +
    +
    \ No newline at end of file diff --git a/functions.php b/functions.php index c849101..8332bdc 100644 --- a/functions.php +++ b/functions.php @@ -33,3 +33,20 @@ function themeConfig($form) { $form->addInput($socialWeibo); } +function getCommentAt($coid){ + $db = Typecho_Db::get(); + $prow = $db->fetchRow($db->select('parent') + ->from('table.comments') + ->where('coid = ? AND status = ?', $coid, 'approved')); + $parent = $prow['parent']; + if ($parent != "0") { + $arow = $db->fetchRow($db->select('author') + ->from('table.comments') + ->where('coid = ? AND status = ?', $parent, 'approved')); + $author = $arow['author']; + $href = '@'.$author.''; + echo $href; + } else { + echo ''; + } +} \ No newline at end of file