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


PHP Comment::get方法代码示例

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


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

示例1: getOrCreateComment

 protected function getOrCreateComment($wordpressID)
 {
     if ($wordpressID && ($comment = Comment::get()->filter(array('WordpressID' => $wordpressID))->first())) {
         return $comment;
     }
     return Comment::create();
 }
开发者ID:camfindlay,项目名称:silverstripe-wordpressimport,代码行数:7,代码来源:WpImporter.php

示例2: delete

 /**
  * Delete Comment using Username
  */
 public function delete()
 {
     $comment_id = Param::get('comment_id');
     $comment = Comment::get(Param::get('comment_id'));
     $page = Param::get('page_next', 'delete');
     $status = "";
     switch ($page) {
         case 'delete':
             break;
         case 'delete_end':
             try {
                 if (Param::get('reply') == 'no') {
                     redirect(url('thread/index'));
                 } else {
                     $comment->delete($_SESSION['username']);
                 }
             } catch (ValidationException $e) {
                 $status = notify($e->getMessage(), "error");
                 $page = 'delete';
             }
             break;
         default:
             throw new PageNotFoundException("{$page} is not found");
             break;
     }
     $this->set(get_defined_vars());
     $this->render($page);
 }
开发者ID:jeszytanada,项目名称:BoardJeszy,代码行数:31,代码来源:comment_controller.php

示例3: getEditForm

 /**
  * @return Form
  */
 public function getEditForm($id = null, $fields = null)
 {
     if (!$id) {
         $id = $this->currentPageID();
     }
     $form = parent::getEditForm($id);
     $record = $this->getRecord($id);
     if ($record && !$record->canView()) {
         return Security::permissionFailure($this);
     }
     $newComments = Comment::get()->filter('Moderated', 0);
     $newGrid = new CommentsGridField('NewComments', _t('CommentsAdmin.NewComments', 'New'), $newComments, CommentsGridFieldConfig::create());
     $approvedComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 0);
     $approvedGrid = new CommentsGridField('ApprovedComments', _t('CommentsAdmin.ApprovedComments', 'Approved'), $approvedComments, CommentsGridFieldConfig::create());
     $spamComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 1);
     $spamGrid = new CommentsGridField('SpamComments', _t('CommentsAdmin.SpamComments', 'Spam'), $spamComments, CommentsGridFieldConfig::create());
     $newCount = '(' . count($newComments) . ')';
     $approvedCount = '(' . count($approvedComments) . ')';
     $spamCount = '(' . count($spamComments) . ')';
     $fields = new FieldList($root = new TabSet('Root', new Tab('NewComments', _t('CommentAdmin.NewComments', 'New') . ' ' . $newCount, $newGrid), new Tab('ApprovedComments', _t('CommentAdmin.ApprovedComments', 'Approved') . ' ' . $approvedCount, $approvedGrid), new Tab('SpamComments', _t('CommentAdmin.SpamComments', 'Spam') . ' ' . $spamCount, $spamGrid)));
     $root->setTemplate('CMSTabSet');
     $actions = new FieldList();
     $form = new Form($this, 'EditForm', $fields, $actions);
     $form->addExtraClass('cms-edit-form');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
         $form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
     }
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:krissihall,项目名称:sm_ss,代码行数:35,代码来源:CommentAdmin.php

