/**
  * @brief postComment 发表评论
  *
  * @return void
  */
 public function postComment()
 {
     $c = array();
     // 如果用户已登录,则可以不填写基本信息
     if (Widget::getWidget('User')->isLogin()) {
         $user = Widget::getWidget('User')->getUser();
         $c['uid'] = $user['uid'];
         $c['author'] = $user['username'];
         $c['email'] = $user['email'];
         $c['website'] = $user['website'];
     } else {
         $c['uid'] = 0;
         $c['author'] = Request::P('author', 'string');
         $c['email'] = Request::P('email', 'string');
         $c['website'] = Request::P('website', 'string');
     }
     $c['pid'] = Request::P('postId');
     $c['content'] = Request::P('content', 'string');
     $error = '';
     if (!$c['pid'] || !$c['author'] || !$c['email'] || !$c['content']) {
         // 检查信息完整性
         $error = _t('Author, Email and Content can not be null.');
     } else {
         // 检查文章是否存在、是否允许评论
         Widget::initWidget('Post');
         $post = new PostLibrary();
         $p = $post->getPost($c['pid']);
         if ($p) {
             Widget::getWidget('Post')->setPID($c['pid']);
         } else {
             $p = $post->getPage($c['pid'], FALSE);
             Widget::getWidget('Post')->setAlias($p['alias']);
         }
         if (!Widget::getWidget('Post')->query() || !Widget::getWidget('Post')->postAllowReply()) {
             $error = _t('Comment closed.');
         } else {
             // TODO 敏感词过滤
             // TODO 内容处理
             $c['content'] = str_replace(array("\r\n", "\n", "\r"), '<br />', htmlspecialchars($c['content']));
             $c = Plugin::call('postComment', $c);
             // 写入评论
             $comment = new CommentLibrary();
             $comment->postComment($c);
             // 评论计数加一
             $post->incReply($c['pid']);
             // 保存用户信息
             Response::setCookie('author', $c['author'], time() + 24 * 3600 * 365);
             Response::setCookie('email', $c['email'], time() + 24 * 3600 * 365);
             Response::setCookie('website', $c['website'], time() + 24 * 3600 * 365);
         }
     }
     if ($error) {
         $r = array('success' => FALSE, 'message' => $error);
     } else {
         $r = array('success' => TRUE, 'message' => _t('Post comment success.'));
     }
     if (Request::isAjax()) {
         Response::ajaxReturn($r);
     } else {
         if ($error) {
             Response::error(_t('Post failed'), $error);
         } else {
             Response::back();
         }
     }
 }
?>
</a></dt>
	<dd id="tabPostAdd" style="display: <?php 
if (!Request::G('page')) {
    ?>
block<?php 
} else {
    ?>
none<?php 
}
?>
; ">
<?php 
if ($pid = Request::G('pid')) {
    $post = new PostLibrary();
    $p = $post->getPost($pid);
    ?>
		<form action="<?php 
    path(array('do' => 'editPost'), 'AdminDo');
    ?>
" method="post" name="add_post" id="add-post">
			<div id="add-post-left">
				<textarea style="height: 440px;width:550px;" autocomplete="off" id="add-post-content" name="content"><?php 
    echo $p['content'];
    ?>
</textarea>
			</div>
			<div id="add-post-right">
				<ul id="add-post-option">
				<li>
					<label for="add-post-title" class="add-post-label"><?php 
 /**
  * @brief query 根据条件取出文章数据
  *
  * @return bool
  */
 public function query()
 {
     $post = new PostLibrary();
     if ($this->pid) {
         $this->currentPost = 1;
         $page = $post->getPost($this->pid);
         if ($page) {
             $this->posts = array($page);
             return TRUE;
         } else {
             return FALSE;
         }
     } elseif ($this->alias) {
         $this->currentPost = 1;
         $page = $post->getPage($this->alias);
         if ($page) {
             $this->posts = array($page);
             return TRUE;
         } else {
             return FALSE;
         }
     } else {
         $this->currentPost = 0;
         $post->setPerPage($this->perPage);
         $post->setAuthor($this->authorID);
         $post->setCurrentPage($this->currentPage);
         $post->setCurrentMeta($this->currentMeta);
         $post->setSearchWord($this->searchWord);
         $this->posts = $post->getPosts();
         return TRUE;
     }
 }