[spalenque] - #7812 *WIP

This commit is contained in:
santipalenque 2014-12-03 13:39:24 -03:00 committed by Sebastian Marcet
parent 42f2681f9f
commit a541409705
10 changed files with 40 additions and 41 deletions

View File

@ -92,6 +92,7 @@ final class EventRegistrationRequestPage_Controller extends Page_Controller {
if(class_exists('SpamProtectorManager')) { if(class_exists('SpamProtectorManager')) {
SpamProtectorManager::update_form($form); SpamProtectorManager::update_form($form);
} }
return $form; return $form;
} }
@ -106,6 +107,7 @@ final class EventRegistrationRequestPage_Controller extends Page_Controller {
try{ try{
$this->event_registration_request_manager->registerEventRegistrationRequest($data); $this->event_registration_request_manager->registerEventRegistrationRequest($data);
Session::clear("FormInfo.Form_EventRegistrationRequestForm.data"); Session::clear("FormInfo.Form_EventRegistrationRequestForm.data");
$form->clearMessage();
return $this->redirect($this->Link('?saved=1')); return $this->redirect($this->Link('?saved=1'));
} }
catch(EntityValidationException $ex1){ catch(EntityValidationException $ex1){

View File

@ -1,4 +1,5 @@
<? <?php
/** /**
* Copyright 2014 Openstack Foundation * Copyright 2014 Openstack Foundation
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -13,34 +13,27 @@
**/ **/
class FeedbackForm extends Form { class FeedbackForm extends Form {
function __construct($controller, $name) {
$FeedbackField = new TextAreaField('Content', 'My Feedback About This Page'); function __construct($controller, $name) {
$FeedbackField = new TextareaField('Content', 'My Feedback About This Page');
$fields = new FieldList( $fields = new FieldList(
$FeedbackField $FeedbackField
); );
$tellUsButton = new FormAction('submitFeedback', 'Tell Us'); $tellUsButton = new FormAction('submitFeedback', 'Tell Us');
$tellUsButton->addExtraClass('button'); $tellUsButton->addExtraClass('button');
$actions = new FieldList( $actions = new FieldList(
$tellUsButton $tellUsButton
); );
parent::__construct($controller, $name, $fields, $actions); parent::__construct($controller, $name, $fields, $actions);
} }
function forTemplate() { function submitFeedback(array $data, Form $form) {
return $this->renderWith(array(
$this->class,
'Form'
));
}
function submitFeedback($data, $form) {
// TRUE if the submission contains a link. Crude spam mitigation. // TRUE if the submission contains a link. Crude spam mitigation.
$ContainsLink = strpos($data['Content'], "http://") !== false; $ContainsLink = strpos($data['Content'], "http://") !== false;
@ -52,6 +45,7 @@ class FeedbackForm extends Form {
// Tie the URL of the current page to the feedback submission // Tie the URL of the current page to the feedback submission
$page = Director::get_current_page(); $page = Director::get_current_page();
$FeedbackSubmission->Page = $page->Link(); $FeedbackSubmission->Page = $page->Link();
//$FeedbackSubmission->write();
//Send email alert about submission //Send email alert about submission
$Subject = "New Website Feedback Submission"; $Subject = "New Website Feedback Submission";
@ -63,7 +57,7 @@ class FeedbackForm extends Form {
// Redirect back to the page with a success message // Redirect back to the page with a success message
$form->controller->setMessage('Success', 'Thanks for providing feedback to improve the OpenStack website!'); $form->controller->setMessage('Success', 'Thanks for providing feedback to improve the OpenStack website!');
$form->controller->redirectBack(); $form->controller->redirectBack();
} else { } else {
$form->controller->setMessage('Error', "Oops! It doesn't look like you provided any feedback. Please check the form and try again."); $form->controller->setMessage('Error', "Oops! It doesn't look like you provided any feedback. Please check the form and try again.");
@ -71,4 +65,11 @@ class FeedbackForm extends Form {
} }
} }
function forTemplate() {
return $this->renderWith(array(
$this->class,
'Form'
));
}
} }

View File

@ -122,7 +122,7 @@ class HomePage_Controller extends Page_Controller {
$item->pubDate = date("D, M jS Y", strtotime($item->pubDate)); $item->pubDate = date("D, M jS Y", strtotime($item->pubDate));
} }
return $result->limit(0,$limit); return $result->limit($limit,0);
} }
function PastEvents($num=1) { function PastEvents($num=1) {

View File

@ -202,7 +202,7 @@ class Page_Controller extends ContentController {
*/ */
private static $allowed_actions = array ( private static $allowed_actions = array (
'logout', 'logout',
'FeedbackForm' 'FeedbackForm',
); );
@ -326,7 +326,7 @@ class Page_Controller extends ContentController {
)); ));
} }
public function getMessage() { public function getMessage() {
if($message = Session::get('Message')){ if($message = Session::get('Message')){
Session::clear('Message'); Session::clear('Message');
$array = new ArrayData($message); $array = new ArrayData($message);

View File

@ -5,7 +5,6 @@ label.error, .recaptcha .message.validation
color: #fff; color: #fff;
padding: 5px; padding: 5px;
margin: 0; margin: 0;
width: 100%;
-webkit-border-radius: 05px; -webkit-border-radius: 05px;
-moz-border-radius: 05px; -moz-border-radius: 05px;
border-radius: 05px; border-radius: 05px;

View File

@ -120,8 +120,8 @@ jQuery(document).ready(function($) {
GenderField.on('change',function(){ GenderField.on('change',function(){
var value = $(this).val(); var value = $(this).val();
if(value == 'Specify'){ if(value == 'Specify'){
$('#GenderSpecify').fadeIn(); $('#GenderSpecify').removeClass('hide').fadeIn();
GenderSpecify.fadeIn(); GenderSpecify.removeClass('hide').fadeIn();
} else { } else {
$('#GenderSpecify').fadeOut(); $('#GenderSpecify').fadeOut();
GenderSpecify.fadeOut(); GenderSpecify.fadeOut();

View File

@ -113,8 +113,8 @@ jQuery(document).ready(function($) {
GenderField.on('change',function(){ GenderField.on('change',function(){
var value = $(this).val(); var value = $(this).val();
if(value == 'Specify'){ if(value == 'Specify'){
$('#GenderSpecify').fadeIn(); $('#GenderSpecify').removeClass('hide').fadeIn();
GenderSpecify.fadeIn(); GenderSpecify.removeClass('hide').fadeIn();
} else { } else {
$('#GenderSpecify').fadeOut(); $('#GenderSpecify').fadeOut();
GenderSpecify.fadeOut(); GenderSpecify.fadeOut();

View File

@ -1,9 +1,11 @@
<form class="form-inline" $FormAttributes> <form class="form-inline" $FormAttributes>
<div class="form-group"> <div class="form-group">
<div> <div>
<input class="feedback-input" type="input" placeholder="Give Us Your Feedback On This Page" id="FeedbackForm_FeedbackForm_Content" name="Content"> <fieldset style="border:none;margin:0;padding:0;">
$dataFieldByName(SecurityID) <input class="feedback-input" type="input" placeholder="Give Us Your Feedback On This Page" id="FeedbackForm_FeedbackForm_Content" name="Content">
<button type="submit" class="feedback-btn" id="FeedbackForm_FeedbackForm_action_submitFeedback" type="submit" name="action_submitFeedback">Submit</button> $Fields.dataFieldByName(SecurityID)
<button type="submit" class="feedback-btn" id="FeedbackForm_FeedbackForm_action_submitFeedback" name="action_submitFeedback">Submit</button>
</fieldset>
</div>
</div> </div>
</div> </form>
</form>

View File

@ -50,14 +50,8 @@
<% include Navigation %> <% include Navigation %>
<!-- Page Content --> <!-- Page Content -->
<% if BootstrapConverted %> $Message
$Message $Layout
$Layout
<% else %>
<div class="container">
$Layout
</div>
<% end_if %>
<% include Footer %> <% include Footer %>