示例4: unsubscribenotification

 /**
  * Uses $this->owner->request (a {@link SS_HTTPRequest} object) to determine which comment we want to unsubscribe
  * the member from. If the current user isn't logged in, or is logged in as a different user, then we send them to
  * the login screen.
  */
 public function unsubscribenotification()
 {
     $request = $this->owner->getRequest();
     $commentID = $request->param('ID');
     $member = Member::currentUser();
     if (!$commentID) {
         $this->owner->httpError(403);
         return;
     }
     $comment = Comment::get()->byID($commentID);
     if (!$comment) {
         $this->owner->httpError(403);
         return;
     }
     if (!$member || $member->ID != $comment->AuthorID) {
         return Security::permissionFailure($this->owner, array('default' => _t('CommentingControllerUserNotificationsExtension.DEFAULTFAIL', 'You must login to unsubscribe.'), 'alreadyLoggedIn' => _t('CommentingControllerUserNotificationsExtension.ALREADYLOGGEDINFAIL', 'You must login as the correct user (the user who submitted the comment) to continue.'), 'logInAgain' => _t('CommentingControllerUserNotificationsExtension.LOGINAGAINFAIL', 'You have been logged out. If you would like to login again, enter your credentials below.')));
     }
     // Currently logged in Member's ID matches the author of the comment, so we can unsubscribe them
     // We want to find all comments posted to this object by this author, and unsubscribe all of them.
     $allComments = Comment::get()->filter(array('BaseClass' => $comment->BaseClass, 'ParentID' => $comment->ParentID, 'NotifyOfUpdates' => true));
     foreach ($allComments as $c) {
         $c->NotifyOfUpdates = false;
         $c->write();
     }
     // This sets a session var that can be queried on the page that we redirect the user back to, so that we can
     // display a nice message to let the user know their unsubscription was successful.
     Session::set('CommentUserNotificationsUnsubscribed', '1');
     $this->owner->redirectBack();
 }
开发者ID:helpfulrobot,项目名称:madmatt-silverstripe-user-comment-notifications,代码行数:34,代码来源:CommentingControllerUserNotificationsExtension.php

示例5: rss

 /**
  * Return an RSS feed of comments for a given set of comments or all 
  * comments on the website.
  *
  * To maintain backwards compatibility with 2.4 this supports mapping
  * of PageComment/rss?pageid= as well as the new RSS format for comments
  * of CommentingController/rss/{classname}/{id}
  *
  * @return RSS
  */
 public function rss()
 {
     $link = $this->Link('rss');
     $class = $this->urlParams['ID'];
     $id = $this->urlParams['OtherID'];
     if (isset($_GET['pageid'])) {
         $id = Convert::raw2sql($_GET['pageid']);
         $comments = Comment::get()->where(sprintf("BaseClass = 'SiteTree' AND ParentID = '%s' AND Moderated = 1 AND IsSpam = 0", $id));
         $link = $this->Link('rss', 'SiteTree', $id);
     } else {
         if ($class && $id) {
             if (Commenting::has_commenting($class)) {
                 $comments = Comment::get()->where(sprintf("BaseClass = '%s' AND ParentID = '%s' AND Moderated = 1 AND IsSpam = 0", Convert::raw2sql($class), Convert::raw2sql($id)));
                 $link = $this->Link('rss', Convert::raw2xml($class), (int) $id);
             } else {
                 return $this->httpError(404);
             }
         } else {
             if ($class) {
                 if (Commenting::has_commenting($class)) {
                     $comments = Comment::get()->where(sprintf("BaseClass = '%s' AND Moderated = 1 AND IsSpam = 0", Convert::raw2sql($class)));
                 } else {
                     return $this->httpError(404);
                 }
             } else {
                 $comments = Comment::get();
             }
         }
     }
     $title = _t('CommentingController.RSSTITLE', "Comments RSS Feed");
     $feed = new RSSFeed($comments, $link, $title, $link, 'Title', 'Comment', 'AuthorName');
     $feed->outputToBrowser();
 }
开发者ID:roed,项目名称:silverstripe-comments,代码行数:43,代码来源:CommentingController.php

