summaryrefslogtreecommitdiffstats
path: root/saying.php
blob: 1de52e53a52be597bb5bd39b0f316fd76469f311 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit;
/**
 * 说说动态
 *
 * @package custom
 */
$this->need('includes/head.php');
$this->need('includes/header.php');
?>
<?php function threadedComments($comments, $options) {
    $commentClass = '';
    if ($comments->authorId) {
        if ($comments->authorId == $comments->ownerId) {
            $commentClass .= ' comment-by-author';  //如果是文章作者的评论添加 .comment-by-author 样式
        } else {
            $commentClass .= ' comment-by-user';  //如果是评论作者的添加 .comment-by-user 样式
        }
    } 
    $commentLevelClass = $comments->_levels > 0 ? ' comment-child' : ' comment-parent';  //评论层数大于0为子级,否则是父级
?>
<div>
<div id="li-<?php $comments->theId(); ?>" class="bubble saying-body comment-body<?php 
if ($comments->_levels > 0) {
    echo ' comment-child';
    $comments->levelsAlt(' comment-level-odd', ' comment-level-even');
} else {
    echo ' comment-parent';
}
$comments->alt(' comment-odd', ' comment-even');
echo $commentClass; 
?>">
  <div class="saying-content">
    <span class="saying-author"><?php $comments->author(); ?> said:</span>
    <?php $comments->content(); ?>
	<span class="saying-meta"><i class="iconfont icon-clock"></i> <?php $comments->date('F jS, Y'); ?></span>
  </div>
</div>
</div>
<?php } ?>
    <main class="main-container container">
	  <div class="post-body">
	    <div class="post-content">
		  <?php //判断当前用户是否登陆
		  if($this->user->hasLogin()): 
		  //已登录则输出说说表单 ?>
		  <form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" class="saying-form" role="form">
		    <textarea rows="8" cols="50" name="text" id="textarea" class="OwO-textarea comment-textarea textarea saying-textarea" required ><?php $this->remember('text'); ?></textarea>
		    <p class="saying-action">
			  <div title="OwO" class="saying-OwO OwO"></div>
			  <button type="submit" class="saying-submit submit"><?php _e('发表动态'); ?></button>
	        </p>
		  </form>
		  <hr>
		  <?php endif; ?>
		  <?php //输出说说列表
		  $this->comments()->to($comments); ?>
		  <h3 class="comment-title">
		    <?php $this->commentsNum(_t('暂无动态'), _t('仅有一条动态'), _t('已有 %d 条动态')); ?>
		  </h3>
		  <?php if ($comments->have()): ?>
		    <?php $comments->listComments(); ?>
			<div class="comment-pagenav saying-pagenav">
              <?php $comments->pageNav('<i class="iconfont icon-chevron-left"></i>', '<i class="iconfont icon-chevron-right"></i>'); ?>
            </div>
          <?php endif; ?>
		</div>
	  </div>
	</main>
<?php $this->need('includes/footer.php'); ?>