You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
6.2 KiB

  1. <?php function threadedComments($comments, $options) {
  2. $commentClass = '';
  3. if ($comments->authorId) {
  4. if ($comments->authorId == $comments->ownerId) {
  5. //如果是文章作者的评论添加 .comment-by-author 样式
  6. $commentClass .= 'comment-by-author';
  7. } else {
  8. //如果是评论作者的添加 .comment-by-user 样式
  9. $commentClass .= 'comment-by-user';
  10. }
  11. }
  12. //评论层数大于0为子级,否则是父级
  13. $commentLevelClass = $comments->_levels > 0 ? ' comment-child' : ' comment-parent';
  14. $depth = $comments->levels +1;
  15. //判断博主头像
  16. if($commentClass=='comment-by-author'){
  17. $avatar = $avatar2x = theprofile;
  18. }else{
  19. $email = $comments->mail;
  20. //判断邮箱类型选取头像地址
  21. if(preg_match('|^[1-9]\d{4,10}@qq\.com$|i',$email)){
  22. $qqnumber = explode("@",$email);
  23. $avatar = '//q.qlogo.cn/g?b=qq&nk=' . $qqnumber[0]. '&s=100';
  24. $avatar2x = '//q.qlogo.cn/g?b=qq&nk=' . $qqnumber[0]. '&s=160';
  25. }else{
  26. $avatar = 'https://gravatar.loli.net/avatar/' . md5(strtolower($comments->mail)) . '?s=80&r=X&d=mm';
  27. $avatar2x = 'https://gravatar.loli.net/avatar/' . md5(strtolower($comments->mail)) . '?s=160&r=X&d=mm';
  28. }
  29. }
  30. ?>
  31. <li class="comment <?php $comments->alt('comment-odd', 'comment-even');?> depth-<?php echo $depth ?>" id="li-<?php $comments->theId(); ?>">
  32. <div id="<?php $comments->theId(); ?>" class="comment_body contents">
  33. <div class="profile">
  34. <a href="<?php $comments->url(); ?>"><img alt="<?php $comments->author(false); ?>" src="<?php echo $avatar ?>" srcset="<?php echo $avatar2x ?> 2x" class="avatar avatar-50 photo" height="50" width="50"></a>
  35. </div>
  36. <section class="commeta">
  37. <div class="left">
  38. <h4 class="author"><a href="<?php $comments->url(); ?>"><img alt="<?php $comments->author(false); ?>" src="<?php echo $avatar ?>" srcset="<?php echo $avatar2x ?> 2x" class="avatar avatar-50 photo" height="50" width="50"/><?php $comments->author(false); ?><span class="isauthor" title="Author"><i class="iconfont">&#xe615;</i></span></a></h4>
  39. </div>
  40. <a rel='nofollow' class='comment-reply-link' href='<?php $comments->responseUrl(); ?>' onclick="return TypechoComment.reply('<?php $comments->theId(); ?>', <?php $comments->coid();?>);" aria-label='回复给<?php $comments->author(false); ?>'>回复</a>
  41. <div class="right">
  42. <div class="info"><time datetime="<?php $comments->date('Y-m-d'); ?>"><?php $comments->date('Y年m月d日'); ?></time></div>
  43. </div>
  44. </section>
  45. <div class="body">
  46. <p>
  47. <?php get_commentReply_at($comments->coid); ?> <!-- 评论@ -->
  48. <?php $cos = preg_replace('#</?[p|P][^>]*>#','',$comments->content);echo $cos;?> <!-- 评论内容 -->
  49. </p>
  50. </div>
  51. </div>
  52. <?php if ($comments->children){ ?>
  53. <!-- 嵌套评论代码 -->
  54. <div class="children">
  55. <?php $comments->threadedComments($options); ?>
  56. </div>
  57. <?php } ?>
  58. </li>
  59. <?php } ?>
  60. <section id="comments" class="comments">
  61. <!-- 隐藏评论 -->
  62. <div class="commentwrap comments-hidden">
  63. <div class="notification"><i class="iconfont">&#xe610;</i><?php $this->commentsNum(_t('添加评论'), _t('查看沙发'), _t('查看评论')); ?></div>
  64. </div>
  65. <!-- 输出评论信息 -->
  66. <div class="comments-main">
  67. <h3 id="comments-list-title">Comments | <a ><?php $this->commentsNum(_t('NOTHING'), _t('<span class="noticom">1</span>条评论'), _t('<span class="noticom">%d</span>条评论')); ?></a></h3>
  68. <div id="loading-comments"><span></span></div>
  69. <!-- 评论内容 -->
  70. <div id="comments-ajax">
  71. <?php $this->comments()->to($comments); ?>
  72. <?php $comments->listComments(); ?>
  73. </div>
  74. <?php if ($comments->have()): ?>
  75. <!-- 评论翻页 -->
  76. <nav id="comments-navi">
  77. <?php $comments->pageNav('←','→','1','...'); ?>
  78. </nav>
  79. <?php endif; ?>
  80. <!--评论框-->
  81. <!-- 判断设置是否允许对当前文章进行评论 -->
  82. <?php if($this->allow('comment')): ?>
  83. <div id="respond_box">
  84. <div id="<?php $this->respondId(); ?>" class="comment-respond">
  85. <div class="cancel-comment-reply">
  86. <?php $comments->cancelReply(); ?>
  87. </div>
  88. <!-- 输入表单开始 -->
  89. <form action="<?php $this->commentUrl() ?>" method="post" id="commentform">
  90. <!-- 如果当前用户已经登录 -->
  91. <?php if($this->user->hasLogin()): ?>
  92. <p>登录者: <a href="<?php $this->options->adminUrl(); ?>"><?php $this->user->screenName(); ?></a>&nbsp;&nbsp;<a href="<?php $this->options->logoutUrl(); ?>"title="退出">[ 退出 ] →</a></p>
  93. <!-- 若当前用户未登录 -->
  94. <?php else: ?>
  95. <div class="author-updown">Welcome back ,&nbsp;<?php $this->remember('author'); ?>&nbsp;<a id="toggle-comment-info">[ 修改 ] ↓</a></div>
  96. <div id="comment-author-info">
  97. <input type="text" name="author" id="author" class="commenttext" placeholder="Name" value="<?php $this->remember('author'); ?>" size="22" tabindex="1" placeholder="Name" />
  98. <label for="author"></label>
  99. <input type="text" name="mail" id="mail" class="commenttext" value="<?php $this->remember('mail'); ?>" size="22" placeholder="Email" tabindex="2" />
  100. <label for="mail"></label>
  101. <input type="text" name="url" id="url" class="commenttext" value="<?php $this->remember('url'); ?>" size="22"placeholder="http://" tabindex="3" />
  102. <label for="url"></label>
  103. </div>
  104. <div class="clear"></div>
  105. <?php endif; ?>
  106. <p><textarea name="text" id="comment" class="OwO-textarea" placeholder="come on baby !" tabindex="4" cols="50" rows="5"></textarea></p>
  107. <div class="com-footer">
  108. <input class="submit" name="submit" type="submit" id="submit" tabindex="5" value="发表评论" />
  109. <input type='hidden' name='comment_post_ID' value='58' id='comment_post_ID' />
  110. <input type='hidden' name='comment_parent' id='comment_parent' value='0' />
  111. <!--表情-->
  112. <div class="OwO"></div>
  113. <script type="text/javascript" src="<?php echo theurl; ?>js/OwO.js" defer="defer"></script>
  114. </div>
  115. </form>
  116. <?php else: ?>
  117. <section class="author-profile">
  118. <p><i class="iconfont">&#xe61a;</i>该文章已经关闭评论</p>
  119. </section>
  120. <?php endif; ?>
  121. <div class="clear"></div>
  122. </div>
  123. </div>
  124. </div>
  125. </section>