示例6: getEditForm

 /**
  * @return Form
  */
 public function getEditForm($id = null, $fields = null)
 {
     if (!$id) {
         $id = $this->currentPageID();
     }
     $form = parent::getEditForm($id);
     $record = $this->getRecord($id);
     if ($record && !$record->canView()) {
         return Security::permissionFailure($this);
     }
     $commentsConfig = GridFieldConfig::create()->addComponents(new GridFieldFilterHeader(), new GridFieldDataColumns(), new GridFieldSortableHeader(), new GridFieldPaginator(25), new GridFieldDeleteAction(), new GridFieldDetailForm(), new GridFieldExportButton(), new GridFieldEditButton(), new GridFieldDetailForm());
     $needs = new GridField('Comments', _t('CommentsAdmin.NeedsModeration', 'Needs Moderation'), Comment::get()->where('Moderated = 0'), $commentsConfig);
     $moderated = new GridField('CommentsModerated', _t('CommentsAdmin.CommentsModerated'), Comment::get()->where('Moderated = 1'), $commentsConfig);
     $fields = new FieldList($root = new TabSet('Root', new Tab('NeedsModeration', _t('CommentAdmin.NeedsModeration', 'Needs Moderation'), $needs), new Tab('Comments', _t('CommentAdmin.Moderated', 'Moderated'), $moderated)));
     $root->setTemplate('CMSTabSet');
     $actions = new FieldList();
     $form = new Form($this, 'EditForm', $fields, $actions);
     $form->addExtraClass('cms-edit-form');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
         $form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
     }
     $this->extend('updateEditForm', $form);
     return $form;
 }
开发者ID:roed,项目名称:silverstripe-comments,代码行数:29,代码来源:CommentAdmin.php

示例7: CommentUserNotificationSubscriptionsFor

 /**
  * This method is overly complex, because {@link Comment} doesn't have a standard 'Parent' has_one, as it can be
  * attached to multiple different object types.
  *
  * @todo Can we fix this method without losing the flexibility that {@link Comment} provides?
  *
  * @see the above CommentUserNotificationSubscriptions() method for documentation
  * @param Member $member The {@link Member} object to find comments posted by, where `NotifyOfUpdates` = 1
  * @return ArrayList The list of {@link ArrayData} objects that can be shown in the template
  */
 public function CommentUserNotificationSubscriptionsFor(Member $member)
 {
     if (!$member || !$member->isInDB()) {
         return null;
     }
     // No member (or no ID yet), so nothing to find
     $allComments = Comment::get()->filter(array('AuthorID' => $member->ID, 'NotifyOfUpdates' => true));
     if (!$allComments) {
         return null;
     }
     $allObjects = new ArrayList();
     $allAddedComments = new ArrayList();
     // @todo O(n^2) :(
     foreach ($allComments as $comment) {
         $alreadyAdded = false;
         foreach ($allAddedComments as $obj) {
             if ($comment->BaseClass == $obj->BaseClass && $comment->ParentID == $obj->ParentID) {
                 $alreadyAdded = true;
                 break;
             }
         }
         if (!$alreadyAdded) {
             $baseClass = $comment->BaseClass;
             $baseObject = $baseClass::get()->byID($comment->ParentID);
             if ($baseObject) {
                 // @todo This could return the actual DataObject that we're expecting (e.g. the SiteTree object),
                 // but we can't add the 'CommentUserNotificationUnsubscribeLink' easily to it
                 $allObjects->push(new ArrayData(array('CommentUserNotificationUnsubscribeLink' => Controller::join_links('CommentingController', 'unsubscribenotification', $comment->ID), 'Title' => $baseObject->Title)));
                 $allAddedComments->push($comment);
                 // Keep track of what we've already added
             }
         }
     }
     return $allObjects;
 }
开发者ID:helpfulrobot,项目名称:madmatt-silverstripe-user-comment-notifications,代码行数:45,代码来源:ControllerCommentUserNotificationsExtension.php

