Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions code/extensions/BootstrapExtraFieldsControllerExtension.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

class BootstrapExtraFieldsControllerExtension extends Extension {

public function onAfterInit(){
Requirements::javascript('bootstrap_extra_fields/javascript/tooltip.js');
}
class BootstrapExtraFieldsControllerExtension extends Extension
{

public function onAfterInit()
{
Requirements::javascript('bootstrap_extra_fields/javascript/tooltip.js');
}
}
7 changes: 4 additions & 3 deletions code/extensions/BootstrapFormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
class BootstrapFormExtension extends Extension {
class BootstrapFormExtension extends Extension
{

public function IsHorizontal(){
public function IsHorizontal()
{
return false;
}
}

10 changes: 6 additions & 4 deletions code/extensions/BootstrapFormFieldExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
class BootstrapFormFieldExtension extends Extension {
class BootstrapFormFieldExtension extends Extension
{

public function setPlaceholder($value){
public function setPlaceholder($value)
{
return $this->owner->setAttribute('placeholder', $value);
}

public function IsHorizontal(){
public function IsHorizontal()
{
return $this->owner->form->IsHorizontal();
}
}

21 changes: 13 additions & 8 deletions code/extensions/ExtendedDatetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@
* @package framework
* @subpackage model
*/
class ExtendedDatetime extends DataExtension {
class ExtendedDatetime extends DataExtension
{

protected $locale_formats = array(
'en_US' => 'm/d/Y g:i A', //
'de_DE' => 'd.m.Y H:i \U\h\r',
'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];
}
Expand All @@ -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));
}
}
}
}
13 changes: 7 additions & 6 deletions code/extensions/ExtendedDecimal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
62 changes: 35 additions & 27 deletions code/forms/BootstrapAjaxForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

}
62 changes: 35 additions & 27 deletions code/forms/BootstrapAjaxModalForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

}
26 changes: 14 additions & 12 deletions code/forms/BootstrapButtonCheckboxField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Loading