mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merged from branches/2.3
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@75580 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
76b5adc979
commit
56fbe55a47
@ -63,7 +63,7 @@ class SapphireSoapServer extends Controller {
|
||||
fwrite($fh, $wsdl);
|
||||
fclose($fh);
|
||||
|
||||
$s = new SoapServer($wsdlFile);
|
||||
$s = new SoapServer($wsdlFile, array('cache_wsdl' => WSDL_CACHE_NONE));
|
||||
$s->setClass($this->class);
|
||||
$s->handle();
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* A redirector page redirects when the page is visited.
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage content
|
||||
*/
|
||||
class RedirectorPage extends Page {
|
||||
|
||||
static $add_action = "Redirector to another page";
|
||||
|
||||
static $icon = array("cms/images/treeicons/page-shortcut","file");
|
||||
|
||||
static $db = array(
|
||||
|
@ -194,6 +194,15 @@ abstract class DBField extends ViewableData {
|
||||
return Convert::raw2xml(strtolower($this->value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the current value for this Enum DBField to uppercase.
|
||||
* @return string
|
||||
*/
|
||||
function UpperCase() {
|
||||
return Convert::raw2xml(strtoupper($this->value));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value to be set in the database to blank this field.
|
||||
* Usually it's a choice between null, 0, and ''
|
||||
|
@ -21,6 +21,13 @@
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* popup */
|
||||
.ComplexTableField_ItemRequest_Popup {
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* table */
|
||||
.ComplexTableField {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ class FunctionalTest extends SapphireTest {
|
||||
foreach($expectedMatches as $match) {
|
||||
if(!isset($actuals[$match])) {
|
||||
throw new PHPUnit_Framework_AssertionFailedError(
|
||||
"Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "'\n\n"
|
||||
"Failed asserting the CSS selector '$selector' has a partial match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "'\n\n"
|
||||
. "Instead the following elements were found:\n'" . implode("'\n'", array_keys($actuals)) . "'"
|
||||
);
|
||||
return false;
|
||||
@ -217,7 +217,7 @@ class FunctionalTest extends SapphireTest {
|
||||
foreach($expectedMatches as $match) {
|
||||
if(!isset($actuals[$match])) {
|
||||
throw new PHPUnit_Framework_AssertionFailedError(
|
||||
"Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "'\n\n"
|
||||
"Failed asserting the CSS selector '$selector' has a partial match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "'\n\n"
|
||||
. "Instead the following elements were found:\n'" . implode("'\n'", array_keys($actuals)) . "'"
|
||||
);
|
||||
return false;
|
||||
|
@ -117,6 +117,8 @@ class ConfirmedPasswordField extends FormField {
|
||||
}
|
||||
|
||||
foreach($this->children as $field) {
|
||||
$field->setDisabled($this->isDisabled());
|
||||
$field->setReadonly($this->isReadonly());
|
||||
$content .= $field->FieldHolder();
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ Behaviour.register({
|
||||
if(!el || !el.value) return true;
|
||||
|
||||
var value = \$F(el);
|
||||
if(value.length > 0 && !value.match(/^\\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\$/)) {
|
||||
if(value.length > 0 && !value.match(/^\s*\\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*\$/)) {
|
||||
validationError(el,"$error","validation",false);
|
||||
return false;
|
||||
}
|
||||
@ -71,7 +71,7 @@ JS;
|
||||
}
|
||||
|
||||
function validate($validator) {
|
||||
if(!empty ($this->value) && !preg_match('/^\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $this->value)) {
|
||||
if(!empty ($this->value) && !preg_match('/^\s*\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*$/', $this->value)) {
|
||||
$validator->validationError($this->name, _t('Form.VALIDCURRENCY', "Please enter a valid currency."), "validation", false);
|
||||
return false;
|
||||
}
|
||||
|
@ -172,7 +172,8 @@ class FieldSet extends DataObjectSet {
|
||||
}
|
||||
|
||||
foreach($this->items as $i => $child) {
|
||||
if(is_object($child) && ($child->Name() == $fieldName || $child->Title() == $fieldName) && (!$dataFieldOnly || $child->hasData())) {
|
||||
if(is_object($child)){
|
||||
if(($child->Name() == $fieldName || $child->Title() == $fieldName) && (!$dataFieldOnly || $child->hasData())) {
|
||||
array_splice( $this->items, $i, 1 );
|
||||
break;
|
||||
} else if($child->isComposite()) {
|
||||
@ -180,6 +181,7 @@ class FieldSet extends DataObjectSet {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace a single field with another. Ignores dataless fields such as Tabs and TabSets
|
||||
|
@ -58,6 +58,11 @@ class FormField extends RequestHandler {
|
||||
*/
|
||||
protected $disabled = false;
|
||||
|
||||
/**
|
||||
* @var Custom Validation Message for the Field
|
||||
*/
|
||||
protected $customValidationMessage = "";
|
||||
|
||||
/**
|
||||
* Create a new field.
|
||||
* @param name The internal field name, passed to forms.
|
||||
@ -309,6 +314,29 @@ class FormField extends RequestHandler {
|
||||
$this->messageType = $messageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the custom error message to show instead of the default
|
||||
* format of Please Fill In XXX. Different from setError() as
|
||||
* that appends it to the standard error messaging
|
||||
*
|
||||
* @param String Message for the error
|
||||
*/
|
||||
public function setCustomValidationMessage($msg) {
|
||||
$this->customValidationMessage = $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom error message for this form field. If a custom
|
||||
* message has not been defined then just return blank. The default
|
||||
* error is defined on {@link Validator}.
|
||||
*
|
||||
* @todo Should the default error message be stored here instead
|
||||
* @return String
|
||||
*/
|
||||
public function getCustomValidationMessage() {
|
||||
return $this->customValidationMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the form field - used by templates.
|
||||
* Although FieldHolder is generally what is inserted into templates, all of the field holder
|
||||
|
@ -17,7 +17,7 @@ Behaviour.register({
|
||||
el = _CURRENT_FORM.elements[fieldName];
|
||||
if(!el || !el.value) return true;
|
||||
|
||||
if(el.value.match(/^([0-9]+(\.[0-9]+)?$)/)) {
|
||||
if(el.value.match(/^\s*([0-9]+(\.[0-9]+)?\s*$)/)) {
|
||||
return true;
|
||||
} else {
|
||||
validationError(el, "'" + el.value + "' $error","validation");
|
||||
@ -43,7 +43,7 @@ JS;
|
||||
|
||||
/** PHP Validation **/
|
||||
function validate($validator){
|
||||
if($this->value && !is_numeric($this->value)){
|
||||
if($this->value && !is_numeric(trim($this->value))){
|
||||
$validator->validationError(
|
||||
$this->name,
|
||||
sprintf(
|
||||
|
@ -25,13 +25,15 @@ class PasswordField extends FormField {
|
||||
|
||||
|
||||
function Field() {
|
||||
$disabled = $this->isDisabled()?"disabled=\"disabled\"":"";
|
||||
$readonly = $this->isReadonly()?"readonly=\"readonly\"":"";
|
||||
if($this->maxLength) {
|
||||
return "<input class=\"text\" type=\"password\" id=\"" . $this->id() .
|
||||
"\" name=\"{$this->name}\" value=\"" . $this->attrValue() .
|
||||
"\" maxlength=\"$this->maxLength\" size=\"$this->maxLength\"/>";
|
||||
"\" maxlength=\"$this->maxLength\" size=\"$this->maxLength\" $disabled $readonly />";
|
||||
} else {
|
||||
return "<input class=\"text\" type=\"password\" id=\"" . $this->id() .
|
||||
"\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" />";
|
||||
"\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" $disabled $readonly />";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,12 @@
|
||||
* Submit an array of arguments or each field as a
|
||||
* seperate argument. Validation is performed on a name by
|
||||
* name basis.
|
||||
*
|
||||
* @package forms
|
||||
* @subpackage validators
|
||||
*/
|
||||
class RequiredFields extends Validator {
|
||||
|
||||
protected $required;
|
||||
protected $useLabels = true;
|
||||
|
||||
@ -99,12 +101,13 @@ JS;
|
||||
foreach($this->required as $fieldName) {
|
||||
$formField = $fields->dataFieldByName($fieldName);
|
||||
if($formField && !$data[$fieldName]) {
|
||||
$errorMessage = sprintf(_t('Form.FIELDISREQUIRED').'.', strip_tags('"' . ($formField->Title() ? $formField->Title() : $fieldName) . '"'));
|
||||
if($msg = $formField->getCustomValidationMessage()) {
|
||||
$errorMessage = $msg;
|
||||
}
|
||||
$this->validationError(
|
||||
$fieldName,
|
||||
sprintf(
|
||||
_t('Form.FIELDISREQUIRED').'.',
|
||||
strip_tags('"' . ($formField->Title() ? $formField->Title() : $fieldName) . '"')
|
||||
),
|
||||
$errorMessage,
|
||||
"required"
|
||||
);
|
||||
$valid = false;
|
||||
|
@ -8,21 +8,6 @@
|
||||
class ResetFormAction extends FormAction {
|
||||
|
||||
function Field() {
|
||||
if($this->useButtonTag) {
|
||||
$attributes = array(
|
||||
'class' => 'action' . ($this->extraClass() ? $this->extraClass() : ''),
|
||||
'id' => $this->id(),
|
||||
'type' => 'reset',
|
||||
'name' => $this->action
|
||||
);
|
||||
|
||||
if($this->isReadonly()) {
|
||||
$attributes['disabled'] = 'disabled';
|
||||
$attributes['class'] = $attributes['class'] . ' disabled';
|
||||
}
|
||||
|
||||
return $this->createTag('button', $attributes, $this->attrTitle());
|
||||
} else {
|
||||
$attributes = array(
|
||||
'class' => 'action' . ($this->extraClass() ? $this->extraClass() : ''),
|
||||
'id' => $this->id(),
|
||||
@ -37,8 +22,11 @@ class ResetFormAction extends FormAction {
|
||||
|
||||
$attributes['title'] = ($this->description) ? $this->description : ($this->dontEscape) ? $this->Title() : $this->attrTitle();
|
||||
|
||||
return $this->createTag('input', $attributes);
|
||||
if($this->useButtonTag) {
|
||||
return $this->createTag('button', $attributes, $this->attrTitle());
|
||||
}
|
||||
|
||||
return $this->createTag('input', $attributes);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ class SimpleImageField extends FileField {
|
||||
public $allowedExtensions = array('jpg','gif','png');
|
||||
|
||||
function Field() {
|
||||
$record = $this->form->getRecord();
|
||||
if($this->form) $record = $this->form->getRecord();
|
||||
$fieldName = $this->name;
|
||||
if($record) {
|
||||
if(isset($record)&&$record) {
|
||||
$imageField = $record->$fieldName();
|
||||
} else {
|
||||
$imageField = "";
|
||||
@ -47,7 +47,8 @@ class SimpleImageField extends FileField {
|
||||
"type" => "file",
|
||||
"name" => $this->name,
|
||||
"id" => $this->id(),
|
||||
"tabindex" => $this->getTabIndex()
|
||||
"tabindex" => $this->getTabIndex(),
|
||||
'disabled' => $this->disabled
|
||||
)
|
||||
);
|
||||
$html .= $this->createTag("input",
|
||||
|
Loading…
Reference in New Issue
Block a user