代码: 全选
<?php $comments->listComments(); ?>
还没有整理过所以代码非常乱...
代码: 全选
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php function threadedComments($comments, $singleCommentOptions) {
$commentClass = '';
if ($comments->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;
?>
<li id="li-<?php $comments->theId(); ?>" class="comment-body<?php
if ( $depth > 1 && $depth < 3 ) {
echo ' comment-child';
$comments->levelsAlt(' comment-level-odd', ' comment-level-even');
}
elseif ( $depth > 2 ) {
echo ' comment-child2';
$comments->levelsAlt(' comment-level-odd', ' comment-level-even');
}
else {
echo ' comment-parent';
}
$comments->alt(' comment-odd', ' comment-even');
echo $commentClass; ?>">
<div class="comment-author">
<div class="gravatar">
<?php $comments->gravatar($singleCommentOptions->avatarSize, $singleCommentOptions->defaultAvatar); ?>
</div>
<cite class="fn"><?php $singleCommentOptions->beforeAuthor();
$comments->author();$singleCommentOptions->afterAuthor(); ?>
</cite>
<div class="comment-meta">
<a href="<?php $comments->permalink(); ?>"><?php $singleCommentOptions->beforeDate();
$comments->date($singleCommentOptions->dateFormat);
$singleCommentOptions->afterDate(); ?></a>
</div>
<div class="comment-reply">
<?php $comments->reply($singleCommentOptions->replyWord); ?>
</div>
<div class="comment-content">
<?php $comments->content(); ?>
</div>
<?php if ($comments->children) { ?>
<div class="comment-children">
<?php $comments->threadedComments($singleCommentOptions); ?>
</div>
<?php } ?>
</li>
<?php
}
?>
<div id="comments">
<?php $this->comments()->to($comments); ?>
<?php if ($comments->have()): ?>
<h3><?php $this->commentsNum(_t('暂无评论'), _t('仅有一条评论'), _t('已有 %d 条评论')); ?></h3>
<?php $comments->pageNav('«', '»', 10, '', array('wrapTag' => 'ol', 'wrapClass' => 'page-navigator','itemTag' => 'li', 'textTag' => 'span', 'currentClass' => 'current', 'prevClass' => 'prev', 'nextClass' => 'next')); ?>
<?php endif; ?>
<?php $comments->listComments(); ?>
<?php if($this->allow('comment')): ?>
<div id="<?php $this->respondId(); ?>" class="respond">
<div class="cancel-comment-reply">
<?php $comments->cancelReply(); ?>
</div>
<form method="post" action="<?php $this->commentUrl() ?>" id="comment_form" role="form">
<?php if($this->user->hasLogin()): ?>
<p><?php _e('登录身份: '); ?><a href="<?php $this->options->profileUrl(); ?>"><?php $this->user->screenName(); ?></a>. <a href="<?php $this->options->logoutUrl(); ?>" title="Logout"><?php _e('退出'); ?> »</a></p>
<?php else: ?>
<div class="comment_input">
<label for="author"><?php _e('称呼'); ?> *</label>
<input type="text" name="author" id="author" placeholder="" class="text" size="15" value="<?php $this->remember('author'); ?>" required >
</div>
<div class="comment_input">
<label for="mail"><?php _e('邮箱'); ?> *</label>
<input type="text" name="mail" id="mail" class="text" size="15" value="<?php $this->remember('mail'); ?>"><?php if ($this->options->commentsRequireMail): ?> <?php endif; ?>
</div>
<div class="comment_input">
<label for="url">链接</label>
<input type="text" name="url" id="url" class="text" size="15" value="<?php $this->remember('url'); ?>"<?php if ($this->options->commentsRequireURL): ?> <?php endif; ?> />
</div>
<?php endif; ?>
<textarea rows="8" cols="50" name="text" id="textarea" class="textarea" required placeholder="<?php _e('评论内容'); ?> *"><?php $this->remember('text'); ?></textarea>
<div> <button type="submit" class="submit"><?php _e('提交评论'); ?></button></div>
</form>
</div>
</div>
<?php else: ?>
<h3><?php _e('评论已关闭'); ?> :(</h3>
<?php endif; ?>
</div>