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


PHP Feedback::get方法代码示例

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


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

示例1: form_appears_and_saves

 /**
  * @test
  */
 public function form_appears_and_saves()
 {
     Config::inst()->update('Controller', 'extensions', array('QuickFeedbackExtension'));
     $controller = new TestController();
     $result = $controller->handleRequest(new SS_HTTPRequest('GET', 'form_appears_and_saves'), DataModel::inst());
     $body = $result->getBody();
     $this->assertContains('Form_QuickFeedbackForm', $body);
     $this->assertContains('Form_QuickFeedbackForm_Rating', $body);
     $this->assertContains('Form_QuickFeedbackForm_Comment', $body);
     preg_match('/action="([^"]+)"/', $body, $action);
     if (!count($action)) {
         $this->fail('No form action');
     }
     preg_match('/name="SecurityID" value="([^"]+)"/', $body, $token);
     if (!count($action)) {
         $this->fail('No token');
     }
     $parts = explode('/', $action[1]);
     $action = end($parts);
     $time = time();
     $data = ['SecurityID' => $token[1], 'Rating' => '0', 'Comment' => 'comment at ' . $time];
     $controller->handleRequest(new SS_HTTPRequest('POST', $action, array(), $data), DataModel::inst());
     $existing = Feedback::get()->filter('Comment', 'comment at ' . $time)->first();
     if (!$existing) {
         $this->fail('Record missing');
     }
 }
开发者ID:helpfulrobot,项目名称:mandrew-silverstripe-quickfeedback,代码行数:30,代码来源:QuickFeedbackExtensionTest.php

示例2: doSubmit

 /**
  * @param array $data
  * @param Form $form
  *
  * @return mixed
  */
 public function doSubmit($data, $form)
 {
     $controller = Controller::curr();
     $redirect = Director::baseURL() . $this->owner->URLSegment;
     if ((bool) Config::inst()->get('QuickFeedbackExtension', 'redirect_field') && isset($data['Redirect']) && Director::is_site_url($data['Redirect'])) {
         $redirect = Director::absoluteURL($data['Redirect'], true);
     }
     if (!$controller) {
         goto error;
     }
     $request = $controller->getRequest();
     if (!$request) {
         goto error;
     }
     $limit = (int) Config::inst()->get('QuickFeedbackExtension', 'rate_limit');
     $existing = Feedback::get()->filter('IP', $request->getIP())->sort('Created desc')->first();
     if ($existing) {
         $created = $existing->dbObject('Created');
         if (!$created) {
             goto error;
         }
         $seconds = abs(time() - strtotime($created->getValue()));
         $minutes = round($seconds / 60);
         if ($minutes <= $limit) {
             goto rate;
         }
     }
     $feedback = Feedback::create();
     $feedback->Rating = $data['Rating'];
     $feedback->Comment = $data['Comment'];
     $feedback->IP = $request->getIP();
     if (!empty($this->owner->ID)) {
         $feedback->PageID = $this->owner->ID;
     }
     if (!empty($this->owner->URLSegment)) {
         $feedback->URL = $this->owner->RelativeLink();
     }
     if ((bool) Config::inst()->get('QuickFeedbackExtension', 'redirect_field') && isset($data['Redirect'])) {
         $feedback->URL = $data['Redirect'];
     }
     $feedback->write();
     $form->sessionMessage(_t('QuickFeedback.ThanksMessage', 'Thanks for your comment!'), 'good');
     return $this->owner->redirect($redirect . '?success=1');
     error:
     $form->sessionMessage(_t('QuickFeedback.ErrorMessage', 'An error occurred!'), 'error');
     return $this->owner->redirect($redirect . '?error=1');
     rate:
     $form->sessionMessage(_t('QuickFeedback.RateMessage', 'Please wait a while before submitting!'), 'error');
     return $this->owner->redirect($redirect . '?rate=1');
 }
开发者ID:assertchris,项目名称:silverstripe-quickfeedback,代码行数:56,代码来源:QuickFeedbackExtension.php

示例3: YuiDatatable

     $dt = new YuiDatatable();
     $dt->addColumn('id', '#', 'link', 'a/feedback/handle/', 'subject');
     $dt->addColumn('time_created', 'Created');
     $dt->addColumn('from', 'From', 'link', 'u/profile/');
     $dt->setDataSource($list);
     echo $dt->render();
     break;
 case 'handle':
     // child = tblFeedback.id
     function fbHandle($p)
     {
         $msg_id = Message::send($p['to'], $p['msg']);
         Feedback::markHandled($p['owner'], $msg_id);
         js_redirect('a/feedback/default');
     }
     $fb = Feedback::get($this->child);
     if (!$fb) {
         die('Eppp');
     }
     if ($fb->type == USER) {
         $from = User::get($fb->from);
         echo '<h2>User feedback from ' . $fb->name . '</h2>';
     }
     echo 'Subject: ' . $fb->subject . '<br/>';
     if ($fb->body) {
         echo 'Message: ' . nl2br($fb->body);
     }
     echo '<br/>';
     if ($fb->type == USER) {
         $msg = "In response to your feedback:\n\n" . $fb->body;
         $frm = new XhtmlForm();
开发者ID:martinlindhe,项目名称:core_dev,代码行数:31,代码来源:feedback.php


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