本文整理汇总了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');
}
示例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();