示例8: delete

 public function delete()
 {
     redirect_guest_user(LOGIN_URL);
     $id = Param::get('id');
     $comment = Comment::get($id);
     $auth_user = User::getAuthenticated();
     $page = Param::get('page_next', 'delete');
     if (!$comment->isAuthor($auth_user)) {
         throw new PermissionException();
     }
     if ($comment->isThreadBody()) {
         redirect(DELETE_THREAD_URL, array('id' => $comment->thread_id));
     }
     switch ($page) {
         case 'delete':
             break;
         case 'delete_end':
             $comment->delete();
             redirect(VIEW_THREAD_URL, array('id' => $comment->thread_id));
             break;
         default:
             throw new PageNotFoundException();
             break;
     }
     $title = 'Delete comment';
     $this->set(get_defined_vars());
 }
开发者ID:rdaitan,项目名称:dc-board,代码行数:27,代码来源:comment_controller.php

示例9: findDuplicateByCid

 /**
  * @return Comment
  */
 protected function findDuplicateByCid($cid, $record)
 {
     $page = $this->getPage($record);
     if (!$page) {
         return;
     }
     return Comment::get()->filter(array('DrupalCid' => $cid))->First();
 }
开发者ID:helpfulrobot,项目名称:chillu-drupal-blog-importer,代码行数:11,代码来源:DrupalBlogCommentBulkLoader.php

示例10: getComment

 protected function getComment(SS_HTTPRequest $request)
 {
     $id = $request->param('ID');
     if ($id != (int) $id && $id > 0) {
         return false;
     }
     return Comment::get()->byId($id);
 }
开发者ID:micmania1,项目名称:silverstripe-flagcomments,代码行数:8,代码来源:FlagCommentControllerExtension.php

示例11: Comments

 /**
  * Returns a list of all the comments attached to this record.
  *
  * @return PaginatedList
  */
 public function Comments()
 {
     $order = Commenting::get_config_value($this->ownerBaseClass, 'order_comments_by');
     $list = new PaginatedList(Comment::get()->where(sprintf("ParentID = '%s' AND BaseClass = '%s'", $this->owner->ID, $this->ownerBaseClass))->sort($order));
     $list->setPageLength(Commenting::get_config_value($this->ownerBaseClass, 'comments_per_page'));
     $controller = Controller::curr();
     $list->setPageStart($controller->request->getVar("commentsstart" . $this->owner->ID));
     $list->setPaginationGetVar("commentsstart" . $this->owner->ID);
     $list->MoreThanOnePage();
     return $list;
 }
开发者ID:roed,项目名称:silverstripe-comments,代码行数:16,代码来源:CommentsExtension.php

