Completed
Branch 3.1 (d6060c)
by Gordon
04:27
created
code/ContactPage.php 2 patches
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 		} else {
40 40
 			$map = $this->owner->RenderMap();
41 41
 			// $map->setDelayLoadMapFunction( true );
42
-			$map->setZoom( 10 );
43
-			$map->setAdditionalCSSClasses( 'fullWidthMap' );
44
-			$map->setShowInlineMapDivStyle( true );
42
+			$map->setZoom(10);
43
+			$map->setAdditionalCSSClasses('fullWidthMap');
44
+			$map->setShowInlineMapDivStyle(true);
45 45
 			$map->setClusterer(false);
46 46
 			//$map->addKML('http://assets.tripodtravel.co.nz/cycling/meuang-nont-to-bang-sue-loop.kml');
47 47
 			return $map;
@@ -58,25 +58,25 @@  discard block
 block discarded – undo
58 58
 
59 59
 		$fields->addFieldToTab('Root.Main', new CheckboxField('ShowOnMap', 'Tick this box to show a map'));
60 60
 
61
-		$fields->addFieldToTab( "Root.OnSubmission",
62
-			new TextField( 'Mailto', _t( 'ContactPage.EMAIL_SUBMISSIONS_TO', 'Email submissions to' )
63
-			) );
61
+		$fields->addFieldToTab("Root.OnSubmission",
62
+			new TextField('Mailto', _t('ContactPage.EMAIL_SUBMISSIONS_TO', 'Email submissions to')
63
+			));
64 64
 
65
-		$fields->addFieldToTab( "Root.OnSubmission",
66
-			new HTMLEditorField( 'SubmitText', _t( 'ContactPage.TEXT_SHOWN_AFTER_SUBMISSION', 'Text on Submission' ) ) );
65
+		$fields->addFieldToTab("Root.OnSubmission",
66
+			new HTMLEditorField('SubmitText', _t('ContactPage.TEXT_SHOWN_AFTER_SUBMISSION', 'Text on Submission')));
67 67
 
68
-		$fields->addFieldToTab( $addresstabname, new TextAreaField( 'ContactAddress', _t( 'ContactPage.ADDRESS', 'Address' ) ) );
69
-		$fields->addFieldToTab( $addresstabname, new TextField( 'ContactTelephoneNumber',
70
-				_t( 'ContactPage.CONTACT_TELEPHONE_NUMBER', 'Contact Tel. Number' ) ) );
71
-		$fields->addFieldToTab( $addresstabname, new TextField( 'ContactFaxNumber',
72
-				_t( 'ContactPage.CONTACT_FAX_NUMBER', 'Contact Fax Number' ) ) );
73
-		$fields->addFieldToTab( $addresstabname, new TextField( 'ContactEmailAddress',
74
-				_t( 'ContactPage.CONTACT_EMAIL_ADDRESS_ADMIN', '(TH) Contact Email Address' ) ) );
68
+		$fields->addFieldToTab($addresstabname, new TextAreaField('ContactAddress', _t('ContactPage.ADDRESS', 'Address')));
69
+		$fields->addFieldToTab($addresstabname, new TextField('ContactTelephoneNumber',
70
+				_t('ContactPage.CONTACT_TELEPHONE_NUMBER', 'Contact Tel. Number')));
71
+		$fields->addFieldToTab($addresstabname, new TextField('ContactFaxNumber',
72
+				_t('ContactPage.CONTACT_FAX_NUMBER', 'Contact Fax Number')));
73
+		$fields->addFieldToTab($addresstabname, new TextField('ContactEmailAddress',
74
+				_t('ContactPage.CONTACT_EMAIL_ADDRESS_ADMIN', '(TH) Contact Email Address')));
75 75
 
76
-		$fields->addFieldToTab( $socialmediatabname, new TextField( 'Facebook',
77
-				_t( 'ContactPage.FACEBOOK_URL', 'Facebook URL' ) ) );
78
-		$fields->addFieldToTab( $socialmediatabname, new TextField( 'Twitter',
79
-				_t( 'ContactPage.TWITTER_USERNAME', 'Twitter Username' ) ) );
76
+		$fields->addFieldToTab($socialmediatabname, new TextField('Facebook',
77
+				_t('ContactPage.FACEBOOK_URL', 'Facebook URL')));
78
+		$fields->addFieldToTab($socialmediatabname, new TextField('Twitter',
79
+				_t('ContactPage.TWITTER_USERNAME', 'Twitter Username')));
80 80
 
81 81
 		$this->extend('updateContactPageForm', $fields);
82 82
 
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 
108 108
 	function init() {
109 109
 		//add a javascript library for easy interaction with the server
110
-		Requirements::javascript( 'mysite/javascript/jQuery.js' );
111
-		if ( Director::is_ajax() ) {
110
+		Requirements::javascript('mysite/javascript/jQuery.js');
111
+		if (Director::is_ajax()) {
112 112
 			$this->isAjax = true;
113 113
 		}
114 114
 		else {
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 
120 120
 
121 121
 	function index() {
122
-		error_log( "Contact page index" );
123
-		error_log( "AJAX? ".$this->isAjax );
122
+		error_log("Contact page index");
123
+		error_log("AJAX? ".$this->isAjax);
124 124
 
125
-		if ( $this->isAjax ) {
126
-			return $this->renderWith( "ContactPageModal" );
125
+		if ($this->isAjax) {
126
+			return $this->renderWith("ContactPageModal");
127 127
 		}
128 128
 		else {
129 129
 			return array();
@@ -134,21 +134,21 @@  discard block
 block discarded – undo
134 134
 
135 135
 	//The function which generates our form
136 136
 	function ContactForm() {
137
-		error_log( "Render form" );
138
-		$name = _t( 'ContactPage.NAME', 'Name' );
139
-		$email = _t( 'ContactPage.EMAIL', 'Email' );
140
-		$comments = _t( 'ContactPage.COMMENTS', 'Comments' );
141
-		$send = _t( 'ContactPage.SEND', 'Send' );
137
+		error_log("Render form");
138
+		$name = _t('ContactPage.NAME', 'Name');
139
+		$email = _t('ContactPage.EMAIL', 'Email');
140
+		$comments = _t('ContactPage.COMMENTS', 'Comments');
141
+		$send = _t('ContactPage.SEND', 'Send');
142 142
 
143 143
 		// Create fields
144
-		$tf = new TextField( 'Name', $name );
145
-		$tf->addExtraClass( 'span11' );
144
+		$tf = new TextField('Name', $name);
145
+		$tf->addExtraClass('span11');
146 146
 
147
-		$ef = new EmailField( 'Email', $email );
148
-		$ef->addExtraClass( 'span11' );
147
+		$ef = new EmailField('Email', $email);
148
+		$ef->addExtraClass('span11');
149 149
 
150
-		$taf = new TextareaField( 'Comments', $comments );
151
-		$taf->addExtraClass( 'span11' );
150
+		$taf = new TextareaField('Comments', $comments);
151
+		$taf->addExtraClass('span11');
152 152
 
153 153
 		$fields = new FieldList(
154 154
 			$tf,
@@ -157,24 +157,24 @@  discard block
 block discarded – undo
157 157
 		);
158 158
 
159 159
 		// Create action
160
-		$fa = new FormAction( 'SendContactForm', $send );
160
+		$fa = new FormAction('SendContactForm', $send);
161 161
 
162 162
 		// for bootstrap
163 163
 		$fa->useButtonTag = true;
164
-		$fa->addExtraClass( 'btn btn-primary buttonright' );
164
+		$fa->addExtraClass('btn btn-primary buttonright');
165 165
 
166 166
 		$actions = new FieldList(
167 167
 			$fa
168 168
 		);
169 169
 
170 170
 		// Create action
171
-		$validator = new RequiredFields( 'Name', 'Email', 'Comments' );
171
+		$validator = new RequiredFields('Name', 'Email', 'Comments');
172 172
 
173
-		$form = new Form( $this, 'ContactForm', $fields, $actions, $validator );
174
-		$form->setTemplate( 'VerticalForm' );
175
-		$form->addExtraClass( 'well' );
173
+		$form = new Form($this, 'ContactForm', $fields, $actions, $validator);
174
+		$form->setTemplate('VerticalForm');
175
+		$form->addExtraClass('well');
176 176
 
177
-		if(class_exists('SpamProtectorManager')) {
177
+		if (class_exists('SpamProtectorManager')) {
178 178
 			$form->enableSpamProtection();
179 179
 		}
180 180
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
 
185 185
 	//The function that handles our form submission
186
-	function SendContactForm( $data, $form ) {
186
+	function SendContactForm($data, $form) {
187 187
 		// saving data before sending contact form
188 188
 		$cpm = new ContactPageMessage();
189 189
 		$cpm->Email = $data['Email'];
@@ -198,35 +198,35 @@  discard block
 block discarded – undo
198 198
 		$To = $this->Mailto;
199 199
 		$Subject = $this->SiteConfig()->Title.' - ';
200 200
 		$Subject .= "Website Contact message";
201
-		$email = new Email( $From, $To, $Subject );
201
+		$email = new Email($From, $To, $Subject);
202 202
 		//set template
203
-		$email->setTemplate( 'ContactEmail' );
203
+		$email->setTemplate('ContactEmail');
204 204
 		//populate template
205
-		$email->populateTemplate( $data );
205
+		$email->populateTemplate($data);
206 206
 		//send mail
207 207
 		$email->send();
208 208
 
209
-		if ( $this->isAjax ) {
209
+		if ($this->isAjax) {
210 210
 			$result = array();
211 211
 			$result['message'] = $this->SubmitText;
212 212
 			$result['success'] = 1;
213
-			echo json_encode( $result );
213
+			echo json_encode($result);
214 214
 			die;
215 215
 		}
216 216
 		else {
217
-			Controller::redirect( Director::baseURL(). $this->URLSegment . "/?success=1" );
217
+			Controller::redirect(Director::baseURL().$this->URLSegment."/?success=1");
218 218
 		}
219 219
 	}
220 220
 
221 221
 
222 222
 	//The function to test whether to display the Submit Text or not
223 223
 	public function Success() {
224
-		return isset( $_REQUEST['success'] ) && $_REQUEST['success'] == "1";
224
+		return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";
225 225
 	}
226 226
 
227 227
 
228 228
 	public function HasGeo() {
229
-		return (($this->Latitude !=0) && ($this->Longitude != 0));
229
+		return (($this->Latitude != 0) && ($this->Longitude != 0));
230 230
 	}
231 231
 
232 232
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -110,8 +110,7 @@  discard block
 block discarded – undo
110 110
 		Requirements::javascript( 'mysite/javascript/jQuery.js' );
111 111
 		if ( Director::is_ajax() ) {
112 112
 			$this->isAjax = true;
113
-		}
114
-		else {
113
+		} else {
115 114
 			$this->isAjax = false;
116 115
 		}
117 116
 		parent::init();
@@ -124,8 +123,7 @@  discard block
 block discarded – undo
124 123
 
125 124
 		if ( $this->isAjax ) {
126 125
 			return $this->renderWith( "ContactPageModal" );
127
-		}
128
-		else {
126
+		} else {
129 127
 			return array();
130 128
 		}
131 129
 
@@ -212,8 +210,7 @@  discard block
 block discarded – undo
212 210
 			$result['success'] = 1;
213 211
 			echo json_encode( $result );
214 212
 			die;
215
-		}
216
-		else {
213
+		} else {
217 214
 			Controller::redirect( Director::baseURL(). $this->URLSegment . "/?success=1" );
218 215
 		}
219 216
 	}
Please login to merge, or discard this patch.