本文整理汇总了PHP中CommentModel类的典型用法代码示例。如果您正苦于以下问题:PHP CommentModel类的具体用法?PHP CommentModel怎么用?PHP CommentModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommentModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modify
/**
* modify comment
*/
public function modify()
{
if ($this->isPost()) {
$uid = $this->user['uid'];
if (empty($uid)) {
Message::showError('please login');
}
$comment_id = trim($_POST['id']);
if (!is_numeric($comment_id)) {
Message::showError('comment id necessay');
}
$content = trim($_POST['content']);
if (empty($content)) {
Message::showError('content is empty');
}
if (!is_numeric($_POST['star'])) {
Message::showError('star is not number');
}
$star = trim($_POST['star']);
$commentModel = new CommentModel();
$result = $commentModel->modify($uid, $comment_id, $star, $content);
if (!empty($result)) {
Message::showSucc('modify comment success');
} else {
Message::showError('modify comment failed');
}
}
$this->display('comment.html');
}
示例2: sus_opp
private function sus_opp()
{
$comment = new CommentModel();
$comment->cid = $_GET['cid'];
//支持
if ($_GET['action'] == 'sustain') {
$comment->sustain() ? Tool::alertLocation('谢谢您的评价', 'feedback.php?cid=' . $comment->cid) : Tool::alertBack('对不起,请重试');
}
//反对
if ($_GET['action'] == 'oppose') {
$comment->oppose() ? Tool::alertLocation('谢谢您的评价', 'feedback.php?cid=' . $comment->cid) : Tool::alertBack('对不起,请重试');
}
}
示例3: indexAction
public function indexAction()
{
header('content-type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');
$valid = true;
$errors = [];
if (CommentModel::exists($this->pdo, htmlentities($_POST['id']))) {
$id = htmlentities($_POST['id']);
} else {
return json_encode($errors['id'] = '<span class="errors">Cet article n\'existe pas</span>');
}
$content = trim(htmlentities($_POST['content']));
$timestamp = time();
if (!isset($content) || empty($content)) {
$errors['content'] = '<span class="errors">Non saisi</span>';
$valid = false;
} elseif (strlen($content) > 200) {
$errors['content'] = '<span class="errors">200 caractères max</span>';
$valid = false;
}
$errors['valid'] = $valid;
if ($valid) {
CommentModel::edit($this->pdo, $id, $content, $timestamp);
}
echo json_encode($errors);
}
示例4: indexAction
public function indexAction()
{
$articles = ArticlesModel::getList($this->pdo);
$commentaires = CommentModel::getList($this->pdo);
include "../view/home.php";
return;
}
示例5: edit
public function edit()
{
$this->assign('userInfo', $this->userInfo);
$id = request('id');
if (isset($_POST['id'])) {
$content = request('content');
$reply = request('reply');
if (mb_strlen($content, 'utf8') > 200) {
$this->error('留言的长度不能超过200字符');
}
if (mb_strlen($reply, 'utf8') > 200) {
$this->error('回复的长度不能超过200字符');
}
$data['content'] = $content;
$data['reply'] = $reply;
$data['replytime'] = time();
$data['status'] = 'replied';
if (CommentModel::update($id, $data)) {
$this->success(request('reffer'));
} else {
$this->error();
}
} else {
$comment = CommentModel::get($id);
$this->assign('comment', $comment);
$this->assign('reffer', $this->reffer());
$this->display();
}
}
示例6: indexAction
public function indexAction()
{
header('content-type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
echo json_encode(CommentModel::showAllComments($this->pdo));
}
示例7: index
public function index()
{
//header('content-type:text/html;charset=utf-8');
$userId = $_SESSION['qq']['userId'];
$collect = new CollectModel();
//查询收藏
$user_collect = $collect->getCollectByuserId($userId);
$article = new ArticleModel();
$arr = array();
foreach ($user_collect as $v) {
//根据收藏的文章id查询文章
$a = $article->getArticleById($v['articleId']);
//取出admin的昵称
$a['adminName'] = $this->getAdmin($a['adminId']);
$arr[] = $a;
}
$comment = new CommentModel();
$commentAlbum = $comment->getCommentByAlbum($userId);
$album = new AlbumModel();
$articles = array();
$albums = array();
foreach ($commentAlbum as $v) {
if ($v['albumId'] != null) {
$c = $album->getAlbumById($v['albumId']);
$c['adminName'] = $this->getAdmin($v['adminId']);
$albums[] = $c;
}
}
$commentArticle = $comment->getCommentByArticle($userId);
foreach ($commentArticle as $v) {
if ($v['articleId'] != null) {
$a = $article->getArticleById($v['articleId']);
$a['adminName'] = $this->getAdmin($v['adminId']);
$articles[] = $a;
}
}
var_dump($albums);
$this->assign('user', $_SESSION['qq']['userName']);
//评论过的相册
$this->assign('albums', $albums);
//评论过的文章
$this->assign('articles', $articles);
//收藏
$this->assign('user_collect', $arr);
$this->display();
}
示例8: deleteAction
public function deleteAction()
{
if (!isset($_POST['comment_id'])) {
return json_encode(["error" => "comment_id missing"]);
}
$comment_id = $_POST['comment_id'];
CommentModel::delete($this->pdo, $comment_id);
return json_encode(["message" => "Supprimé !", "comment_id" => $comment_id]);
}
示例9: AddReplyButton
protected function AddReplyButton($Sender)
{
if (!Gdn::Session()->UserID) {
return;
}
if (isset($Sender->EventArguments['Comment'])) {
$Model = new CommentModel();
$Data = $Model->GetID($Sender->EventArguments['Comment']->CommentID);
} else {
$Model = new DiscussionModel();
$Data = $Model->GetID($Sender->Data['Discussion']->DiscussionID);
}
$ReplyURL = "#" . "{$Data->InsertName}";
$ReplyText = T('Reply');
echo <<<QUOTE
<span class="CommentReply"><a href="{$ReplyURL}">{$ReplyText}</a></span>
QUOTE;
}
示例10: comment
public function comment()
{
if (!empty($_POST)) {
$_POST['userId'] = $_SESSION['qq']['userId'];
$arr = $_POST;
$comment = new CommentModel();
$row = $comment->addComment($_POST);
if ($row) {
$user = new UserModel();
$arr['addTime'] = data('Y-m-d H:i:s');
$user = $user->getUser($_POST['userId']);
$arr['face'] = $user['face'];
$arr['userName'] = $user['userName'];
echo json_encode($arr);
} else {
exit('发表失败');
}
}
}
示例11: indexAction
public function indexAction()
{
if (empty(explode('/', $_SERVER['REQUEST_URI'], 4)[2])) {
header('Location: /');
exit;
} else {
$id = explode('/', $_SERVER['REQUEST_URI'], 4)[2];
}
if (CommentModel::exists($this->pdo, $id)) {
if ($_SESSION['auth']['username'] === CommentModel::getAuthor($this->pdo, $id)) {
include '../app/views/editcomment.php';
return;
}
} else {
header('Location: /404');
exit;
}
}
示例12: indexAction
public function indexAction()
{
header('content-type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');
$comments = CommentModel::showComments($this->pdo, htmlentities($_POST['id']));
if (isset($_SESSION['auth'])) {
$needed = $_SESSION['auth']['username'];
} else {
$needed = '';
}
for ($i = 0; $i < count($comments); $i++) {
if ($comments[$i]['author'] == $needed) {
$comments[$i]['author'] = 'Moi';
}
}
echo json_encode($comments);
}
示例13: indexAction
public function indexAction()
{
if (empty(explode('/', $_SERVER['REQUEST_URI'], 4)[2])) {
header('Location: /');
exit;
} else {
$article_id = explode('/', $_SERVER['REQUEST_URI'], 4)[2];
}
if (CommentModel::exists($this->pdo, $article_id)) {
if ($_SESSION['auth']['username'] === CommentModel::getAuthor($this->pdo, $article_id) || $_SESSION['auth']['permissions'] === 'superadmin') {
CommentModel::delete($this->pdo, $article_id);
header('Location: /');
exit;
}
} else {
header('Location: /404');
exit;
}
}
示例14: commentModel_afterSaveComment_handler
/**
* Give point(s) to the current user if the right conditions are met.
*
* @param CommentModel $sender Sending controller instance.
* @param array $args Event arguments.
*/
public function commentModel_afterSaveComment_handler($sender, $args)
{
if (!c('QnA.Points.Enabled', false) || !$args['Insert']) {
return;
}
$discussionModel = new DiscussionModel();
$discussion = $discussionModel->getID($args['CommentData']['DiscussionID'], DATASET_TYPE_ARRAY);
$isCommentAnAnswer = $discussion['Type'] === 'Question';
$isQuestionResolved = $discussion['QnA'] === 'Accepted';
$isCurrentUserOriginalPoster = $discussion['InsertUserID'] == GDN::session()->UserID;
if (!$isCommentAnAnswer || $isQuestionResolved || $isCurrentUserOriginalPoster) {
return;
}
$userAnswersToQuestion = $sender->getWhere(array('DiscussionID' => $args['CommentData']['DiscussionID'], 'InsertUserId' => GDN::session()->UserID));
// Award point(s) only for the first answer to the question
if ($userAnswersToQuestion->count() > 1) {
return;
}
UserModel::givePoints(GDN::session()->UserID, c('QnA.Points.Answer', 1), 'QnA');
}
示例15: getDetails
private function getDetails()
{
if (isset($_GET['id'])) {
parent::__construct($this->_tpl, new ContentModel());
$this->_model->id = $_GET['id'];
if (!$this->_model->getOneContent()) {
Tool::alertBack('警告:不存在此文档!');
}
$_content = $this->_model->getOneContent();
$_comment = new CommentModel();
$_comment->cid = $this->_model->id;
$_tarArr = explode(',', $_content->tag);
if (is_array($_tarArr)) {
foreach ($_tarArr as $_value) {
$_content->tag = str_replace($_value, '<a href="search.php?type=3&inputkeyword=' . $_value . '">' . $_value . '</a>', $_content->tag);
}
}
$this->_tpl->assign('id', $_content->id);
$this->_tpl->assign('titlec', $_content->title);
$this->_tpl->assign('date', $_content->date);
$this->_tpl->assign('source', $_content->source);
$this->_tpl->assign('author', $_content->author);
$this->_tpl->assign('info', $_content->info);
$this->_tpl->assign('tag', $_content->tag);
$this->_tpl->assign('content', Tool::unHtml($_content->content));
$this->getNav($_content->nav);
if (IS_CAHCE) {
$this->_tpl->assign('count', '<script type="text/javascript">getContentCount();</script>');
} else {
$this->_tpl->assign('count', $_content->count);
}
$this->_tpl->assign('comment', $_comment->getCommentTotal());
$_object = $_comment->getNewThreeComment();
if ($_object) {
foreach ($_object as $_value) {
switch ($_value->manner) {
case -1:
$_value->manner = '反对';
break;
case 0:
$_value->manner = '中立';
break;
case 1:
$_value->manner = '支持';
break;
}
if (empty($_value->face)) {
$_value->face = '00.gif';
}
if (!empty($_value->oppose)) {
$_value->oppose = '-' . $_value->oppose;
}
}
}
$this->_tpl->assign('NewThreeComment', $_object);
$this->_model->nav = $_content->nav;
$_object = $this->_model->getMonthNavRec();
$this->setObject($_object);
$this->_tpl->assign('MonthNavRec', $_object);
$_object = $this->_model->getMonthNavHot();
$this->setObject($_object);
$this->_tpl->assign('MonthNavHot', $_object);
$_object = $this->_model->getMonthNavPic();
$this->setObject($_object);
$this->_tpl->assign('MonthNavPic', $_object);
} else {
Tool::alertBack('警告:非法操作!');
}
}