示例12: CommentLink

 public function CommentLink()
 {
     if (!Permission::check('BLOG_FRONTENDMANAGEMENT') || !class_exists('Comment')) {
         return false;
     }
     $unmoderated = Comment::get()->filter("Moderated", 0)->count();
     if ($unmoderated > 0) {
         return "admin/comments/unmoderated";
     } else {
         return "admin/comments";
     }
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-blog-frontend,代码行数:12,代码来源:BlogManagementWidget.php

示例13: get_comment

 /**
  * Handles GET requests for an individual comment.
  */
 public function get_comment($update = false)
 {
     if (isset($this->handler_vars['id']) && ($comment = Comment::get($this->handler_vars['id']))) {
         $this->theme->comment = $comment;
         // Convenience array to output actions twice
         $actions = array('deleted' => 'delete', 'spam' => 'spam', 'unapproved' => 'unapprove', 'approved' => 'approve', 'saved' => 'save');
         $form = $this->form_comment($comment, $actions);
         if ($update) {
             // Get the $_POSTed values
             $form->process();
             foreach ($actions as $key => $action) {
                 $id_one = $action . '_1';
                 $id_two = $action . '_2';
                 if ($form->{$id_one}->value != null || $form->{$id_two}->value != null) {
                     if ($action == 'delete') {
                         $comment->delete();
                         Utils::redirect(URL::get('display_comments'));
                     }
                     if ($action != 'save') {
                         foreach (Comment::list_comment_statuses() as $status) {
                             if ($status == $key) {
                                 $comment->status = Comment::status_name($status);
                                 $set_status = true;
                             }
                         }
                     }
                 }
             }
             $comment->content = $form->content->value;
             $comment->name = $form->author_name->value;
             $comment->url = $form->author_url->value;
             $comment->email = $form->author_email->value;
             $comment->ip = $form->author_ip->value;
             $comment->date = DateTime::create($form->comment_date->value);
             $comment->post_id = $form->comment_post->value;
             if (!isset($set_status)) {
                 $comment->status = $form->comment_status->value;
             }
             $comment->update();
             Plugins::act('comment_edit', $comment, $form);
             Utils::redirect();
         }
         $comment->content = $form;
         $this->theme->form = $form;
         $this->display('comment');
     } else {
         Utils::redirect(URL::get('display_comments'));
     }
 }
开发者ID:habari,项目名称:system,代码行数:52,代码来源:admincommentshandler.php

示例14: handleAction

 /**
  * {@inheritdoc}
  */
 public function handleAction(GridField $gridField, $actionName, $arguments, $data)
 {
     if ($actionName == 'spam') {
         $comment = Comment::get()->byID($arguments["RecordID"]);
         $comment->markSpam();
         // output a success message to the user
         Controller::curr()->getResponse()->setStatusCode(200, 'Comment marked as spam.');
     }
     if ($actionName == 'approve') {
         $comment = Comment::get()->byID($arguments["RecordID"]);
         $comment->markApproved();
         // output a success message to the user
         Controller::curr()->getResponse()->setStatusCode(200, 'Comment approved.');
     }
 }
开发者ID:krissihall,项目名称:sm_ss,代码行数:18,代码来源:CommentsGridFieldAction.php

示例15: testCommentsForm

 public function testCommentsForm()
 {
     SecurityToken::disable();
     $this->autoFollowRedirection = false;
     $parent = $this->objFromFixture('CommentableItem', 'first');
     // Test posting to base comment
     $response = $this->post('CommentingController/CommentsForm', array('Name' => 'Poster', 'Email' => 'guy@test.com', 'Comment' => 'My Comment', 'ParentID' => $parent->ID, 'BaseClass' => 'CommentableItem', 'action_doPostComment' => 'Post'));
     $this->assertEquals(302, $response->getStatusCode());
     $this->assertStringStartsWith('CommentableItem_Controller#comment-', $response->getHeader('Location'));
     $this->assertDOSEquals(array(array('Name' => 'Poster', 'Email' => 'guy@test.com', 'Comment' => 'My Comment', 'ParentID' => $parent->ID, 'BaseClass' => 'CommentableItem')), Comment::get()->filter('Email', 'guy@test.com'));
     // Test posting to parent comment
     $parentComment = $this->objFromFixture('Comment', 'firstComA');
     $this->assertEquals(0, $parentComment->ChildComments()->count());
     $response = $this->post('CommentingController/reply/' . $parentComment->ID, array('Name' => 'Test Author', 'Email' => 'test@test.com', 'Comment' => 'Making a reply to firstComA', 'ParentID' => $parent->ID, 'BaseClass' => 'CommentableItem', 'ParentCommentID' => $parentComment->ID, 'action_doPostComment' => 'Post'));
     $this->assertEquals(302, $response->getStatusCode());
     $this->assertStringStartsWith('CommentableItem_Controller#comment-', $response->getHeader('Location'));
     $this->assertDOSEquals(array(array('Name' => 'Test Author', 'Email' => 'test@test.com', 'Comment' => 'Making a reply to firstComA', 'ParentID' => $parent->ID, 'BaseClass' => 'CommentableItem', 'ParentCommentID' => $parentComment->ID)), $parentComment->ChildComments());
 }
开发者ID:tcaiger,项目名称:mSupplyNZ,代码行数:18,代码来源:CommentingControllerTest.php


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