mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
(merged from branches/roa. use "svn log -c <changeset> -g <module-svn-path>" for detailed commit message)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@59969 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
aeab0115a0
commit
0365bc113f
@ -2146,5 +2146,4 @@ class DataObject extends ViewableData implements DataObjectInterface {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
@ -404,6 +404,13 @@ class Form extends ViewableData {
|
|||||||
return $this->class . '_' . str_replace('.', '', $this->name);
|
return $this->class . '_' . str_replace('.', '', $this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this form's controller
|
||||||
|
*/
|
||||||
|
function Controller() {
|
||||||
|
return $this->controller;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -412,12 +419,12 @@ class Form extends ViewableData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the field referenced by $_GET[fieldName].
|
* Returns an object where there is a method with the same name as each data field on the form.
|
||||||
* Used for embedding entire extra helper forms inside complex field types (such as ComplexTableField)
|
* That method will return the field itself.
|
||||||
* @return FormField The field referenced by $_GET[fieldName]
|
* It means that you can execute $firstNameField = $form->FieldMap()->FirstName(), which can be handy
|
||||||
*/
|
*/
|
||||||
function ReferencedField() {
|
function FieldMap() {
|
||||||
return $this->dataFieldByName($_GET['fieldName']);
|
return new Form_FieldMap($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -854,3 +861,16 @@ class Form extends ViewableData {
|
|||||||
return $this->testSubmission($action, $data);
|
return $this->testSubmission($action, $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Form_FieldMap extends Object {
|
||||||
|
protected $form;
|
||||||
|
|
||||||
|
function __construct($form) {
|
||||||
|
$this->form = $form;
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
function __call($method, $args = null) {
|
||||||
|
return $this->form->dataFieldByName($method);
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
class FormAction extends FormField {
|
class FormAction extends FormField {
|
||||||
protected $extraData;
|
protected $extraData;
|
||||||
|
protected $action;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new action button.
|
* Create a new action button.
|
||||||
@ -20,7 +21,8 @@ class FormAction extends FormField {
|
|||||||
function __construct($action, $title = "", $form = null, $extraData = null, $extraClass = '') {
|
function __construct($action, $title = "", $form = null, $extraData = null, $extraClass = '') {
|
||||||
$this->extraData = $extraData;
|
$this->extraData = $extraData;
|
||||||
$this->extraClass = ' '.$extraClass;
|
$this->extraClass = ' '.$extraClass;
|
||||||
parent::__construct("action_$action", $title, null, $form);
|
$this->action = "action_$action";
|
||||||
|
parent::__construct($this->action, $title, null, $form);
|
||||||
}
|
}
|
||||||
static function create($action, $title = "", $extraData = null, $extraClass = null) {
|
static function create($action, $title = "", $extraData = null, $extraClass = null) {
|
||||||
return new FormAction($action, $title, null, $extraData, $extraClass);
|
return new FormAction($action, $title, null, $extraData, $extraClass);
|
||||||
@ -29,6 +31,14 @@ class FormAction extends FormField {
|
|||||||
function actionName() {
|
function actionName() {
|
||||||
return substr($this->name,7);
|
return substr($this->name,7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the full action name, including action_
|
||||||
|
* This provides an opportunity to replace it with something else
|
||||||
|
*/
|
||||||
|
function setFullAction($fullAction) {
|
||||||
|
$this->action = $fullAction;
|
||||||
|
}
|
||||||
|
|
||||||
function extraData() {
|
function extraData() {
|
||||||
return $this->extraData;
|
return $this->extraData;
|
||||||
@ -36,7 +46,7 @@ class FormAction extends FormField {
|
|||||||
|
|
||||||
function Field() {
|
function Field() {
|
||||||
$titleAttr = $this->description ? "title=\"" . Convert::raw2att($this->description) . "\"" : '';
|
$titleAttr = $this->description ? "title=\"" . Convert::raw2att($this->description) . "\"" : '';
|
||||||
return "<input class=\"action " . $this->extraClass() . "\" id=\"" . $this->id() . "\" type=\"submit\" name=\"{$this->name}\" value=\"" . $this->attrTitle() . "\" $titleAttr />\n";
|
return "<input class=\"action " . $this->extraClass() . "\" id=\"" . $this->id() . "\" type=\"submit\" name=\"$this->action\" value=\"" . $this->attrTitle() . "\" $titleAttr />\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -458,6 +458,16 @@ HTML;
|
|||||||
user_error('FormField::setExtraClass() is deprecated. Use FormField::addExtraClass() instead.', E_USER_NOTICE);
|
user_error('FormField::setExtraClass() is deprecated. Use FormField::addExtraClass() instead.', E_USER_NOTICE);
|
||||||
$this->extraClasses[] = $extraClass;
|
$this->extraClasses[] = $extraClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns a link used to specify a controller in a form action.
|
||||||
|
* This lets us use FormFields as controllers.
|
||||||
|
*/
|
||||||
|
function FormObjectLink($formName) {
|
||||||
|
return $this->form->Controller()->Link() . "?executeController=" . $this->form->Name() . ".FieldMap." . $this->Name() . "&executeForm=" . $formName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
28
forms/NestedForm.php
Normal file
28
forms/NestedForm.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a form decorator that lets you place a form inside another form.
|
||||||
|
* The actions will be appropriately rewritten so that the nested form gets called, rather than the parent form.
|
||||||
|
*/
|
||||||
|
class NestedForm extends ViewableData {
|
||||||
|
protected $form;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represent the given form in a tabular style
|
||||||
|
* @param form The form to decorate.
|
||||||
|
*/
|
||||||
|
function __construct(Form $form) {
|
||||||
|
$this->form = $form;
|
||||||
|
$this->failover = $form;
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
function Actions() {
|
||||||
|
$actions = $this->form->Actions();
|
||||||
|
foreach($actions as $action) {
|
||||||
|
$action->setFullAction('action_' . $action->actionName()
|
||||||
|
.'?formController=' . str_replace(array('?','.'), array('&','%2e'), $this->form->FormAction()) );
|
||||||
|
}
|
||||||
|
return $actions;
|
||||||
|
}
|
||||||
|
}
|
@ -957,13 +957,6 @@ JS
|
|||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a link by which we can access this form
|
|
||||||
*/
|
|
||||||
function FormObjectLink($formName) {
|
|
||||||
return $this->form->FormAction() . ".ReferencedField.$formName&fieldName={$this->Name()}";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Int
|
* @return Int
|
||||||
*/
|
*/
|
||||||
|
@ -5,15 +5,17 @@
|
|||||||
* @package forms
|
* @package forms
|
||||||
* @subpackage transformations
|
* @subpackage transformations
|
||||||
*/
|
*/
|
||||||
class TabularStyle extends Form {
|
class TabularStyle extends ViewableData {
|
||||||
protected $form;
|
protected $form;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represent the given form in a tabular style
|
* Represent the given form in a tabular style
|
||||||
* @param form The form to decorate.
|
* @param form The form to decorate.
|
||||||
*/
|
*/
|
||||||
function __construct(Form $form) {
|
function __construct($form) {
|
||||||
$this->form = $form;
|
$this->form = $form;
|
||||||
|
$this->failover = $form;
|
||||||
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,7 +44,7 @@ class TabularStyle extends Form {
|
|||||||
|
|
||||||
function CellActions() {
|
function CellActions() {
|
||||||
$actions = "";
|
$actions = "";
|
||||||
foreach($this->form->actions as $action) {
|
foreach($this->form->Actions() as $action) {
|
||||||
$actions .= $action->Field();
|
$actions .= $action->Field();
|
||||||
}
|
}
|
||||||
return $actions;
|
return $actions;
|
||||||
|
@ -128,7 +128,9 @@ class Member extends DataObject {
|
|||||||
* quirky problems (such as using the Windmill 0.3.6 proxy).
|
* quirky problems (such as using the Windmill 0.3.6 proxy).
|
||||||
*/
|
*/
|
||||||
static function session_regenerate_id() {
|
static function session_regenerate_id() {
|
||||||
if(!headers_sent()) session_regenerate_id(true);
|
$file = ""; $line = "";
|
||||||
|
if (!headers_sent($file, $line)) session_regenerate_id(true);
|
||||||
|
else user_error("Content already sent at line $line in $file, can't call session_regenerate_id", E_USER_WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user