Skip to content

Commit 520b321

Browse files
author
helpfulrobot
committed
Converted to PSR-2
1 parent e8bf7a0 commit 520b321

38 files changed

Lines changed: 2085 additions & 1855 deletions
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22

3-
class BootstrapExtraFieldsControllerExtension extends Extension {
4-
5-
public function onAfterInit(){
6-
Requirements::javascript('bootstrap_extra_fields/javascript/tooltip.js');
7-
}
3+
class BootstrapExtraFieldsControllerExtension extends Extension
4+
{
85

6+
public function onAfterInit()
7+
{
8+
Requirements::javascript('bootstrap_extra_fields/javascript/tooltip.js');
9+
}
910
}

code/extensions/BootstrapFormExtension.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
* To change this template file, choose Tools | Templates
66
* and open the template in the editor.
77
*/
8-
class BootstrapFormExtension extends Extension {
8+
class BootstrapFormExtension extends Extension
9+
{
910

10-
public function IsHorizontal(){
11+
public function IsHorizontal()
12+
{
1113
return false;
1214
}
1315
}
14-

code/extensions/BootstrapFormFieldExtension.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
* To change this template file, choose Tools | Templates
66
* and open the template in the editor.
77
*/
8-
class BootstrapFormFieldExtension extends Extension {
8+
class BootstrapFormFieldExtension extends Extension
9+
{
910

10-
public function setPlaceholder($value){
11+
public function setPlaceholder($value)
12+
{
1113
return $this->owner->setAttribute('placeholder', $value);
1214
}
1315

14-
public function IsHorizontal(){
16+
public function IsHorizontal()
17+
{
1518
return $this->owner->form->IsHorizontal();
1619
}
1720
}
18-

code/extensions/ExtendedDatetime.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@
55
* @package framework
66
* @subpackage model
77
*/
8-
class ExtendedDatetime extends DataExtension {
8+
class ExtendedDatetime extends DataExtension
9+
{
910

1011
protected $locale_formats = array(
1112
'en_US' => 'm/d/Y g:i A', //
1213
'de_DE' => 'd.m.Y H:i \U\h\r',
1314
'en_GB' => 'd/m/Y H:i'
1415
);
1516

16-
protected function getFormat(){
17-
if(array_key_exists(i18n::get_locale(), $this->locale_formats)) $locale = i18n::get_locale();
18-
else $locale = 'en_US';
17+
protected function getFormat()
18+
{
19+
if (array_key_exists(i18n::get_locale(), $this->locale_formats)) {
20+
$locale = i18n::get_locale();
21+
} else {
22+
$locale = 'en_US';
23+
}
1924

2025
return $this->locale_formats[$locale];
2126
}
@@ -25,10 +30,10 @@ protected function getFormat(){
2530
*
2631
* @return string
2732
*/
28-
public function NiceLocale(){
29-
30-
if($this->owner->value){
33+
public function NiceLocale()
34+
{
35+
if ($this->owner->value) {
3136
return date($this->getFormat(), strtotime($this->owner->value));
3237
}
3338
}
34-
}
39+
}

code/extensions/ExtendedDecimal.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,27 @@
55
* @package framework
66
* @subpackage model
77
*/
8-
class ExtendedDecimal extends DataExtension {
8+
class ExtendedDecimal extends DataExtension
9+
{
910

1011
/**
1112
* returns the value formatet in the current locales currency format
1213
*
1314
* @return string
1415
*/
15-
public function Currency($symbol = false){
16-
16+
public function Currency($symbol = false)
17+
{
1718
require_once THIRDPARTY_PATH."/Zend/Locale/Format.php";
1819
require_once THIRDPARTY_PATH."/Zend/Currency.php";
1920

20-
if($this->owner->value){
21+
if ($this->owner->value) {
2122
$locale = new Zend_Locale(i18n::get_locale());
2223
$number = Zend_Locale_Format::toNumber($this->owner->value, array('locale' => $locale));
23-
if($symbol){
24+
if ($symbol) {
2425
$symbol = new Zend_Currency($locale);
2526
$number = $symbol->getSymbol()." ".$number;
2627
}
2728
return $number;
2829
}
2930
}
30-
}
31+
}

code/forms/BootstrapAjaxForm.php

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@
6565
* @package bootstrap_extra_fields
6666
* @subpackage forms
6767
*/
68-
class BootstrapAjaxForm extends Form {
68+
class BootstrapAjaxForm extends Form
69+
{
6970

7071

7172

72-
public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null){
73-
73+
public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null)
74+
{
7475
parent::__construct(
7576
$controller,
7677
$name,
@@ -99,46 +100,53 @@ public function __construct($controller, $name, FieldList $fields, FieldList $ac
99100
JS;
100101
Requirements::customScript($js, 'BootstrapAjaxForm_Js_'.$this->FormName());
101102

102-
if(!Director::is_ajax()) $this->setTemplate('BootstrapAjaxForm');
103+
if (!Director::is_ajax()) {
104+
$this->setTemplate('BootstrapAjaxForm');
105+
}
103106
}
104107

105-
/**
106-
* Return a rendered version of this form, suitable for ajax post-back.
107-
* It triggers slightly different behaviour, such as disabling the rewriting of # links
108-
*/
109-
public function forAjaxTemplate() {
110-
$view = new SSViewer(array(
111-
$this->getTemplate(),
112-
'Form'
113-
));
108+
/**
109+
* Return a rendered version of this form, suitable for ajax post-back.
110+
* It triggers slightly different behaviour, such as disabling the rewriting of # links
111+
*/
112+
public function forAjaxTemplate()
113+
{
114+
$view = new SSViewer(array(
115+
$this->getTemplate(),
116+
'Form'
117+
));
114118

115119
$return = $view->dontRewriteHashlinks()->process($this);
116120

117121
// Now that we're rendered, clear message
118-
$this->clearMessage();
122+
$this->clearMessage();
119123

120-
return $return;
121-
}
124+
return $return;
125+
}
122126

123-
public function AjaxReturn($request){
124-
if(!Director::is_ajax()){
127+
public function AjaxReturn($request)
128+
{
129+
if (!Director::is_ajax()) {
125130
return $this;
126-
}else{
127-
if($this->examineFormAction($request)) return $this;
128-
else return $this->forAjaxTemplate();
131+
} else {
132+
if ($this->examineFormAction($request)) {
133+
return $this;
134+
} else {
135+
return $this->forAjaxTemplate();
136+
}
129137
}
130138
}
131139

132-
protected function examineFormAction($request){
140+
protected function examineFormAction($request)
141+
{
133142
// Determine the action button clicked
134143
$actionSet = false;
135-
foreach($request->requestVars() as $paramName => $paramVal){
136-
if(substr($paramName,0,7) == 'action_'){
144+
foreach ($request->requestVars() as $paramName => $paramVal) {
145+
if (substr($paramName, 0, 7) == 'action_') {
137146
$actionSet = true;
138147
break;
139-
}
140-
}
148+
}
149+
}
141150
return $actionSet;
142151
}
143-
144152
}

code/forms/BootstrapAjaxModalForm.php

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,13 @@
7575
* @package bootstrap_extra_fields
7676
* @subpackage forms
7777
*/
78-
class BootstrapAjaxModalForm extends BootstrapModalForm {
78+
class BootstrapAjaxModalForm extends BootstrapModalForm
79+
{
7980

8081

8182

82-
public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction){
83-
83+
public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction)
84+
{
8485
parent::__construct(
8586
$controller,
8687
$name,
@@ -121,46 +122,53 @@ public function __construct($controller, $name, FieldList $fields, FieldList $ac
121122
JS;
122123
Requirements::customScript($js, 'BootstrapAjaxModalForm_Js_'.$this->FormName());
123124

124-
if(Director::is_ajax()) $this->setTemplate('BootstrapAjaxModalForm');
125+
if (Director::is_ajax()) {
126+
$this->setTemplate('BootstrapAjaxModalForm');
127+
}
125128
}
126129

127-
/**
128-
* Return a rendered version of this form, suitable for ajax post-back.
129-
* It triggers slightly different behaviour, such as disabling the rewriting of # links
130-
*/
131-
public function forAjaxTemplate() {
132-
$view = new SSViewer(array(
133-
$this->getTemplate(),
134-
'Form'
135-
));
130+
/**
131+
* Return a rendered version of this form, suitable for ajax post-back.
132+
* It triggers slightly different behaviour, such as disabling the rewriting of # links
133+
*/
134+
public function forAjaxTemplate()
135+
{
136+
$view = new SSViewer(array(
137+
$this->getTemplate(),
138+
'Form'
139+
));
136140

137-
$return = $view->dontRewriteHashlinks()->process($this);
141+
$return = $view->dontRewriteHashlinks()->process($this);
138142

139143
// Now that we're rendered, clear message
140-
$this->clearMessage();
144+
$this->clearMessage();
141145

142-
return $return;
143-
}
146+
return $return;
147+
}
144148

145-
public function AjaxReturn($request){
146-
if(!Director::is_ajax()){
149+
public function AjaxReturn($request)
150+
{
151+
if (!Director::is_ajax()) {
147152
return $this;
148-
}else{
149-
if($this->examineFormAction($request)) return $this;
150-
else return $this->forAjaxTemplate();
153+
} else {
154+
if ($this->examineFormAction($request)) {
155+
return $this;
156+
} else {
157+
return $this->forAjaxTemplate();
158+
}
151159
}
152160
}
153161

154-
protected function examineFormAction($request){
162+
protected function examineFormAction($request)
163+
{
155164
// Determine the action button clicked
156165
$actionSet = false;
157-
foreach($request->requestVars() as $paramName => $paramVal){
158-
if(substr($paramName,0,7) == 'action_'){
166+
foreach ($request->requestVars() as $paramName => $paramVal) {
167+
if (substr($paramName, 0, 7) == 'action_') {
159168
$actionSet = true;
160169
break;
161-
}
170+
}
162171
}
163172
return $actionSet;
164173
}
165-
166174
}

code/forms/BootstrapButtonCheckboxField.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,22 @@
1818
* @package bootstrap_extra_fields
1919
* @subpackage forms
2020
*/
21-
class BootstrapButtonCheckboxField extends CheckboxField {
21+
class BootstrapButtonCheckboxField extends CheckboxField
22+
{
2223

2324

2425

25-
/**
26-
* Creates a new field.
27-
*
28-
* @param string $name The internal field name, passed to forms.
29-
* @param string $title The human-readable field label.
30-
* @param mixed $value The value of the field.
31-
*/
32-
public function __construct($name, $title = null, $value = null) {
33-
parent::__construct($name, $title, $value);
26+
/**
27+
* Creates a new field.
28+
*
29+
* @param string $name The internal field name, passed to forms.
30+
* @param string $title The human-readable field label.
31+
* @param mixed $value The value of the field.
32+
*/
33+
public function __construct($name, $title = null, $value = null)
34+
{
35+
parent::__construct($name, $title, $value);
3436

35-
$this->setFieldHolderTemplate('FormField_holder');
36-
}
37+
$this->setFieldHolderTemplate('FormField_holder');
38+
}
3739
}

0 commit comments

Comments
 (0)