コード例 #1
0
_e('List');
?>
</a></dt>
	<dd id="tabPageAdd" style="display: <?php 
if (!Request::G('page')) {
    ?>
block<?php 
} else {
    ?>
none<?php 
}
?>
; ">
<?php 
if ($pid = Request::G('pid')) {
    $post = new PostLibrary();
    $p = $post->getPage($pid, FALSE);
    ?>
		<form action="<?php 
    path(array('do' => 'editPage'), '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>
コード例 #2
0
_e('List');
?>
</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>
コード例 #3
0
 /**
  * @brief deletePost 删除一篇文章
  *
  * @return void
  */
 public function deletePost()
 {
     $pid = Request::P('pid');
     // 删除文章
     $post = new PostLibrary();
     $post->deletePost($pid);
     // 删除 Meta 关系
     $meta = new MetaLibrary();
     $meta->setPID($pid);
     $metas = $meta->getMeta();
     foreach ($metas as $m) {
         if ($m['type'] == 1 || $m['type'] == 2) {
             $meta->delRelation($m['mid'], $pid);
         } elseif ($m['type'] == 3) {
             $meta->movRelation($m['mid'], $pid, 1000000000);
         }
     }
     // 删除评论
     $comment = new CommentLibrary();
     $comment->deleteComments($pid);
     $r = array('success' => TRUE);
     Response::ajaxReturn($r);
 }
コード例 #4
0
 /**
  * @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();
         }
     }
 }
コード例 #5
0
 /**
  * @brief deleteComments 删除某文章的所有评论
  *
  * @param $pid 文章 ID
  *
  * @return void
  */
 public function deleteComments($pid)
 {
     $post = new PostLibrary();
     $post->resetReply($pid);
     return Database::query("DELETE FROM `{$this->prefix}comments` WHERE `pid`={$pid}");
 }