DOCS Fixing docs (and bad API usage)

This commit is contained in:
Daniel Hensby 2015-06-20 11:11:08 +01:00
parent 230094e65a
commit 79c4f63855
15 changed files with 93 additions and 26 deletions

View File

@ -120,7 +120,7 @@ class ConfirmedPasswordField extends FormField {
/**
* @param array $properties
*
* @return string
* @return HTMLText
*/
public function Field($properties = array()) {
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');

View File

@ -31,6 +31,8 @@ class DatalessField extends FormField {
/**
* Returns the field's representation in the form.
* For dataless fields, this defaults to $Field.
*
* @return HTMLText
*/
public function FieldHolder($properties = array()) {
return $this->Field($properties);

View File

@ -88,7 +88,10 @@ class DatetimeField extends FormField {
return $this;
}
/**
* @param array $properties
* @return HTMLText
*/
public function FieldHolder($properties = array()) {
$config = array(
'datetimeorder' => $this->getConfig('datetimeorder'),
@ -100,14 +103,19 @@ class DatetimeField extends FormField {
return parent::FieldHolder($properties);
}
/**
* @param array $properties
* @return HTMLText
*/
public function Field($properties = array()) {
Requirements::css(FRAMEWORK_DIR . '/css/DatetimeField.css');
$tzField = ($this->getConfig('usertimezone')) ? $this->timezoneField->FieldHolder() : '';
return $this->dateField->FieldHolder() .
return DBField::create_field('HTMLText', $this->dateField->FieldHolder() .
$this->timeField->FieldHolder() .
$tzField .
'<div class="clear"><!-- --></div>';
'<div class="clear"><!-- --></div>'
);
}
/**

View File

@ -128,6 +128,10 @@ class DropdownField extends FormField {
parent::__construct($name, ($title===null) ? $name : $title, $value, $form);
}
/**
* @param array $properties
* @return HTMLText
*/
public function Field($properties = array()) {
$source = $this->getSource();
$options = array();

View File

@ -83,6 +83,10 @@ class FileField extends FormField {
parent::__construct($name, $title, $value);
}
/**
* @param array $properties
* @return HTMLText
*/
public function Field($properties = array()) {
$properties = array_merge($properties, array(
'MaxFileSize' => $this->getValidator()->getAllowedMaxFileSize()

View File

@ -49,7 +49,7 @@ class FormAction extends FormField {
public function __construct($action, $title = "", $form = null) {
$this->action = "action_$action";
$this->setForm($form);
parent::__construct($this->action, $title);
}
@ -74,6 +74,10 @@ class FormAction extends FormField {
return $this;
}
/**
* @param array $properties
* @return HTMLText
*/
public function Field($properties = array()) {
$properties = array_merge(
$properties,
@ -87,6 +91,10 @@ class FormAction extends FormField {
return parent::Field($properties);
}
/**
* @param array $properties
* @return HTMLText
*/
public function FieldHolder($properties = array()) {
return $this->Field($properties);
}

View File

@ -10,7 +10,7 @@ class HiddenField extends FormField {
/**
* @param array $properties
*
* @return string
* @return HTMLText
*/
public function FieldHolder($properties = array()) {
return $this->Field($properties);

View File

@ -27,14 +27,25 @@ class InlineFormAction extends FormField {
return $this->castedCopy('InlineFormAction_ReadOnly');
}
/**
* @param array $properties
* @return HTMLText
*/
public function Field($properties = array()) {
if($this->includeDefaultJS) {
Requirements::javascriptTemplate(FRAMEWORK_DIR . '/javascript/InlineFormAction.js',
array('ID'=>$this->id()));
}
return "<input type=\"submit\" name=\"action_{$this->name}\" value=\"{$this->title}\" id=\"{$this->id()}\""
. " class=\"action{$this->extraClass}\" />";
return DBField::create_field(
'HTMLText',
FormField::create('input', array(
'name' => sprintf('action_%s', $this->getName()),
'value' => $this->title,
'id' => $this->ID(),
'class' => sprintf('action%s', $this->extraClass),
))
);
}
public function Title() {
@ -61,9 +72,21 @@ class InlineFormAction_ReadOnly extends FormField {
protected $readonly = true;
/**
* @param array $properties
* @return HTMLText
*/
public 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\" />";
return DBField::create_field('HTMLText',
FormField::create_tag('input', array(
'type' => 'submit',
'name' => sprintf('action_%s', $this->name),
'value' => $this->title,
'id' => $this->id(),
'disabled' => 'disabled',
'class' => 'action disabled ' . $this->extraClass,
))
);
}
public function Title() {

View File

@ -41,13 +41,16 @@ class MoneyField extends FormField {
}
/**
* @return string
* @param array
* @return HTMLText
*/
public function Field($properties = array()) {
return "<div class=\"fieldgroup\">" .
return DBField::create_field('HTMLText',
"<div class=\"fieldgroup\">" .
"<div class=\"fieldgroup-field\">" . $this->fieldCurrency->SmallFieldHolder() . "</div>" .
"<div class=\"fieldgroup-field\">" . $this->fieldAmount->SmallFieldHolder() . "</div>" .
"</div>";
"</div>"
);
}
/**

View File

@ -42,7 +42,6 @@ class NullableField extends FormField {
*/
protected $isNullLabel;
/**
* Create a new nullable field
*
@ -103,7 +102,7 @@ class NullableField extends FormField {
/**
* @param array $properties
*
* @return string
* @return HTMLText
*/
public function Field($properties = array()) {
if($this->isReadonly()) {
@ -114,12 +113,12 @@ class NullableField extends FormField {
$nullableCheckbox->setValue(is_null($this->dataValue()));
return sprintf(
return DBField::create_field('HTMLText', sprintf(
'%s %s&nbsp;<span>%s</span>',
$this->valueField->Field(),
$nullableCheckbox->Field(),
$this->getIsNullLabel()
);
));
}
/**

View File

@ -27,6 +27,10 @@ class PhoneNumberField extends FormField {
parent::__construct($name, $title, $value);
}
/**
* @param array $properties
* @return FieldGroup|HTMLText
*/
public function Field($properties = array()) {
$fields = new FieldGroup( $this->name );
$fields->setID("{$this->name}_Holder");

View File

@ -36,6 +36,10 @@ class ReadonlyField extends FormField {
return clone $this;
}
/**
* @param array $properties
* @return HTMLText
*/
public function Field($properties = array()) {
// Include a hidden field in the HTML
if($this->includeHiddenField && $this->readonly) {

View File

@ -204,7 +204,7 @@ class TreeDropdownField extends FormField {
}
/**
* @return string
* @return HTMLText
*/
public function Field($properties = array()) {
Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/javascript/lang');

View File

@ -279,7 +279,7 @@ class GridField extends FormField {
*
* @param array $properties
*
* @return string
* @return HTMLText
*/
public function FieldHolder($properties = array()) {
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
@ -501,11 +501,11 @@ class GridField extends FormField {
$header . "\n" . $footer . "\n" . $body
);
return FormField::create_tag(
return DBField::create_field('HTMLText', FormField::create_tag(
'fieldset',
$fieldsetAttributes,
$content['before'] . $table . $content['after']
);
));
}
/**
@ -589,7 +589,7 @@ class GridField extends FormField {
/**
* @param array $properties
*
* @return string
* @return HTMLText
*/
public function Field($properties = array()) {
return $this->FieldHolder($properties);

View File

@ -71,6 +71,10 @@ class PermissionCheckboxSetField extends FormField {
return $this->hiddenPermissions;
}
/**
* @param array $properties
* @return HTMLText
*/
public function Field($properties = array()) {
Requirements::css(FRAMEWORK_DIR . '/css/CheckboxSetField.css');
Requirements::javascript(FRAMEWORK_DIR . '/javascript/PermissionCheckboxSetField.js');
@ -227,7 +231,8 @@ class PermissionCheckboxSetField extends FormField {
}
}
if($this->readonly) {
return "<ul id=\"{$this->id()}\" class=\"optionset checkboxsetfield{$this->extraClass()}\">\n" .
return DBField::create_field('HTMLText',
"<ul id=\"{$this->id()}\" class=\"optionset checkboxsetfield{$this->extraClass()}\">\n" .
"<li class=\"help\">" .
_t(
'Permissions.UserPermissionsIntro',
@ -236,11 +241,14 @@ class PermissionCheckboxSetField extends FormField {
) .
"</li>" .
$options .
"</ul>\n";
"</ul>\n"
);
} else {
return "<ul id=\"{$this->id()}\" class=\"optionset checkboxsetfield{$this->extraClass()}\">\n" .
return DBField::create_field('HTMLText',
"<ul id=\"{$this->id()}\" class=\"optionset checkboxsetfield{$this->extraClass()}\">\n" .
$options .
"</ul>\n";
"</ul>\n"
);
}
}