mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #299 from ajoneil/sapphire
--- Conflicts: forms/NumericField.php
This commit is contained in:
commit
6cd91ff449
@ -122,7 +122,7 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
* @return SS_HTTPResponse The response that this controller produces,
|
||||
* including HTTP headers such as redirection info
|
||||
*/
|
||||
function handleRequest(SS_HTTPRequest $request, DataModel $model = null) {
|
||||
function handleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||
if(!$request) user_error("Controller::handleRequest() not passed a request!", E_USER_ERROR);
|
||||
|
||||
$this->pushCurrent();
|
||||
|
@ -220,7 +220,7 @@ class Debug {
|
||||
),
|
||||
SS_Log::NOTICE
|
||||
);
|
||||
|
||||
|
||||
if(Director::isDev()) {
|
||||
self::showError($errno, $errstr, $errfile, $errline, $errcontext, "Notice");
|
||||
}
|
||||
@ -699,6 +699,7 @@ function errorHandler($errno, $errstr, $errfile, $errline) {
|
||||
case E_USER_NOTICE:
|
||||
case E_DEPRECATED:
|
||||
case E_USER_DEPRECATED:
|
||||
case E_STRICT:
|
||||
Debug::noticeHandler($errno, $errstr, $errfile, $errline, null);
|
||||
break;
|
||||
}
|
||||
|
@ -53,6 +53,10 @@ class DebugView extends Object {
|
||||
E_USER_WARNING => array(
|
||||
'title' => 'User Warning',
|
||||
'class' => 'warning'
|
||||
),
|
||||
E_STRICT => array(
|
||||
'title' => 'Strict Notice',
|
||||
'class' => 'notice'
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -28,7 +28,7 @@ class AjaxUniqueTextField extends TextField {
|
||||
parent::__construct($name, $title, $value);
|
||||
}
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/prototype/prototype.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/behaviour/behaviour.js");
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
|
@ -133,11 +133,6 @@ class CheckboxSetField extends OptionsetField {
|
||||
return $this->customise($properties)->renderWith($this->getTemplate());
|
||||
}
|
||||
|
||||
function setDisabled($val) {
|
||||
$this->disabled = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default selections, regardless of the {@link setValue()} settings.
|
||||
* Note: Items marked as disabled through {@link setDisabledItems()} can still be
|
||||
@ -180,7 +175,7 @@ class CheckboxSetField extends OptionsetField {
|
||||
*
|
||||
* @param DataObject $record The record to save into
|
||||
*/
|
||||
function saveInto(DataObject $record) {
|
||||
function saveInto(DataObjectInterface $record) {
|
||||
$fieldname = $this->name;
|
||||
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
|
||||
if($fieldname && $record && $relation && $relation instanceof RelationList) {
|
||||
|
@ -206,7 +206,7 @@ class ComplexTableField extends TableListField {
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
function FieldHolder() {
|
||||
function FieldHolder($properties = array()) {
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/prototype/prototype.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/behaviour/behaviour.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/greybox/AmiJS.js");
|
||||
|
@ -134,7 +134,7 @@ class CompositeField extends FormField {
|
||||
);
|
||||
}
|
||||
|
||||
public function Field() {
|
||||
public function Field($properties = array()) {
|
||||
$content = '';
|
||||
|
||||
if($this->tag == 'fieldset' && $this->legend) {
|
||||
@ -158,7 +158,7 @@ class CompositeField extends FormField {
|
||||
/**
|
||||
* Returns the fields nested inside another DIV
|
||||
*/
|
||||
function FieldHolder() {
|
||||
function FieldHolder($properties = array()) {
|
||||
$content = '';
|
||||
|
||||
if($this->tag == 'fieldset' && $this->legend) {
|
||||
|
@ -93,7 +93,7 @@ class ConfirmedPasswordField extends FormField {
|
||||
$this->setValue($value);
|
||||
}
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/ConfirmedPasswordField.js');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/ConfirmedPasswordField.css');
|
||||
@ -286,7 +286,7 @@ class ConfirmedPasswordField extends FormField {
|
||||
* @param DataObject $record
|
||||
* @return bool
|
||||
*/
|
||||
function saveInto(DataObject $record) {
|
||||
function saveInto(DataObjectInterface $record) {
|
||||
if(!$this->isSaveable()) return false;
|
||||
|
||||
if(!($this->canBeEmpty && !$this->value)) {
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
class CreditCardField extends TextField {
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$parts = $this->value;
|
||||
if(!is_array($parts)) $parts = explode("\n", chunk_split($parts,4,"\n"));
|
||||
$parts = array_pad($parts, 4, "");
|
||||
|
@ -67,7 +67,7 @@ class CurrencyField_Readonly extends ReadonlyField{
|
||||
/**
|
||||
* overloaded to display the correctly formated value for this datatype
|
||||
*/
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
if($this->value){
|
||||
$val = $this->dontEscape ? $this->value : Convert::raw2xml($this->value);
|
||||
$val = _t('CurrencyField.CURRENCYSYMBOL', '$') . number_format(preg_replace('/[^0-9.]/',"",$val), 2);
|
||||
@ -100,7 +100,7 @@ class CurrencyField_Disabled extends CurrencyField{
|
||||
/**
|
||||
* overloaded to display the correctly formated value for this datatype
|
||||
*/
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
if($this->value){
|
||||
$val = $this->dontEscape ? $this->value : Convert::raw2xml($this->value);
|
||||
$val = _t('CurrencyField.CURRENCYSYMBOL', '$') . number_format(preg_replace('/[^0-9.]/',"",$val), 2);
|
||||
|
@ -32,8 +32,8 @@ class DatalessField extends FormField {
|
||||
* Returns the field's representation in the form.
|
||||
* For dataless fields, this defaults to $Field.
|
||||
*/
|
||||
function FieldHolder() {
|
||||
return $this->Field();
|
||||
function FieldHolder($properties = array()) {
|
||||
return $this->Field($properties);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,7 +110,7 @@ class DateField extends TextField {
|
||||
parent::__construct($name, $title, $value);
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
function FieldHolder($properties = array()) {
|
||||
// TODO Replace with properly extensible view helper system
|
||||
$d = DateField_View_JQuery::create($this);
|
||||
$d->onBeforeRender();
|
||||
@ -120,7 +120,7 @@ class DateField extends TextField {
|
||||
return $html;
|
||||
}
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$config = array(
|
||||
'showcalendar' => $this->getConfig('showcalendar'),
|
||||
'isoDateformat' => $this->getConfig('dateformat'),
|
||||
@ -425,7 +425,7 @@ class DateField_Disabled extends DateField {
|
||||
|
||||
protected $disabled = true;
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
if($this->valueObj) {
|
||||
if($this->valueObj->isToday()) {
|
||||
$val = Convert::raw2xml($this->valueObj->toString($this->getConfig('dateformat')) . ' ('._t('DateField.TODAY','today').')');
|
||||
|
@ -74,17 +74,17 @@ class DatetimeField extends FormField {
|
||||
return $this;
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
function FieldHolder($properties = array()) {
|
||||
$config = array(
|
||||
'datetimeorder' => $this->getConfig('datetimeorder'),
|
||||
);
|
||||
$config = array_filter($config);
|
||||
$this->addExtraClass(Convert::raw2json($config));
|
||||
|
||||
return parent::FieldHolder();
|
||||
return parent::FieldHolder($properties);
|
||||
}
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/DatetimeField.css');
|
||||
|
||||
$tzField = ($this->getConfig('usertimezone')) ? $this->timezoneField->FieldHolder() : '';
|
||||
@ -287,7 +287,7 @@ class DatetimeField_Readonly extends DatetimeField {
|
||||
|
||||
protected $readonly = true;
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$valDate = $this->dateField->dataValue();
|
||||
$valTime = $this->timeField->dataValue();
|
||||
if($valDate && $valTime) {
|
||||
|
@ -238,12 +238,4 @@ class DropdownField extends FormField {
|
||||
$field->setReadonly(true);
|
||||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set form being disabled
|
||||
*/
|
||||
function setDisabled($disabled = true) {
|
||||
$this->disabled = $disabled;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class FieldGroup extends CompositeField {
|
||||
* @todo Shouldn't use SmallFieldHolder() (very difficult to style),
|
||||
* it is easier to overwrite the <div class="field"> behaviour in a more specific class
|
||||
*/
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$fs = $this->FieldList();
|
||||
$spaceZebra = isset($this->zebra) ? " fieldgroup-$this->zebra" : '';
|
||||
$idAtt = isset($this->id) ? " id=\"{$this->id}\"" : '';
|
||||
@ -131,7 +131,7 @@ class FieldGroup extends CompositeField {
|
||||
return $this;
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
function FieldHolder($properties = array()) {
|
||||
$Title = $this->XML_val('Title');
|
||||
$Message = $this->XML_val('Message');
|
||||
$MessageType = $this->XML_val('MessageType');
|
||||
|
@ -123,7 +123,7 @@ class FileField extends FormField {
|
||||
);
|
||||
}
|
||||
|
||||
public function saveInto(DataObject $record) {
|
||||
public function saveInto(DataObjectInterface $record) {
|
||||
if(!isset($_FILES[$this->name])) return false;
|
||||
$fileClass = File::get_class_for_file_extension(pathinfo($_FILES[$this->name]['name'], PATHINFO_EXTENSION));
|
||||
|
||||
|
@ -60,7 +60,7 @@ class FileIFrameField extends FileField {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Field() {
|
||||
public function Field($properties = array()) {
|
||||
Deprecation::notice('3.0', 'Use UploadField');
|
||||
|
||||
Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css');
|
||||
|
@ -70,8 +70,8 @@ class FormAction extends FormField {
|
||||
return $this->customise($properties)->renderWith($this->getTemplate());
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
return $this->Field();
|
||||
function FieldHolder($properties = array()) {
|
||||
return $this->Field($properties);
|
||||
}
|
||||
|
||||
public function Type() {
|
||||
|
@ -39,7 +39,7 @@
|
||||
*/
|
||||
class GroupedDropdownField extends DropdownField {
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$options = '';
|
||||
foreach($this->getSource() as $value => $title) {
|
||||
if(is_array($title)) {
|
||||
|
@ -64,8 +64,8 @@ class HasManyComplexTableField extends ComplexTableField {
|
||||
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
$ret = parent::FieldHolder();
|
||||
function FieldHolder($properties = array()) {
|
||||
$ret = parent::FieldHolder($properties);
|
||||
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/HasManyFileField.js");
|
||||
@ -87,7 +87,7 @@ class HasManyComplexTableField extends ComplexTableField {
|
||||
return $this->controller->ID;
|
||||
}
|
||||
|
||||
function saveInto(DataObject $record) {
|
||||
function saveInto(DataObjectInterface $record) {
|
||||
$fieldName = $this->name;
|
||||
$saveDest = $record->$fieldName();
|
||||
|
||||
|
@ -47,7 +47,7 @@ class HasOneComplexTableField extends HasManyComplexTableField {
|
||||
return $this->controller->{$this->joinField};
|
||||
}
|
||||
|
||||
function saveInto(DataObject $record) {
|
||||
function saveInto(DataObjectInterface $record) {
|
||||
$fieldName = $this->name;
|
||||
$fieldNameID = $fieldName . 'ID';
|
||||
|
||||
|
@ -8,8 +8,8 @@ class HiddenField extends FormField {
|
||||
|
||||
protected $template = 'HiddenField';
|
||||
|
||||
function FieldHolder() {
|
||||
return $this->Field();
|
||||
function FieldHolder($properties = array()) {
|
||||
return $this->Field($properties);
|
||||
}
|
||||
|
||||
function performReadonlyTransformation() {
|
||||
|
@ -56,7 +56,7 @@ class HtmlEditorField extends TextareaField {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
// mark up broken links
|
||||
$value = new SS_HTMLValue($this->value);
|
||||
|
||||
@ -96,7 +96,7 @@ class HtmlEditorField extends TextareaField {
|
||||
);
|
||||
}
|
||||
|
||||
public function saveInto($record) {
|
||||
public function saveInto(DataObjectInterface $record) {
|
||||
if($record->escapeTypeForField($this->name) != 'xml') {
|
||||
throw new Exception (
|
||||
'HtmlEditorField->saveInto(): This field should save into a HTMLText or HTMLVarchar field.'
|
||||
@ -221,7 +221,7 @@ class HtmlEditorField extends TextareaField {
|
||||
* @subpackage fields-formattedinput
|
||||
*/
|
||||
class HtmlEditorField_Readonly extends ReadonlyField {
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$valforInput = $this->value ? Convert::raw2att($this->value) : "";
|
||||
return "<span class=\"readonly typography\" id=\"" . $this->id() . "\">" . ( $this->value && $this->value != '<p></p>' ? $this->value : '<i>(not set)</i>' ) . "</span><input type=\"hidden\" name=\"".$this->name."\" value=\"".$valforInput."\" />";
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class ImageFormAction extends FormAction {
|
||||
parent::__construct($action, $title, $form);
|
||||
}
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/ImageFormAction.js');
|
||||
|
||||
|
@ -27,7 +27,7 @@ class InlineFormAction extends FormField {
|
||||
return new InlineFormAction_ReadOnly( $this->name, $this->title );
|
||||
}
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
if($this->includeDefaultJS) {
|
||||
Requirements::javascriptTemplate(SAPPHIRE_DIR . '/javascript/InlineFormAction.js',array('ID'=>$this->id()));
|
||||
}
|
||||
@ -59,7 +59,7 @@ class InlineFormAction_ReadOnly extends FormField {
|
||||
|
||||
protected $readonly = true;
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
return "<input type=\"submit\" name=\"action_{$this->name}\" value=\"{$this->title}\" id=\"{$this->id()}\" disabled=\"disabled\" class=\"action disabled$this->extraClass\" />";
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ class ListboxField extends DropdownField {
|
||||
*
|
||||
* @param DataObject $record The record to save into
|
||||
*/
|
||||
function saveInto(DataObject $record) {
|
||||
function saveInto(DataObjectInterface $record) {
|
||||
if($this->multiple) {
|
||||
$fieldname = $this->name;
|
||||
$relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null;
|
||||
|
@ -27,12 +27,19 @@ class LiteralField extends DatalessField {
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
return is_object($this->content) ? $this->content->forTemplate() : $this->content;
|
||||
function FieldHolder($properties = array()) {
|
||||
if(is_object($this->content)) {
|
||||
$obj = $this->content;
|
||||
if($properties)
|
||||
$obj = $obj->customise($properties);
|
||||
return $obj->forTemplate();
|
||||
} else {
|
||||
return $this->content;
|
||||
}
|
||||
}
|
||||
|
||||
function Field() {
|
||||
return $this->FieldHolder();
|
||||
function Field($properties = array()) {
|
||||
return $this->FieldHolder($properties);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,7 +12,7 @@ class LookupField extends DropdownField {
|
||||
/**
|
||||
* Returns a readonly span containing the correct value.
|
||||
*/
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$source = $this->getSource();
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
class MemberDatetimeOptionsetField extends OptionsetField {
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$options = '';
|
||||
$odd = 0;
|
||||
$source = $this->getSource();
|
||||
|
@ -43,7 +43,7 @@ class MoneyField extends FormField {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
return "<div class=\"fieldgroup\">" .
|
||||
"<div class=\"fieldgroupField\">" . $this->fieldCurrency->SmallFieldHolder() . "</div>" .
|
||||
"<div class=\"fieldgroupField\">" . $this->fieldAmount->SmallFieldHolder() . "</div>" .
|
||||
@ -100,7 +100,7 @@ class MoneyField extends FormField {
|
||||
*
|
||||
* (see @link MoneyFieldTest_CustomSetter_Object for more information)
|
||||
*/
|
||||
function saveInto($dataObject) {
|
||||
function saveInto(DataObjectInterface $dataObject) {
|
||||
$fieldName = $this->name;
|
||||
if($dataObject->hasMethod("set$fieldName")) {
|
||||
$dataObject->$fieldName = DBField::create_field('Money', array(
|
||||
|
@ -76,7 +76,7 @@ class NullableField extends FormField {
|
||||
* (non-PHPdoc)
|
||||
* @see sapphire/forms/FormField#Field()
|
||||
*/
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
if ( $this->isReadonly()) {
|
||||
$nullableCheckbox = new CheckboxField_Readonly($this->getIsNullId());
|
||||
} else {
|
||||
|
@ -26,7 +26,7 @@ class PhoneNumberField extends FormField {
|
||||
parent::__construct($name, $title, $value);
|
||||
}
|
||||
|
||||
public function Field() {
|
||||
public function Field($properties = array()) {
|
||||
$fields = new FieldGroup( $this->name );
|
||||
$fields->setID("{$this->name}_Holder");
|
||||
list($countryCode, $areaCode, $phoneNumber, $extension) = $this->parseValue();
|
||||
@ -103,8 +103,7 @@ class PhoneNumberField extends FormField {
|
||||
return $parts;
|
||||
}
|
||||
|
||||
public function saveInto( $record ) {
|
||||
|
||||
public function saveInto(DataObjectInterface $record) {
|
||||
list( $countryCode, $areaCode, $phoneNumber, $extension ) = $this->parseValue();
|
||||
$fieldName = $this->name;
|
||||
|
||||
|
@ -25,7 +25,7 @@ class PrintableTransformation_TabSet extends TabSet {
|
||||
CompositeField::__construct($tabs);
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
function FieldHolder($properties = array()) {
|
||||
// This gives us support for sub-tabs.
|
||||
$tag = ($this->tabSet) ? "h2>" : "h1>";
|
||||
|
||||
|
@ -85,12 +85,14 @@ class SelectionGroup extends CompositeField {
|
||||
return true;
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
function FieldHolder($properties = array()) {
|
||||
Requirements::javascript(THIRDPARTY_DIR .'/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/SelectionGroup.js');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/SelectionGroup.css');
|
||||
|
||||
$obj = $properties ? $this->customise($properties) : $this;
|
||||
|
||||
return $this->renderWith($this->template);
|
||||
return $obj->renderWith($this->template);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ class SimpleImageField extends FileField {
|
||||
$this->getValidator()->setAllowedExtensions(array('jpg','gif','png'));
|
||||
}
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
if($this->form) $record = $this->form->getRecord();
|
||||
$fieldName = $this->name;
|
||||
if(isset($record)&&$record) {
|
||||
@ -141,7 +141,7 @@ class SimpleImageField_Disabled extends FormField {
|
||||
|
||||
protected $readonly = true;
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$record = $this->form->getRecord();
|
||||
$fieldName = $this->name;
|
||||
|
||||
|
@ -69,7 +69,7 @@ class TabSet extends CompositeField {
|
||||
* Returns a tab-strip and the associated tabs.
|
||||
* The HTML is a standardised format, containing a <ul;
|
||||
*/
|
||||
public function FieldHolder() {
|
||||
public function FieldHolder($properties = array()) {
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-cookie/jquery.cookie.js');
|
||||
@ -80,7 +80,8 @@ class TabSet extends CompositeField {
|
||||
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TabSet.js');
|
||||
|
||||
return $this->renderWith($this->template);
|
||||
$obj = $properties ? $this->customise($properties) : $this;
|
||||
return $obj->renderWith($this->template);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -231,7 +231,7 @@ class TableField extends TableListField {
|
||||
/**
|
||||
* Saves the Dataobjects contained in the field
|
||||
*/
|
||||
function saveInto(DataObject $record) {
|
||||
function saveInto(DataObjectInterface $record) {
|
||||
// CMS sometimes tries to set the value to one.
|
||||
if(is_array($this->value)){
|
||||
$newFields = array();
|
||||
@ -463,7 +463,7 @@ class TableField extends TableListField {
|
||||
/**
|
||||
* Sets the template to be rendered with
|
||||
*/
|
||||
function FieldHolder() {
|
||||
function FieldHolder($properties = array()) {
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/prototype/prototype.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
|
||||
@ -472,7 +472,8 @@ class TableField extends TableListField {
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableField.js');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/TableListField.css');
|
||||
|
||||
return $this->renderWith($this->template);
|
||||
$obj = $properties ? $this->customise($properties) : $this;
|
||||
return $obj->renderWith($this->template);
|
||||
}
|
||||
|
||||
function setTransformationConditions($conditions) {
|
||||
|
@ -278,7 +278,7 @@ class TableListField extends FormField {
|
||||
return new TableListField_ItemRequest($this, $request->param('ID'));
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
function FieldHolder($properties = array()) {
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
|
||||
@ -299,7 +299,9 @@ class TableListField extends FormField {
|
||||
});
|
||||
JS
|
||||
);}
|
||||
return $this->renderWith($this->template);
|
||||
|
||||
$obj = $properties ? $this->customise($properties) : $this;
|
||||
return $obj->renderWith($this->template);
|
||||
}
|
||||
|
||||
function Headings() {
|
||||
|
@ -63,13 +63,13 @@ class TimeField extends TextField {
|
||||
parent::__construct($name,$title,$value);
|
||||
}
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$config = array(
|
||||
'timeformat' => $this->getConfig('timeformat')
|
||||
);
|
||||
$config = array_filter($config);
|
||||
$this->addExtraClass(Convert::raw2json($config));
|
||||
return parent::Field();
|
||||
return parent::Field($properties);
|
||||
}
|
||||
|
||||
function Type() {
|
||||
@ -206,7 +206,7 @@ class TimeField_Readonly extends TimeField {
|
||||
|
||||
protected $readonly = true;
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
if($this->valueObj) {
|
||||
$val = Convert::raw2xml($this->valueObj->toString($this->getConfig('timeformat')));
|
||||
} else {
|
||||
|
@ -22,12 +22,13 @@ class ToggleCompositeField extends CompositeField {
|
||||
parent::__construct($children);
|
||||
}
|
||||
|
||||
public function FieldHolder() {
|
||||
public function FieldHolder($properties = array()) {
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ToggleCompositeField.js");
|
||||
|
||||
return $this->renderWith($this->template);
|
||||
$obj = $properties ? $this->customise($properties) : $this;
|
||||
return $obj->renderWith($this->template);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ class ToggleField extends ReadonlyField {
|
||||
parent::__construct($name, $title, $value);
|
||||
}
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$content = '';
|
||||
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
|
||||
|
@ -78,7 +78,7 @@ class TreeMultiselectField extends TreeDropdownField {
|
||||
* We overwrite the field attribute to add our hidden fields, as this
|
||||
* formfield can contain multiple values.
|
||||
*/
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||
@ -132,7 +132,7 @@ class TreeMultiselectField extends TreeDropdownField {
|
||||
* Calls function $record->onChange($items) before saving to the assummed
|
||||
* Component set.
|
||||
*/
|
||||
function saveInto(DataObject $record) {
|
||||
function saveInto(DataObjectInterface $record) {
|
||||
// Detect whether this field has actually been updated
|
||||
if($this->value !== 'unchanged') {
|
||||
$items = array();
|
||||
@ -178,7 +178,7 @@ class TreeMultiselectField_Readonly extends TreeMultiselectField {
|
||||
|
||||
protected $readonly = true;
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$titleArray = $itemIDs = array();
|
||||
$titleList = $itemIDsList = "";
|
||||
if($items = $this->getItems()) {
|
||||
|
@ -310,7 +310,7 @@ class UploadField extends FileField {
|
||||
);
|
||||
}
|
||||
|
||||
public function Field() {
|
||||
public function Field($properties = array()) {
|
||||
$record = $this->getRecord();
|
||||
$name = $this->getName();
|
||||
|
||||
|
@ -289,7 +289,7 @@ class GridField extends FormField {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function FieldHolder() {
|
||||
public function FieldHolder($properties = array()) {
|
||||
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/GridField.css');
|
||||
|
||||
@ -448,8 +448,8 @@ class GridField extends FormField {
|
||||
);
|
||||
}
|
||||
|
||||
public function Field() {
|
||||
return $this->FieldHolder();
|
||||
public function Field($properties = array()) {
|
||||
return $this->FieldHolder($properties);
|
||||
}
|
||||
|
||||
public function getAttributes() {
|
||||
|
@ -596,7 +596,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
if(!array_key_exists($k, $customFields)) continue;
|
||||
|
||||
$dbObj = ($v instanceof DBField) ? $v : $this->dbObject($k);
|
||||
$isEmpty = ($isEmpty && !$dbObj->hasValue());
|
||||
$isEmpty = ($isEmpty && !$dbObj->exists());
|
||||
}
|
||||
}
|
||||
return $isEmpty;
|
||||
@ -3346,7 +3346,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
function hasValue($field, $arguments = null, $cache = true) {
|
||||
$obj = $this->dbObject($field);
|
||||
if($obj) {
|
||||
return $obj->hasValue();
|
||||
return $obj->exists();
|
||||
} else {
|
||||
return parent::hasValue($field, $arguments, $cache);
|
||||
}
|
||||
|
@ -177,6 +177,6 @@ interface CompositeDBField {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function hasValue();
|
||||
function exists();
|
||||
|
||||
}
|
@ -120,6 +120,7 @@ abstract class DBField extends ViewableData {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines if the field has a value which
|
||||
* is not considered to be 'null' in
|
||||
@ -127,15 +128,8 @@ abstract class DBField extends ViewableData {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function hasValue() {
|
||||
return ($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function exists() {
|
||||
return $this->hasValue();
|
||||
return ($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,7 +161,7 @@ abstract class DBField extends ViewableData {
|
||||
* @param array $manipulation
|
||||
*/
|
||||
function writeToManipulation(&$manipulation) {
|
||||
$manipulation['fields'][$this->name] = $this->hasValue() ? $this->prepValueForDB($this->value) : $this->nullValue();
|
||||
$manipulation['fields'][$this->name] = $this->exists() ? $this->prepValueForDB($this->value) : $this->nullValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,8 +128,8 @@ class HTMLText extends Text {
|
||||
return ShortcodeParser::get_active()->parse($this->value);
|
||||
}
|
||||
|
||||
public function hasValue() {
|
||||
return parent::hasValue() && $this->value != '<p></p>';
|
||||
public function exists() {
|
||||
return parent::exists() && $this->value != '<p></p>';
|
||||
}
|
||||
|
||||
public function scaffoldFormField($title = null, $params = null) {
|
||||
|
@ -14,8 +14,8 @@ class HTMLVarchar extends Varchar {
|
||||
return ShortcodeParser::get_active()->parse($this->value);
|
||||
}
|
||||
|
||||
public function hasValue() {
|
||||
return parent::hasValue() && $this->value != '<p></p>';
|
||||
public function exists() {
|
||||
return parent::exists() && $this->value != '<p></p>';
|
||||
}
|
||||
|
||||
public function scaffoldFormField($title = null, $params = null) {
|
||||
|
@ -102,7 +102,7 @@ class Money extends DBField implements CompositeDBField {
|
||||
|
||||
function setValue($value, $record = null, $markChanged = true) {
|
||||
// @todo Allow resetting value to NULL through Money $value field
|
||||
if ($value instanceof Money && $value->hasValue()) {
|
||||
if ($value instanceof Money && $value->exists()) {
|
||||
$this->setCurrency($value->getCurrency(), $markChanged);
|
||||
$this->setAmount($value->getAmount(), $markChanged);
|
||||
if($markChanged) $this->isChanged = true;
|
||||
@ -190,7 +190,7 @@ class Money extends DBField implements CompositeDBField {
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
function hasValue() {
|
||||
function exists() {
|
||||
return ($this->getCurrency() && is_numeric($this->getAmount()));
|
||||
}
|
||||
|
||||
|
@ -64,9 +64,9 @@ abstract class StringField extends DBField {
|
||||
|
||||
/**
|
||||
* (non-PHPdoc)
|
||||
* @see core/model/fieldtypes/DBField#hasValue()
|
||||
* @see core/model/fieldtypes/DBField#exists()
|
||||
*/
|
||||
function hasValue() {
|
||||
function exists() {
|
||||
return ($this->value || $this->value == '0') || ( !$this->nullifyEmpty && $this->value === '');
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class Varchar extends StringField {
|
||||
* Return the first letter of the string followed by a .
|
||||
*/
|
||||
function Initial() {
|
||||
if($this->hasValue()) return $this->value[0] . '.';
|
||||
if($this->exists()) return $this->value[0] . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +70,7 @@ class PermissionCheckboxSetField extends FormField {
|
||||
return $this->hiddenPermissions;
|
||||
}
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/CheckboxSetField.css');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
|
||||
|
||||
@ -215,7 +215,7 @@ class PermissionCheckboxSetField extends FormField {
|
||||
*
|
||||
* @param DataObject $record
|
||||
*/
|
||||
function saveInto(DataObject $record) {
|
||||
function saveInto(DataObjectInterface $record) {
|
||||
$fieldname = $this->name;
|
||||
$managedClass = $this->managedClass;
|
||||
|
||||
|
@ -157,42 +157,42 @@ class DBFieldTest extends SapphireTest {
|
||||
$this->assertEquals("00:00:00", $time->getValue());
|
||||
}
|
||||
|
||||
function testHasValue() {
|
||||
function testExists() {
|
||||
$varcharField = new Varchar("testfield");
|
||||
$this->assertTrue($varcharField->getNullifyEmpty());
|
||||
$varcharField->setValue('abc');
|
||||
$this->assertTrue($varcharField->hasValue());
|
||||
$this->assertTrue($varcharField->exists());
|
||||
$varcharField->setValue('');
|
||||
$this->assertFalse($varcharField->hasValue());
|
||||
$this->assertFalse($varcharField->exists());
|
||||
$varcharField->setValue(null);
|
||||
$this->assertFalse($varcharField->hasValue());
|
||||
$this->assertFalse($varcharField->exists());
|
||||
|
||||
$varcharField = new Varchar("testfield", 50, array('nullifyEmpty'=>false));
|
||||
$this->assertFalse($varcharField->getNullifyEmpty());
|
||||
$varcharField->setValue('abc');
|
||||
$this->assertTrue($varcharField->hasValue());
|
||||
$this->assertTrue($varcharField->exists());
|
||||
$varcharField->setValue('');
|
||||
$this->assertTrue($varcharField->hasValue());
|
||||
$this->assertTrue($varcharField->exists());
|
||||
$varcharField->setValue(null);
|
||||
$this->assertFalse($varcharField->hasValue());
|
||||
$this->assertFalse($varcharField->exists());
|
||||
|
||||
$textField = new Text("testfield");
|
||||
$this->assertTrue($textField->getNullifyEmpty());
|
||||
$textField->setValue('abc');
|
||||
$this->assertTrue($textField->hasValue());
|
||||
$this->assertTrue($textField->exists());
|
||||
$textField->setValue('');
|
||||
$this->assertFalse($textField->hasValue());
|
||||
$this->assertFalse($textField->exists());
|
||||
$textField->setValue(null);
|
||||
$this->assertFalse($textField->hasValue());
|
||||
$this->assertFalse($textField->exists());
|
||||
|
||||
$textField = new Text("testfield", array('nullifyEmpty'=>false));
|
||||
$this->assertFalse($textField->getNullifyEmpty());
|
||||
$textField->setValue('abc');
|
||||
$this->assertTrue($textField->hasValue());
|
||||
$this->assertTrue($textField->exists());
|
||||
$textField->setValue('');
|
||||
$this->assertTrue($textField->hasValue());
|
||||
$this->assertTrue($textField->exists());
|
||||
$textField->setValue(null);
|
||||
$this->assertFalse($textField->hasValue());
|
||||
$this->assertFalse($textField->exists());
|
||||
}
|
||||
|
||||
function testStringFieldsWithMultibyteData() {
|
||||
|
@ -207,23 +207,23 @@ class MoneyTest extends SapphireTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testHasValue() {
|
||||
function testExists() {
|
||||
$m1 = new Money();
|
||||
$this->assertFalse($m1->hasValue());
|
||||
$this->assertFalse($m1->exists());
|
||||
|
||||
$m2 = new Money();
|
||||
$m2->setValue(array(
|
||||
'Currency' => 'EUR',
|
||||
'Amount' => 3.44
|
||||
));
|
||||
$this->assertTrue($m2->hasValue());
|
||||
$this->assertTrue($m2->exists());
|
||||
|
||||
$m3 = new Money();
|
||||
$m3->setValue(array(
|
||||
'Currency' => 'EUR',
|
||||
'Amount' => 0
|
||||
));
|
||||
$this->assertTrue($m3->hasValue());
|
||||
$this->assertTrue($m3->exists());
|
||||
}
|
||||
|
||||
function testLoadIntoDataObject() {
|
||||
|
6
thirdparty/php-peg/Parser.php
vendored
6
thirdparty/php-peg/Parser.php
vendored
@ -269,16 +269,16 @@ class FalseOnlyPackrat extends Parser {
|
||||
* @author Hamish Friedlander
|
||||
*/
|
||||
class ConservativePackrat extends Parser {
|
||||
function packhas( $key ) {
|
||||
function packhas( $key, $pos ) {
|
||||
return isset( $this->packres[$key] ) && $this->packres[$key] !== NULL ;
|
||||
}
|
||||
|
||||
function packread( $key ) {
|
||||
function packread( $key, $pos ) {
|
||||
$this->pos = $this->packpos[$key];
|
||||
return $this->packres[$key] ;
|
||||
}
|
||||
|
||||
function packwrite( $key, $res ) {
|
||||
function packwrite( $key, $pos, $res ) {
|
||||
if ( isset( $this->packres[$key] ) ) {
|
||||
$this->packres[$key] = $res ;
|
||||
$this->packpos[$key] = $this->pos ;
|
||||
|
@ -719,7 +719,9 @@ class SSViewer {
|
||||
if(isset($this->chosenTemplates['main'])) {
|
||||
$template = $this->chosenTemplates['main'];
|
||||
} else {
|
||||
$template = $this->chosenTemplates[ reset($dummy = array_keys($this->chosenTemplates)) ];
|
||||
$keys = array_keys($this->chosenTemplates);
|
||||
$key = reset($keys);
|
||||
$template = $this->chosenTemplates[$key];
|
||||
}
|
||||
|
||||
if(isset($_GET['debug_profile'])) Profiler::mark("SSViewer::process", " for $template");
|
||||
|
Loading…
x
Reference in New Issue
Block a user