当前位置: 首页>>代码示例>>PHP>>正文


PHP Comment类代码示例

本文整理汇总了PHP中Comment的典型用法代码示例。如果您正苦于以下问题:PHP Comment类的具体用法?PHP Comment怎么用?PHP Comment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Comment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildComment

 /**
  *
  * @param $comment
  * @return Comment 
  */
 private function buildComment($comment)
 {
     $cmt = new Comment($comment['datetime'], $comment['title'], $comment['text']);
     $user = new User($comment['nameUser'], null);
     $cmt->setUser($user);
     return $cmt;
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:12,代码来源:CommentDao.php

示例2: addComment

 /**
  * Create new comment. This function is used by ProjectForms to post comments
  * to the messages
  *
  * @param string $content
  * @param boolean $is_private
  * @return Comment or NULL if we fail to save comment
  * @throws DAOValidationError
  */
 function addComment($content, $is_private = false)
 {
     $comment = new Comment();
     $comment->setText($content);
     $comment->setIsPrivate($is_private);
     return $this->attachComment($comment);
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:16,代码来源:ProjectMessage.class.php

示例3: saveComment

 public static function saveComment($userId)
 {
     $comment = new Comment();
     $comment->text = $_POST['text'];
     $comment->user_id = $userId;
     $comment->save();
 }
开发者ID:AJIACTOP,项目名称:MVC-Framework,代码行数:7,代码来源:Comment.php

示例4: testCounterIncrementsAndDecrementsWhen

 public function testCounterIncrementsAndDecrementsWhen()
 {
     $post_with_comments = new Post();
     $post_with_comments->title = 'post 1';
     $this->assertTrue($post_with_comments->save());
     $post_without_comments = new Post();
     $post_without_comments->title = 'post 2';
     $this->assertTrue($post_without_comments->save());
     //Create 10 comments, ensure counter increments
     for ($i = 1; $i <= 10; $i++) {
         $comment = new Comment();
         $comment->postId = $post_with_comments->id;
         $comment->text = 'comment ' . $i;
         $this->assertTrue($comment->save());
         $post_with_comments->refresh();
         $post_without_comments->refresh();
         $this->assertEquals($post_with_comments->commentsCount, $i);
         $this->assertEquals($post_without_comments->commentsCount, 0);
     }
     //Delete all comments, ensure counter decrements
     $comments = Comment::find()->all();
     $count = count($comments);
     foreach ($comments as $comment) {
         $this->assertEquals($comment->delete(), 1);
         $count--;
         $post_with_comments->refresh();
         $this->assertEquals($post_with_comments->commentsCount, $count);
     }
 }
开发者ID:ostapetc,项目名称:yii2-cache-counter-behavior,代码行数:29,代码来源:CounterCacheBehaviorTest.php

示例5: moderateComment

function moderateComment($id, $action, $fullUser)
{
    global $dbConnectionInfo;
    $toReturn = "";
    $act = false;
    if ($action == "approved") {
        $act = true;
    }
    $cmt = new Comment($dbConnectionInfo, "", $fullUser);
    $return = $cmt->moderate($id, $action);
    $toReturn = $return['page'];
    if ($return['page'] != "" && $act && $return['oldState'] == 'new') {
        // notify users
        $user = new User($dbConnectionInfo);
        $usersToNotify = $user->getUsersToNotify($toReturn, $id);
        $cmtInfo = $cmt->getInfo($id);
        $productTranslate = defined("__PRODUCT_NAME__") ? __PRODUCT_NAME__ : $cmtInfo['product'];
        $template = new Template("./templates/newComment.html");
        $confirmationMsg = $template->replace(array("page" => __BASE_URL__ . $toReturn . "#" . $id, "text" => $cmtInfo['text'], "user" => $cmtInfo['name'], "productName" => $productTranslate));
        foreach ($usersToNotify as $key => $value) {
            $mail = new Mail();
            $subject = "[" . $productTranslate . "] " . Utils::translate('newCommentApproved');
            $subject .= " [" . $toReturn . "]";
            $mail->Subject($subject);
            $mail->To($value);
            $mail->From(__EMAIL__);
            $mail->Body($confirmationMsg);
            $mail->Send();
            //$toReturn = "\nSEND to ".$value."user email='".$userEmail."'";
        }
    }
    return $toReturn;
}
开发者ID:aidanreilly,项目名称:documentation,代码行数:33,代码来源:moderate.php

示例6: processRequest

 /**
  * @param $model
  * @return Comment
  */
 public function processRequest($model)
 {
     $comment = new Comment();
     if (Yii::app()->request->isPostRequest) {
         $comment->attributes = Yii::app()->request->getPost('Comment');
         if (!Yii::app()->user->isGuest) {
             $comment->name = Yii::app()->user->name;
             $comment->email = Yii::app()->user->email;
         }
         if ($comment->validate()) {
             $pkAttr = $model->getObjectPkAttribute();
             $comment->class_name = $model->getClassName();
             $comment->object_pk = $model->{$pkAttr};
             $comment->user_id = Yii::app()->user->isGuest ? 0 : Yii::app()->user->id;
             $comment->save();
             $url = Yii::app()->getRequest()->getUrl();
             if ($comment->status == Comment::STATUS_WAITING) {
                 $url .= '#';
                 Yii::app()->user->setFlash('messages', Yii::t('CommentsModule.core', 'Ваш комментарий успешно добавлен. Он будет опубликован после проверки администратором.'));
             } elseif ($comment->status == Comment::STATUS_APPROVED) {
                 $url .= '#comment_' . $comment->id;
             }
             // Refresh page
             Yii::app()->request->redirect($url, true);
         }
     }
     return $comment;
 }
开发者ID:kolbensky,项目名称:rybolove,代码行数:32,代码来源:CommentsModule.php

示例7: actionAdmin

 public function actionAdmin()
 {
     // delete comment request
     if (Rays::isPost()) {
         if (isset($_POST['checked_comments'])) {
             $commentIds = $_POST['checked_comments'];
             foreach ($commentIds as $id) {
                 if (!is_numeric($id)) {
                     return;
                 } else {
                     $comment = new Comment();
                     $comment->id = $id;
                     $comment->delete();
                 }
             }
         }
     }
     $curPage = $this->getPage("page");
     $pageSize = $this->getPageSize('pagesize', 10);
     $count = Comment::find()->count();
     $comments = Comment::find()->join("user")->join("topic")->order_desc("id")->range(($curPage - 1) * $pageSize, $pageSize);
     $pager = new RPager('page', $count, $pageSize, RHtml::siteUrl('comment/admin'), $curPage);
     $this->layout = 'admin';
     $this->setHeaderTitle("Comments administration");
     $data = array('count' => $count, 'comments' => $comments, 'pager' => $pager->showPager());
     $this->render('admin', $data, false);
 }
开发者ID:a4501150,项目名称:FDUGroup,代码行数:27,代码来源:CommentController.php

示例8: executeDoAdd

 /**
  * executeDo_add_new_comment 
  * 
  * @access public
  * @return void
  */
 public function executeDoAdd(sfWebRequest $request)
 {
     // Pull associated model
     $record_id = $request->getParameter('record_id');
     $model = $request->getParameter('model');
     $this->record = Doctrine::getTable($model)->find($record_id);
     $commentForm = new CommentForm();
     $commentForm->bind($request->getParameter('comment'));
     // return bound form with errors if form is invalid
     if (!$commentForm->isValid()) {
         return $this->renderPartial('csComments/add_comment', array('commentForm' => $commentForm));
     }
     // save the object
     /* SHOULD USE IMBEDDED FORMS
            Used this hack instead.  Need to fix
            -B.Shaffer
        */
     $commentVals = $commentForm->getValues();
     $commenter = new Commenter();
     $commenter->fromArray($commentVals['Commenter']);
     $commenter->save();
     $comment = new Comment();
     $comment['body'] = $commentVals['body'];
     $comment['Commenter'] = $commenter;
     $comment->save();
     $this->comment = $comment;
     // Pass parent comment id if comment is nested
     $parent_id = $this->getRequestParameter('comment_id');
     $this->record->addComment($this->comment, $parent_id);
     $this->record->save();
 }
开发者ID:bshaffer,项目名称:Symplist,代码行数:37,代码来源:BasecsCommentsActions.class.php

示例9: postBlogComment

 /**
  * 提交评论
  * @param  string $slug 文章缩略名
  * @return response
  */
 public function postBlogComment($slug)
 {
     // 获取评论内容
     $content = e(Input::get('content'));
     // 字数检查
     if (mb_strlen($content) < 3) {
         return Redirect::back()->withInput()->withErrors($this->messages->add('content', '评论不得少于3个字符。'));
     }
     // 查找对应文章
     $article = Article::where('slug', $slug)->first();
     // 创建文章评论
     $comment = new Comment();
     $comment->content = $content;
     $comment->article_id = $article->id;
     $comment->user_id = Auth::user()->id;
     if ($comment->save()) {
         // 创建成功
         // 更新评论数
         $article->comments_count = $article->comments->count();
         $article->save();
         // 返回成功信息
         return Redirect::back()->with('success', '评论成功。');
     } else {
         // 创建失败
         return Redirect::back()->withInput()->with('error', '评论失败。');
     }
 }
开发者ID:ningcaichen,项目名称:laravel-4.1-simple-blog,代码行数:32,代码来源:BlogController.php

示例10: add

 function add()
 {
     $response = new Response();
     try {
         $workOrderId = $this->input->post("workOrderId");
         $commentText = $this->input->post("comment");
         $workOrder = $this->findById("Workorder", $workOrderId);
         $loggedInUser = $this->getLoggedInUser();
         $comment = new Comment();
         $comment->setCreated(new DateTime());
         $comment->setCommentedBy($loggedInUser);
         $comment->setComment($commentText);
         $workOrder->getComments()->add($comment);
         $this->save($workOrder);
         $cmt = new Commentdto();
         $cmt->setId($comment->getId());
         $cmt->setComment($comment->getComment());
         $cmt->setCommentedBy($comment->getCommentedBy()->getFirstName() . " " . $comment->getCommentedBy()->getLastName());
         $cmt->setCreated(date_format($comment->getCreated(), "d-M-Y"));
         $response->setData($cmt);
     } catch (Exception $e) {
         $response->setStatus(false);
         $response->setErrorMessage($e->getMessage());
     }
     $this->output->set_content_type('application/json')->set_output(json_encode($response));
 }
开发者ID:digvijaymohite,项目名称:e-tender,代码行数:26,代码来源:Comments.php

示例11: parents

	/**
	 * get a list of all parent comments
	 *
	 * Starts with the rubric as the top level and ends with the parent of this comment.
	 *
	 * @return array
	 */
	public function parents() {
		if (!$this->parent) return array($this->rubric);
		$parent = new Comment($this->parent);
		$parents = $parent->parents();
		$parents[] = $this->parent;
		return $parents;
	}
开发者ID:ppschweiz,项目名称:basisentscheid,代码行数:14,代码来源:Comment.php

示例12: addCommentAction

 /**
  * @Route("/ajax/add-comment", name="add_comment")
  */
 public function addCommentAction()
 {
     $request = $this->get('request');
     if ($request->isXmlHttpRequest()) {
         $akismet = $this->get('ornicar_akismet');
         $name = $request->get('name');
         $email = $request->get('email');
         $commentContent = $request->get('comment');
         $id = $request->get('id');
         $isSpam = $akismet->isSpam(array('comment_author' => $name, 'comment_content' => $commentContent));
         if ($isSpam === false) {
             $em = $this->getDoctrine()->getManager();
             $article = $em->getRepository('CoreBundle:Article')->find($id);
             if (!$article) {
                 throw $this->createNotFoundException('Unable to find Article entity.');
             }
             $comment = new Comment();
             $comment->setCommentAuthor($name);
             $comment->setCommentAuthorEmail($email);
             $comment->setCommentContent($commentContent);
             $article->addComment($comment);
             $em->persist($article);
             $em->flush();
             $message = \Swift_Message::newInstance()->setSubject('Hello Author, New Comment added')->setFrom('info@es-blog.com')->setTo('essam_2060@hotmail.com')->setBody('You have a new Comment! please check your blog');
             $this->get('mailer')->send($message);
             return new JsonResponse(1);
         }
     }
 }
开发者ID:EssamKhaled,项目名称:tawsella,代码行数:32,代码来源:HomeController.php

示例13: post

 public function post()
 {
     // Only permit logged in users to comment
     if (Auth::check()) {
         // Add a rule to verify the particular item exists
         Validator::extend('itemExists', function ($attribute, $value, $parameters) {
             $type = ucfirst(Input::get('type'));
             $item = $type::find($value);
             return $item;
         });
         // Validate the data
         $validator = Validator::make(Input::all(), array('id' => 'itemExists', 'type' => 'in:doctor,companion,enemy,episode', 'title' => 'required|min:5', 'email' => 'required|email', 'content' => 'required'), array('required' => 'You forgot to include the :attribute on your comment!', 'itemExists' => 'If you can see this, the universe is broken because that ' . Input::get('type') . ' does not exist.'));
         if ($validator->fails()) {
             return Redirect::to(URL::previous() . '#comments')->withErrors($validator)->withInput();
         } else {
             $comment = new Comment();
             $comment->user_id = Auth::id();
             $comment->item_id = Input::get('id');
             $comment->item_type = Input::get('type');
             $comment->title = Input::get('title');
             $comment->content = Input::get('content');
             $comment->save();
             return Redirect::to(URL::previous() . '#comments')->with('message', 'Comment posted');
         }
     }
 }
开发者ID:thechrisroberts,项目名称:thedoctor,代码行数:26,代码来源:CommentController.php

示例14: run

 public function run()
 {
     $controller = $this->getController();
     $controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'My Replys') . ' - ' . $controller->_setting['site_name'];
     //我的回复
     $uid = Yii::app()->user->id;
     $comment_mod = new Comment();
     $reply_mod = new Reply();
     $criteria = new CDbCriteria();
     $criteria->addColumnCondition(array('t.user_id' => $uid));
     $criteria->order = 't.id DESC';
     //分页
     $count = $reply_mod->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 15;
     $pages->applyLimit($criteria);
     $datalist = $reply_mod->findAll($criteria);
     foreach ((array) $datalist as $k => $v) {
         $reply = $comment_mod->findByPk($v->cid);
         if ($reply) {
             $c_mod_class = $controller->_content_models[$reply->type];
             $c_mod_name = strtolower($c_mod_class);
             $content_mod = new $c_mod_class();
             $content = $content_mod->findByPk($reply->content_id);
             $datalist[$k]['title'] = $content->title;
             $datalist[$k]['url'] = $controller->createUrl($c_mod_name . '/view', array('id' => $reply->content_id));
         }
     }
     $controller->render('my_replys', array('datalist' => $datalist, 'pages' => $pages));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:30,代码来源:MyreplysAction.php

示例15: run

 public function run()
 {
     $controller = $this->getController();
     $this->_setting = $controller->_setting;
     $this->_stylePath = $controller->_stylePath;
     $this->_static_public = $controller->_static_public;
     $controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'My Comments') . ' - ' . $this->_setting['site_name'];
     //加载css,js
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/user.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
     //我的评论
     $uid = Yii::app()->user->id;
     $comment_mod = new Comment();
     $model_type = new ModelType();
     $uid = Yii::app()->user->id;
     $criteria = new CDbCriteria();
     $criteria->condition = 't.user_id=' . $uid;
     $criteria->order = 't.id DESC';
     //分页
     $count = $comment_mod->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 15;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $datalist = $comment_mod->findAll($criteria);
     foreach ((array) $datalist as $k => $v) {
         $c_mod_class = $controller->_content_models[$v->type];
         $c_mod_name = strtolower($c_mod_class);
         $content_mod = new $c_mod_class();
         $content = $content_mod->findByPk($v->topic_id);
         $datalist[$k]['title'] = $content->title;
         $datalist[$k]['url'] = $controller->createUrl($c_mod_name . '/view', array('id' => $content->id));
     }
     $controller->render('my_comments', array('datalist' => $datalist));
 }
开发者ID:SallyU,项目名称:yiicms,代码行数:35,代码来源:MycommentsAction.php


注:本文中的Comment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。