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);
|
fwrite($fh, $wsdl);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
|
|
||||||
$s = new SoapServer($wsdlFile);
|
$s = new SoapServer($wsdlFile, array('cache_wsdl' => WSDL_CACHE_NONE));
|
||||||
$s->setClass($this->class);
|
$s->setClass($this->class);
|
||||||
$s->handle();
|
$s->handle();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* A redirector page redirects when the page is visited.
|
* A redirector page redirects when the page is visited.
|
||||||
|
*
|
||||||
* @package cms
|
* @package cms
|
||||||
* @subpackage content
|
* @subpackage content
|
||||||
*/
|
*/
|
||||||
class RedirectorPage extends Page {
|
class RedirectorPage extends Page {
|
||||||
|
|
||||||
static $add_action = "Redirector to another page";
|
static $add_action = "Redirector to another page";
|
||||||
|
|
||||||
static $icon = array("cms/images/treeicons/page-shortcut","file");
|
static $icon = array("cms/images/treeicons/page-shortcut","file");
|
||||||
|
|
||||||
static $db = array(
|
static $db = array(
|
||||||
|
@ -192,7 +192,16 @@ abstract class DBField extends ViewableData {
|
|||||||
*/
|
*/
|
||||||
function LowerCase() {
|
function LowerCase() {
|
||||||
return Convert::raw2xml(strtolower($this->value));
|
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.
|
* Returns the value to be set in the database to blank this field.
|
||||||
|
@ -21,6 +21,13 @@
|
|||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* popup */
|
||||||
|
.ComplexTableField_ItemRequest_Popup {
|
||||||
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* table */
|
||||||
.ComplexTableField {
|
.ComplexTableField {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ class FunctionalTest extends SapphireTest {
|
|||||||
foreach($expectedMatches as $match) {
|
foreach($expectedMatches as $match) {
|
||||||
if(!isset($actuals[$match])) {
|
if(!isset($actuals[$match])) {
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
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)) . "'"
|
. "Instead the following elements were found:\n'" . implode("'\n'", array_keys($actuals)) . "'"
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
@ -217,7 +217,7 @@ class FunctionalTest extends SapphireTest {
|
|||||||
foreach($expectedMatches as $match) {
|
foreach($expectedMatches as $match) {
|
||||||
if(!isset($actuals[$match])) {
|
if(!isset($actuals[$match])) {
|
||||||
throw new PHPUnit_Framework_AssertionFailedError(
|
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)) . "'"
|
. "Instead the following elements were found:\n'" . implode("'\n'", array_keys($actuals)) . "'"
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
|
@ -117,6 +117,8 @@ class ConfirmedPasswordField extends FormField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->children as $field) {
|
foreach($this->children as $field) {
|
||||||
|
$field->setDisabled($this->isDisabled());
|
||||||
|
$field->setReadonly($this->isReadonly());
|
||||||
$content .= $field->FieldHolder();
|
$content .= $field->FieldHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ Behaviour.register({
|
|||||||
if(!el || !el.value) return true;
|
if(!el || !el.value) return true;
|
||||||
|
|
||||||
var value = \$F(el);
|
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);
|
validationError(el,"$error","validation",false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ JS;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validate($validator) {
|
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);
|
$validator->validationError($this->name, _t('Form.VALIDCURRENCY', "Please enter a valid currency."), "validation", false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -172,11 +172,13 @@ class FieldSet extends DataObjectSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->items as $i => $child) {
|
foreach($this->items as $i => $child) {
|
||||||
if(is_object($child) && ($child->Name() == $fieldName || $child->Title() == $fieldName) && (!$dataFieldOnly || $child->hasData())) {
|
if(is_object($child)){
|
||||||
array_splice( $this->items, $i, 1 );
|
if(($child->Name() == $fieldName || $child->Title() == $fieldName) && (!$dataFieldOnly || $child->hasData())) {
|
||||||
break;
|
array_splice( $this->items, $i, 1 );
|
||||||
} else if($child->isComposite()) {
|
break;
|
||||||
$child->removeByName($fieldName, $dataFieldOnly);
|
} else if($child->isComposite()) {
|
||||||
|
$child->removeByName($fieldName, $dataFieldOnly);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,11 @@ class FormField extends RequestHandler {
|
|||||||
*/
|
*/
|
||||||
protected $disabled = false;
|
protected $disabled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Custom Validation Message for the Field
|
||||||
|
*/
|
||||||
|
protected $customValidationMessage = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new field.
|
* Create a new field.
|
||||||
* @param name The internal field name, passed to forms.
|
* @param name The internal field name, passed to forms.
|
||||||
@ -309,6 +314,29 @@ class FormField extends RequestHandler {
|
|||||||
$this->messageType = $messageType;
|
$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.
|
* Returns the form field - used by templates.
|
||||||
* Although FieldHolder is generally what is inserted into templates, all of the field holder
|
* 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];
|
el = _CURRENT_FORM.elements[fieldName];
|
||||||
if(!el || !el.value) return true;
|
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;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
validationError(el, "'" + el.value + "' $error","validation");
|
validationError(el, "'" + el.value + "' $error","validation");
|
||||||
@ -43,7 +43,7 @@ JS;
|
|||||||
|
|
||||||
/** PHP Validation **/
|
/** PHP Validation **/
|
||||||
function validate($validator){
|
function validate($validator){
|
||||||
if($this->value && !is_numeric($this->value)){
|
if($this->value && !is_numeric(trim($this->value))){
|
||||||
$validator->validationError(
|
$validator->validationError(
|
||||||
$this->name,
|
$this->name,
|
||||||
sprintf(
|
sprintf(
|
||||||
|
@ -25,13 +25,15 @@ class PasswordField extends FormField {
|
|||||||
|
|
||||||
|
|
||||||
function Field() {
|
function Field() {
|
||||||
|
$disabled = $this->isDisabled()?"disabled=\"disabled\"":"";
|
||||||
|
$readonly = $this->isReadonly()?"readonly=\"readonly\"":"";
|
||||||
if($this->maxLength) {
|
if($this->maxLength) {
|
||||||
return "<input class=\"text\" type=\"password\" id=\"" . $this->id() .
|
return "<input class=\"text\" type=\"password\" id=\"" . $this->id() .
|
||||||
"\" name=\"{$this->name}\" value=\"" . $this->attrValue() .
|
"\" name=\"{$this->name}\" value=\"" . $this->attrValue() .
|
||||||
"\" maxlength=\"$this->maxLength\" size=\"$this->maxLength\"/>";
|
"\" maxlength=\"$this->maxLength\" size=\"$this->maxLength\" $disabled $readonly />";
|
||||||
} else {
|
} else {
|
||||||
return "<input class=\"text\" type=\"password\" id=\"" . $this->id() .
|
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
|
* Submit an array of arguments or each field as a
|
||||||
* seperate argument. Validation is performed on a name by
|
* seperate argument. Validation is performed on a name by
|
||||||
* name basis.
|
* name basis.
|
||||||
|
*
|
||||||
* @package forms
|
* @package forms
|
||||||
* @subpackage validators
|
* @subpackage validators
|
||||||
*/
|
*/
|
||||||
class RequiredFields extends Validator{
|
class RequiredFields extends Validator {
|
||||||
|
|
||||||
protected $required;
|
protected $required;
|
||||||
protected $useLabels = true;
|
protected $useLabels = true;
|
||||||
|
|
||||||
@ -99,12 +101,13 @@ JS;
|
|||||||
foreach($this->required as $fieldName) {
|
foreach($this->required as $fieldName) {
|
||||||
$formField = $fields->dataFieldByName($fieldName);
|
$formField = $fields->dataFieldByName($fieldName);
|
||||||
if($formField && !$data[$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(
|
$this->validationError(
|
||||||
$fieldName,
|
$fieldName,
|
||||||
sprintf(
|
$errorMessage,
|
||||||
_t('Form.FIELDISREQUIRED').'.',
|
|
||||||
strip_tags('"' . ($formField->Title() ? $formField->Title() : $fieldName) . '"')
|
|
||||||
),
|
|
||||||
"required"
|
"required"
|
||||||
);
|
);
|
||||||
$valid = false;
|
$valid = false;
|
||||||
|
@ -8,37 +8,25 @@
|
|||||||
class ResetFormAction extends FormAction {
|
class ResetFormAction extends FormAction {
|
||||||
|
|
||||||
function Field() {
|
function Field() {
|
||||||
if($this->useButtonTag) {
|
$attributes = array(
|
||||||
$attributes = array(
|
'class' => 'action' . ($this->extraClass() ? $this->extraClass() : ''),
|
||||||
'class' => 'action' . ($this->extraClass() ? $this->extraClass() : ''),
|
'id' => $this->id(),
|
||||||
'id' => $this->id(),
|
'type' => 'reset',
|
||||||
'type' => 'reset',
|
'name' => $this->action,
|
||||||
'name' => $this->action
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if($this->isReadonly()) {
|
if($this->isReadonly()) {
|
||||||
$attributes['disabled'] = 'disabled';
|
$attributes['disabled'] = 'disabled';
|
||||||
$attributes['class'] = $attributes['class'] . ' 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(),
|
|
||||||
'type' => 'reset',
|
|
||||||
'name' => $this->action,
|
|
||||||
);
|
|
||||||
|
|
||||||
if($this->isReadonly()) {
|
|
||||||
$attributes['disabled'] = 'disabled';
|
|
||||||
$attributes['class'] = $attributes['class'] . ' disabled';
|
|
||||||
}
|
|
||||||
|
|
||||||
$attributes['title'] = ($this->description) ? $this->description : ($this->dontEscape) ? $this->Title() : $this->attrTitle();
|
|
||||||
|
|
||||||
return $this->createTag('input', $attributes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$attributes['title'] = ($this->description) ? $this->description : ($this->dontEscape) ? $this->Title() : $this->attrTitle();
|
||||||
|
|
||||||
|
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');
|
public $allowedExtensions = array('jpg','gif','png');
|
||||||
|
|
||||||
function Field() {
|
function Field() {
|
||||||
$record = $this->form->getRecord();
|
if($this->form) $record = $this->form->getRecord();
|
||||||
$fieldName = $this->name;
|
$fieldName = $this->name;
|
||||||
if($record) {
|
if(isset($record)&&$record) {
|
||||||
$imageField = $record->$fieldName();
|
$imageField = $record->$fieldName();
|
||||||
} else {
|
} else {
|
||||||
$imageField = "";
|
$imageField = "";
|
||||||
@ -47,7 +47,8 @@ class SimpleImageField extends FileField {
|
|||||||
"type" => "file",
|
"type" => "file",
|
||||||
"name" => $this->name,
|
"name" => $this->name,
|
||||||
"id" => $this->id(),
|
"id" => $this->id(),
|
||||||
"tabindex" => $this->getTabIndex()
|
"tabindex" => $this->getTabIndex(),
|
||||||
|
'disabled' => $this->disabled
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$html .= $this->createTag("input",
|
$html .= $this->createTag("input",
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<tr class="notfound">
|
<tr class="notfound">
|
||||||
<% if Markable %><th width="18"> </th><% end_if %>
|
<% if Markable %><th width="18"> </th><% end_if %>
|
||||||
<td colspan="$Headings.Count"><i><% _t('NOITEMSFOUND', 'No items found') %></i></td>
|
<td colspan="$Headings.Count"><i><% _t('NOITEMSFOUND','No items found') %></i></td>
|
||||||
<% if Can(delete) %><td width="18"> </td><% end_if %>
|
<% if Can(delete) %><td width="18"> </td><% end_if %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
@ -78,4 +78,4 @@
|
|||||||
<span class="item"><a href="$Link">$Title</a></span>
|
<span class="item"><a href="$Link">$Title</a></span>
|
||||||
<% end_control %>
|
<% end_control %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user