diff --git a/code/extensions/BootstrapExtraFieldsControllerExtension.php b/code/extensions/BootstrapExtraFieldsControllerExtension.php
index 8aadfc5..9986dba 100644
--- a/code/extensions/BootstrapExtraFieldsControllerExtension.php
+++ b/code/extensions/BootstrapExtraFieldsControllerExtension.php
@@ -1,9 +1,10 @@
owner->setAttribute('placeholder', $value);
}
- public function IsHorizontal(){
+ public function IsHorizontal()
+ {
return $this->owner->form->IsHorizontal();
}
}
-
diff --git a/code/extensions/ExtendedDatetime.php b/code/extensions/ExtendedDatetime.php
index 8bc81c8..692931c 100644
--- a/code/extensions/ExtendedDatetime.php
+++ b/code/extensions/ExtendedDatetime.php
@@ -5,7 +5,8 @@
* @package framework
* @subpackage model
*/
-class ExtendedDatetime extends DataExtension {
+class ExtendedDatetime extends DataExtension
+{
protected $locale_formats = array(
'en_US' => 'm/d/Y g:i A', //
@@ -13,9 +14,13 @@ class ExtendedDatetime extends DataExtension {
'en_GB' => 'd/m/Y H:i'
);
- protected function getFormat(){
- if(array_key_exists(i18n::get_locale(), $this->locale_formats)) $locale = i18n::get_locale();
- else $locale = 'en_US';
+ protected function getFormat()
+ {
+ if (array_key_exists(i18n::get_locale(), $this->locale_formats)) {
+ $locale = i18n::get_locale();
+ } else {
+ $locale = 'en_US';
+ }
return $this->locale_formats[$locale];
}
@@ -25,10 +30,10 @@ protected function getFormat(){
*
* @return string
*/
- public function NiceLocale(){
-
- if($this->owner->value){
+ public function NiceLocale()
+ {
+ if ($this->owner->value) {
return date($this->getFormat(), strtotime($this->owner->value));
}
}
-}
\ No newline at end of file
+}
diff --git a/code/extensions/ExtendedDecimal.php b/code/extensions/ExtendedDecimal.php
index e3fe518..eb03aa7 100644
--- a/code/extensions/ExtendedDecimal.php
+++ b/code/extensions/ExtendedDecimal.php
@@ -5,26 +5,27 @@
* @package framework
* @subpackage model
*/
-class ExtendedDecimal extends DataExtension {
+class ExtendedDecimal extends DataExtension
+{
/**
* returns the value formatet in the current locales currency format
*
* @return string
*/
- public function Currency($symbol = false){
-
+ public function Currency($symbol = false)
+ {
require_once THIRDPARTY_PATH."/Zend/Locale/Format.php";
require_once THIRDPARTY_PATH."/Zend/Currency.php";
- if($this->owner->value){
+ if ($this->owner->value) {
$locale = new Zend_Locale(i18n::get_locale());
$number = Zend_Locale_Format::toNumber($this->owner->value, array('locale' => $locale));
- if($symbol){
+ if ($symbol) {
$symbol = new Zend_Currency($locale);
$number = $symbol->getSymbol()." ".$number;
}
return $number;
}
}
-}
\ No newline at end of file
+}
diff --git a/code/forms/BootstrapAjaxForm.php b/code/forms/BootstrapAjaxForm.php
index 2607578..4fc5aec 100644
--- a/code/forms/BootstrapAjaxForm.php
+++ b/code/forms/BootstrapAjaxForm.php
@@ -65,12 +65,13 @@
* @package bootstrap_extra_fields
* @subpackage forms
*/
-class BootstrapAjaxForm extends Form {
+class BootstrapAjaxForm extends Form
+{
- public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null){
-
+ public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null)
+ {
parent::__construct(
$controller,
$name,
@@ -99,46 +100,53 @@ public function __construct($controller, $name, FieldList $fields, FieldList $ac
JS;
Requirements::customScript($js, 'BootstrapAjaxForm_Js_'.$this->FormName());
- if(!Director::is_ajax()) $this->setTemplate('BootstrapAjaxForm');
+ if (!Director::is_ajax()) {
+ $this->setTemplate('BootstrapAjaxForm');
+ }
}
- /**
- * Return a rendered version of this form, suitable for ajax post-back.
- * It triggers slightly different behaviour, such as disabling the rewriting of # links
- */
- public function forAjaxTemplate() {
- $view = new SSViewer(array(
- $this->getTemplate(),
- 'Form'
- ));
+ /**
+ * Return a rendered version of this form, suitable for ajax post-back.
+ * It triggers slightly different behaviour, such as disabling the rewriting of # links
+ */
+ public function forAjaxTemplate()
+ {
+ $view = new SSViewer(array(
+ $this->getTemplate(),
+ 'Form'
+ ));
$return = $view->dontRewriteHashlinks()->process($this);
// Now that we're rendered, clear message
- $this->clearMessage();
+ $this->clearMessage();
- return $return;
- }
+ return $return;
+ }
- public function AjaxReturn($request){
- if(!Director::is_ajax()){
+ public function AjaxReturn($request)
+ {
+ if (!Director::is_ajax()) {
return $this;
- }else{
- if($this->examineFormAction($request)) return $this;
- else return $this->forAjaxTemplate();
+ } else {
+ if ($this->examineFormAction($request)) {
+ return $this;
+ } else {
+ return $this->forAjaxTemplate();
+ }
}
}
- protected function examineFormAction($request){
+ protected function examineFormAction($request)
+ {
// Determine the action button clicked
$actionSet = false;
- foreach($request->requestVars() as $paramName => $paramVal){
- if(substr($paramName,0,7) == 'action_'){
+ foreach ($request->requestVars() as $paramName => $paramVal) {
+ if (substr($paramName, 0, 7) == 'action_') {
$actionSet = true;
break;
- }
- }
+ }
+ }
return $actionSet;
}
-
}
diff --git a/code/forms/BootstrapAjaxModalForm.php b/code/forms/BootstrapAjaxModalForm.php
index 9dc50f2..fc14e90 100644
--- a/code/forms/BootstrapAjaxModalForm.php
+++ b/code/forms/BootstrapAjaxModalForm.php
@@ -75,12 +75,13 @@
* @package bootstrap_extra_fields
* @subpackage forms
*/
-class BootstrapAjaxModalForm extends BootstrapModalForm {
+class BootstrapAjaxModalForm extends BootstrapModalForm
+{
- public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction){
-
+ public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction)
+ {
parent::__construct(
$controller,
$name,
@@ -121,46 +122,53 @@ public function __construct($controller, $name, FieldList $fields, FieldList $ac
JS;
Requirements::customScript($js, 'BootstrapAjaxModalForm_Js_'.$this->FormName());
- if(Director::is_ajax()) $this->setTemplate('BootstrapAjaxModalForm');
+ if (Director::is_ajax()) {
+ $this->setTemplate('BootstrapAjaxModalForm');
+ }
}
- /**
- * Return a rendered version of this form, suitable for ajax post-back.
- * It triggers slightly different behaviour, such as disabling the rewriting of # links
- */
- public function forAjaxTemplate() {
- $view = new SSViewer(array(
- $this->getTemplate(),
- 'Form'
- ));
+ /**
+ * Return a rendered version of this form, suitable for ajax post-back.
+ * It triggers slightly different behaviour, such as disabling the rewriting of # links
+ */
+ public function forAjaxTemplate()
+ {
+ $view = new SSViewer(array(
+ $this->getTemplate(),
+ 'Form'
+ ));
- $return = $view->dontRewriteHashlinks()->process($this);
+ $return = $view->dontRewriteHashlinks()->process($this);
// Now that we're rendered, clear message
- $this->clearMessage();
+ $this->clearMessage();
- return $return;
- }
+ return $return;
+ }
- public function AjaxReturn($request){
- if(!Director::is_ajax()){
+ public function AjaxReturn($request)
+ {
+ if (!Director::is_ajax()) {
return $this;
- }else{
- if($this->examineFormAction($request)) return $this;
- else return $this->forAjaxTemplate();
+ } else {
+ if ($this->examineFormAction($request)) {
+ return $this;
+ } else {
+ return $this->forAjaxTemplate();
+ }
}
}
- protected function examineFormAction($request){
+ protected function examineFormAction($request)
+ {
// Determine the action button clicked
$actionSet = false;
- foreach($request->requestVars() as $paramName => $paramVal){
- if(substr($paramName,0,7) == 'action_'){
+ foreach ($request->requestVars() as $paramName => $paramVal) {
+ if (substr($paramName, 0, 7) == 'action_') {
$actionSet = true;
break;
- }
+ }
}
return $actionSet;
}
-
}
diff --git a/code/forms/BootstrapButtonCheckboxField.php b/code/forms/BootstrapButtonCheckboxField.php
index 6a5d0b7..a4695e6 100644
--- a/code/forms/BootstrapButtonCheckboxField.php
+++ b/code/forms/BootstrapButtonCheckboxField.php
@@ -18,20 +18,22 @@
* @package bootstrap_extra_fields
* @subpackage forms
*/
-class BootstrapButtonCheckboxField extends CheckboxField {
+class BootstrapButtonCheckboxField extends CheckboxField
+{
- /**
- * Creates a new field.
- *
- * @param string $name The internal field name, passed to forms.
- * @param string $title The human-readable field label.
- * @param mixed $value The value of the field.
- */
- public function __construct($name, $title = null, $value = null) {
- parent::__construct($name, $title, $value);
+ /**
+ * Creates a new field.
+ *
+ * @param string $name The internal field name, passed to forms.
+ * @param string $title The human-readable field label.
+ * @param mixed $value The value of the field.
+ */
+ public function __construct($name, $title = null, $value = null)
+ {
+ parent::__construct($name, $title, $value);
- $this->setFieldHolderTemplate('FormField_holder');
- }
+ $this->setFieldHolderTemplate('FormField_holder');
+ }
}
diff --git a/code/forms/BootstrapButtonCheckboxSetField.php b/code/forms/BootstrapButtonCheckboxSetField.php
index 2b43e03..e648701 100644
--- a/code/forms/BootstrapButtonCheckboxSetField.php
+++ b/code/forms/BootstrapButtonCheckboxSetField.php
@@ -16,42 +16,46 @@
* @package bootstrap_extra_fields
* @subpackage forms
*/
-class BootstrapButtonCheckboxSetField extends CheckboxSetField {
-
- /**
- * @var array $optionClasses The keys for items that should get an extra class in the dropdown
- */
- protected $optionClasses = array();
+class BootstrapButtonCheckboxSetField extends CheckboxSetField
+{
+
+ /**
+ * @var array $optionClasses The keys for items that should get an extra class in the dropdown
+ */
+ protected $optionClasses = array();
/**
* @var string $buttonClass class for the buttons (default/info/primary/success/warning/danger)
*/
protected $buttonClass = 'default';
-
- /**
- * Set the specific classes for single items
- *
- * @param array $classes Collection of array keys, as defined in the $source array
- */
- public function setOptionClasses($classes = array()){
- $this->optionClasses = $classes;
- return $this;
- }
-
- /**
- * @return Array
- */
- public function getOptionClasses(){
- return $this->optionClasses;
- }
-
- /**
- * set the general button class for the Buttons Optionset field
- *
- * @param string $class set the button class (default/info/primary/success/warning/danger)
- */
- public function setButtonClass($class = 'default'){
- switch($class){
+
+ /**
+ * Set the specific classes for single items
+ *
+ * @param array $classes Collection of array keys, as defined in the $source array
+ */
+ public function setOptionClasses($classes = array())
+ {
+ $this->optionClasses = $classes;
+ return $this;
+ }
+
+ /**
+ * @return Array
+ */
+ public function getOptionClasses()
+ {
+ return $this->optionClasses;
+ }
+
+ /**
+ * set the general button class for the Buttons Optionset field
+ *
+ * @param string $class set the button class (default/info/primary/success/warning/danger)
+ */
+ public function setButtonClass($class = 'default')
+ {
+ switch ($class) {
case 'info':
$this->buttonClass = 'info';
break;
@@ -71,127 +75,127 @@ public function setButtonClass($class = 'default'){
$this->buttonClass = 'default';
break;
}
- return $this;
- }
-
- /**
- * @return Array
- */
- public function getButtonClass(){
- return $this->buttonClass;
- }
-
- /**
- * @todo Explain different source data that can be used with this field,
- * e.g. SQLMap, ArrayList or an array.
- */
- public function Field($properties = array()) {
-
- $properties = array_merge($properties, array(
- 'Options' => $this->getOptions()
- ));
+ return $this;
+ }
+
+ /**
+ * @return Array
+ */
+ public function getButtonClass()
+ {
+ return $this->buttonClass;
+ }
- return $this->customise($properties)->renderWith(
- $this->getTemplates()
- );
- }
+ /**
+ * @todo Explain different source data that can be used with this field,
+ * e.g. SQLMap, ArrayList or an array.
+ */
+ public function Field($properties = array())
+ {
+ $properties = array_merge($properties, array(
+ 'Options' => $this->getOptions()
+ ));
- /**
- * @return ArrayList
- */
- public function getOptions() {
+ return $this->customise($properties)->renderWith(
+ $this->getTemplates()
+ );
+ }
- $source = $this->source;
- $values = $this->value;
- $items = array();
+ /**
+ * @return ArrayList
+ */
+ public function getOptions()
+ {
+ $source = $this->source;
+ $values = $this->value;
+ $items = array();
- // Get values from the join, if available
- if(is_object($this->form)) {
- $record = $this->form->getRecord();
- if(!$values && $record && $record->hasMethod($this->name)) {
- $funcName = $this->name;
- $join = $record->$funcName();
- if($join) {
- foreach($join as $joinItem) {
- $values[] = $joinItem->ID;
- }
- }
- }
- }
-
- // Source is not an array
- if(!is_array($source) && !is_a($source, 'SQLMap')) {
- if(is_array($values)) {
- $items = $values;
- } else {
- // Source and values are DataObject sets.
- if($values && is_a($values, 'SS_List')) {
- foreach($values as $object) {
- if(is_a($object, 'DataObject')) {
- $items[] = $object->ID;
- }
- }
- } elseif($values && is_string($values)) {
- $items = explode(',', $values);
- $items = str_replace('{comma}', ',', $items);
- }
- }
- } else {
- // Sometimes we pass a singluar default value thats ! an array && !SS_List
- if($values instanceof SS_List || is_array($values)) {
- $items = $values;
- } else {
- if($values === null) {
- $items = array();
- }
- else {
- $items = explode(',', $values);
- $items = str_replace('{comma}', ',', $items);
- }
- }
- }
+ // Get values from the join, if available
+ if (is_object($this->form)) {
+ $record = $this->form->getRecord();
+ if (!$values && $record && $record->hasMethod($this->name)) {
+ $funcName = $this->name;
+ $join = $record->$funcName();
+ if ($join) {
+ foreach ($join as $joinItem) {
+ $values[] = $joinItem->ID;
+ }
+ }
+ }
+ }
+
+ // Source is not an array
+ if (!is_array($source) && !is_a($source, 'SQLMap')) {
+ if (is_array($values)) {
+ $items = $values;
+ } else {
+ // Source and values are DataObject sets.
+ if ($values && is_a($values, 'SS_List')) {
+ foreach ($values as $object) {
+ if (is_a($object, 'DataObject')) {
+ $items[] = $object->ID;
+ }
+ }
+ } elseif ($values && is_string($values)) {
+ $items = explode(',', $values);
+ $items = str_replace('{comma}', ',', $items);
+ }
+ }
+ } else {
+ // Sometimes we pass a singluar default value thats ! an array && !SS_List
+ if ($values instanceof SS_List || is_array($values)) {
+ $items = $values;
+ } else {
+ if ($values === null) {
+ $items = array();
+ } else {
+ $items = explode(',', $values);
+ $items = str_replace('{comma}', ',', $items);
+ }
+ }
+ }
- if(is_array($source)) {
- unset($source['']);
- }
-
- $options = array();
-
- if ($source == null) {
- $source = array();
- }
+ if (is_array($source)) {
+ unset($source['']);
+ }
+
+ $options = array();
+
+ if ($source == null) {
+ $source = array();
+ }
- foreach($source as $value => $item) {
- if($item instanceof DataObject) {
- $value = $item->ID;
- $title = $item->Title;
- } else {
- $title = $item;
- }
+ foreach ($source as $value => $item) {
+ if ($item instanceof DataObject) {
+ $value = $item->ID;
+ $title = $item->Title;
+ } else {
+ $title = $item;
+ }
- $itemID = $this->ID() . '_' . preg_replace('/[^a-zA-Z0-9]/', '', $value);
-
- $class = false;
- if(array_key_exists($value, $this->optionClasses)){
+ $itemID = $this->ID() . '_' . preg_replace('/[^a-zA-Z0-9]/', '', $value);
+
+ $class = false;
+ if (array_key_exists($value, $this->optionClasses)) {
$class = $this->optionClasses[$value];
}
- $options[] = new ArrayData(array(
- 'ID' => $itemID,
- 'ButtonClass' => $this->buttonClass,
- 'ExtraClass' => $class,
- 'Name' => "{$this->name}[{$value}]",
- 'Value' => $value,
- 'Title' => $title,
- 'isChecked' => in_array($value, $items) || in_array($value, $this->defaultItems),
- 'isDisabled' => $this->disabled || in_array($value, $this->disabledItems)
- ));
- }
+ $options[] = new ArrayData(array(
+ 'ID' => $itemID,
+ 'ButtonClass' => $this->buttonClass,
+ 'ExtraClass' => $class,
+ 'Name' => "{$this->name}[{$value}]",
+ 'Value' => $value,
+ 'Title' => $title,
+ 'isChecked' => in_array($value, $items) || in_array($value, $this->defaultItems),
+ 'isDisabled' => $this->disabled || in_array($value, $this->disabledItems)
+ ));
+ }
- $options = new ArrayList($options);
+ $options = new ArrayList($options);
- $this->extend('updateGetOptions', $options);
+ $this->extend('updateGetOptions', $options);
- return $options;
- }
+ return $options;
+ }
}
diff --git a/code/forms/BootstrapButtonOptionsetField.php b/code/forms/BootstrapButtonOptionsetField.php
index 1aacebc..0b1be02 100644
--- a/code/forms/BootstrapButtonOptionsetField.php
+++ b/code/forms/BootstrapButtonOptionsetField.php
@@ -18,42 +18,46 @@
* @package bootstrap_extra_fields
* @subpackage forms
*/
-class BootstrapButtonOptionsetField extends OptionsetField {
-
- /**
- * @var array $optionClasses The keys for items that should get an extra class in the dropdown
- */
- protected $optionClasses = array();
+class BootstrapButtonOptionsetField extends OptionsetField
+{
+
+ /**
+ * @var array $optionClasses The keys for items that should get an extra class in the dropdown
+ */
+ protected $optionClasses = array();
/**
* @var string $buttonClass class for the buttons (default/info/primary/success/warning/danger)
*/
protected $buttonClass = 'default';
-
- /**
- * Set the specific classes for single items
- *
- * @param array $classes Collection of array keys, as defined in the $source array
- */
- public function setOptionClasses($classes = array()){
- $this->optionClasses = $classes;
- return $this;
- }
-
- /**
- * @return Array
- */
- public function getOptionClasses(){
- return $this->optionClasses;
- }
-
- /**
- * set the general button class for the Buttons Optionset field
- *
- * @param string $class set the button class (default/info/primary/success/warning/danger)
- */
- public function setButtonClass($class = 'default'){
- switch($class){
+
+ /**
+ * Set the specific classes for single items
+ *
+ * @param array $classes Collection of array keys, as defined in the $source array
+ */
+ public function setOptionClasses($classes = array())
+ {
+ $this->optionClasses = $classes;
+ return $this;
+ }
+
+ /**
+ * @return Array
+ */
+ public function getOptionClasses()
+ {
+ return $this->optionClasses;
+ }
+
+ /**
+ * set the general button class for the Buttons Optionset field
+ *
+ * @param string $class set the button class (default/info/primary/success/warning/danger)
+ */
+ public function setButtonClass($class = 'default')
+ {
+ switch ($class) {
case 'info':
$this->buttonClass = 'info';
break;
@@ -73,48 +77,50 @@ public function setButtonClass($class = 'default'){
$this->buttonClass = 'default';
break;
}
- return $this;
- }
-
- /**
- * @return Array
- */
- public function getButtonClass(){
- return $this->buttonClass;
- }
+ return $this;
+ }
+
+ /**
+ * @return Array
+ */
+ public function getButtonClass()
+ {
+ return $this->buttonClass;
+ }
- public function Field($properties = array()) {
- $source = $this->getSource();
- $options = array();
-
- if($source) {
- foreach($source as $value => $title) {
- $itemID = $this->ID() . '_' . preg_replace('/[^a-zA-Z0-9]/', '', $value);
-
- $class = false;
- if(array_key_exists($value, $this->optionClasses)){
- $class = $this->optionClasses[$value];
- }
-
- $options[] = new ArrayData(array(
- 'ID' => $itemID,
- 'ButtonClass' => $this->buttonClass,
- 'ExtraClass' => $class,
- 'Name' => $this->name,
- 'Value' => $value,
- 'Title' => $title,
- 'isChecked' => $value == $this->value,
- 'isDisabled' => $this->disabled || in_array($value, $this->disabledItems),
- ));
- }
- }
+ public function Field($properties = array())
+ {
+ $source = $this->getSource();
+ $options = array();
+
+ if ($source) {
+ foreach ($source as $value => $title) {
+ $itemID = $this->ID() . '_' . preg_replace('/[^a-zA-Z0-9]/', '', $value);
+
+ $class = false;
+ if (array_key_exists($value, $this->optionClasses)) {
+ $class = $this->optionClasses[$value];
+ }
+
+ $options[] = new ArrayData(array(
+ 'ID' => $itemID,
+ 'ButtonClass' => $this->buttonClass,
+ 'ExtraClass' => $class,
+ 'Name' => $this->name,
+ 'Value' => $value,
+ 'Title' => $title,
+ 'isChecked' => $value == $this->value,
+ 'isDisabled' => $this->disabled || in_array($value, $this->disabledItems),
+ ));
+ }
+ }
- $properties = array_merge($properties, array(
- 'Options' => new ArrayList($options)
- ));
+ $properties = array_merge($properties, array(
+ 'Options' => new ArrayList($options)
+ ));
- return $this->customise($properties)->renderWith(
- $this->getTemplates()
- );
- }
+ return $this->customise($properties)->renderWith(
+ $this->getTemplates()
+ );
+ }
}
diff --git a/code/forms/BootstrapCaptchaField.php b/code/forms/BootstrapCaptchaField.php
index 3586a55..f765dba 100644
--- a/code/forms/BootstrapCaptchaField.php
+++ b/code/forms/BootstrapCaptchaField.php
@@ -6,73 +6,78 @@
* @subpackage fields
*/
-class BootstrapCaptchaField extends TextField {
-
- /**
- * Returns an input field, class="text" and type="text" with an optional maxlength
- */
- public function __construct($name, $title = null, $value = '', $maxLength = null, $form = null) {
- $this->setAttribute('placeholder', _t('BootstrapCaptchaField.PLACEHOLDER', "Type the code shown"));
-
- parent::__construct($name, $title, $value, $form);
- }
+class BootstrapCaptchaField extends TextField
+{
- protected function GenerateImage($string){
- $image = imagecreatetruecolor(200, 50);
-
- $background_color = imagecolorallocate($image, 255, 255, 255);
- imagefilledrectangle($image,0,0,200,50,$background_color);
-
- $line_color = imagecolorallocate($image, 128,128,128);
- for($i=0;$i<5;$i++) {
- imageline($image,0,rand()%50,200,rand()%50,$line_color);
- }
-
- $pixel_color = imagecolorallocate($image, 0,0,128);
- for($i=0;$i<500;$i++) {
- imagesetpixel($image,rand()%200,rand()%50,$pixel_color);
- }
-
- $pixel_color = imagecolorallocate($image, 128,0,0);
- for($i=0;$i<500;$i++) {
- imagesetpixel($image,rand()%200,rand()%50,$pixel_color);
- }
-
- $text_color = imagecolorallocate($image, 255,0,0);
- $i=0;
- foreach(str_split($string) as $letter){
- imagestring($image, 5, 5+($i*30), 20, $letter, $text_color);
- $i++;
- }
-
- $resized = imagecreatetruecolor(300, 75);
-
- imagecopyresampled($resized, $image, 0, 0, 0, 0, 300, 75, 200, 50);
-
- ob_start();
- imagepng($resized);
- $contents = ob_get_contents();
- ob_end_clean();
-
- $Base64Image = base64_encode($contents);
-
- imagedestroy($image);
-
- return "data:image/png;base64,".$Base64Image;
- }
-
- protected function GenerateString(){
- $letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
- $len = strlen($letters);
- $captcha = '';
- for ($i = 0; $i< 6;$i++) {
- $letter = $letters[rand(0, $len-1)];
- $captcha.=$letter;
- }
- return $captcha;
- }
-
- public function Field($properties = array()) {
+ /**
+ * Returns an input field, class="text" and type="text" with an optional maxlength
+ */
+ public function __construct($name, $title = null, $value = '', $maxLength = null, $form = null)
+ {
+ $this->setAttribute('placeholder', _t('BootstrapCaptchaField.PLACEHOLDER', "Type the code shown"));
+
+ parent::__construct($name, $title, $value, $form);
+ }
+
+ protected function GenerateImage($string)
+ {
+ $image = imagecreatetruecolor(200, 50);
+
+ $background_color = imagecolorallocate($image, 255, 255, 255);
+ imagefilledrectangle($image, 0, 0, 200, 50, $background_color);
+
+ $line_color = imagecolorallocate($image, 128, 128, 128);
+ for ($i=0;$i<5;$i++) {
+ imageline($image, 0, rand()%50, 200, rand()%50, $line_color);
+ }
+
+ $pixel_color = imagecolorallocate($image, 0, 0, 128);
+ for ($i=0;$i<500;$i++) {
+ imagesetpixel($image, rand()%200, rand()%50, $pixel_color);
+ }
+
+ $pixel_color = imagecolorallocate($image, 128, 0, 0);
+ for ($i=0;$i<500;$i++) {
+ imagesetpixel($image, rand()%200, rand()%50, $pixel_color);
+ }
+
+ $text_color = imagecolorallocate($image, 255, 0, 0);
+ $i=0;
+ foreach (str_split($string) as $letter) {
+ imagestring($image, 5, 5+($i*30), 20, $letter, $text_color);
+ $i++;
+ }
+
+ $resized = imagecreatetruecolor(300, 75);
+
+ imagecopyresampled($resized, $image, 0, 0, 0, 0, 300, 75, 200, 50);
+
+ ob_start();
+ imagepng($resized);
+ $contents = ob_get_contents();
+ ob_end_clean();
+
+ $Base64Image = base64_encode($contents);
+
+ imagedestroy($image);
+
+ return "data:image/png;base64,".$Base64Image;
+ }
+
+ protected function GenerateString()
+ {
+ $letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
+ $len = strlen($letters);
+ $captcha = '';
+ for ($i = 0; $i< 6;$i++) {
+ $letter = $letters[rand(0, $len-1)];
+ $captcha.=$letter;
+ }
+ return $captcha;
+ }
+
+ public function Field($properties = array())
+ {
// Fetch the Field Record
$CaptchaValue = $this->GenerateString();
@@ -80,29 +85,30 @@ public function Field($properties = array()) {
Session::set('BootstrapCaptchaFieldValue', $CaptchaValue);
$ImageSrc = $this->GenerateImage($CaptchaValue);
- $properties = array_merge($properties, array(
+ $properties = array_merge($properties, array(
'ImageSrc' => $ImageSrc
));
-
+
return parent::Field($properties);
- }
-
- public function validate($validator) {
- if(!$this->value && !$validator->fieldIsRequired($this->name)) {
- return true;
- }
-
- if(strtolower($this->value) == strtolower(Session::get('BootstrapCaptchaFieldValue'))){
+ }
+
+ public function validate($validator)
+ {
+ if (!$this->value && !$validator->fieldIsRequired($this->name)) {
+ return true;
+ }
+
+ if (strtolower($this->value) == strtolower(Session::get('BootstrapCaptchaFieldValue'))) {
$this->value == '';
Session::clear('BootstrapCaptchaFieldValue');
return true;
}
- $validator->validationError(
- $this->name,
- _t('BootstrapCaptchaField.VALIDATION', "Invalid code, try again."),
- "validation"
- );
- return false;
- }
-}
\ No newline at end of file
+ $validator->validationError(
+ $this->name,
+ _t('BootstrapCaptchaField.VALIDATION', "Invalid code, try again."),
+ "validation"
+ );
+ return false;
+ }
+}
diff --git a/code/forms/BootstrapConfirmFormAction.php b/code/forms/BootstrapConfirmFormAction.php
index 07a5269..6cbef2e 100644
--- a/code/forms/BootstrapConfirmFormAction.php
+++ b/code/forms/BootstrapConfirmFormAction.php
@@ -7,11 +7,13 @@
* @package forms
* @subpackage fields-formattedinput
*/
-class BootstrapConfirmFormAction extends FormAction {
+class BootstrapConfirmFormAction extends FormAction
+{
protected $confirmMessage;
- public function setConfirmMessage($message){
+ public function setConfirmMessage($message)
+ {
$this->confirmMessage = $message;
$this->setAttribute('onclick', "javascript:return confirm('".$this->confirmMessage."');");
return $this;
diff --git a/code/forms/BootstrapConfirmedPasswordField.php b/code/forms/BootstrapConfirmedPasswordField.php
index db53b5e..af828da 100644
--- a/code/forms/BootstrapConfirmedPasswordField.php
+++ b/code/forms/BootstrapConfirmedPasswordField.php
@@ -7,112 +7,116 @@
* @package forms
* @subpackage fields-formattedinput
*/
-class BootstrapConfirmedPasswordField extends ConfirmedPasswordField {
-
- /**
- * @param string $name
- * @param string $title
- * @param mixed $value
- * @param Form $form
- * @param boolean $showOnClick
- * @param string $titleConfirmField Alternate title (not localizeable)
- */
- public function __construct($name, $title = null, $value = "", $form = null, $showOnClick = false, $titleConfirmField = null) {
-
- parent::__construct($name, $title, $value, $form, $showOnClick, $titleConfirmField);
- $this->setValue($value);
+class BootstrapConfirmedPasswordField extends ConfirmedPasswordField
+{
+
+ /**
+ * @param string $name
+ * @param string $title
+ * @param mixed $value
+ * @param Form $form
+ * @param boolean $showOnClick
+ * @param string $titleConfirmField Alternate title (not localizeable)
+ */
+ public function __construct($name, $title = null, $value = "", $form = null, $showOnClick = false, $titleConfirmField = null)
+ {
+ parent::__construct($name, $title, $value, $form, $showOnClick, $titleConfirmField);
+ $this->setValue($value);
$this->setTitle($title);
- }
-
- public function Field($properties = array()) {
-
+ }
+
+ public function Field($properties = array())
+ {
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
- Requirements::javascript('bootstrap_extra_fields/javascript/BootstrapConfirmedPasswordField.js');
- Requirements::css(FRAMEWORK_DIR . '/css/ConfirmedPasswordField.css');
-
- $content = '';
-
- if($this->showOnClick) {
- if($this->showOnClickTitle) {
- $title = $this->showOnClickTitle;
- } else {
- $title = _t(
- 'ConfirmedPasswordField.SHOWONCLICKTITLE',
- 'Change Password',
-
- 'Label of the link which triggers display of the "change password" formfields'
- );
- }
-
- $content .= "
\n";
- $content .= "
{$title}\n";
- $content .= "
";
- }
+ Requirements::javascript('bootstrap_extra_fields/javascript/BootstrapConfirmedPasswordField.js');
+ Requirements::css(FRAMEWORK_DIR . '/css/ConfirmedPasswordField.css');
+
+ $content = '';
+
+ if ($this->showOnClick) {
+ if ($this->showOnClickTitle) {
+ $title = $this->showOnClickTitle;
+ } else {
+ $title = _t(
+ 'ConfirmedPasswordField.SHOWONCLICKTITLE',
+ 'Change Password',
+
+ 'Label of the link which triggers display of the "change password" formfields'
+ );
+ }
+
+ $content .= "
\n";
+ $content .= "
{$title}\n";
+ $content .= "
";
+ }
- foreach($this->children as $field) {
- $field->setDisabled($this->isDisabled());
- $field->setReadonly($this->isReadonly());
- if(count($this->attributes)) {
- foreach($this->attributes as $name => $value) {
- $field->setAttribute($name, $value);
- }
- }
+ foreach ($this->children as $field) {
+ $field->setDisabled($this->isDisabled());
+ $field->setReadonly($this->isReadonly());
+ if (count($this->attributes)) {
+ foreach ($this->attributes as $name => $value) {
+ $field->setAttribute($name, $value);
+ }
+ }
$field->addExtraClass($this->extraClass());
- $content .= $field->FieldHolder();
- }
+ $content .= $field->FieldHolder();
+ }
- if($this->showOnClick) {
- $content .= "
\n";
- $content .= "
\n";
- }
-
- return $content;
- }
-
- public function Fields() {
+ if ($this->showOnClick) {
+ $content .= "
\n";
+ $content .= "
\n";
+ }
+ return $content;
+ }
+
+ public function Fields()
+ {
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
- Requirements::javascript('bootstrap_extra_fields/javascript/BootstrapConfirmedPasswordField.js');
- Requirements::css(FRAMEWORK_DIR . '/css/ConfirmedPasswordField.css');
-
- $Fields = new FieldList();
+ Requirements::javascript('bootstrap_extra_fields/javascript/BootstrapConfirmedPasswordField.js');
+ Requirements::css(FRAMEWORK_DIR . '/css/ConfirmedPasswordField.css');
+
+ $Fields = new FieldList();
- foreach($this->children as $field) {
- $field->setDisabled($this->isDisabled());
- $field->setReadonly($this->isReadonly());
- if(count($this->attributes)) {
- foreach($this->attributes as $name => $value) {
- $field->setAttribute($name, $value);
- }
- }
+ foreach ($this->children as $field) {
+ $field->setDisabled($this->isDisabled());
+ $field->setReadonly($this->isReadonly());
+ if (count($this->attributes)) {
+ foreach ($this->attributes as $name => $value) {
+ $field->setAttribute($name, $value);
+ }
+ }
$field->addExtraClass($this->extraClass());
- $Fields->add($field);
- }
-
- return $Fields;
- }
+ $Fields->add($field);
+ }
+
+ return $Fields;
+ }
- public function getShowTitle(){
- if($this->showOnClickTitle){
- $title = $this->showOnClickTitle;
- }else{
- $title = _t(
- 'ConfirmedPasswordField.SHOWONCLICKTITLE',
- 'Change Password',
- 'Label of the link which triggers display of the "change password" formfields'
- );
- }
+ public function getShowTitle()
+ {
+ if ($this->showOnClickTitle) {
+ $title = $this->showOnClickTitle;
+ } else {
+ $title = _t(
+ 'ConfirmedPasswordField.SHOWONCLICKTITLE',
+ 'Change Password',
+ 'Label of the link which triggers display of the "change password" formfields'
+ );
+ }
- return $title;
- }
-
- public function setShowOnClick($show) {
- $this->showOnClick = (bool)$show;
+ return $title;
+ }
+
+ public function setShowOnClick($show)
+ {
+ $this->showOnClick = (bool)$show;
- return $this;
- }
+ return $this;
+ }
- public function getShowOnClick(){
- return $this->showOnClick;
- }
+ public function getShowOnClick()
+ {
+ return $this->showOnClick;
+ }
}
diff --git a/code/forms/BootstrapCurrencyField.php b/code/forms/BootstrapCurrencyField.php
index ea7cfe2..b8bef41 100644
--- a/code/forms/BootstrapCurrencyField.php
+++ b/code/forms/BootstrapCurrencyField.php
@@ -7,54 +7,57 @@
* @package forms
* @subpackage fields-formattedinput
*/
-class BootstrapCurrencyField extends NumericField {
+class BootstrapCurrencyField extends NumericField
+{
- /**
- * displays the value in its current locality format
- */
- public function setValue($value, $data = array()) {
- require_once THIRDPARTY_PATH."/Zend/Locale/Format.php";
+ /**
+ * displays the value in its current locality format
+ */
+ public function setValue($value, $data = array())
+ {
+ require_once THIRDPARTY_PATH."/Zend/Locale/Format.php";
- // If passing in a non-string number, or a value
- // directly from a dataobject then localise this number
- if ((is_numeric($value) && !is_string($value)) ||
- ($value && $data instanceof DataObject)
- ){
- $locale = new Zend_Locale($this->getLocale());
- $this->value = Zend_Locale_Format::toNumber($value, array('locale' => $locale));
- }else if(Zend_Locale_Format::isNumber(
- $this->clean($value),
- array('locale' => i18n::get_locale())
- )){
- // If an invalid number, store it anyway, but validate() will fail
- $this->value = $this->clean($value);
- }
- return $this;
- }
-
+ // If passing in a non-string number, or a value
+ // directly from a dataobject then localise this number
+ if ((is_numeric($value) && !is_string($value)) ||
+ ($value && $data instanceof DataObject)
+ ) {
+ $locale = new Zend_Locale($this->getLocale());
+ $this->value = Zend_Locale_Format::toNumber($value, array('locale' => $locale));
+ } elseif (Zend_Locale_Format::isNumber(
+ $this->clean($value),
+ array('locale' => i18n::get_locale())
+ )) {
+ // If an invalid number, store it anyway, but validate() will fail
+ $this->value = $this->clean($value);
+ }
+ return $this;
+ }
+
/**
* extracts the
* @return type
*/
- public function dataValue() {
-
- require_once THIRDPARTY_PATH."/Zend/Locale/Format.php";
+ public function dataValue()
+ {
+ require_once THIRDPARTY_PATH."/Zend/Locale/Format.php";
$locale = new Zend_Locale(i18n::get_locale());
$number = Zend_Locale_Format::getNumber($this->value, array('locale' => $locale));
- return $number;
- }
+ return $number;
+ }
- public function CurrencySymbol(){
-
- require_once THIRDPARTY_PATH."/Zend/Currency.php";
+ public function CurrencySymbol()
+ {
+ require_once THIRDPARTY_PATH."/Zend/Currency.php";
- $locale = new Zend_Locale(i18n::get_locale());
- $symbol = new Zend_Currency($locale);
- return $symbol->getSymbol();
- }
+ $locale = new Zend_Locale(i18n::get_locale());
+ $symbol = new Zend_Currency($locale);
+ return $symbol->getSymbol();
+ }
- public function setEmpty(){
- $this->value = null;
- }
+ public function setEmpty()
+ {
+ $this->value = null;
+ }
}
diff --git a/code/forms/BootstrapDatetimepickerField.php b/code/forms/BootstrapDatetimepickerField.php
index 301c04f..d13bd18 100644
--- a/code/forms/BootstrapDatetimepickerField.php
+++ b/code/forms/BootstrapDatetimepickerField.php
@@ -9,16 +9,17 @@
* @package forms
* @subpackage fields-formattedinput
*/
-class BootstrapDatetimepickerField extends TextField {
+class BootstrapDatetimepickerField extends TextField
+{
- protected $locale = false;
+ protected $locale = false;
- protected $supported_locales = array(
+ protected $supported_locales = array(
'de_DE' => 'de',
'en_GB' => 'en-gb'
);
- protected $locale_formats = array(
+ protected $locale_formats = array(
'en_US' => 'm/d/Y g:i A', //
'de_DE' => 'd.m.Y G:i \U\h\r',
'en_GB' => 'd/m/Y H:i' // falls das brittische Datum nicht geschrieben wird, kann es an einer fehlenden null vor der Stunde liegen. Einfach "H" durch "G" ersetzen
@@ -28,161 +29,171 @@ class BootstrapDatetimepickerField extends TextField {
// 'de_DE' => '',
// 'en_GB' => 'en-gb'
//);
-
- public function Field($properties = array()) {
-
+
+ public function Field($properties = array())
+ {
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
- Requirements::javascript('bootstrap_extra_fields/javascript/moment.min.js');
- Requirements::javascript('bootstrap_extra_fields/javascript/bootstrap-datetimepicker.min.js');
- Requirements::css('bootstrap_extra_fields/css/bootstrap-datetimepicker.min.css');
+ Requirements::javascript('bootstrap_extra_fields/javascript/moment.min.js');
+ Requirements::javascript('bootstrap_extra_fields/javascript/bootstrap-datetimepicker.min.js');
+ Requirements::css('bootstrap_extra_fields/css/bootstrap-datetimepicker.min.css');
$language = '';
- if(array_key_exists(i18n::get_locale(), $this->supported_locales)){
+ if (array_key_exists(i18n::get_locale(), $this->supported_locales)) {
Requirements::javascript('bootstrap_extra_fields/javascript/locales/bootstrap-datetimepicker.'.$this->supported_locales[i18n::get_locale()].'.js');
$language = "language: '{$this->supported_locales[i18n::get_locale()]}'";
- }else if($this->locale){
+ } elseif ($this->locale) {
Requirements::javascript('bootstrap_extra_fields/javascript/locales/bootstrap-datetimepicker.'.$this->locale.'.js');
$language = "language: '{$this->locale}'";
}
-
- $name = $this->ID();
-
- // set caption if required
- $js = <<ID();
+
+ // set caption if required
+ $js = <<ID());
+ Requirements::customScript($js, 'BootstrapDatetimepickerForm_Js_'.$this->ID());
return parent::Field($properties);
- }
+ }
- public function setLocale($locale){
- $this->locale = $locale;
- }
+ public function setLocale($locale)
+ {
+ $this->locale = $locale;
+ }
- public function getLocale(){
- return $this->locale;
- }
+ public function getLocale()
+ {
+ return $this->locale;
+ }
- protected function validateDate($date, $format = 'Y-m-d H:i:s'){
- $d = DateTime::createFromFormat($format, $date);
- return $d && $d->format($format) == $date;
- }
+ protected function validateDate($date, $format = 'Y-m-d H:i:s')
+ {
+ $d = DateTime::createFromFormat($format, $date);
+ return $d && $d->format($format) == $date;
+ }
- protected function getFormat(){
- if(array_key_exists(i18n::get_locale(), $this->supported_locales)) $locale = i18n::get_locale();
- else $locale = 'en_US';
-
- return $this->locale_formats[$locale];
+ protected function getFormat()
+ {
+ if (array_key_exists(i18n::get_locale(), $this->supported_locales)) {
+ $locale = i18n::get_locale();
+ } else {
+ $locale = 'en_US';
}
+
+ return $this->locale_formats[$locale];
+ }
- /**
- * displays the value in its current locality format
- */
- public function setValue($val) {
-
+ /**
+ * displays the value in its current locality format
+ */
+ public function setValue($val)
+ {
+
//require_once THIRDPARTY_PATH."/Zend/Locale/Format.php";
//require_once THIRDPARTY_PATH."/Zend/Date.php";
-
- if(is_numeric($val) && (int)$val == $val){
+
+ if (is_numeric($val) && (int)$val == $val) {
// is Timestamp
$this->value = date($this->getFormat(), (int)$val);
- }else if($this->validateDate($val, 'Y-m-d H:i:s')){
+ } elseif ($this->validateDate($val, 'Y-m-d H:i:s')) {
// is Time from Database
$d = DateTime::createFromFormat('Y-m-d H:i:s', $val);
$this->value = $d->format($this->getFormat());
- }else if($this->validateDate($val, $this->getFormat())){
+ } elseif ($this->validateDate($val, $this->getFormat())) {
$d = DateTime::createFromFormat($this->getFormat(), $val);
$this->value = $d->format($this->getFormat());
}
- return $this;
- }
-
+ return $this;
+ }
+
/**
* extracts the
* @return type
*/
- public function dataValue() {
- if($this->value){
- $d = DateTime::createFromFormat($this->getFormat(), $this->value);
- return $d->format('Y-m-d H:i:s');
- }
- }
+ public function dataValue()
+ {
+ if ($this->value) {
+ $d = DateTime::createFromFormat($this->getFormat(), $this->value);
+ return $d->format('Y-m-d H:i:s');
+ }
+ }
- /**
- * @return Boolean
- */
- public function validate($validator) {
- /*$valid = true;
-
- // Don't validate empty fields
- if(empty($this->value)) return true;
+ /**
+ * @return Boolean
+ */
+ public function validate($validator)
+ {
+ /*$valid = true;
+
+ // Don't validate empty fields
+ if(empty($this->value)) return true;
- // date format
- if($this->getConfig('dmyfields')) {
- $valid = (!$this->value || $this->validateArrayValue($this->value));
- } else {
- $valid = (Zend_Date::isDate($this->value, $this->getConfig('dateformat'), $this->locale));
- }
- if(!$valid) {
- $validator->validationError(
- $this->name,
- _t(
- 'DateField.VALIDDATEFORMAT2', "Please enter a valid date format ({format})",
- array('format' => $this->getConfig('dateformat'))
- ),
- "validation",
- false
- );
- return false;
- }
-
- // min/max - Assumes that the date value was valid in the first place
- if($min = $this->getConfig('min')) {
- // ISO or strtotime()
- if(Zend_Date::isDate($min, $this->getConfig('datavalueformat'))) {
- $minDate = new Zend_Date($min, $this->getConfig('datavalueformat'));
- } else {
- $minDate = new Zend_Date(strftime('%Y-%m-%d', strtotime($min)), $this->getConfig('datavalueformat'));
- }
- if(!$this->valueObj || (!$this->valueObj->isLater($minDate) && !$this->valueObj->equals($minDate))) {
- $validator->validationError(
- $this->name,
- _t(
- 'DateField.VALIDDATEMINDATE',
- "Your date has to be newer or matching the minimum allowed date ({date})",
- array('date' => $minDate->toString($this->getConfig('dateformat')))
- ),
- "validation",
- false
- );
- return false;
- }
- }
- if($max = $this->getConfig('max')) {
- // ISO or strtotime()
- if(Zend_Date::isDate($min, $this->getConfig('datavalueformat'))) {
- $maxDate = new Zend_Date($max, $this->getConfig('datavalueformat'));
- } else {
- $maxDate = new Zend_Date(strftime('%Y-%m-%d', strtotime($max)), $this->getConfig('datavalueformat'));
- }
- if(!$this->valueObj || (!$this->valueObj->isEarlier($maxDate) && !$this->valueObj->equals($maxDate))) {
- $validator->validationError(
- $this->name,
- _t('DateField.VALIDDATEMAXDATE',
- "Your date has to be older or matching the maximum allowed date ({date})",
- array('date' => $maxDate->toString($this->getConfig('dateformat')))
- ),
- "validation",
- false
- );
- return false;
- }
- }
- */
- return true;
- }
+ // date format
+ if($this->getConfig('dmyfields')) {
+ $valid = (!$this->value || $this->validateArrayValue($this->value));
+ } else {
+ $valid = (Zend_Date::isDate($this->value, $this->getConfig('dateformat'), $this->locale));
+ }
+ if(!$valid) {
+ $validator->validationError(
+ $this->name,
+ _t(
+ 'DateField.VALIDDATEFORMAT2', "Please enter a valid date format ({format})",
+ array('format' => $this->getConfig('dateformat'))
+ ),
+ "validation",
+ false
+ );
+ return false;
+ }
+
+ // min/max - Assumes that the date value was valid in the first place
+ if($min = $this->getConfig('min')) {
+ // ISO or strtotime()
+ if(Zend_Date::isDate($min, $this->getConfig('datavalueformat'))) {
+ $minDate = new Zend_Date($min, $this->getConfig('datavalueformat'));
+ } else {
+ $minDate = new Zend_Date(strftime('%Y-%m-%d', strtotime($min)), $this->getConfig('datavalueformat'));
+ }
+ if(!$this->valueObj || (!$this->valueObj->isLater($minDate) && !$this->valueObj->equals($minDate))) {
+ $validator->validationError(
+ $this->name,
+ _t(
+ 'DateField.VALIDDATEMINDATE',
+ "Your date has to be newer or matching the minimum allowed date ({date})",
+ array('date' => $minDate->toString($this->getConfig('dateformat')))
+ ),
+ "validation",
+ false
+ );
+ return false;
+ }
+ }
+ if($max = $this->getConfig('max')) {
+ // ISO or strtotime()
+ if(Zend_Date::isDate($min, $this->getConfig('datavalueformat'))) {
+ $maxDate = new Zend_Date($max, $this->getConfig('datavalueformat'));
+ } else {
+ $maxDate = new Zend_Date(strftime('%Y-%m-%d', strtotime($max)), $this->getConfig('datavalueformat'));
+ }
+ if(!$this->valueObj || (!$this->valueObj->isEarlier($maxDate) && !$this->valueObj->equals($maxDate))) {
+ $validator->validationError(
+ $this->name,
+ _t('DateField.VALIDDATEMAXDATE',
+ "Your date has to be older or matching the maximum allowed date ({date})",
+ array('date' => $maxDate->toString($this->getConfig('dateformat')))
+ ),
+ "validation",
+ false
+ );
+ return false;
+ }
+ }
+ */
+ return true;
+ }
}
diff --git a/code/forms/BootstrapDependentTypeaheadField.php b/code/forms/BootstrapDependentTypeaheadField.php
index 7984050..5fd7932 100644
--- a/code/forms/BootstrapDependentTypeaheadField.php
+++ b/code/forms/BootstrapDependentTypeaheadField.php
@@ -7,53 +7,59 @@
* @package forms
* @subpackage fields-formattedinput
*/
-class BootstrapDependentTypeaheadField extends TextField {
-
- public static $allowed_actions = array(
- 'load'
- );
-
- protected $depends;
-
- protected $source;
-
- public function load($request) {
- $response = new SS_HTTPResponse();
- $response->addHeader('Content-Type', 'application/json');
- $response->setBody(Convert::array2json(call_user_func(
- $this->source, $request->getVar('val'), $request->getVar('dependentval')
- )));
- return $response;
- }
-
- public function getDepends() {
- return $this->depends;
- }
-
- public function setDepends(FormField $field) {
- $this->depends = $field;
- return $this;
- }
-
- public function setSource($source) {
- if(!is_callable($source)) {
- die('Source on BootstrapTypeaheadField needs to be an executable method');
- }
+class BootstrapDependentTypeaheadField extends TextField
+{
+
+ public static $allowed_actions = array(
+ 'load'
+ );
+
+ protected $depends;
+
+ protected $source;
+
+ public function load($request)
+ {
+ $response = new SS_HTTPResponse();
+ $response->addHeader('Content-Type', 'application/json');
+ $response->setBody(Convert::array2json(call_user_func(
+ $this->source, $request->getVar('val'), $request->getVar('dependentval')
+ )));
+ return $response;
+ }
+
+ public function getDepends()
+ {
+ return $this->depends;
+ }
+
+ public function setDepends(FormField $field)
+ {
+ $this->depends = $field;
+ return $this;
+ }
+
+ public function setSource($source)
+ {
+ if (!is_callable($source)) {
+ die('Source on BootstrapTypeaheadField needs to be an executable method');
+ }
$this->source = $source;
return $this;
- }
+ }
- public function Field($properties = array()) {
- Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
- Requirements::javascript('bootstrap_extra_fields/javascript/bootstrap3-typeahead.min.js');
- Requirements::javascript('bootstrap_extra_fields/javascript/bootstrapdependenttypeaheadfield.js');
+ public function Field($properties = array())
+ {
+ Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
+ Requirements::javascript('bootstrap_extra_fields/javascript/bootstrap3-typeahead.min.js');
+ Requirements::javascript('bootstrap_extra_fields/javascript/bootstrapdependenttypeaheadfield.js');
- $this->addExtraClass('dependenttypeahead');
- $this->setAttribute('autocomplete', 'off');
- $this->setAttribute('data-link', $this->Link('load'));
- $this->setAttribute('data-depends', $this->getDepends()->getName());
+ $this->addExtraClass('dependenttypeahead');
+ $this->setAttribute('autocomplete', 'off');
+ $this->setAttribute('data-link', $this->Link('load'));
+ $this->setAttribute('data-depends', $this->getDepends()->getName());
- return parent::Field($properties);
- }
-}
\ No newline at end of file
+ return parent::Field($properties);
+ }
+}
diff --git a/code/forms/BootstrapDropdownDateField.php b/code/forms/BootstrapDropdownDateField.php
index 5d38ecc..089ef68 100644
--- a/code/forms/BootstrapDropdownDateField.php
+++ b/code/forms/BootstrapDropdownDateField.php
@@ -40,11 +40,12 @@
* @package forms
* @subpackage fields-datetime
*/
-class BootstrapDropdownDateField extends DropdownDateField {
+class BootstrapDropdownDateField extends DropdownDateField
+{
- public function Field($properties = array()) {
-
+ public function Field($properties = array())
+ {
$this->setConfig('dmyseparator', '');
return '
'.parent::Field($properties).'
';
- }
+ }
}
diff --git a/code/forms/BootstrapFieldColumn.php b/code/forms/BootstrapFieldColumn.php
index 0aaaf8e..5c8b888 100644
--- a/code/forms/BootstrapFieldColumn.php
+++ b/code/forms/BootstrapFieldColumn.php
@@ -22,38 +22,43 @@
*
* @package bootstrap_extra_fields
*/
-class BootstrapFieldColumn extends FieldGroup {
+class BootstrapFieldColumn extends FieldGroup
+{
protected $column_width;
-
- public function __construct($arg1 = null, $arg2 = null, $arg3 = null) {
-
- if(!is_numeric($arg1) || $arg1 < 1 || 12 < $arg1) throw new Exception(sprintf('Invalid Column with on BootstrapFieldColumn: %s', $arg1));
- else $this->column_width = (int)$arg1;
+
+ public function __construct($arg1 = null, $arg2 = null, $arg3 = null)
+ {
+ if (!is_numeric($arg1) || $arg1 < 1 || 12 < $arg1) {
+ throw new Exception(sprintf('Invalid Column with on BootstrapFieldColumn: %s', $arg1));
+ } else {
+ $this->column_width = (int)$arg1;
+ }
- if(is_array($arg2) || is_a($arg2, 'FieldSet')) {
- $fields = $arg2;
-
- } else if(is_array($arg3) || is_a($arg3, 'FieldList')) {
- $this->title = $arg2;
- $fields = $arg3;
-
- } else {
- $fields = func_get_args();
+ if (is_array($arg2) || is_a($arg2, 'FieldSet')) {
+ $fields = $arg2;
+ } elseif (is_array($arg3) || is_a($arg3, 'FieldList')) {
+ $this->title = $arg2;
+ $fields = $arg3;
+ } else {
+ $fields = func_get_args();
reset($fields);
$this->column_width = (int)array_shift($fields);
- if(!is_object(reset($fields))) $this->title = array_shift($fields);
- }
-
- parent::__construct($fields);
- }
+ if (!is_object(reset($fields))) {
+ $this->title = array_shift($fields);
+ }
+ }
+
+ parent::__construct($fields);
+ }
- public function setColumnWidth($width){
- $this->column_width = (int)$width;
- }
+ public function setColumnWidth($width)
+ {
+ $this->column_width = (int)$width;
+ }
- public function getColumnWidth(){
- return $this->column_width;
- }
-
-}
\ No newline at end of file
+ public function getColumnWidth()
+ {
+ return $this->column_width;
+ }
+}
diff --git a/code/forms/BootstrapFieldRow.php b/code/forms/BootstrapFieldRow.php
index 102aabb..3097548 100644
--- a/code/forms/BootstrapFieldRow.php
+++ b/code/forms/BootstrapFieldRow.php
@@ -6,22 +6,23 @@
* and open the template in the editor.
*/
-class BootstrapFieldRow extends FieldGroup {
+class BootstrapFieldRow extends FieldGroup
+{
- public function __construct($arg1 = null, $arg2 = null) {
- if(is_array($arg1) || is_a($arg1, 'FieldSet')) {
- $fields = $arg1;
-
- } else if(is_array($arg2) || is_a($arg2, 'FieldList')) {
- $this->title = $arg1;
- $fields = $arg2;
-
- } else {
- $fields = func_get_args();
- if(!is_object(reset($fields))) $this->title = array_shift($fields);
- }
-
- parent::__construct($fields);
- }
-
-}
\ No newline at end of file
+ public function __construct($arg1 = null, $arg2 = null)
+ {
+ if (is_array($arg1) || is_a($arg1, 'FieldSet')) {
+ $fields = $arg1;
+ } elseif (is_array($arg2) || is_a($arg2, 'FieldList')) {
+ $this->title = $arg1;
+ $fields = $arg2;
+ } else {
+ $fields = func_get_args();
+ if (!is_object(reset($fields))) {
+ $this->title = array_shift($fields);
+ }
+ }
+
+ parent::__construct($fields);
+ }
+}
diff --git a/code/forms/BootstrapFileField.php b/code/forms/BootstrapFileField.php
index 7f7cefe..09620e8 100644
--- a/code/forms/BootstrapFileField.php
+++ b/code/forms/BootstrapFileField.php
@@ -7,145 +7,160 @@
* @package forms
* @subpackage fields-formattedinput
*/
-class BootstrapFileField extends FileField {
+class BootstrapFileField extends FileField
+{
- /**
- * Config for this field used in the front-end javascript
- * (will be merged into the config of the javascript file upload plugin).
- * See framework/_config/uploadfield.yml for configuration defaults and documentation.
- *
- * @var array
- */
- protected $bffConfig = array(
- /**
- * Show the data-icon
- *
- * @var boolean
- */
- 'dataIcon' => true,
+ /**
+ * Config for this field used in the front-end javascript
+ * (will be merged into the config of the javascript file upload plugin).
+ * See framework/_config/uploadfield.yml for configuration defaults and documentation.
+ *
+ * @var array
+ */
+ protected $bffConfig = array(
+ /**
+ * Show the data-icon
+ *
+ * @var boolean
+ */
+ 'dataIcon' => true,
/**
- * Show the data-input
- *
- * @var boolean
- */
- 'dataInput' => true,
+ * Show the data-input
+ *
+ * @var boolean
+ */
+ 'dataInput' => true,
/**
- * Button Class
- *
- * @var boolean
- */
- 'dataButtonName' => 'btn btn-primary',
+ * Button Class
+ *
+ * @var boolean
+ */
+ 'dataButtonName' => 'btn btn-primary',
/**
- * Button Class
- *
- * @var boolean
- */
- 'dataSize' => 'md',
+ * Button Class
+ *
+ * @var boolean
+ */
+ 'dataSize' => 'md',
/**
- * Button Class
- *
- * @var boolean
- */
- 'dataIconName' => 'glyphicon-folder-open'
- );
+ * Button Class
+ *
+ * @var boolean
+ */
+ 'dataIconName' => 'glyphicon-folder-open'
+ );
- /**
- * Assign a front-end config variable for the upload field
- *
- * @see https://github.com/blueimp/jQuery-File-Upload/wiki/Options for the list of front end options available
- *
- * @param string $key
- * @param mixed $val
- * @return UploadField self reference
- */
- public function setConfig($key, $val) {
- $this->bffConfig[$key] = $val;
- return $this;
- }
+ /**
+ * Assign a front-end config variable for the upload field
+ *
+ * @see https://github.com/blueimp/jQuery-File-Upload/wiki/Options for the list of front end options available
+ *
+ * @param string $key
+ * @param mixed $val
+ * @return UploadField self reference
+ */
+ public function setConfig($key, $val)
+ {
+ $this->bffConfig[$key] = $val;
+ return $this;
+ }
- /**
- * Gets a front-end config variable for the upload field
- *
- * @see https://github.com/blueimp/jQuery-File-Upload/wiki/Options for the list of front end options available
- *
- * @param string $key
- * @return mixed
- */
- public function getConfig($key) {
- if(!isset($this->bffConfig[$key])) return null;
- return $this->bffConfig[$key];
- }
+ /**
+ * Gets a front-end config variable for the upload field
+ *
+ * @see https://github.com/blueimp/jQuery-File-Upload/wiki/Options for the list of front end options available
+ *
+ * @param string $key
+ * @return mixed
+ */
+ public function getConfig($key)
+ {
+ if (!isset($this->bffConfig[$key])) {
+ return null;
+ }
+ return $this->bffConfig[$key];
+ }
- protected $button_title = null;
-
- /**
- * Returns the field label - used by templates.
- */
- public function ButtonTitle() {
- return $this->button_title;
- }
-
- public function setButtonTitle($val) {
- $this->button_title = $val;
- return $this;
- }
+ protected $button_title = null;
+
+ /**
+ * Returns the field label - used by templates.
+ */
+ public function ButtonTitle()
+ {
+ return $this->button_title;
+ }
+
+ public function setButtonTitle($val)
+ {
+ $this->button_title = $val;
+ return $this;
+ }
- public function __construct($name, $title = null, $value = null) {
-
- $this->bffConfig = array_merge($this->bffConfig, self::config()->defaultConfig);
+ public function __construct($name, $title = null, $value = null)
+ {
+ $this->bffConfig = array_merge($this->bffConfig, self::config()->defaultConfig);
- parent::__construct($name, $title, $value);
+ parent::__construct($name, $title, $value);
- // filter out '' since this would be a regex problem on JS end
- $this->getValidator()->setAllowedExtensions(
- array_filter(Config::inst()->get('File', 'allowed_extensions'))
- );
+ // filter out '' since this would be a regex problem on JS end
+ $this->getValidator()->setAllowedExtensions(
+ array_filter(Config::inst()->get('File', 'allowed_extensions'))
+ );
- $this->addExtraClass('filestyle');
- }
+ $this->addExtraClass('filestyle');
+ }
- public function Field($properties = array()) {
-
- $this->setAttribute('data-icon', $this->getConfig('dataIcon'));
+ public function Field($properties = array())
+ {
+ $this->setAttribute('data-icon', $this->getConfig('dataIcon'));
- $this->setAttribute('data-input', $this->getConfig('dataInput'));
+ $this->setAttribute('data-input', $this->getConfig('dataInput'));
- $this->setAttribute('data-ButtonName', $this->getConfig('dataButtonName'));
+ $this->setAttribute('data-ButtonName', $this->getConfig('dataButtonName'));
- $this->setAttribute('data-size', $this->getConfig('dataSize'));
+ $this->setAttribute('data-size', $this->getConfig('dataSize'));
- $this->setAttribute('data-IconName', $this->getConfig('dataIconName'));
+ $this->setAttribute('data-IconName', $this->getConfig('dataIconName'));
- // Set Button Title
- $this->setAttribute('data-buttonText', _t('BootstrapFileField.CHOOSEFILE', 'BootstrapFileField.CHOOSEFILE'));
+ // Set Button Title
+ $this->setAttribute('data-buttonText', _t('BootstrapFileField.CHOOSEFILE', 'BootstrapFileField.CHOOSEFILE'));
- // Overwrite Button Title
- if($this->button_title) $this->setAttribute('data-buttonText', $this->button_title);
+ // Overwrite Button Title
+ if ($this->button_title) {
+ $this->setAttribute('data-buttonText', $this->button_title);
+ }
- Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
- Requirements::javascript('bootstrap_extra_fields/javascript/bootstrap-filestyle.min.js');
+ Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
+ Requirements::javascript('bootstrap_extra_fields/javascript/bootstrap-filestyle.min.js');
// Fetch the Field Record
- if($this->form) $record = $this->form->getRecord();
- $fieldName = $this->name;
- if(isset($record)&&$record) {
- $fileField = $record->$fieldName();
- if($fileField && $fileField->exists()){
- if($fileField->hasMethod('Thumbnail') && $fileField->Thumbnail()) $Image = $fileField->Thumbnail()->getTag();
- else if($fileField->CMSThumbnail()) $Image = $fileField->CMSThumbnail();
- else $Image = false;
- }else{
- $Image = false;
- }
- }else{
- $Image = false;
- }
+ if ($this->form) {
+ $record = $this->form->getRecord();
+ }
+ $fieldName = $this->name;
+ if (isset($record)&&$record) {
+ $fileField = $record->$fieldName();
+ if ($fileField && $fileField->exists()) {
+ if ($fileField->hasMethod('Thumbnail') && $fileField->Thumbnail()) {
+ $Image = $fileField->Thumbnail()->getTag();
+ } elseif ($fileField->CMSThumbnail()) {
+ $Image = $fileField->CMSThumbnail();
+ } else {
+ $Image = false;
+ }
+ } else {
+ $Image = false;
+ }
+ } else {
+ $Image = false;
+ }
- $properties = array_merge($properties, array(
- 'MaxFileSize' => $this->getValidator()->getAllowedMaxFileSize(),
- 'Image' => $Image
- ));
+ $properties = array_merge($properties, array(
+ 'MaxFileSize' => $this->getValidator()->getAllowedMaxFileSize(),
+ 'Image' => $Image
+ ));
- return parent::Field($properties);
- }
+ return parent::Field($properties);
+ }
}
diff --git a/code/forms/BootstrapGeoLocationField.php b/code/forms/BootstrapGeoLocationField.php
index 4a88078..7d09ac3 100644
--- a/code/forms/BootstrapGeoLocationField.php
+++ b/code/forms/BootstrapGeoLocationField.php
@@ -5,31 +5,37 @@
* @package geoform
* @subpackage fields-formattedinput
*/
-class BootstrapGeoLocationField extends GeoLocationField {
-
- /**
- * @param string $name - Name of field
- * @return FormField
- */
- protected function FieldAddress($name) {
-
- $field = new TextField("{$name}[Address]");
-
- return $field;
- }
-
- public function Field($properties = array()) {
- Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
- Requirements::javascript('geoform/javascript/jquery.geocomplete.js');
+class BootstrapGeoLocationField extends GeoLocationField
+{
+
+ /**
+ * @param string $name - Name of field
+ * @return FormField
+ */
+ protected function FieldAddress($name)
+ {
+ $field = new TextField("{$name}[Address]");
+
+ return $field;
+ }
+
+ public function Field($properties = array())
+ {
+ Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
+ Requirements::javascript('geoform/javascript/jquery.geocomplete.js');
- if(GoogleMaps::getApiKey()) Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language='.i18n::get_tinymce_lang().'&key='.GoogleMaps::getApiKey()); // don't use Sensor on this Field
- else Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language='.i18n::get_tinymce_lang());
+ if (GoogleMaps::getApiKey()) {
+ Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language='.i18n::get_tinymce_lang().'&key='.GoogleMaps::getApiKey());
+ } // don't use Sensor on this Field
+ else {
+ Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language='.i18n::get_tinymce_lang());
+ }
- $name = $this->getName();
- $this->fieldAddress->setPlaceholder(_t('GeoLocationField.ADDRESSPLACEHOLDER', 'Address'));
-
- // set caption if required
- $js = <<
getName();
+ $this->fieldAddress->setPlaceholder(_t('GeoLocationField.ADDRESSPLACEHOLDER', 'Address'));
+
+ // set caption if required
+ $js = <<ID());
+ Requirements::customScript($js, 'BootstrapGeoLocationField_Js_'.$this->ID());
- $css = <<ID());
+ Requirements::customCSS($css, 'BootstrapGeoLocationField_Css_'.$this->ID());
- return $this->fieldLatitude->Field().
- $this->fieldLongditude->Field().
- ''.
- '
'.
- $this->fieldAddress->Field().
- '
'.
- '
';
- }
-}
\ No newline at end of file
+ return $this->fieldLatitude->Field().
+ $this->fieldLongditude->Field().
+ ''.
+ '
'.
+ $this->fieldAddress->Field().
+ '
'.
+ '
';
+ }
+}
diff --git a/code/forms/BootstrapHorizontalAjaxForm.php b/code/forms/BootstrapHorizontalAjaxForm.php
index 05483b9..0da0689 100644
--- a/code/forms/BootstrapHorizontalAjaxForm.php
+++ b/code/forms/BootstrapHorizontalAjaxForm.php
@@ -65,14 +65,16 @@
* @package bootstrap_extra_fields
* @subpackage forms
*/
-class BootstrapHorizontalAjaxForm extends BootstrapAjaxForm {
+class BootstrapHorizontalAjaxForm extends BootstrapAjaxForm
+{
- public function IsHorizontal(){
+ public function IsHorizontal()
+ {
return true;
}
- public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null){
-
+ public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null)
+ {
parent::__construct(
$controller,
$name,
@@ -81,11 +83,11 @@ public function __construct($controller, $name, FieldList $fields, FieldList $ac
$validator
);
- if(!Director::is_ajax()){
+ if (!Director::is_ajax()) {
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
Requirements::javascript('bootstrap_extra_fields/javascript/tooltip.js');
$this->setTemplate('BootstrapHorizontalAjaxForm')->addExtraClass('form-horizontal');
- }else{
+ } else {
$this->setTemplate('BootstrapHorizontalForm')->addExtraClass('form-horizontal');
}
}
diff --git a/code/forms/BootstrapHorizontalAjaxModalForm.php b/code/forms/BootstrapHorizontalAjaxModalForm.php
index 53929e2..1035df3 100644
--- a/code/forms/BootstrapHorizontalAjaxModalForm.php
+++ b/code/forms/BootstrapHorizontalAjaxModalForm.php
@@ -75,14 +75,16 @@
* @package bootstrap_extra_fields
* @subpackage forms
*/
-class BootstrapHorizontalAjaxModalForm extends BootstrapAjaxModalForm {
+class BootstrapHorizontalAjaxModalForm extends BootstrapAjaxModalForm
+{
- public function IsHorizontal(){
+ public function IsHorizontal()
+ {
return true;
}
- public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction){
-
+ public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction)
+ {
parent::__construct(
$controller,
$name,
@@ -93,13 +95,12 @@ public function __construct($controller, $name, FieldList $fields, FieldList $ac
$ModalFormAction
);
- if(Director::is_ajax()){
+ if (Director::is_ajax()) {
$this->setTemplate('BootstrapHorizontalAjaxModalForm')->addExtraClass('form-horizontal');
- }else{
+ } else {
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
Requirements::javascript('bootstrap_extra_fields/javascript/tooltip.js');
$this->setTemplate('BootstrapHorizontalModalForm')->addExtraClass('form-horizontal')->setLarge();
}
}
-
}
diff --git a/code/forms/BootstrapHorizontalForm.php b/code/forms/BootstrapHorizontalForm.php
index 7eed061..8b6cf11 100644
--- a/code/forms/BootstrapHorizontalForm.php
+++ b/code/forms/BootstrapHorizontalForm.php
@@ -25,14 +25,16 @@
* @package forms
* @subpackage fields-structural
*/
-class BootstrapHorizontalForm extends Form {
+class BootstrapHorizontalForm extends Form
+{
- public function IsHorizontal(){
+ public function IsHorizontal()
+ {
return true;
}
- public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null){
-
+ public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null)
+ {
parent::__construct(
$controller,
$name,
@@ -46,5 +48,4 @@ public function __construct($controller, $name, FieldList $fields, FieldList $ac
$this->setTemplate('BootstrapHorizontalForm')->addExtraClass('form-horizontal');
}
-
}
diff --git a/code/forms/BootstrapHorizontalModalForm.php b/code/forms/BootstrapHorizontalModalForm.php
index 79787cf..67d5504 100644
--- a/code/forms/BootstrapHorizontalModalForm.php
+++ b/code/forms/BootstrapHorizontalModalForm.php
@@ -19,14 +19,16 @@
* @package bootstrap_extra_fields
* @subpackage forms
*/
-class BootstrapHorizontalModalForm extends BootstrapModalForm {
+class BootstrapHorizontalModalForm extends BootstrapModalForm
+{
- public function IsHorizontal(){
+ public function IsHorizontal()
+ {
return true;
}
- public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction){
-
+ public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction)
+ {
parent::__construct(
$controller,
$name,
@@ -42,5 +44,4 @@ public function __construct($controller, $name, FieldList $fields, FieldList $ac
$this->setTemplate('BootstrapHorizontalModalForm')->addExtraClass('form-horizontal')->setLarge();
}
-
}
diff --git a/code/forms/BootstrapLoadingFormAction.php b/code/forms/BootstrapLoadingFormAction.php
index cae4b2b..81d2cc9 100644
--- a/code/forms/BootstrapLoadingFormAction.php
+++ b/code/forms/BootstrapLoadingFormAction.php
@@ -7,7 +7,8 @@
* @package forms
* @subpackage fields-formattedinput
*/
-class BootstrapLoadingFormAction extends FormAction {
+class BootstrapLoadingFormAction extends FormAction
+{
protected $sendingMessage;
@@ -19,23 +20,27 @@ class BootstrapLoadingFormAction extends FormAction {
* @param title The label on the button
* @param form The parent form, auto-set when the field is placed inside a form
*/
- public function __construct($action, $title = "", $form = null){
+ public function __construct($action, $title = "", $form = null)
+ {
parent::__construct($action, $title, $form);
$this->sendingMessage = _t('BootstrapLoadingFormAction.LOADING', 'BootstrapLoadingFormAction.LOADING');
}
- public function Field($properties = array()) {
+ public function Field($properties = array())
+ {
$this->setAttribute('onclick', "javascript:(function(that){setTimeout(function(){if(that.form.checkValidity()){that.disabled=true;that.innerHTML='" .$this->sendingMessage."';}},0);})(this);");
return parent::Field($properties);
}
- public function setSendingMessage($message){
+ public function setSendingMessage($message)
+ {
$this->sendingMessage = $message;
return $this;
}
- public function getSendingMessage(){
+ public function getSendingMessage()
+ {
return $this->sendingMessage;
}
}
diff --git a/code/forms/BootstrapLocationField.php b/code/forms/BootstrapLocationField.php
index 433c588..c73271c 100644
--- a/code/forms/BootstrapLocationField.php
+++ b/code/forms/BootstrapLocationField.php
@@ -5,42 +5,44 @@
* @package geoform
* @subpackage fields-formattedinput
*/
-class BootstrapLocationField extends LocationField {
-
- /**
- * @param string $name - Name of field
- * @return FormField
- */
- protected function FieldLatitude($name) {
-
- $field = new TextField("{$name}[Latitude]");
-
- return $field;
- }
-
- /**
- * @param string $name - Name of field
- * @return FormField
- */
- protected function FieldLongditude($name) {
-
- $field = new TextField("{$name}[Longditude]");
-
- return $field;
- }
-
- public function Field($properties = array()) {
- $name = $this->getName();
- $this->fieldLatitude->setPlaceholder(_t('GeoForm.FIELDLABELLATITUDE', 'Latitude'));
- $this->fieldLongditude->setPlaceholder(_t('GeoForm.FIELDLABELLONGDITUDE', 'Longditude'));
+class BootstrapLocationField extends LocationField
+{
+
+ /**
+ * @param string $name - Name of field
+ * @return FormField
+ */
+ protected function FieldLatitude($name)
+ {
+ $field = new TextField("{$name}[Latitude]");
+
+ return $field;
+ }
+
+ /**
+ * @param string $name - Name of field
+ * @return FormField
+ */
+ protected function FieldLongditude($name)
+ {
+ $field = new TextField("{$name}[Longditude]");
+
+ return $field;
+ }
+
+ public function Field($properties = array())
+ {
+ $name = $this->getName();
+ $this->fieldLatitude->setPlaceholder(_t('GeoForm.FIELDLABELLATITUDE', 'Latitude'));
+ $this->fieldLongditude->setPlaceholder(_t('GeoForm.FIELDLABELLONGDITUDE', 'Longditude'));
- return ''.
- '
'.
- $this->fieldLatitude->Field().
- '
'.
- '
'.
- $this->fieldLongditude->Field().
- '
'.
- '
';
- }
-}
\ No newline at end of file
+ return ''.
+ '
'.
+ $this->fieldLatitude->Field().
+ '
'.
+ '
'.
+ $this->fieldLongditude->Field().
+ '
'.
+ '
';
+ }
+}
diff --git a/code/forms/BootstrapModalForm.php b/code/forms/BootstrapModalForm.php
index 2ec35c6..55fda2b 100644
--- a/code/forms/BootstrapModalForm.php
+++ b/code/forms/BootstrapModalForm.php
@@ -19,38 +19,43 @@
* @package bootstrap_extra_fields
* @subpackage forms
*/
-class BootstrapModalForm extends Form {
+class BootstrapModalForm extends Form
+{
protected $ModalFormAction;
protected $title;
protected $size = 'normal';
- public function hasErrors(){
+ public function hasErrors()
+ {
$errorInfo = Session::get("FormInfo.{$this->FormName()}");
- if(isset($errorInfo['errors']) && is_array($errorInfo['errors'])){
+ if (isset($errorInfo['errors']) && is_array($errorInfo['errors'])) {
return true;
}
- if(isset($errorInfo['message']) && isset($errorInfo['type'])) {
+ if (isset($errorInfo['message']) && isset($errorInfo['type'])) {
return true;
}
return false;
}
- public function setTitle($title){
+ public function setTitle($title)
+ {
$this->title = $title;
return $this;
}
- public function getTitle(){
+ public function getTitle()
+ {
return $this->title;
}
- public function setSize($size = 'normal'){
- switch($size){
+ public function setSize($size = 'normal')
+ {
+ switch ($size) {
case 'large':
$this->size = 'large';
break;
@@ -66,23 +71,27 @@ public function setSize($size = 'normal'){
return $this;
}
- public function setLarge(){
+ public function setLarge()
+ {
$this->size = 'large';
return $this;
}
- public function setSmall(){
+ public function setSmall()
+ {
$this->size = 'small';
return $this;
}
- public function setNormal(){
+ public function setNormal()
+ {
$this->size = 'normal';
return $this;
}
- public function getSize(){
- switch($this->size){
+ public function getSize()
+ {
+ switch ($this->size) {
case 'large':
return 'modal-lg';
break;
@@ -97,8 +106,8 @@ public function getSize(){
}
}
- public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction){
-
+ public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction)
+ {
parent::__construct(
$controller,
$name,
@@ -112,7 +121,7 @@ public function __construct($controller, $name, FieldList $fields, FieldList $ac
$this->ModalFormAction = $ModalFormAction;
$this->ModalFormAction->setTarget("Modal_".$this->FormName());
- if($this->hasErrors()){
+ if ($this->hasErrors()) {
// set Modal open
$name = $this->FormName();
$js = <<setTemplate('BootstrapModalForm');
}
-
}
diff --git a/code/forms/BootstrapModalFormAction.php b/code/forms/BootstrapModalFormAction.php
index 73ea509..ad6772d 100644
--- a/code/forms/BootstrapModalFormAction.php
+++ b/code/forms/BootstrapModalFormAction.php
@@ -15,42 +15,47 @@
* @package forms
* @subpackage actions
*/
-class BootstrapModalFormAction extends FormAction {
+class BootstrapModalFormAction extends FormAction
+{
- protected $target;
-
- /**
- * Enables the use of