mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
Merge pull request #13 from helpfulrobot/convert-to-psr-2
Converted to PSR-2
This commit is contained in:
commit
13ea394f64
@ -1,275 +1,284 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class BasicFieldsTestPage extends TestPage {
|
class BasicFieldsTestPage extends TestPage
|
||||||
private static $db = array(
|
{
|
||||||
'Required' => 'Text',
|
private static $db = array(
|
||||||
'Validated' => 'Text',
|
'Required' => 'Text',
|
||||||
'Checkbox' => 'Boolean',
|
'Validated' => 'Text',
|
||||||
'Readonly' => 'Varchar',
|
'Checkbox' => 'Boolean',
|
||||||
'Textarea' => 'Text',
|
'Readonly' => 'Varchar',
|
||||||
'Text' => 'Varchar',
|
'Textarea' => 'Text',
|
||||||
'CalendarDate' => 'Date',
|
'Text' => 'Varchar',
|
||||||
'CompositeDate' => 'Date',
|
'CalendarDate' => 'Date',
|
||||||
'Date' => 'Date',
|
'CompositeDate' => 'Date',
|
||||||
'DMYCalendarDate' => 'Date',
|
'Date' => 'Date',
|
||||||
'DMYDate' => 'Date',
|
'DMYCalendarDate' => 'Date',
|
||||||
'DateTime' => 'Datetime',
|
'DMYDate' => 'Date',
|
||||||
'DateTimeWithCalendar' => 'Datetime',
|
'DateTime' => 'Datetime',
|
||||||
'Time' => 'Time',
|
'DateTimeWithCalendar' => 'Datetime',
|
||||||
'TimeWithDropdown' => 'Time',
|
'Time' => 'Time',
|
||||||
'Money' => 'Money',
|
'TimeWithDropdown' => 'Time',
|
||||||
'Number' => 'Int',
|
'Money' => 'Money',
|
||||||
'Price' => 'Double',
|
'Number' => 'Int',
|
||||||
'Email' => 'Varchar',
|
'Price' => 'Double',
|
||||||
'Password' => 'Varchar',
|
'Email' => 'Varchar',
|
||||||
'ConfirmedPassword' => 'Varchar',
|
'Password' => 'Varchar',
|
||||||
'HTMLField' => 'HTMLText',
|
'ConfirmedPassword' => 'Varchar',
|
||||||
'HTMLOneLine' => 'HTMLVarchar',
|
'HTMLField' => 'HTMLText',
|
||||||
'UniqueText' => 'Varchar',
|
'HTMLOneLine' => 'HTMLVarchar',
|
||||||
'AjaxUniqueText' => 'Varchar',
|
'UniqueText' => 'Varchar',
|
||||||
'UniqueRestrictedText' => 'Varchar',
|
'AjaxUniqueText' => 'Varchar',
|
||||||
'BankNumber' => 'Varchar',
|
'UniqueRestrictedText' => 'Varchar',
|
||||||
'PhoneNumber' => 'Varchar',
|
'BankNumber' => 'Varchar',
|
||||||
'Autocomplete' => 'Varchar',
|
'PhoneNumber' => 'Varchar',
|
||||||
'CreditCard' => 'Varchar',
|
'Autocomplete' => 'Varchar',
|
||||||
'GSTNumber' => 'Varchar',
|
'CreditCard' => 'Varchar',
|
||||||
'OptionSet' => 'Int',
|
'GSTNumber' => 'Varchar',
|
||||||
);
|
'OptionSet' => 'Int',
|
||||||
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Dropdown' => 'TestCategory',
|
'Dropdown' => 'TestCategory',
|
||||||
'GroupedDropdown' => 'TestCategory',
|
'GroupedDropdown' => 'TestCategory',
|
||||||
'ListboxField' => 'TestCategory',
|
'ListboxField' => 'TestCategory',
|
||||||
'File' => 'File',
|
'File' => 'File',
|
||||||
'AttachedFile' => 'File',
|
'AttachedFile' => 'File',
|
||||||
'Image' => 'Image',
|
'Image' => 'Image',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_many = array(
|
private static $has_many = array(
|
||||||
'HasManyFiles' => 'File',
|
'HasManyFiles' => 'File',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $many_many = array(
|
private static $many_many = array(
|
||||||
'ManyManyFiles' => 'File',
|
'ManyManyFiles' => 'File',
|
||||||
'MultipleListboxField' => 'TestCategory',
|
'MultipleListboxField' => 'TestCategory',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $defaults = array(
|
private static $defaults = array(
|
||||||
'Validated' => 2
|
'Validated' => 2
|
||||||
);
|
);
|
||||||
|
|
||||||
function requireDefaultRecords() {
|
public function requireDefaultRecords()
|
||||||
parent::requireDefaultRecords();
|
{
|
||||||
|
parent::requireDefaultRecords();
|
||||||
|
|
||||||
if($inst = DataObject::get_one('BasicFieldsTestPage')) {
|
if ($inst = DataObject::get_one('BasicFieldsTestPage')) {
|
||||||
$data = $this->getDefaultData();
|
$data = $this->getDefaultData();
|
||||||
$inst->update($data);
|
$inst->update($data);
|
||||||
$inst->write();
|
$inst->write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultData() {
|
public function getDefaultData()
|
||||||
$cats = TestCategory::get();
|
{
|
||||||
if(!$cats->Count()) return array(); // not initialized yet
|
$cats = TestCategory::get();
|
||||||
|
if (!$cats->Count()) {
|
||||||
|
return array();
|
||||||
|
} // not initialized yet
|
||||||
|
|
||||||
$firstCat = $cats->offsetGet(0);
|
$firstCat = $cats->offsetGet(0);
|
||||||
$thirdCat = $cats->offsetGet(2);
|
$thirdCat = $cats->offsetGet(2);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'Readonly' => 'My value (ä!)',
|
'Readonly' => 'My value (ä!)',
|
||||||
'Textarea' => 'My value (ä!)',
|
'Textarea' => 'My value (ä!)',
|
||||||
'Required' => 'My required value (delete to test)',
|
'Required' => 'My required value (delete to test)',
|
||||||
'Validated' => '1',
|
'Validated' => '1',
|
||||||
'Text' => 'My value (ä!)',
|
'Text' => 'My value (ä!)',
|
||||||
'Textarea' => 'My value (ä!)',
|
'Textarea' => 'My value (ä!)',
|
||||||
'HTMLField' => 'My value (ä!)',
|
'HTMLField' => 'My value (ä!)',
|
||||||
'Email' => 'test@test.com',
|
'Email' => 'test@test.com',
|
||||||
'Password' => 'My value (ä!)',
|
'Password' => 'My value (ä!)',
|
||||||
'Number' => 99,
|
'Number' => 99,
|
||||||
'Price' => 99.99,
|
'Price' => 99.99,
|
||||||
'MoneyAmount' => 99.99,
|
'MoneyAmount' => 99.99,
|
||||||
'MoneyCurrency' => 'EUR',
|
'MoneyCurrency' => 'EUR',
|
||||||
'PhoneNumber' => '021 1235',
|
'PhoneNumber' => '021 1235',
|
||||||
'CreditCard' => '4000400040004111',
|
'CreditCard' => '4000400040004111',
|
||||||
'Checkbox' => 1,
|
'Checkbox' => 1,
|
||||||
'CheckboxSetID' => $firstCat->ID,
|
'CheckboxSetID' => $firstCat->ID,
|
||||||
'DropdownID' => $firstCat->ID,
|
'DropdownID' => $firstCat->ID,
|
||||||
'GroupedDropdownID' => $firstCat->ID,
|
'GroupedDropdownID' => $firstCat->ID,
|
||||||
'ListboxFieldID' => $firstCat->ID,
|
'ListboxFieldID' => $firstCat->ID,
|
||||||
'MultipleListboxFieldID' => join(',', array($thirdCat->ID, $firstCat->ID)),
|
'MultipleListboxFieldID' => join(',', array($thirdCat->ID, $firstCat->ID)),
|
||||||
'OptionSet' => join(',', array($thirdCat->ID, $firstCat->ID)),
|
'OptionSet' => join(',', array($thirdCat->ID, $firstCat->ID)),
|
||||||
'Date' => "2002-10-23",
|
'Date' => "2002-10-23",
|
||||||
'CalendarDate' => "2002-10-23",
|
'CalendarDate' => "2002-10-23",
|
||||||
'DMYDate' => "2002-10-23",
|
'DMYDate' => "2002-10-23",
|
||||||
'Time' => "23:59",
|
'Time' => "23:59",
|
||||||
'TimeWithDropdown' => "23:59",
|
'TimeWithDropdown' => "23:59",
|
||||||
'DateTime' => "2002-10-23 23:59",
|
'DateTime' => "2002-10-23 23:59",
|
||||||
'DateTimeWithCalendar' => "2002-10-23 23:59",
|
'DateTimeWithCalendar' => "2002-10-23 23:59",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCMSFields() {
|
public function getCMSFields()
|
||||||
$fields = parent::getCMSFields();
|
{
|
||||||
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$description = 'This is <strong>bold</strong> help text';
|
$description = 'This is <strong>bold</strong> help text';
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Text', array(
|
$fields->addFieldsToTab('Root.Text', array(
|
||||||
Object::create('TextField', 'Required', 'Required field'),
|
Object::create('TextField', 'Required', 'Required field'),
|
||||||
Object::create('TextField', 'Validated', 'Validated field (checks range between 1 and 3)'),
|
Object::create('TextField', 'Validated', 'Validated field (checks range between 1 and 3)'),
|
||||||
Object::create('ReadonlyField', 'Readonly', 'ReadonlyField'),
|
Object::create('ReadonlyField', 'Readonly', 'ReadonlyField'),
|
||||||
Object::create('TextareaField', 'Textarea', 'TextareaField - 8 rows')
|
Object::create('TextareaField', 'Textarea', 'TextareaField - 8 rows')
|
||||||
->setRows(8),
|
->setRows(8),
|
||||||
Object::create('TextField', 'Text', 'TextField'),
|
Object::create('TextField', 'Text', 'TextField'),
|
||||||
Object::create('HtmlEditorField', 'HTMLField', 'HtmlEditorField'),
|
Object::create('HtmlEditorField', 'HTMLField', 'HtmlEditorField'),
|
||||||
Object::create('EmailField', 'Email', 'EmailField'),
|
Object::create('EmailField', 'Email', 'EmailField'),
|
||||||
Object::create('PasswordField', 'Password', 'PasswordField')
|
Object::create('PasswordField', 'Password', 'PasswordField')
|
||||||
));
|
));
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Numeric', array(
|
$fields->addFieldsToTab('Root.Numeric', array(
|
||||||
Object::create('NumericField', 'Number', 'NumericField'),
|
Object::create('NumericField', 'Number', 'NumericField'),
|
||||||
Object::create('CurrencyField', 'Price', 'CurrencyField'),
|
Object::create('CurrencyField', 'Price', 'CurrencyField'),
|
||||||
Object::create('MoneyField', 'Money', 'MoneyField', array('Amount' => 99.99, 'Currency' => 'EUR')),
|
Object::create('MoneyField', 'Money', 'MoneyField', array('Amount' => 99.99, 'Currency' => 'EUR')),
|
||||||
Object::create('PhoneNumberField', 'PhoneNumber', 'PhoneNumberField'),
|
Object::create('PhoneNumberField', 'PhoneNumber', 'PhoneNumberField'),
|
||||||
Object::create('CreditCardField', 'CreditCard', 'CreditCardField')
|
Object::create('CreditCardField', 'CreditCard', 'CreditCardField')
|
||||||
));
|
));
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Option', array(
|
$fields->addFieldsToTab('Root.Option', array(
|
||||||
Object::create('CheckboxField', 'Checkbox', 'CheckboxField'),
|
Object::create('CheckboxField', 'Checkbox', 'CheckboxField'),
|
||||||
Object::create('CheckboxSetField', 'CheckboxSet', 'CheckboxSetField', TestCategory::map()),
|
Object::create('CheckboxSetField', 'CheckboxSet', 'CheckboxSetField', TestCategory::map()),
|
||||||
Object::create('DropdownField', 'DropdownID', 'DropdownField', TestCategory::map())
|
Object::create('DropdownField', 'DropdownID', 'DropdownField', TestCategory::map())
|
||||||
->setHasEmptyDefault(true),
|
->setHasEmptyDefault(true),
|
||||||
Object::create('GroupedDropdownField', 'GroupedDropdownID',
|
Object::create('GroupedDropdownField', 'GroupedDropdownID',
|
||||||
'GroupedDropdown', array('Test Categorys' => TestCategory::map())
|
'GroupedDropdown', array('Test Categorys' => TestCategory::map())
|
||||||
),
|
),
|
||||||
Object::create('ListboxField', 'ListboxFieldID', 'ListboxField', TestCategory::map())
|
Object::create('ListboxField', 'ListboxFieldID', 'ListboxField', TestCategory::map())
|
||||||
->setSize(3),
|
->setSize(3),
|
||||||
Object::create('ListboxField', 'MultipleListboxFieldID', 'ListboxField (multiple)', TestCategory::map())
|
Object::create('ListboxField', 'MultipleListboxFieldID', 'ListboxField (multiple)', TestCategory::map())
|
||||||
->setMultiple(true)
|
->setMultiple(true)
|
||||||
->setSize(3),
|
->setSize(3),
|
||||||
Object::create('OptionsetField', 'OptionSet', 'OptionSetField', TestCategory::map()),
|
Object::create('OptionsetField', 'OptionSet', 'OptionSetField', TestCategory::map()),
|
||||||
Object::create('ToggleCompositeField', 'ToggleCompositeField', 'ToggleCompositeField', new FieldList(
|
Object::create('ToggleCompositeField', 'ToggleCompositeField', 'ToggleCompositeField', new FieldList(
|
||||||
Object::create('TextField', 'ToggleCompositeTextField1'),
|
Object::create('TextField', 'ToggleCompositeTextField1'),
|
||||||
Object::create('TextField', 'ToggleCompositeTextField2'),
|
Object::create('TextField', 'ToggleCompositeTextField2'),
|
||||||
Object::create('DropdownField', 'ToggleCompositeDropdownField', 'ToggleCompositeDropdownField', TestCategory::map()),
|
Object::create('DropdownField', 'ToggleCompositeDropdownField', 'ToggleCompositeDropdownField', TestCategory::map()),
|
||||||
Object::create('TextField', 'ToggleCompositeTextField3')
|
Object::create('TextField', 'ToggleCompositeTextField3')
|
||||||
))
|
))
|
||||||
));
|
));
|
||||||
|
|
||||||
// All these date/time fields generally have issues saving directly in the CMS
|
// All these date/time fields generally have issues saving directly in the CMS
|
||||||
$fields->addFieldsToTab('Root.DateTime', array(
|
$fields->addFieldsToTab('Root.DateTime', array(
|
||||||
$calendarDateField = Object::create('DateField', 'CalendarDate','DateField with calendar'),
|
$calendarDateField = Object::create('DateField', 'CalendarDate', 'DateField with calendar'),
|
||||||
Object::create('DateField', 'Date','DateField'),
|
Object::create('DateField', 'Date', 'DateField'),
|
||||||
$dmyDateField = Object::create('DateField', 'DMYDate','DateField with separate fields'),
|
$dmyDateField = Object::create('DateField', 'DMYDate', 'DateField with separate fields'),
|
||||||
Object::create('TimeField', 'Time','TimeField'),
|
Object::create('TimeField', 'Time', 'TimeField'),
|
||||||
$timeFieldDropdown = Object::create('TimeField', 'TimeWithDropdown','TimeField with dropdown'),
|
$timeFieldDropdown = Object::create('TimeField', 'TimeWithDropdown', 'TimeField with dropdown'),
|
||||||
Object::create('DatetimeField', 'DateTime', 'DateTime'),
|
Object::create('DatetimeField', 'DateTime', 'DateTime'),
|
||||||
$dateTimeShowCalendar = Object::create('DatetimeField', 'DateTimeWithCalendar', 'DateTime with calendar')
|
$dateTimeShowCalendar = Object::create('DatetimeField', 'DateTimeWithCalendar', 'DateTime with calendar')
|
||||||
));
|
));
|
||||||
$calendarDateField->setConfig('showcalendar', true);
|
$calendarDateField->setConfig('showcalendar', true);
|
||||||
$dmyDateField->setConfig('dmyfields', true);
|
$dmyDateField->setConfig('dmyfields', true);
|
||||||
$timeFieldDropdown->setConfig('showdropdown', true);
|
$timeFieldDropdown->setConfig('showdropdown', true);
|
||||||
$dateTimeShowCalendar->getDateField()->setConfig('showcalendar', true);
|
$dateTimeShowCalendar->getDateField()->setConfig('showcalendar', true);
|
||||||
$dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true);
|
$dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true);
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.File', array(
|
$fields->addFieldsToTab('Root.File', array(
|
||||||
$bla = UploadField::create('File','FileUploadField')
|
$bla = UploadField::create('File', 'FileUploadField')
|
||||||
->setDescription($description)
|
->setDescription($description)
|
||||||
->setConfig('allowedMaxFileNumber', 1)
|
->setConfig('allowedMaxFileNumber', 1)
|
||||||
->setConfig('canPreviewFolder', false),
|
->setConfig('canPreviewFolder', false),
|
||||||
UploadField::create('AttachedFile','UploadField with canUpload=false')
|
UploadField::create('AttachedFile', 'UploadField with canUpload=false')
|
||||||
->setDescription($description)
|
->setDescription($description)
|
||||||
->setConfig('canUpload', false),
|
->setConfig('canUpload', false),
|
||||||
UploadField::create('Image','UploadField for image')
|
UploadField::create('Image', 'UploadField for image')
|
||||||
->setDescription($description),
|
->setDescription($description),
|
||||||
UploadField::create('HasManyFiles','UploadField for has_many')
|
UploadField::create('HasManyFiles', 'UploadField for has_many')
|
||||||
->setDescription($description),
|
->setDescription($description),
|
||||||
UploadField::create('ManyManyFiles','UploadField for many_many')
|
UploadField::create('ManyManyFiles', 'UploadField for many_many')
|
||||||
->setDescription($description)
|
->setDescription($description)
|
||||||
));
|
));
|
||||||
|
|
||||||
$data = $this->getDefaultData();
|
$data = $this->getDefaultData();
|
||||||
foreach($fields->dataFields() as $field) {
|
foreach ($fields->dataFields() as $field) {
|
||||||
$name = $field->getName();
|
$name = $field->getName();
|
||||||
if(isset($data[$name])) {
|
if (isset($data[$name])) {
|
||||||
$field->setValue($data[$name]);
|
$field->setValue($data[$name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$blacklist = array(
|
$blacklist = array(
|
||||||
'DMYDate', 'Required', 'Validated', 'ToggleCompositeField',
|
'DMYDate', 'Required', 'Validated', 'ToggleCompositeField',
|
||||||
);
|
);
|
||||||
|
|
||||||
$tabs = array('Root.Text', 'Root.Numeric', 'Root.Option', 'Root.DateTime', 'Root.File');
|
$tabs = array('Root.Text', 'Root.Numeric', 'Root.Option', 'Root.DateTime', 'Root.File');
|
||||||
foreach($tabs as $tab) {
|
foreach ($tabs as $tab) {
|
||||||
$tabObj = $fields->fieldByName($tab);
|
$tabObj = $fields->fieldByName($tab);
|
||||||
foreach($tabObj->FieldList() as $field) {
|
foreach ($tabObj->FieldList() as $field) {
|
||||||
$field
|
$field
|
||||||
->setDescription($description);
|
->setDescription($description);
|
||||||
// ->addExtraClass('cms-description-tooltip');
|
// ->addExtraClass('cms-description-tooltip');
|
||||||
|
|
||||||
if(in_array($field->getName(), $blacklist)) continue;
|
if (in_array($field->getName(), $blacklist)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$disabledField = $field->performDisabledTransformation();
|
$disabledField = $field->performDisabledTransformation();
|
||||||
$disabledField->setTitle($disabledField->Title() . ' (disabled)');
|
$disabledField->setTitle($disabledField->Title() . ' (disabled)');
|
||||||
$disabledField->setName($disabledField->getName() . '_disabled');
|
$disabledField->setName($disabledField->getName() . '_disabled');
|
||||||
$tabObj->insertAfter($disabledField, $field->getName());
|
$tabObj->insertAfter($disabledField, $field->getName());
|
||||||
|
|
||||||
$readonlyField = $field->performReadonlyTransformation();
|
$readonlyField = $field->performReadonlyTransformation();
|
||||||
$readonlyField->setTitle($readonlyField->Title() . ' (readonly)');
|
$readonlyField->setTitle($readonlyField->Title() . ' (readonly)');
|
||||||
$readonlyField->setName($readonlyField->getName() . '_readonly');
|
$readonlyField->setName($readonlyField->getName() . '_readonly');
|
||||||
$tabObj->insertAfter($readonlyField, $field->getName());
|
$tabObj->insertAfter($readonlyField, $field->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$noLabelField = new TextField('Text_NoLabel', false, 'TextField without label');
|
$noLabelField = new TextField('Text_NoLabel', false, 'TextField without label');
|
||||||
$noLabelField->setDescription($description);
|
$noLabelField->setDescription($description);
|
||||||
$fields->addFieldToTab('Root.Text', $noLabelField, 'Text_disabled');
|
$fields->addFieldToTab('Root.Text', $noLabelField, 'Text_disabled');
|
||||||
|
|
||||||
$fields->addFieldToTab('Root.Text',
|
$fields->addFieldToTab('Root.Text',
|
||||||
FieldGroup::create(
|
FieldGroup::create(
|
||||||
TextField::create('MyFieldGroup1'),
|
TextField::create('MyFieldGroup1'),
|
||||||
TextField::create('MyFieldGroup2'),
|
TextField::create('MyFieldGroup2'),
|
||||||
DropdownField::create('MyFieldGroup3', false, TestCategory::map())
|
DropdownField::create('MyFieldGroup3', false, TestCategory::map())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$fields->addFieldToTab('Root.Text',
|
$fields->addFieldToTab('Root.Text',
|
||||||
FieldGroup::create(
|
FieldGroup::create(
|
||||||
'MyLabelledFieldGroup',
|
'MyLabelledFieldGroup',
|
||||||
array(
|
array(
|
||||||
TextField::create('MyLabelledFieldGroup1'),
|
TextField::create('MyLabelledFieldGroup1'),
|
||||||
TextField::create('MyLabelledFieldGroup2'),
|
TextField::create('MyLabelledFieldGroup2'),
|
||||||
DropdownField::create('MyLabelledFieldGroup3', null, TestCategory::map())
|
DropdownField::create('MyLabelledFieldGroup3', null, TestCategory::map())
|
||||||
)
|
)
|
||||||
)->setTitle('My Labelled Field Group')
|
)->setTitle('My Labelled Field Group')
|
||||||
);
|
);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public function getCMSValidator()
|
||||||
|
{
|
||||||
|
return new RequiredFields('Required');
|
||||||
|
}
|
||||||
|
|
||||||
public function getCMSValidator() {
|
public function validate()
|
||||||
return new RequiredFields('Required');
|
{
|
||||||
}
|
$result = parent::validate();
|
||||||
|
if (!$this->Validated || $this->Validated < 1 || $this->Validated > 3) {
|
||||||
public function validate() {
|
$result->error('"Validated" field needs to be between 1 and 3');
|
||||||
$result = parent::validate();
|
}
|
||||||
if(!$this->Validated || $this->Validated < 1 || $this->Validated > 3) {
|
return $result;
|
||||||
$result->error('"Validated" field needs to be between 1 and 3');
|
}
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class BasicFieldsTestPage_Controller extends TestPage_Controller {
|
class BasicFieldsTestPage_Controller extends TestPage_Controller
|
||||||
function AutoCompleteItems() {
|
{
|
||||||
$items = array(
|
public function AutoCompleteItems()
|
||||||
'TestItem1',
|
{
|
||||||
'TestItem2',
|
$items = array(
|
||||||
'TestItem3',
|
'TestItem1',
|
||||||
'TestItem4',
|
'TestItem2',
|
||||||
);
|
'TestItem3',
|
||||||
return implode(',', $items);
|
'TestItem4',
|
||||||
}
|
);
|
||||||
|
return implode(',', $items);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
621
code/Company.php
621
code/Company.php
@ -1,326 +1,331 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Company extends DataObject {
|
class Company extends DataObject
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'Name'=>'Varchar(255)',
|
'Name'=>'Varchar(255)',
|
||||||
'Category'=>'Varchar(255)',
|
'Category'=>'Varchar(255)',
|
||||||
'Revenue'=>'Float',
|
'Revenue'=>'Float',
|
||||||
'CEO'=>'Varchar(255)',
|
'CEO'=>'Varchar(255)',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'RelationFieldsTestPage' => 'RelationFieldsTestPage',
|
'RelationFieldsTestPage' => 'RelationFieldsTestPage',
|
||||||
'GridFieldTestPageHasOne' => 'GridFieldTestPage'
|
'GridFieldTestPageHasOne' => 'GridFieldTestPage'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_many = array(
|
private static $has_many = array(
|
||||||
'Employees' => 'Employee',
|
'Employees' => 'Employee',
|
||||||
'GroupPhotos' => 'Image'
|
'GroupPhotos' => 'Image'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $many_many = array(
|
private static $many_many = array(
|
||||||
'PastEmployees' => 'Employee'
|
'PastEmployees' => 'Employee'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $many_many_extraFields = array(
|
private static $many_many_extraFields = array(
|
||||||
'PastEmployees' => array(
|
'PastEmployees' => array(
|
||||||
'YearStart' => 'Int',
|
'YearStart' => 'Int',
|
||||||
'YearEnd' => 'Int',
|
'YearEnd' => 'Int',
|
||||||
'Role' => 'Text',
|
'Role' => 'Text',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
||||||
'RelationFieldsTestPages' => 'RelationFieldsTestPage',
|
'RelationFieldsTestPages' => 'RelationFieldsTestPage',
|
||||||
'GridFieldTestPage' => 'GridFieldTestPage'
|
'GridFieldTestPage' => 'GridFieldTestPage'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $summary_fields = array(
|
private static $summary_fields = array(
|
||||||
'Name',
|
'Name',
|
||||||
'Category',
|
'Category',
|
||||||
'Revenue',
|
'Revenue',
|
||||||
'CEO',
|
'CEO',
|
||||||
'DynamicProperty'
|
'DynamicProperty'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $searchable_fields = array(
|
private static $searchable_fields = array(
|
||||||
'Name',
|
'Name',
|
||||||
'Category',
|
'Category',
|
||||||
'Revenue',
|
'Revenue',
|
||||||
'CEO',
|
'CEO',
|
||||||
);
|
);
|
||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields()
|
||||||
$fields = parent::getCMSFields();
|
{
|
||||||
$fields->addFieldToTab('Root.Main',
|
$fields = parent::getCMSFields();
|
||||||
$uploadField = UploadField::create('GroupPhotos')
|
$fields->addFieldToTab('Root.Main',
|
||||||
);
|
$uploadField = UploadField::create('GroupPhotos')
|
||||||
if(method_exists('UploadField', 'setAllowedFileCategories')) {
|
);
|
||||||
$uploadField->setAllowedFileCategories('image');
|
if (method_exists('UploadField', 'setAllowedFileCategories')) {
|
||||||
}
|
$uploadField->setAllowedFileCategories('image');
|
||||||
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
function validate() {
|
public function validate()
|
||||||
if(!$this->Title) {
|
{
|
||||||
return new ValidationResult(false, 'Title is required');
|
if (!$this->Title) {
|
||||||
} else {
|
return new ValidationResult(false, 'Title is required');
|
||||||
return parent::validate();
|
} else {
|
||||||
}
|
return parent::validate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public function DynamicProperty()
|
||||||
|
{
|
||||||
|
return sprintf('%s (%s)', $this->Name, $this->CEO);
|
||||||
|
}
|
||||||
|
|
||||||
public function DynamicProperty() {
|
public function requireDefaultRecords()
|
||||||
return sprintf('%s (%s)', $this->Name, $this->CEO);
|
{
|
||||||
}
|
parent::requireDefaultRecords();
|
||||||
|
$companySet = DataObject::get('Company');
|
||||||
|
foreach ($companySet as $company) {
|
||||||
|
$company->delete();
|
||||||
|
}
|
||||||
|
|
||||||
public function requireDefaultRecords() {
|
foreach ($this->data() as $companyData) {
|
||||||
parent::requireDefaultRecords();
|
$company = new Company();
|
||||||
$companySet = DataObject::get('Company');
|
$company->Name = $companyData[0];
|
||||||
foreach ($companySet as $company) {
|
$company->Category = $companyData[1];
|
||||||
$company->delete();
|
$company->Revenue = $companyData[2];
|
||||||
}
|
$company->CEO = $companyData[3];
|
||||||
|
$company->write();
|
||||||
|
}
|
||||||
|
DB::alteration_message("Added default records to Company table", "created");
|
||||||
|
}
|
||||||
|
|
||||||
foreach($this->data() as $companyData){
|
/**
|
||||||
$company = new Company();
|
* Contains test data
|
||||||
$company->Name = $companyData[0];
|
*
|
||||||
$company->Category = $companyData[1];
|
* @return array
|
||||||
$company->Revenue = $companyData[2];
|
*/
|
||||||
$company->CEO = $companyData[3];
|
public function data()
|
||||||
$company->write();
|
{
|
||||||
}
|
return array(
|
||||||
DB::alteration_message("Added default records to Company table","created");
|
0 => array("Walmart", "Retail", "421.849", "Michael Duke"),
|
||||||
}
|
1 => array("ExxonMobil", "Oil and gas", "370.125", "Rex W. Tillerson"),
|
||||||
|
2 => array("Royal Dutch Shell", "Oil and gas", "368.056", "Peter Voser"),
|
||||||
/**
|
3 => array("BP", "Oil and gas", "297.107", "Robert Dudley"),
|
||||||
* Contains test data
|
4 => array("Sinopec", "Oil and gas", "289.774", "Jiming Wang"),
|
||||||
*
|
5 => array("State Grid Corporation of China", "Electricity", "231.556", "Liu Zhenya"),
|
||||||
* @return array
|
6 => array("Toyota Motors", "Automotive", "228.247", "Fujio Cho"),
|
||||||
*/
|
7 => array("PetroChina", "Oil and gas", "221.955", "Zhou Jiping"),
|
||||||
public function data() {
|
8 => array("Total S.A.", "Oil and gas", "212.815", "Christophe de Margerie"),
|
||||||
return array(
|
9 => array("Japan Post Holdings", "Conglomerate", "211.080", "Jiro Saito"),
|
||||||
0 => array("Walmart", "Retail", "421.849", "Michael Duke"),
|
10 => array("Chevron", "Oil and gas", "204.928", "David J. O'Reilly"),
|
||||||
1 => array("ExxonMobil", "Oil and gas", "370.125", "Rex W. Tillerson"),
|
11 => array("ConocoPhillips", "Oil and gas", "198.655", "James Mulva"),
|
||||||
2 => array("Royal Dutch Shell", "Oil and gas", "368.056", "Peter Voser"),
|
12 => array("Vitol", "Raw material", "195.0", "Ian Taylor"),
|
||||||
3 => array("BP", "Oil and gas", "297.107", "Robert Dudley"),
|
13 => array("Saudi Aramco", "Oil and gas", "182.396", "Waleed Al-Bedaiwi"),
|
||||||
4 => array("Sinopec", "Oil and gas", "289.774", "Jiming Wang"),
|
14 => array("Volkswagen Group", "Automotive", "169.53", "Martin Winterkorn"),
|
||||||
5 => array("State Grid Corporation of China", "Electricity", "231.556", "Liu Zhenya"),
|
15 => array("Fannie Mae", "Financial services", "154.270", "Mike Williams"),
|
||||||
6 => array("Toyota Motors", "Automotive", "228.247", "Fujio Cho"),
|
16 => array("General Electric", "Conglomerate", "150.211", "Jeffrey Immelt"),
|
||||||
7 => array("PetroChina", "Oil and gas", "221.955", "Zhou Jiping"),
|
17 => array("Glencore", "Raw materials", "144.978", "Ivan Glasenberg"),
|
||||||
8 => array("Total S.A.", "Oil and gas", "212.815", "Christophe de Margerie"),
|
18 => array("Allianz", "Financial services", "142.24", "Michael Diekmann"),
|
||||||
9 => array("Japan Post Holdings", "Conglomerate", "211.080", "Jiro Saito"),
|
19 => array("ING Group", "Financial services", "140.729", "Jan Hommen"),
|
||||||
10 => array("Chevron", "Oil and gas", "204.928", "David J. O'Reilly"),
|
20 => array("Berkshire Hathaway", "Conglomerate", "136.185", "Warren Buffett"),
|
||||||
11 => array("ConocoPhillips", "Oil and gas", "198.655", "James Mulva"),
|
21 => array("Samsung Electronics", "Conglomerate", "135.772", "Lee Kun-hee"),
|
||||||
12 => array("Vitol", "Raw material", "195.0", "Ian Taylor"),
|
22 => array("General Motors", "Automotive", "135.592", "Daniel Akerson"),
|
||||||
13 => array("Saudi Aramco", "Oil and gas", "182.396", "Waleed Al-Bedaiwi"),
|
23 => array("Eni", "Oil and gas", "131.292", "Paolo Scaroni"),
|
||||||
14 => array("Volkswagen Group", "Automotive", "169.53", "Martin Winterkorn"),
|
24 => array("Daimler AG", "Automotive", "130.628", "Dieter Zetsche"),
|
||||||
15 => array("Fannie Mae", "Financial services", "154.270", "Mike Williams"),
|
25 => array("Ford Motor Company", "Automotive", "128.954", "Alan Mulally"),
|
||||||
16 => array("General Electric", "Conglomerate", "150.211", "Jeffrey Immelt"),
|
26 => array("Hewlett-Packard", "Information technology", "127.245", "Meg Whitman"),
|
||||||
17 => array("Glencore", "Raw materials", "144.978", "Ivan Glasenberg"),
|
27 => array("Nippon Telegraph and Telephone", "Telecommunications", "124.517", "Norio Wada"),
|
||||||
18 => array("Allianz", "Financial services", "142.24", "Michael Diekmann"),
|
28 => array("AT&T", "Telecommunications", "124.28", "Randall L. Stephenson"),
|
||||||
19 => array("ING Group", "Financial services", "140.729", "Jan Hommen"),
|
29 => array("E.ON", "Electricity; gas", "124.084", "Johannes Teyssen"),
|
||||||
20 => array("Berkshire Hathaway", "Conglomerate", "136.185", "Warren Buffett"),
|
30 => array("Carrefour", "Retailing", "122.280", "Lars Olofsson"),
|
||||||
21 => array("Samsung Electronics", "Conglomerate", "135.772", "Lee Kun-hee"),
|
31 => array("AXA", "Financial services", "121.577", "Henri de Castries"),
|
||||||
22 => array("General Motors", "Automotive", "135.592", "Daniel Akerson"),
|
32 => array("Assicurazioni Generali", "Insurance", "121.299", "Sergio Balbinot, Giovanni Perissinotto"),
|
||||||
23 => array("Eni", "Oil and gas", "131.292", "Paolo Scaroni"),
|
33 => array("Petrobras", "Oil and gas", "120.052", "José Sérgio Gabrielli de Azevedo"),
|
||||||
24 => array("Daimler AG", "Automotive", "130.628", "Dieter Zetsche"),
|
34 => array("Cargill", "Agriculture", "119.469", "Greg Page"),
|
||||||
25 => array("Ford Motor Company", "Automotive", "128.954", "Alan Mulally"),
|
35 => array("JX Holdings", "Energy", "116.414", "-"),
|
||||||
26 => array("Hewlett-Packard", "Information technology", "127.245", "Meg Whitman"),
|
36 => array("GDF Suez", "Public utilities", "112.88", "Gérard Mestrallet"),
|
||||||
27 => array("Nippon Telegraph and Telephone", "Telecommunications", "124.517", "Norio Wada"),
|
37 => array("Hitachi, Ltd.", "Conglomerate", "112.239", "Etsuhiko Shoyama"),
|
||||||
28 => array("AT&T", "Telecommunications", "124.28", "Randall L. Stephenson"),
|
38 => array("McKesson Corporation", "Health care", "112.084", "John Hammergren"),
|
||||||
29 => array("E.ON", "Electricity; gas", "124.084", "Johannes Teyssen"),
|
39 => array("Gazprom", "Oil and Gas", "111.808", "Alexei Miller"),
|
||||||
30 => array("Carrefour", "Retailing", "122.280", "Lars Olofsson"),
|
40 => array("Bank of America", "Banking", "111.39", "Brian Moynihan"),
|
||||||
31 => array("AXA", "Financial services", "121.577", "Henri de Castries"),
|
41 => array("Tesco", "Retailing", "110.85", "Philip Clarke"),
|
||||||
32 => array("Assicurazioni Generali", "Insurance", "121.299", "Sergio Balbinot, Giovanni Perissinotto"),
|
42 => array("Federal Home Loan Mortgage Corporation", "Financial services", "109.956", "Richard F. Syron"),
|
||||||
33 => array("Petrobras", "Oil and gas", "120.052", "José Sérgio Gabrielli de Azevedo"),
|
43 => array("Apple Inc.", "Electronics", "108.249", "Tim Cook"),
|
||||||
34 => array("Cargill", "Agriculture", "119.469", "Greg Page"),
|
44 => array("Honda", "Automotive", "107.985", "Takanobu Ito"),
|
||||||
35 => array("JX Holdings", "Energy", "116.414", "-"),
|
45 => array("Verizon", "Telecommunications", "106.565", "Ivan Seidenberg"),
|
||||||
36 => array("GDF Suez", "Public utilities", "112.88", "Gérard Mestrallet"),
|
46 => array("Nissan Motors", "Automotive", "105.523", "Carlos Ghosn"),
|
||||||
37 => array("Hitachi, Ltd.", "Conglomerate", "112.239", "Etsuhiko Shoyama"),
|
47 => array("Panasonic Corporation", "Electronics", "105.035", "Kunio Nakamura"),
|
||||||
38 => array("McKesson Corporation", "Health care", "112.084", "John Hammergren"),
|
48 => array("Nestlé", "Food processing", "104.972", "Paul Bulcke"),
|
||||||
39 => array("Gazprom", "Oil and Gas", "111.808", "Alexei Miller"),
|
49 => array("LUKoil", "Oil and Gas", "104.956", "Vagit Alekperov"),
|
||||||
40 => array("Bank of America", "Banking", "111.39", "Brian Moynihan"),
|
50 => array("Pemex", "Oil and gas", "103.538", "Juan José Suárez Coppel"),
|
||||||
41 => array("Tesco", "Retailing", "110.85", "Philip Clarke"),
|
51 => array("JPMorgan Chase", "Financial Services", "102.694", "Jamie Dimon"),
|
||||||
42 => array("Federal Home Loan Mortgage Corporation", "Financial services", "109.956", "Richard F. Syron"),
|
52 => array("Cardinal Health", "Health care", "102.644", "George Barrett"),
|
||||||
43 => array("Apple Inc.", "Electronics", "108.249", "Tim Cook"),
|
53 => array("Koch Industries", "Conglomerate", "100.0", "Charles Koch"),
|
||||||
44 => array("Honda", "Automotive", "107.985", "Takanobu Ito"),
|
54 => array("Petróleos de Venezuela", "Oil and gas", "94.929", "Rafael Ramírez"),
|
||||||
45 => array("Verizon", "Telecommunications", "106.565", "Ivan Seidenberg"),
|
55 => array("IBM", "Information technology", "99.87", "Virginia Rometty"),
|
||||||
46 => array("Nissan Motors", "Automotive", "105.523", "Carlos Ghosn"),
|
56 => array("Siemens AG", "Conglomerate", "98.870", "Peter Löscher"),
|
||||||
47 => array("Panasonic Corporation", "Electronics", "105.035", "Kunio Nakamura"),
|
57 => array("Hyundai Motors", "Automotive", "98.858", "Chung Mong-Koo"),
|
||||||
48 => array("Nestlé", "Food processing", "104.972", "Paul Bulcke"),
|
58 => array("Enel", "Electricity generation", "97.782", "Fulvio Conti"),
|
||||||
49 => array("LUKoil", "Oil and Gas", "104.956", "Vagit Alekperov"),
|
59 => array("CVS Caremark", "Retailing", "96.413", "Tom Ryan"),
|
||||||
50 => array("Pemex", "Oil and gas", "103.538", "Juan José Suárez Coppel"),
|
60 => array("Lloyds Banking Group", "Financial Services", "95.342", "António Horta-Osório"),
|
||||||
51 => array("JPMorgan Chase", "Financial Services", "102.694", "Jamie Dimon"),
|
61 => array("UnitedHealth Group", "Health care", "94.155", "Stephen Hemsley"),
|
||||||
52 => array("Cardinal Health", "Health care", "102.644", "George Barrett"),
|
62 => array("Statoil", "Oil and gas", "90.733", "Helge Lund"),
|
||||||
53 => array("Koch Industries", "Conglomerate", "100.0", "Charles Koch"),
|
63 => array("Metro AG", "Retailing", "89.87", "Eckhard Cordes"),
|
||||||
54 => array("Petróleos de Venezuela", "Oil and gas", "94.929", "Rafael Ramírez"),
|
64 => array("Aviva", "Financial services", "89.890", "Andrew Moss"),
|
||||||
55 => array("IBM", "Information technology", "99.87", "Virginia Rometty"),
|
65 => array("Electricité de France", "Electricity generation", "87.073", "Henri Proglio"),
|
||||||
56 => array("Siemens AG", "Conglomerate", "98.870", "Peter Löscher"),
|
66 => array("Costco", "Retailing", "87.048", "Jim Sinegal"),
|
||||||
57 => array("Hyundai Motors", "Automotive", "98.858", "Chung Mong-Koo"),
|
67 => array("Citigroup", "Financial services", "86.601", "Vikram Pandit"),
|
||||||
58 => array("Enel", "Electricity generation", "97.782", "Fulvio Conti"),
|
68 => array("Sony", "Electronics", "86.521", "Howard Stringer"),
|
||||||
59 => array("CVS Caremark", "Retailing", "96.413", "Tom Ryan"),
|
69 => array("BASF", "Chemical industry", "85.347", "Kurt Bock"),
|
||||||
60 => array("Lloyds Banking Group", "Financial Services", "95.342", "António Horta-Osório"),
|
70 => array("Wells Fargo", "Banking / Financial services", "85.21", "John Stumpf"),
|
||||||
61 => array("UnitedHealth Group", "Health care", "94.155", "Stephen Hemsley"),
|
71 => array("Société Générale", "Financial Services", "84.868", "Frédéric Oudéa"),
|
||||||
62 => array("Statoil", "Oil and gas", "90.733", "Helge Lund"),
|
72 => array("Kuwait Petroleum Corporation", "Oil and gas", "84.594", "Saad Al Shuwaib"),
|
||||||
63 => array("Metro AG", "Retailing", "89.87", "Eckhard Cordes"),
|
73 => array("Deutsche Telekom", "Telecommunications", "83.407", "René Obermann"),
|
||||||
64 => array("Aviva", "Financial services", "89.890", "Andrew Moss"),
|
74 => array("Procter & Gamble", "Consumer goods", "82.559", "Robert A. \"Bob\" McDonald"),
|
||||||
65 => array("Electricité de France", "Electricity generation", "87.073", "Henri Proglio"),
|
75 => array("Industrial and Commercial Bank of China", "Banking", "82.536", "Jiang Jianqing"),
|
||||||
66 => array("Costco", "Retailing", "87.048", "Jim Sinegal"),
|
76 => array("Valero Energy", "Oil and gas", "82.233", "Bill Klesse"),
|
||||||
67 => array("Citigroup", "Financial services", "86.601", "Vikram Pandit"),
|
77 => array("Kroger", "Retailing", "82.189", "David Dillon"),
|
||||||
68 => array("Sony", "Electronics", "86.521", "Howard Stringer"),
|
78 => array("Nippon Life Insurance", "Insurance", "81.315", "Kunie Okamoto"),
|
||||||
69 => array("BASF", "Chemical industry", "85.347", "Kurt Bock"),
|
79 => array("Telefónica", "Telecommunications", "80.938", "César Alierta"),
|
||||||
70 => array("Wells Fargo", "Banking / Financial services", "85.21", "John Stumpf"),
|
80 => array("BMW", "Automotive", "80.809", "Norbert Reithofer"),
|
||||||
71 => array("Société Générale", "Financial Services", "84.868", "Frédéric Oudéa"),
|
81 => array("Repsol YPF", "Oil and Gas", "80.747", "Antonio Brufau"),
|
||||||
72 => array("Kuwait Petroleum Corporation", "Oil and gas", "84.594", "Saad Al Shuwaib"),
|
82 => array("Archer Daniels Midland", "Agriculture, Food processing", "80.676", "Patricia A. Woertz"),
|
||||||
73 => array("Deutsche Telekom", "Telecommunications", "83.407", "René Obermann"),
|
83 => array("AmerisourceBergen", "Health care", "80.218", "R. David Yost"),
|
||||||
74 => array("Procter & Gamble", "Consumer goods", "82.559", "Robert A. \"Bob\" McDonald"),
|
84 => array("HSBC", "Financial services", "80.014", "Stuart Gulliver"),
|
||||||
75 => array("Industrial and Commercial Bank of China", "Banking", "82.536", "Jiang Jianqing"),
|
85 => array("SK Group", "Conglomerate", "79.603", "Choi Tae-Won"),
|
||||||
76 => array("Valero Energy", "Oil and gas", "82.233", "Bill Klesse"),
|
86 => array("National Iranian Oil Company", "Oil and gas", "79.277", "Masoud Mir Kazemi"),
|
||||||
77 => array("Kroger", "Retailing", "82.189", "David Dillon"),
|
87 => array("Trafigura", "Raw materials", "79.2", " ?"),
|
||||||
78 => array("Nippon Life Insurance", "Insurance", "81.315", "Kunie Okamoto"),
|
88 => array("ArcelorMittal", "Steel", "78.025", "Lakshmi Mittal"),
|
||||||
79 => array("Telefónica", "Telecommunications", "80.938", "César Alierta"),
|
89 => array("American International Group", "Financial services", "77.301", "Robert Benmosche"),
|
||||||
80 => array("BMW", "Automotive", "80.809", "Norbert Reithofer"),
|
90 => array("Toshiba", "Conglomerate", "77.090", "Tadashi Okamura"),
|
||||||
81 => array("Repsol YPF", "Oil and Gas", "80.747", "Antonio Brufau"),
|
91 => array("Petronas", "Oil and gas", "76.822", "Tan Sri Dato Sri Mohd Hassan Marican"),
|
||||||
82 => array("Archer Daniels Midland", "Agriculture, Food processing", "80.676", "Patricia A. Woertz"),
|
92 => array("Indian Oil Corporation", "Oil and Gas", "75.632", "B.M.Bansal"),
|
||||||
83 => array("AmerisourceBergen", "Health care", "80.218", "R. David Yost"),
|
93 => array("Fiat", "Conglomerate", "75.172", "Sergio Marchionne"),
|
||||||
84 => array("HSBC", "Financial services", "80.014", "Stuart Gulliver"),
|
94 => array("ZEN-NOH", "Agricultural marketing", "75.111", "Katsuyoshi Kitajima"),
|
||||||
85 => array("SK Group", "Conglomerate", "79.603", "Choi Tae-Won"),
|
95 => array("PSA Peugeot Citroën", "Automotive", "74.909", "Philippe Varin"),
|
||||||
86 => array("National Iranian Oil Company", "Oil and gas", "79.277", "Masoud Mir Kazemi"),
|
96 => array("Vodafone", "Telecommunications", "73.635", "Vittorio Colao"),
|
||||||
87 => array("Trafigura", "Raw materials", "79.2", " ?"),
|
97 => array("Marathon Oil", "Oil and gas", "73.621", "Clarence Cazalot, Jr."),
|
||||||
88 => array("ArcelorMittal", "Steel", "78.025", "Lakshmi Mittal"),
|
98 => array("China Mobile", "Telecommunications", "73.520", "Li Yue"),
|
||||||
89 => array("American International Group", "Financial services", "77.301", "Robert Benmosche"),
|
99 => array("Prudential plc", "Banking", "73.337", "Tidjane Thiam"),
|
||||||
90 => array("Toshiba", "Conglomerate", "77.090", "Tadashi Okamura"),
|
100 => array("Walgreens", "Retailing", "72.184", "Jeff Rein"),
|
||||||
91 => array("Petronas", "Oil and gas", "76.822", "Tan Sri Dato Sri Mohd Hassan Marican"),
|
101 => array("Deutsche Post", "Courier", "71.751", "Frank Appel"),
|
||||||
92 => array("Indian Oil Corporation", "Oil and Gas", "75.632", "B.M.Bansal"),
|
102 => array("BHP Billiton", "Mining", "71.739", "Marius Kloppers"),
|
||||||
93 => array("Fiat", "Conglomerate", "75.172", "Sergio Marchionne"),
|
103 => array("RWE", "Public utilities", "71.246", "Jürgen Großmann"),
|
||||||
94 => array("ZEN-NOH", "Agricultural marketing", "75.111", "Katsuyoshi Kitajima"),
|
104 => array("Aegon", "Insurance", "71.148", "Alex Wynaendts"),
|
||||||
95 => array("PSA Peugeot Citroën", "Automotive", "74.909", "Philippe Varin"),
|
105 => array("REWE Group", "Retailing", "70.872", "Alain Caparros"),
|
||||||
96 => array("Vodafone", "Telecommunications", "73.635", "Vittorio Colao"),
|
106 => array("Dexia", "Banking", "70.106", "Pierre Mariani"),
|
||||||
97 => array("Marathon Oil", "Oil and gas", "73.621", "Clarence Cazalot, Jr."),
|
107 => array("Microsoft", "Information technology", "69.943", "Steve Ballmer"),
|
||||||
98 => array("China Mobile", "Telecommunications", "73.520", "Li Yue"),
|
108 => array("China Railway Construction Corporation", "Infrastructure", "69.118", "Meng Fengchao"),
|
||||||
99 => array("Prudential plc", "Banking", "73.337", "Tidjane Thiam"),
|
109 => array("China Railway Engineering Corporation", "Infrastructure", "69.082", "Shi Dahua"),
|
||||||
100 => array("Walgreens", "Retailing", "72.184", "Jeff Rein"),
|
110 => array("Toyota Tsusho", "Sogo shosha", "69.076", "Masaaki Furukawa"),
|
||||||
101 => array("Deutsche Post", "Courier", "71.751", "Frank Appel"),
|
111 => array("China Construction Bank", "Banking", "68.777", "Guo Shuqing"),
|
||||||
102 => array("BHP Billiton", "Mining", "71.739", "Marius Kloppers"),
|
112 => array("Home Depot, Inc.", "Retailing", "67.997", "Frank Blake"),
|
||||||
103 => array("RWE", "Public utilities", "71.246", "Jürgen Großmann"),
|
113 => array("Zurich Financial Services", "Insurance", "67.85", "Martin Senn"),
|
||||||
104 => array("Aegon", "Insurance", "71.148", "Alex Wynaendts"),
|
114 => array("Pfizer", "Health care", "67.809", "Jeff Kindler"),
|
||||||
105 => array("REWE Group", "Retailing", "70.872", "Alain Caparros"),
|
115 => array("Philip Morris International", "Tobacco industry", "67.713", "Louis C. Camilleri"),
|
||||||
106 => array("Dexia", "Banking", "70.106", "Pierre Mariani"),
|
116 => array("Groupe BPCE", "Banking", "67.303", "François Pérol"),
|
||||||
107 => array("Microsoft", "Information technology", "69.943", "Steve Ballmer"),
|
117 => array("Target Corporation", "Retailing", "67.390", "Gregg Steinhafel"),
|
||||||
108 => array("China Railway Construction Corporation", "Infrastructure", "69.118", "Meng Fengchao"),
|
118 => array("Temasek Holdings", "Sovereign Wealth Fund", "66.285", "Suppiah Dhanabalan"),
|
||||||
109 => array("China Railway Engineering Corporation", "Infrastructure", "69.082", "Shi Dahua"),
|
119 => array("Medco Health Solutions", "Health care", "65.968", "David B. Snow, Jr."),
|
||||||
110 => array("Toyota Tsusho", "Sogo shosha", "69.076", "Masaaki Furukawa"),
|
120 => array("United States Postal Service", "Courier", "65.711", "John E. Potter"),
|
||||||
111 => array("China Construction Bank", "Banking", "68.777", "Guo Shuqing"),
|
121 => array("Gunvor", "Raw material", "65.0", "-"),
|
||||||
112 => array("Home Depot, Inc.", "Retailing", "67.997", "Frank Blake"),
|
122 => array("Crédit Agricole", "Financial Services", "64.800", "Jean-Paul Chifflet"),
|
||||||
113 => array("Zurich Financial Services", "Insurance", "67.85", "Martin Senn"),
|
123 => array("Tokyo Electric Power", "Electricity generation", "64.964", "Tsunehisa Katsumata"),
|
||||||
114 => array("Pfizer", "Health care", "67.809", "Jeff Kindler"),
|
124 => array("Boeing", "Aerospace", "64.306", "Jim McNerney"),
|
||||||
115 => array("Philip Morris International", "Tobacco industry", "67.713", "Louis C. Camilleri"),
|
125 => array("Barclays Bank", "Banking", "63.978", "Bob Diamond"),
|
||||||
116 => array("Groupe BPCE", "Banking", "67.303", "François Pérol"),
|
126 => array("State Farm Insurance", "Insurance", "63.2", "Edward B. Rust Jr."),
|
||||||
117 => array("Target Corporation", "Retailing", "67.390", "Gregg Steinhafel"),
|
127 => array("Bosch Group", "Automotive", "63.147", "-"),
|
||||||
118 => array("Temasek Holdings", "Sovereign Wealth Fund", "66.285", "Suppiah Dhanabalan"),
|
128 => array("PTT Public Company Limited", "Oil and Gas", "62.998", "Prasert Bunsumpun"),
|
||||||
119 => array("Medco Health Solutions", "Health care", "65.968", "David B. Snow, Jr."),
|
129 => array("Royal Bank of Scotland", "Financial services", "62.770", "Stephen Hester"),
|
||||||
120 => array("United States Postal Service", "Courier", "65.711", "John E. Potter"),
|
130 => array("Mitsubishi Corporation", "Sogo shosha", "62.733", "Mikio Sasaki"),
|
||||||
121 => array("Gunvor", "Raw material", "65.0", "-"),
|
131 => array("Seven & I Holdings Co.", "Retailing", "62.436", "Toshifumi Suzuki"),
|
||||||
122 => array("Crédit Agricole", "Financial Services", "64.800", "Jean-Paul Chifflet"),
|
132 => array("ÆON", "Retailing", "62.153", "-"),
|
||||||
123 => array("Tokyo Electric Power", "Electricity generation", "64.964", "Tsunehisa Katsumata"),
|
133 => array("Agricultural Bank of China", "Banking", "62.151", "Xiang Junbo"),
|
||||||
124 => array("Boeing", "Aerospace", "64.306", "Jim McNerney"),
|
134 => array("Johnson & Johnson", "Health care", "61.587", "William C. Weldon"),
|
||||||
125 => array("Barclays Bank", "Banking", "63.978", "Bob Diamond"),
|
135 => array("Dell", "Information technology", "61.494", "Michael Dell"),
|
||||||
126 => array("State Farm Insurance", "Insurance", "63.2", "Edward B. Rust Jr."),
|
136 => array("EADS", "Aerospace", "60.969", "Louis Gallois"),
|
||||||
127 => array("Bosch Group", "Automotive", "63.147", "-"),
|
137 => array("Munich Re", "Financial services", "60.851", "Nikolaus von Bomhard"),
|
||||||
128 => array("PTT Public Company Limited", "Oil and Gas", "62.998", "Prasert Bunsumpun"),
|
138 => array("France Télécom", "Telecommunications", "60.801", "Stéphane Richard"),
|
||||||
129 => array("Royal Bank of Scotland", "Financial services", "62.770", "Stephen Hester"),
|
139 => array("Rio Tinto", "Mining", "60.323", "Tom Albanese"),
|
||||||
130 => array("Mitsubishi Corporation", "Sogo shosha", "62.733", "Mikio Sasaki"),
|
140 => array("CNP Assurances", "Insurance", "59.846", "Gilles Benoist"),
|
||||||
131 => array("Seven & I Holdings Co.", "Retailing", "62.436", "Toshifumi Suzuki"),
|
141 => array("Reliance Industries", "Conglomerate", "59.679", "Mukesh Ambani"),
|
||||||
132 => array("ÆON", "Retailing", "62.153", "-"),
|
142 => array("Legal & General", "Financial services", "59.673", "Tim Breedon"),
|
||||||
133 => array("Agricultural Bank of China", "Banking", "62.151", "Xiang Junbo"),
|
143 => array("Bank of China", "Banking", "59.668", "Xiao Gang"),
|
||||||
134 => array("Johnson & Johnson", "Health care", "61.587", "William C. Weldon"),
|
144 => array("Unilever", "Consumer goods", "59.143", "Paul Polman"),
|
||||||
135 => array("Dell", "Information technology", "61.494", "Michael Dell"),
|
145 => array("WellPoint", "Health care", "58.802", "Angela Braly"),
|
||||||
136 => array("EADS", "Aerospace", "60.969", "Louis Gallois"),
|
146 => array("BNP Paribas", "Financial Services", "58.632", "Baudouin Prot"),
|
||||||
137 => array("Munich Re", "Financial services", "60.851", "Nikolaus von Bomhard"),
|
147 => array("China Life Insurance", "Insurance", "58.460", "-"),
|
||||||
138 => array("France Télécom", "Telecommunications", "60.801", "Stéphane Richard"),
|
148 => array("Edeka Group", "Retailing", "57.968", "-"),
|
||||||
139 => array("Rio Tinto", "Mining", "60.323", "Tom Albanese"),
|
149 => array("PepsiCo", "Food", "57.838", "Indra Nooyi"),
|
||||||
140 => array("CNP Assurances", "Insurance", "59.846", "Gilles Benoist"),
|
150 => array("Grupo Santander", "Banking", "57.388", "Emilio Botín"),
|
||||||
141 => array("Reliance Industries", "Conglomerate", "59.679", "Mukesh Ambani"),
|
151 => array("Auchan", "Retailing", "56.778", "Christophe Dubrulle"),
|
||||||
142 => array("Legal & General", "Financial services", "59.673", "Tim Breedon"),
|
152 => array("Noble Group", "Raw materials", "56.696", "Ricardo Leiman"),
|
||||||
143 => array("Bank of China", "Banking", "59.668", "Xiao Gang"),
|
153 => array("China State Construction Engineering Corp", "Infrastructure", "56.104", "Sun Wenjie"),
|
||||||
144 => array("Unilever", "Consumer goods", "59.143", "Paul Polman"),
|
154 => array("Banco Bradesco", "Banking", "56.104", "Luiz Carlos Trabuco Cappi"),
|
||||||
145 => array("WellPoint", "Health care", "58.802", "Angela Braly"),
|
155 => array("A. P. Møller - Mærsk", "Transport", "56.090", "Nils Andersen"),
|
||||||
146 => array("BNP Paribas", "Financial Services", "58.632", "Baudouin Prot"),
|
156 => array("Dongfeng Motor", "Automotive", "55.864", "Xu Ping"),
|
||||||
147 => array("China Life Insurance", "Insurance", "58.460", "-"),
|
157 => array("China Southern Power Grid Company", "Electricity", "55.825", "Yuan Maozhen"),
|
||||||
148 => array("Edeka Group", "Retailing", "57.968", "-"),
|
158 => array("Deutsche Bank", "Banking", "55.804", "Josef Ackermann"),
|
||||||
149 => array("PepsiCo", "Food", "57.838", "Indra Nooyi"),
|
159 => array("Shanghai Automotive Industry Corporation", "Automotive", "55.689", "Shen Jianhua"),
|
||||||
150 => array("Grupo Santander", "Banking", "57.388", "Emilio Botín"),
|
160 => array("Fujitsu", "Electronics", "54.559", "Hiroaki Kurokawa"),
|
||||||
151 => array("Auchan", "Retailing", "56.778", "Christophe Dubrulle"),
|
161 => array("United Technologies", "Conglomerate", "54.326", "Louis R. Chênevert"),
|
||||||
152 => array("Noble Group", "Raw materials", "56.696", "Ricardo Leiman"),
|
162 => array("Credit Suisse", "Financial services", "53.771", "Brady Dougan"),
|
||||||
153 => array("China State Construction Engineering Corp", "Infrastructure", "56.104", "Sun Wenjie"),
|
163 => array("China National Offshore Oil Corporation", "Oil and gas", "53.733", "Wang Yilin"),
|
||||||
154 => array("Banco Bradesco", "Banking", "56.104", "Luiz Carlos Trabuco Cappi"),
|
164 => array("Dow Chemical", "Manufacturing", "53.674", "Andrew N. Liveris"),
|
||||||
155 => array("A. P. Møller - Mærsk", "Transport", "56.090", "Nils Andersen"),
|
165 => array("Saint-Gobain", "Construction", "53.607", "Pierre-André de Chalendar"),
|
||||||
156 => array("Dongfeng Motor", "Automotive", "55.864", "Xu Ping"),
|
166 => array("UniCredit", "Banking", "53.332", "Federico Ghizzoni"),
|
||||||
157 => array("China Southern Power Grid Company", "Electricity", "55.825", "Yuan Maozhen"),
|
167 => array("Nokia", "Telecommunications", "53.322", "Stephen Elop"),
|
||||||
158 => array("Deutsche Bank", "Banking", "55.804", "Josef Ackermann"),
|
168 => array("MetLife", "Insurance", "52.717", "C. Robert Henrikson"),
|
||||||
159 => array("Shanghai Automotive Industry Corporation", "Automotive", "55.689", "Shen Jianhua"),
|
169 => array("Renault", "Automotive", "52.073", "Carlos Ghosn"),
|
||||||
160 => array("Fujitsu", "Electronics", "54.559", "Hiroaki Kurokawa"),
|
170 => array("Mitsubishi UFJ Financial Group", "Banking", "51.479", "Nobuo Kuroyanagi"),
|
||||||
161 => array("United Technologies", "Conglomerate", "54.326", "Louis R. Chênevert"),
|
171 => array("ThyssenKrupp", "Conglomerate", "50.717", "Heinrich Hiesinger"),
|
||||||
162 => array("Credit Suisse", "Financial services", "53.771", "Brady Dougan"),
|
172 => array("Sinochem Group", "Conglomerate", "50.632", "Liu Deschu"),
|
||||||
163 => array("China National Offshore Oil Corporation", "Oil and gas", "53.733", "Wang Yilin"),
|
173 => array("Hoffmann-La Roche", "Health care", "50.632", "Severin Schwan"),
|
||||||
164 => array("Dow Chemical", "Manufacturing", "53.674", "Andrew N. Liveris"),
|
174 => array("Novartis", "Health care", "50.624", "Joseph Jimenez"),
|
||||||
165 => array("Saint-Gobain", "Construction", "53.607", "Pierre-André de Chalendar"),
|
175 => array("Best Buy", "Retailing", "50.272", "Brian J. Dunn"),
|
||||||
166 => array("UniCredit", "Banking", "53.332", "Federico Ghizzoni"),
|
176 => array("United Parcel Service", "Transportation", "49.545", "Scott Davis"),
|
||||||
167 => array("Nokia", "Telecommunications", "53.322", "Stephen Elop"),
|
177 => array("Pertamina", "Oil and gas", "48.717", "Karen Agustiawan"),
|
||||||
168 => array("MetLife", "Insurance", "52.717", "C. Robert Henrikson"),
|
178 => array("Dai-ichi Life", "Insurance", "47.855", "-"),
|
||||||
169 => array("Renault", "Automotive", "52.073", "Carlos Ghosn"),
|
179 => array("Banco Bilbao Vizcaya Argentaria", "Banking", "47.429", "Francisco González"),
|
||||||
170 => array("Mitsubishi UFJ Financial Group", "Banking", "51.479", "Nobuo Kuroyanagi"),
|
180 => array("Lowe's", "Retailing", "47.22", "Robert Niblock"),
|
||||||
171 => array("ThyssenKrupp", "Conglomerate", "50.717", "Heinrich Hiesinger"),
|
181 => array("Rosneft", "Oil and gas", "46.826", "-"),
|
||||||
172 => array("Sinochem Group", "Conglomerate", "50.632", "Liu Deschu"),
|
182 => array("National Mutual Insurance Federation of Agricultural Cooperatives (Zenkyoren or JA Kyosai)", "Insurance", "46.8", "-"),
|
||||||
173 => array("Hoffmann-La Roche", "Health care", "50.632", "Severin Schwan"),
|
183 => array("VINCI", "Construction", "46.762", "Xavier Huillard"),
|
||||||
174 => array("Novartis", "Health care", "50.624", "Joseph Jimenez"),
|
184 => array("Veolia Environnement", "Public utilities", "46.482", "Antoine Frérot"),
|
||||||
175 => array("Best Buy", "Retailing", "50.272", "Brian J. Dunn"),
|
185 => array("Vale", "Mining", "46.481", "Murilo Ferreira"),
|
||||||
176 => array("United Parcel Service", "Transportation", "49.545", "Scott Davis"),
|
186 => array("Woori Financial Group", "Financial services", "46.459", "Lee Pal Seung"),
|
||||||
177 => array("Pertamina", "Oil and gas", "48.717", "Karen Agustiawan"),
|
187 => array("Sonatrach", "Oil and gas", "46.420", "Djenane El Malik"),
|
||||||
178 => array("Dai-ichi Life", "Insurance", "47.855", "-"),
|
188 => array("GlaxoSmithKline", "Health care", "46.016", "Andrew Witty"),
|
||||||
179 => array("Banco Bilbao Vizcaya Argentaria", "Banking", "47.429", "Francisco González"),
|
189 => array("Deutsche Bahn", "Transportation", "45.979", "Rüdiger Grube"),
|
||||||
180 => array("Lowe's", "Retailing", "47.22", "Robert Niblock"),
|
190 => array("Goldman Sachs", "Financial services", "45.976", "Lloyd Blankfein"),
|
||||||
181 => array("Rosneft", "Oil and gas", "46.826", "-"),
|
191 => array("Hon Hai Precision Industry", "Electronics", "45.899", "Terry Gou"),
|
||||||
182 => array("National Mutual Insurance Federation of Agricultural Cooperatives (Zenkyoren or JA Kyosai)", "Insurance", "46.8", "-"),
|
192 => array("Lockheed Martin", "Aerospace", "45.803", "Robert J. Stevens"),
|
||||||
183 => array("VINCI", "Construction", "46.762", "Xavier Huillard"),
|
193 => array("Woolworths Limited", "Retailing", "45.170", "Michael Luscombe"),
|
||||||
184 => array("Veolia Environnement", "Public utilities", "46.482", "Antoine Frérot"),
|
194 => array("Bouygues", "Conglomerate", "45.167", "Martin Bouygues"),
|
||||||
185 => array("Vale", "Mining", "46.481", "Murilo Ferreira"),
|
195 => array("Bayer", "Health care", "44.901", "Marijn Dekkers"),
|
||||||
186 => array("Woori Financial Group", "Financial services", "46.459", "Lee Pal Seung"),
|
196 => array("China Investment Corporation", "Sovereign wealth fund", "44.876", "Lou Jiwei"),
|
||||||
187 => array("Sonatrach", "Oil and gas", "46.420", "Djenane El Malik"),
|
197 => array("Imperial Tobacco", "Tobacco industry", "44.713", "Gareth Davis"),
|
||||||
188 => array("GlaxoSmithKline", "Health care", "46.016", "Andrew Witty"),
|
198 => array("Mitsui & Co.", "Sogo shosha", "44.048", "-"),
|
||||||
189 => array("Deutsche Bahn", "Transportation", "45.979", "Rüdiger Grube"),
|
199 => array("Sears Holdings", "Retailing", "44.043", "Louis D'Ambrosio"),
|
||||||
190 => array("Goldman Sachs", "Financial services", "45.976", "Lloyd Blankfein"),
|
200 => array("LG Electronics", "Conglomerate", "44.000", "Koo Bon-joon"),
|
||||||
191 => array("Hon Hai Precision Industry", "Electronics", "45.899", "Terry Gou"),
|
201 => array("Shinhan Financial Group", "Financial services", "43.975", "Sang Hoon Shin"),
|
||||||
192 => array("Lockheed Martin", "Aerospace", "45.803", "Robert J. Stevens"),
|
202 => array("Wesfarmers", "Retailing", "43.949", "Bob Every"),
|
||||||
193 => array("Woolworths Limited", "Retailing", "45.170", "Michael Luscombe"),
|
203 => array("Intel", "Semiconductors", "43.623", "Paul S. Otellini"),
|
||||||
194 => array("Bouygues", "Conglomerate", "45.167", "Martin Bouygues"),
|
204 => array("Sumitomo Life Insurance", "Insurance", "43.272", "-"),
|
||||||
195 => array("Bayer", "Health care", "44.901", "Marijn Dekkers"),
|
205 => array("Caterpillar", "Heavy equipment", "42.588", "Douglas R. Oberhelman"),
|
||||||
196 => array("China Investment Corporation", "Sovereign wealth fund", "44.876", "Lou Jiwei"),
|
206 => array("Sanofi", "Health care", "42.218", "Chris Viehbacher"),
|
||||||
197 => array("Imperial Tobacco", "Tobacco industry", "44.713", "Gareth Davis"),
|
207 => array("Chrysler", "Automotive", "41.946", "Sergio Marchionne"),
|
||||||
198 => array("Mitsui & Co.", "Sogo shosha", "44.048", "-"),
|
208 => array("Bunge Limited", "Agriculture", "41.926", "Alberto Weisser"),
|
||||||
199 => array("Sears Holdings", "Retailing", "44.043", "Louis D'Ambrosio"),
|
209 => array("Sojitz", "Sogo shosha", "41.338", "Yutaka Kase"),
|
||||||
200 => array("LG Electronics", "Conglomerate", "44.000", "Koo Bon-joon"),
|
210 => array("Safeway", "Retailing", "40.8507", "Steven Burd"),
|
||||||
201 => array("Shinhan Financial Group", "Financial services", "43.975", "Sang Hoon Shin"),
|
211 => array("SuperValu", "Retailing", "40.597", "Craig Herkert"),
|
||||||
202 => array("Wesfarmers", "Retailing", "43.949", "Bob Every"),
|
212 => array("UBS", "Financial services", "40.561", "Oswald Grübel"),
|
||||||
203 => array("Intel", "Semiconductors", "43.623", "Paul S. Otellini"),
|
213 => array("Kraft Foods", "Food", "40.386", "Irene Rosenfeld"),
|
||||||
204 => array("Sumitomo Life Insurance", "Insurance", "43.272", "-"),
|
214 => array("Ahold", "Retailing", "40.229", "Dick Boer"),
|
||||||
205 => array("Caterpillar", "Heavy equipment", "42.588", "Douglas R. Oberhelman"),
|
215 => array("Cisco", "Information technology", "40.04", "John T. Chambers"),
|
||||||
206 => array("Sanofi", "Health care", "42.218", "Chris Viehbacher"),
|
);
|
||||||
207 => array("Chrysler", "Automotive", "41.946", "Sergio Marchionne"),
|
}
|
||||||
208 => array("Bunge Limited", "Agriculture", "41.926", "Alberto Weisser"),
|
|
||||||
209 => array("Sojitz", "Sogo shosha", "41.338", "Yutaka Kase"),
|
|
||||||
210 => array("Safeway", "Retailing", "40.8507", "Steven Burd"),
|
|
||||||
211 => array("SuperValu", "Retailing", "40.597", "Craig Herkert"),
|
|
||||||
212 => array("UBS", "Financial services", "40.561", "Oswald Grübel"),
|
|
||||||
213 => array("Kraft Foods", "Food", "40.386", "Irene Rosenfeld"),
|
|
||||||
214 => array("Ahold", "Retailing", "40.229", "Dick Boer"),
|
|
||||||
215 => array("Cisco", "Information technology", "40.04", "John T. Chambers"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,81 +4,88 @@
|
|||||||
* Description of Employees
|
* Description of Employees
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Employee extends DataObject {
|
class Employee extends DataObject
|
||||||
|
{
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'Name' => 'Varchar',
|
'Name' => 'Varchar',
|
||||||
'Biography' => 'HTMLText'
|
'Biography' => 'HTMLText'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Company' => 'Company',
|
'Company' => 'Company',
|
||||||
'ProfileImage' => 'Image'
|
'ProfileImage' => 'Image'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
||||||
'PastCompanies' => 'Company'
|
'PastCompanies' => 'Company'
|
||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
public function getCMSFields()
|
||||||
$fields = parent::getCMSFields();
|
{
|
||||||
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
if(method_exists('ManyManyList', 'getExtraFields')) {
|
if (method_exists('ManyManyList', 'getExtraFields')) {
|
||||||
$fields->addFieldToTab('Root.Main',
|
$fields->addFieldToTab('Root.Main',
|
||||||
new NumericField('ManyMany[YearStart]', 'Year started (3.1, many-many only)')
|
new NumericField('ManyMany[YearStart]', 'Year started (3.1, many-many only)')
|
||||||
);
|
);
|
||||||
$fields->addFieldToTab('Root.Main',
|
$fields->addFieldToTab('Root.Main',
|
||||||
new TextField('ManyMany[Role]', 'Role (3.1, many-many only)')
|
new TextField('ManyMany[Role]', 'Role (3.1, many-many only)')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.1 only
|
// 3.1 only
|
||||||
if(method_exists('UploadField', 'setAllowedFileCategories')) {
|
if (method_exists('UploadField', 'setAllowedFileCategories')) {
|
||||||
$fields->dataFieldByName('ProfileImage')->setAllowedFileCategories('image');
|
$fields->dataFieldByName('ProfileImage')->setAllowedFileCategories('image');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function requireDefaultRecords() {
|
public function requireDefaultRecords()
|
||||||
parent::requireDefaultRecords();
|
{
|
||||||
$employeeSet = DataObject::get('Employee');
|
parent::requireDefaultRecords();
|
||||||
foreach ($employeeSet as $employee) {
|
$employeeSet = DataObject::get('Employee');
|
||||||
$employee->delete();
|
foreach ($employeeSet as $employee) {
|
||||||
}
|
$employee->delete();
|
||||||
|
}
|
||||||
|
|
||||||
foreach($this->data() as $employeeName){
|
foreach ($this->data() as $employeeName) {
|
||||||
$employee = new Employee();
|
$employee = new Employee();
|
||||||
$employee->Name = $employeeName;
|
$employee->Name = $employeeName;
|
||||||
$employee->write();
|
$employee->write();
|
||||||
}
|
}
|
||||||
DB::alteration_message("Added default records to Employee table","created");
|
DB::alteration_message("Added default records to Employee table", "created");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate() {
|
public function validate()
|
||||||
$result = parent::validate();
|
{
|
||||||
if(!$this->Name) $result->error('"Name" can\'t be blank');
|
$result = parent::validate();
|
||||||
return $result;
|
if (!$this->Name) {
|
||||||
}
|
$result->error('"Name" can\'t be blank');
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains test data
|
* Contains test data
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function data() {
|
public function data()
|
||||||
return array(
|
{
|
||||||
'Hayley', 'Octavius', 'Walker', 'Gary','Elton','Janna','Ursa','Lars','Moses','Lareina',
|
return array(
|
||||||
'Elmo','Cara','Shea','Duncan','Velma','Acton','Galena','Heidi','Troy','Elliott','Cara',
|
'Hayley', 'Octavius', 'Walker', 'Gary','Elton','Janna','Ursa','Lars','Moses','Lareina',
|
||||||
'Whitney','Summer','Olga','Tatum','Zeph','Jared','Hilda','Quinlan','Chaim','Xenos',
|
'Elmo','Cara','Shea','Duncan','Velma','Acton','Galena','Heidi','Troy','Elliott','Cara',
|
||||||
'Cara','Tatiana','Tyrone','Juliet','Chester','Hannah','Imani','Quinn','Ariel','Abel',
|
'Whitney','Summer','Olga','Tatum','Zeph','Jared','Hilda','Quinlan','Chaim','Xenos',
|
||||||
'Aretha','Courtney ','Shellie','Garrett','Camilla','Simon','Mohammad','Kirby','Rae',
|
'Cara','Tatiana','Tyrone','Juliet','Chester','Hannah','Imani','Quinn','Ariel','Abel',
|
||||||
'Xena','Noel','Omar','Shannon','Iola','Maia','Serina','Taylor','Alice','Lucy','Austin',
|
'Aretha','Courtney ','Shellie','Garrett','Camilla','Simon','Mohammad','Kirby','Rae',
|
||||||
'Abel','Quinn','Yetta','Ulysses','Donovan','Castor','Emmanuel','Nero','Virginia',
|
'Xena','Noel','Omar','Shannon','Iola','Maia','Serina','Taylor','Alice','Lucy','Austin',
|
||||||
'Gregory','Neville','Abel','Len','Knox','Gavin','Pascale','Hyatt','Alden','Emerald',
|
'Abel','Quinn','Yetta','Ulysses','Donovan','Castor','Emmanuel','Nero','Virginia',
|
||||||
'Cherokee','Zeph','Adam','Uma','Serena','Isabelle','Kieran','Moses','Gay','Lavinia',
|
'Gregory','Neville','Abel','Len','Knox','Gavin','Pascale','Hyatt','Alden','Emerald',
|
||||||
'Elvis','Illana','Lee','Ariana','Hilel','Juliet','Gage','Larissa','Richard','Allen'
|
'Cherokee','Zeph','Adam','Uma','Serena','Isabelle','Kieran','Moses','Gay','Lavinia',
|
||||||
);
|
'Elvis','Illana','Lee','Ariana','Hilel','Juliet','Gage','Larissa','Richard','Allen'
|
||||||
}
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,25 +5,30 @@
|
|||||||
*
|
*
|
||||||
* @todo Allow passing in counts
|
* @todo Allow passing in counts
|
||||||
*/
|
*/
|
||||||
class FTPageMakerTask extends BuildTask {
|
class FTPageMakerTask extends BuildTask
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
function run($request) {
|
public function run($request)
|
||||||
echo "<h1>Making pages</h1>";
|
{
|
||||||
// Creates 3^5 pages
|
echo "<h1>Making pages</h1>";
|
||||||
$this->makePages(3,5);
|
// Creates 3^5 pages
|
||||||
}
|
$this->makePages(3, 5);
|
||||||
|
}
|
||||||
|
|
||||||
protected function makePages($count, $depth, $prefix = "", $parentID = 0) {
|
protected function makePages($count, $depth, $prefix = "", $parentID = 0)
|
||||||
for($i=1;$i<=$count;$i++) {
|
{
|
||||||
$page = new Page();
|
for ($i=1;$i<=$count;$i++) {
|
||||||
$page->ParentID = $parentID;
|
$page = new Page();
|
||||||
$page->Title = "Test page $prefix$i";
|
$page->ParentID = $parentID;
|
||||||
$page->write();
|
$page->Title = "Test page $prefix$i";
|
||||||
$page->publish('Stage', 'Live');
|
$page->write();
|
||||||
|
$page->publish('Stage', 'Live');
|
||||||
|
|
||||||
echo "<li>Created '$page->Title'";
|
echo "<li>Created '$page->Title'";
|
||||||
if($depth > 1) $this->makePages($count, $depth-1, $prefix."$i.", $page->ID);
|
if ($depth > 1) {
|
||||||
}
|
$this->makePages($count, $depth-1, $prefix."$i.", $page->ID);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
class FileUploadRole extends DataExtension{
|
class FileUploadRole extends DataExtension
|
||||||
private static $has_one = array(
|
{
|
||||||
'AFile' => 'File',
|
private static $has_one = array(
|
||||||
'AImage' => 'Image',
|
'AFile' => 'File',
|
||||||
);
|
'AImage' => 'Image',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
class FrameworkTestFileExtension extends DataExtension {
|
class FrameworkTestFileExtension extends DataExtension
|
||||||
private static $has_one = array(
|
{
|
||||||
'Company' => 'Company',
|
private static $has_one = array(
|
||||||
'BasicFieldsTestPage' => 'BasicFieldsTestPage'
|
'Company' => 'Company',
|
||||||
);
|
'BasicFieldsTestPage' => 'BasicFieldsTestPage'
|
||||||
|
);
|
||||||
}
|
}
|
@ -1,43 +1,46 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class FrameworkTestRole extends DataExtension {
|
class FrameworkTestRole extends DataExtension
|
||||||
|
{
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'FavouritePage' => 'SiteTree',
|
'FavouritePage' => 'SiteTree',
|
||||||
);
|
);
|
||||||
|
|
||||||
function updateCMSFields(FieldList $fields) {
|
public function updateCMSFields(FieldList $fields)
|
||||||
$fields->addFieldToTab(
|
{
|
||||||
'Root.Main',
|
$fields->addFieldToTab(
|
||||||
new TreeDropdownField("FavouritePageID", "Favourite page", "SiteTree")
|
'Root.Main',
|
||||||
);
|
new TreeDropdownField("FavouritePageID", "Favourite page", "SiteTree")
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function requireDefaultRecords() {
|
public function requireDefaultRecords()
|
||||||
$hasTestMembers = DataObject::get('Member')->find('Email', 'hayley@test.com');
|
{
|
||||||
if(!$hasTestMembers) {
|
$hasTestMembers = DataObject::get('Member')->find('Email', 'hayley@test.com');
|
||||||
|
if (!$hasTestMembers) {
|
||||||
|
foreach ($this->data() as $name) {
|
||||||
|
$member = new Member(array(
|
||||||
|
'FirstName' => $name,
|
||||||
|
'FirstName' => 'Smith',
|
||||||
|
'Email' => "{$name}@test.com",
|
||||||
|
));
|
||||||
|
$member->write();
|
||||||
|
}
|
||||||
|
|
||||||
foreach($this->data() as $name) {
|
DB::alteration_message("Added default records to Member table", "created");
|
||||||
$member = new Member(array(
|
}
|
||||||
'FirstName' => $name,
|
}
|
||||||
'FirstName' => 'Smith',
|
|
||||||
'Email' => "{$name}@test.com",
|
|
||||||
));
|
|
||||||
$member->write();
|
|
||||||
}
|
|
||||||
|
|
||||||
DB::alteration_message("Added default records to Member table","created");
|
/**
|
||||||
}
|
* Contains test data
|
||||||
}
|
*
|
||||||
|
* @return array
|
||||||
/**
|
*/
|
||||||
* Contains test data
|
public function data()
|
||||||
*
|
{
|
||||||
* @return array
|
return array(
|
||||||
*/
|
'Hayley', 'Octavius', 'Walker', 'Gary', 'Elton', 'Janna', 'Ursa', 'Lars', 'Moses', 'Lareina', 'Elmo', 'Shea', 'Duncan', 'Velma', 'Acton', 'Galena', 'Heidi', 'Troy', 'Elliott', 'Whitney', 'Summer', 'Olga', 'Tatum', 'Zeph', 'Jared', 'Hilda', 'Quinlan', 'Chaim', 'Xenos', 'Cara', 'Tatiana', 'Tyrone', 'Juliet', 'Chester', 'Hannah', 'Imani', 'Quinn', 'Ariel', 'Aretha', 'Courtney ', 'Shellie', 'Garrett', 'Camilla', 'Simon', 'Mohammad', 'Kirby', 'Rae', 'Xena', 'Noel', 'Omar', 'Shannon', 'Iola', 'Maia', 'Serina', 'Taylor', 'Alice', 'Lucy', 'Austin', 'Abel', 'Yetta', 'Ulysses', 'Donovan', 'Castor', 'Emmanuel', 'Nero', 'Virginia', 'Gregory', 'Neville', 'Len', 'Knox', 'Gavin', 'Pascale', 'Hyatt', 'Alden', 'Emerald', 'Cherokee', 'Adam', 'Uma', 'Serena', 'Isabelle', 'Kieran', 'Gay', 'Lavinia', 'Elvis', 'Illana', 'Lee', 'Ariana', 'Hilel', 'Gage', 'Larissa', 'Richard', 'Allen'
|
||||||
public function data() {
|
);
|
||||||
return array(
|
}
|
||||||
'Hayley', 'Octavius', 'Walker', 'Gary', 'Elton', 'Janna', 'Ursa', 'Lars', 'Moses', 'Lareina', 'Elmo', 'Shea', 'Duncan', 'Velma', 'Acton', 'Galena', 'Heidi', 'Troy', 'Elliott', 'Whitney', 'Summer', 'Olga', 'Tatum', 'Zeph', 'Jared', 'Hilda', 'Quinlan', 'Chaim', 'Xenos', 'Cara', 'Tatiana', 'Tyrone', 'Juliet', 'Chester', 'Hannah', 'Imani', 'Quinn', 'Ariel', 'Aretha', 'Courtney ', 'Shellie', 'Garrett', 'Camilla', 'Simon', 'Mohammad', 'Kirby', 'Rae', 'Xena', 'Noel', 'Omar', 'Shannon', 'Iola', 'Maia', 'Serina', 'Taylor', 'Alice', 'Lucy', 'Austin', 'Abel', 'Yetta', 'Ulysses', 'Donovan', 'Castor', 'Emmanuel', 'Nero', 'Virginia', 'Gregory', 'Neville', 'Len', 'Knox', 'Gavin', 'Pascale', 'Hyatt', 'Alden', 'Emerald', 'Cherokee', 'Adam', 'Uma', 'Serena', 'Isabelle', 'Kieran', 'Gay', 'Lavinia', 'Elvis', 'Illana', 'Lee', 'Ariana', 'Hilel', 'Gage', 'Larissa', 'Richard', 'Allen'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
class FrameworkTestSiteTreeExtension extends DataExtension {
|
class FrameworkTestSiteTreeExtension extends DataExtension
|
||||||
|
{
|
||||||
private static $has_one = array('RelationFieldsTestPage' => 'RelationFieldsTestPage');
|
|
||||||
private static $belongs_many_many = array('RelationFieldsTestPages' => 'RelationFieldsTestPage');
|
|
||||||
|
|
||||||
|
private static $has_one = array('RelationFieldsTestPage' => 'RelationFieldsTestPage');
|
||||||
|
private static $belongs_many_many = array('RelationFieldsTestPages' => 'RelationFieldsTestPage');
|
||||||
}
|
}
|
||||||
|
@ -4,85 +4,92 @@
|
|||||||
* These configurations are assumed to be evaluated in mysite/_config.php,
|
* These configurations are assumed to be evaluated in mysite/_config.php,
|
||||||
* with custom switches for the different options.
|
* with custom switches for the different options.
|
||||||
*/
|
*/
|
||||||
class FrameworktestRegressSessionAdmin extends Controller {
|
class FrameworktestRegressSessionAdmin extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
protected $template = 'BlankPage';
|
protected $template = 'BlankPage';
|
||||||
|
|
||||||
function init() {
|
public function init()
|
||||||
parent::init();
|
{
|
||||||
|
parent::init();
|
||||||
|
|
||||||
if(!Permission::check('ADMIN')) return Security::permissionFailure($this);
|
if (!Permission::check('ADMIN')) {
|
||||||
}
|
return Security::permissionFailure($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function Link($action = null) {
|
public function Link($action = null)
|
||||||
return Controller::join_links('dev', 'regress', $action);
|
{
|
||||||
}
|
return Controller::join_links('dev', 'regress', $action);
|
||||||
|
}
|
||||||
|
|
||||||
function Form() {
|
public function Form()
|
||||||
$isRunning = (Session::get('db'));
|
{
|
||||||
|
$isRunning = (Session::get('db'));
|
||||||
|
|
||||||
if($isRunning) {
|
if ($isRunning) {
|
||||||
$actions = new FieldList(
|
$actions = new FieldList(
|
||||||
new FormAction('endsession', 'End Session')
|
new FormAction('endsession', 'End Session')
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$actions = new FieldList(
|
$actions = new FieldList(
|
||||||
new FormAction('startsession', 'Start Session')
|
new FormAction('startsession', 'Start Session')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'Form',
|
'Form',
|
||||||
new FieldList(
|
new FieldList(
|
||||||
new HeaderField('Header1', ($isRunning) ? 'Session is already running' : 'Start new regress session'),
|
new HeaderField('Header1', ($isRunning) ? 'Session is already running' : 'Start new regress session'),
|
||||||
new LiteralField('Lit1',
|
new LiteralField('Lit1',
|
||||||
'<p>Use this form to set configuration prior to starting a <a href="http://regress.silverstripe.com">regress.silverstripe.com</a> test session (manual testing).</p>'
|
'<p>Use this form to set configuration prior to starting a <a href="http://regress.silverstripe.com">regress.silverstripe.com</a> test session (manual testing).</p>'
|
||||||
),
|
),
|
||||||
$dbField = new DropdownField(
|
$dbField = new DropdownField(
|
||||||
'db',
|
'db',
|
||||||
'Database',
|
'Database',
|
||||||
array(
|
array(
|
||||||
'mysql' => 'MySQL',
|
'mysql' => 'MySQL',
|
||||||
'postgresql' => 'Postgres',
|
'postgresql' => 'Postgres',
|
||||||
'mssql' => 'MSSQL',
|
'mssql' => 'MSSQL',
|
||||||
'sqlite3' => 'SQLite3',
|
'sqlite3' => 'SQLite3',
|
||||||
),
|
),
|
||||||
Session::get('db')
|
Session::get('db')
|
||||||
),
|
),
|
||||||
$chkField = new CheckboxField(
|
$chkField = new CheckboxField(
|
||||||
'enabletranslatable',
|
'enabletranslatable',
|
||||||
'Translatable?',
|
'Translatable?',
|
||||||
Session::get('enabletranslatable')
|
Session::get('enabletranslatable')
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
$actions
|
$actions
|
||||||
);
|
);
|
||||||
$dbField->setHasEmptyDefault(false);
|
$dbField->setHasEmptyDefault(false);
|
||||||
|
|
||||||
if($isRunning) {
|
if ($isRunning) {
|
||||||
foreach($form->Fields() as $field) {
|
foreach ($form->Fields() as $field) {
|
||||||
$form->Fields()->replaceField($field->Name(),
|
$form->Fields()->replaceField($field->Name(),
|
||||||
$field->performReadonlyTransformation()
|
$field->performReadonlyTransformation()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
function startsession($data, $form) {
|
public function startsession($data, $form)
|
||||||
Session::set('enabletranslatable', (isset($data['enabletranslatable'])) ? $data['enabletranslatable'] : null);
|
{
|
||||||
Session::set('db', $data['db']);
|
Session::set('enabletranslatable', (isset($data['enabletranslatable'])) ? $data['enabletranslatable'] : null);
|
||||||
|
Session::set('db', $data['db']);
|
||||||
|
|
||||||
return $this->redirect('dev/build/?BackURL=admin');
|
return $this->redirect('dev/build/?BackURL=admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
function endsession() {
|
public function endsession()
|
||||||
Session::set('enabletranslatable', null);
|
{
|
||||||
Session::set('db', null);
|
Session::set('enabletranslatable', null);
|
||||||
|
Session::set('db', null);
|
||||||
return $this->redirectBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return $this->redirectBack();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,75 +1,78 @@
|
|||||||
<?php
|
<?php
|
||||||
class GridFieldTestPage extends TestPage {
|
class GridFieldTestPage extends TestPage
|
||||||
|
{
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
"HasOneCompany" => "Company",
|
"HasOneCompany" => "Company",
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_many = array(
|
private static $has_many = array(
|
||||||
"HasManyCompanies" => "Company",
|
"HasManyCompanies" => "Company",
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $many_many = array(
|
private static $many_many = array(
|
||||||
"ManyManyCompanies" => "Company",
|
"ManyManyCompanies" => "Company",
|
||||||
);
|
);
|
||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields()
|
||||||
$fields = parent::getCMSFields();
|
{
|
||||||
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$grids = array();
|
$grids = array();
|
||||||
|
|
||||||
$config = new GridFieldConfig_RecordEditor();
|
$config = new GridFieldConfig_RecordEditor();
|
||||||
$grid = new GridField('Companies', 'Companies', new DataList('Company'),$config);
|
$grid = new GridField('Companies', 'Companies', new DataList('Company'), $config);
|
||||||
$fields->addFieldToTab('Root.NoRelation', $grid);
|
$fields->addFieldToTab('Root.NoRelation', $grid);
|
||||||
$grids[] = $grid;
|
$grids[] = $grid;
|
||||||
|
|
||||||
$config = new GridFieldConfig_RelationEditor();
|
$config = new GridFieldConfig_RelationEditor();
|
||||||
$grid = new GridField('HasManyCompanies', 'HasManyCompanies', $this->HasManyCompanies(),$config);
|
$grid = new GridField('HasManyCompanies', 'HasManyCompanies', $this->HasManyCompanies(), $config);
|
||||||
$fields->addFieldToTab('Root.HasMany', $grid);
|
$fields->addFieldToTab('Root.HasMany', $grid);
|
||||||
$grids[] = $grid;
|
$grids[] = $grid;
|
||||||
|
|
||||||
$config = new GridFieldConfig_RelationEditor();
|
$config = new GridFieldConfig_RelationEditor();
|
||||||
$grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', $this->ManyManyCompanies(),$config);
|
$grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', $this->ManyManyCompanies(), $config);
|
||||||
$fields->addFieldToTab('Root.ManyMany', $grid);
|
$fields->addFieldToTab('Root.ManyMany', $grid);
|
||||||
$grids[] = $grid;
|
$grids[] = $grid;
|
||||||
|
|
||||||
foreach($grids as $grid) {
|
|
||||||
$grid
|
|
||||||
->setDescription('This is <strong>bold</strong> help text');
|
|
||||||
// ->addExtraClass('cms-description-tooltip');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
foreach ($grids as $grid) {
|
||||||
|
$grid
|
||||||
|
->setDescription('This is <strong>bold</strong> help text');
|
||||||
|
// ->addExtraClass('cms-description-tooltip');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $fields;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GridFieldTestPage_Controller extends Page_Controller {
|
class GridFieldTestPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'Form',
|
'Form',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Title = "GridFieldTestPage";
|
public $Title = "GridFieldTestPage";
|
||||||
|
|
||||||
public function init(){
|
public function init()
|
||||||
parent::init();
|
{
|
||||||
Requirements::css('frameworktest/css/gridfieldtest.css','screen');
|
parent::init();
|
||||||
}
|
Requirements::css('frameworktest/css/gridfieldtest.css', 'screen');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
public function Form(){
|
public function Form()
|
||||||
$config = new GridFieldConfig_RecordEditor();
|
{
|
||||||
|
$config = new GridFieldConfig_RecordEditor();
|
||||||
|
|
||||||
$grid = new GridField('Companies', 'Companies', new DataList('Company'),$config);
|
$grid = new GridField('Companies', 'Companies', new DataList('Company'), $config);
|
||||||
return new Form($this,'Form',new FieldList($grid),new FieldList());
|
return new Form($this, 'Form', new FieldList($grid), new FieldList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Organisation extends DataObject {
|
class Organisation extends DataObject
|
||||||
|
{
|
||||||
// Used to test the Multiform module
|
|
||||||
private static $db = array(
|
|
||||||
'OrganisationName' => 'Text'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
// Used to test the Multiform module
|
||||||
|
private static $db = array(
|
||||||
|
'OrganisationName' => 'Text'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -1,56 +1,58 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class RelationFieldsTestPage extends TestPage {
|
class RelationFieldsTestPage extends TestPage
|
||||||
|
{
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
"HasOneCompany" => "Company",
|
"HasOneCompany" => "Company",
|
||||||
"HasOnePage" => "SiteTree",
|
"HasOnePage" => "SiteTree",
|
||||||
"HasOnePageWithSearch" => "SiteTree",
|
"HasOnePageWithSearch" => "SiteTree",
|
||||||
);
|
);
|
||||||
private static $has_many = array(
|
private static $has_many = array(
|
||||||
"HasManyCompanies" => "Company",
|
"HasManyCompanies" => "Company",
|
||||||
"HasManyPages" => "SiteTree",
|
"HasManyPages" => "SiteTree",
|
||||||
);
|
);
|
||||||
private static $many_many = array(
|
private static $many_many = array(
|
||||||
"ManyManyCompanies" => "Company",
|
"ManyManyCompanies" => "Company",
|
||||||
"ManyManyPages" => "SiteTree",
|
"ManyManyPages" => "SiteTree",
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $defaults = array(
|
private static $defaults = array(
|
||||||
'Title' => 'Relational Fields'
|
'Title' => 'Relational Fields'
|
||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
public function getCMSFields()
|
||||||
$fields = parent::getCMSFields();
|
{
|
||||||
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$allFields = array();
|
$allFields = array();
|
||||||
|
|
||||||
$checkboxFields = array(
|
$checkboxFields = array(
|
||||||
new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map())
|
new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map())
|
||||||
);
|
);
|
||||||
$fields->addFieldsToTab("Root.CheckboxSet", $checkboxFields);
|
$fields->addFieldsToTab("Root.CheckboxSet", $checkboxFields);
|
||||||
$allFields += $checkboxFields;
|
$allFields += $checkboxFields;
|
||||||
|
|
||||||
$treeFields = array(
|
$treeFields = array(
|
||||||
TreeDropdownField::create('HasOnePageID', 'HasOnePage', 'SiteTree'),
|
TreeDropdownField::create('HasOnePageID', 'HasOnePage', 'SiteTree'),
|
||||||
TreeDropdownField::create('HasOnePageWithSearchID', 'HasOnePageWithSearch', 'SiteTree')->setShowSearch(true),
|
TreeDropdownField::create('HasOnePageWithSearchID', 'HasOnePageWithSearch', 'SiteTree')->setShowSearch(true),
|
||||||
TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'),
|
TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'),
|
||||||
TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true)
|
TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true)
|
||||||
);
|
);
|
||||||
$fields->addFieldsToTab('Root.Tree', $treeFields);
|
$fields->addFieldsToTab('Root.Tree', $treeFields);
|
||||||
$allFields += $treeFields;
|
$allFields += $treeFields;
|
||||||
|
|
||||||
foreach($allFields as $field) {
|
foreach ($allFields as $field) {
|
||||||
$field
|
$field
|
||||||
->setDescription('This is <strong>bold</strong> help text')
|
->setDescription('This is <strong>bold</strong> help text')
|
||||||
->addExtraClass('cms-help');
|
->addExtraClass('cms-help');
|
||||||
// ->addExtraClass('cms-help cms-help-tooltip');
|
// ->addExtraClass('cms-help cms-help-tooltip');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RelationFieldsTestPage_Controller extends TestPage_Controller {
|
class RelationFieldsTestPage_Controller extends TestPage_Controller
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
@ -3,34 +3,37 @@
|
|||||||
/**
|
/**
|
||||||
* A data type that is related many-many to RelationFieldsTestPage, for testing purposes
|
* A data type that is related many-many to RelationFieldsTestPage, for testing purposes
|
||||||
*/
|
*/
|
||||||
class TestCategory extends DataObject {
|
class TestCategory extends DataObject
|
||||||
private static $db = array(
|
{
|
||||||
"Title" => "Varchar",
|
private static $db = array(
|
||||||
);
|
"Title" => "Varchar",
|
||||||
private static $belongs_many_many = array(
|
);
|
||||||
"RelationPages" => "RelationFieldsTestPage",
|
private static $belongs_many_many = array(
|
||||||
);
|
"RelationPages" => "RelationFieldsTestPage",
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a dropdown map of all objects of this class
|
* Returns a dropdown map of all objects of this class
|
||||||
*/
|
*/
|
||||||
static function map() {
|
public static function map()
|
||||||
$categories = DataObject::get('TestCategory');
|
{
|
||||||
if($categories) return $categories->map('ID', 'Title')->toArray();
|
$categories = DataObject::get('TestCategory');
|
||||||
else return array();
|
if ($categories) {
|
||||||
}
|
return $categories->map('ID', 'Title')->toArray();
|
||||||
|
} else {
|
||||||
function requireDefaultRecords(){
|
return array();
|
||||||
$class = $this->class;
|
}
|
||||||
if(!DataObject::get_one($class)) {
|
}
|
||||||
foreach(array("A","B","C","D") as $item) {
|
|
||||||
$page = new $class();
|
|
||||||
$page->Title = "Test Category $item";
|
|
||||||
$page->write();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function requireDefaultRecords()
|
||||||
|
{
|
||||||
|
$class = $this->class;
|
||||||
|
if (!DataObject::get_one($class)) {
|
||||||
|
foreach (array("A", "B", "C", "D") as $item) {
|
||||||
|
$page = new $class();
|
||||||
|
$page->Title = "Test Category $item";
|
||||||
|
$page->write();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -1,34 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class TestFileUploadPage extends TestPage{
|
class TestFileUploadPage extends TestPage
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestFileUploadPage_Controller extends TestPage_Controller{
|
class TestFileUploadPage_Controller extends TestPage_Controller
|
||||||
|
{
|
||||||
|
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'Form'
|
'Form'
|
||||||
);
|
);
|
||||||
|
|
||||||
function Form(){
|
public function Form()
|
||||||
$fields = new FieldList(
|
{
|
||||||
new EmailField('Email', 'EmailField'),
|
$fields = new FieldList(
|
||||||
new FileField('AFile','FileField'),
|
new EmailField('Email', 'EmailField'),
|
||||||
$aImage = new UploadField('AImage','SimpleImageField')
|
new FileField('AFile', 'FileField'),
|
||||||
);
|
$aImage = new UploadField('AImage', 'SimpleImageField')
|
||||||
|
);
|
||||||
|
|
||||||
$aImage->allowedExtensions = array('jpg', 'gif', 'png');
|
$aImage->allowedExtensions = array('jpg', 'gif', 'png');
|
||||||
|
|
||||||
$actions = new FieldList(
|
$actions = new FieldList(
|
||||||
new FormAction('addMember', "Add a member with two Files uploaded")
|
new FormAction('addMember', "Add a member with two Files uploaded")
|
||||||
);
|
);
|
||||||
return new Form($this, "Form", $fields, $actions);
|
return new Form($this, "Form", $fields, $actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMember($data, $form){
|
public function addMember($data, $form)
|
||||||
$member = new Member();
|
{
|
||||||
$form->saveInto($member);
|
$member = new Member();
|
||||||
$member->write();
|
$form->saveInto($member);
|
||||||
$this->redirectBack();
|
$member->write();
|
||||||
}
|
$this->redirectBack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class TestModelAdmin extends ModelAdmin {
|
class TestModelAdmin extends ModelAdmin
|
||||||
private static $url_segment = 'test';
|
{
|
||||||
private static $menu_title = 'Test ModelAdmin';
|
private static $url_segment = 'test';
|
||||||
|
private static $menu_title = 'Test ModelAdmin';
|
||||||
private static $managed_models = array(
|
|
||||||
"Company",
|
|
||||||
"Employee",
|
|
||||||
);
|
|
||||||
|
|
||||||
|
private static $managed_models = array(
|
||||||
|
"Company",
|
||||||
|
"Employee",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -3,106 +3,118 @@
|
|||||||
/**
|
/**
|
||||||
* Parent class of all test pages
|
* Parent class of all test pages
|
||||||
*/
|
*/
|
||||||
class TestPage extends Page {
|
class TestPage extends Page
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We can only create subclasses of TestPage
|
* We can only create subclasses of TestPage
|
||||||
*/
|
*/
|
||||||
function canCreate($member = null) {
|
public function canCreate($member = null)
|
||||||
// Don't allow creation other than through requireDefaultRecords
|
{
|
||||||
return false;
|
// Don't allow creation other than through requireDefaultRecords
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function requireDefaultRecords(){
|
public function requireDefaultRecords()
|
||||||
if($this->class == 'TestPage') return;
|
{
|
||||||
|
if ($this->class == 'TestPage') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$class = $this->class;
|
$class = $this->class;
|
||||||
if(!DataObject::get_one($class)) {
|
if (!DataObject::get_one($class)) {
|
||||||
// Try to create common parent
|
// Try to create common parent
|
||||||
$parent = SiteTree::get()
|
$parent = SiteTree::get()
|
||||||
->filter('URLSegment', 'feature-test-pages')
|
->filter('URLSegment', 'feature-test-pages')
|
||||||
->First();
|
->First();
|
||||||
|
|
||||||
if(!$parent) {
|
if (!$parent) {
|
||||||
$parent = new Page(array(
|
$parent = new Page(array(
|
||||||
'Title' => 'Feature Test Pages',
|
'Title' => 'Feature Test Pages',
|
||||||
'Content' => 'A collection of pages for testing various features in the SilverStripe CMS',
|
'Content' => 'A collection of pages for testing various features in the SilverStripe CMS',
|
||||||
'ShowInMenus' => 0
|
'ShowInMenus' => 0
|
||||||
));
|
));
|
||||||
$parent->write();
|
$parent->write();
|
||||||
$parent->doPublish();
|
$parent->doPublish();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create actual page
|
|
||||||
$page = new $class();
|
|
||||||
$page->Title = str_replace("TestPage","",$class);
|
|
||||||
$page->ShowInMenus = 0;
|
|
||||||
if($parent) $page->ParentID = $parent->ID;
|
|
||||||
$page->write();
|
|
||||||
$page->publish('Stage', 'Live');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Create actual page
|
||||||
|
$page = new $class();
|
||||||
|
$page->Title = str_replace("TestPage", "", $class);
|
||||||
|
$page->ShowInMenus = 0;
|
||||||
|
if ($parent) {
|
||||||
|
$page->ParentID = $parent->ID;
|
||||||
|
}
|
||||||
|
$page->write();
|
||||||
|
$page->publish('Stage', 'Live');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent class of all test page controllers
|
* Parent class of all test page controllers
|
||||||
*/
|
*/
|
||||||
class TestPage_Controller extends Page_Controller {
|
class TestPage_Controller extends Page_Controller
|
||||||
private static $allowed_actions = array(
|
{
|
||||||
'Form',
|
private static $allowed_actions = array(
|
||||||
'save',
|
'Form',
|
||||||
);
|
'save',
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This form is exactly like the CMS form. It gives us an opportunity to test the fields outside of the CMS context
|
* This form is exactly like the CMS form. It gives us an opportunity to test the fields outside of the CMS context
|
||||||
*/
|
*/
|
||||||
function Form() {
|
public function Form()
|
||||||
$fields = $this->getCMSFields();
|
{
|
||||||
$actions = new FieldList(
|
$fields = $this->getCMSFields();
|
||||||
new FormAction("save", "Save"),
|
$actions = new FieldList(
|
||||||
$gohome = new FormAction("gohome", "Go home")
|
new FormAction("save", "Save"),
|
||||||
);
|
$gohome = new FormAction("gohome", "Go home")
|
||||||
$gohome->setAttribute('src', 'frameworktest/images/test-button.png');
|
);
|
||||||
$form = new Form($this, "Form", $fields, $actions);
|
$gohome->setAttribute('src', 'frameworktest/images/test-button.png');
|
||||||
$form->loadDataFrom($this->dataRecord);
|
$form = new Form($this, "Form", $fields, $actions);
|
||||||
return $form;
|
$form->loadDataFrom($this->dataRecord);
|
||||||
}
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
function save($data, $form) {
|
public function save($data, $form)
|
||||||
$form->saveInto($this->dataRecord);
|
{
|
||||||
$this->dataRecord->write();
|
$form->saveInto($this->dataRecord);
|
||||||
$this->redirectBack();
|
$this->dataRecord->write();
|
||||||
}
|
$this->redirectBack();
|
||||||
|
}
|
||||||
|
|
||||||
function gohome() {
|
public function gohome()
|
||||||
$this->redirect("./");
|
{
|
||||||
}
|
$this->redirect("./");
|
||||||
|
}
|
||||||
|
|
||||||
function EmailForm() {
|
public function EmailForm()
|
||||||
return new Form($this, "EmailForm", new FieldList(
|
{
|
||||||
new TextField("Email", "Email address")
|
return new Form($this, "EmailForm", new FieldList(
|
||||||
), new FieldList(
|
new TextField("Email", "Email address")
|
||||||
new FormAction("sendEmail", "Send test email to this address")
|
), new FieldList(
|
||||||
));
|
new FormAction("sendEmail", "Send test email to this address")
|
||||||
}
|
));
|
||||||
|
}
|
||||||
|
|
||||||
function email() {
|
public function email()
|
||||||
return array(
|
{
|
||||||
'Content' => '<p>Use this form to send a test email</p>',
|
return array(
|
||||||
'Form' => $this->EmailForm()
|
'Content' => '<p>Use this form to send a test email</p>',
|
||||||
);
|
'Form' => $this->EmailForm()
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function sendEmail($data, $form) {
|
public function sendEmail($data, $form)
|
||||||
$email = new Email();
|
{
|
||||||
$email->setTo($data['Email']);
|
$email = new Email();
|
||||||
$email->setFrom($data['Email']);
|
$email->setTo($data['Email']);
|
||||||
$email->setSubject('A subject with some umlauts: öäüß');
|
$email->setFrom($data['Email']);
|
||||||
$email->setBody('A body with some umlauts: öäüß');
|
$email->setSubject('A subject with some umlauts: öäüß');
|
||||||
$email->send();
|
$email->setBody('A body with some umlauts: öäüß');
|
||||||
|
$email->send();
|
||||||
|
|
||||||
echo "<p>email sent to " . $data['Email'] . "</p>";
|
echo "<p>email sent to " . $data['Email'] . "</p>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
@ -1,64 +1,68 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Page2MultiForm extends MultiForm {
|
class Page2MultiForm extends MultiForm
|
||||||
|
{
|
||||||
|
|
||||||
public static $start_step = 'Page2PersonalDetailsFormStep';
|
public static $start_step = 'Page2PersonalDetailsFormStep';
|
||||||
|
|
||||||
public function finish($data, $form) {
|
public function finish($data, $form)
|
||||||
parent::finish($data, $form);
|
{
|
||||||
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
|
parent::finish($data, $form);
|
||||||
if($steps) {
|
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
|
||||||
foreach($steps as $step) {
|
if ($steps) {
|
||||||
if($step->class == 'Page2PersonalDetailsFormStep') {
|
foreach ($steps as $step) {
|
||||||
$member = new Member();
|
if ($step->class == 'Page2PersonalDetailsFormStep') {
|
||||||
$data = $step->loadData();
|
$member = new Member();
|
||||||
if($data) {
|
$data = $step->loadData();
|
||||||
$member->update($data);
|
if ($data) {
|
||||||
$member->write();
|
$member->update($data);
|
||||||
}
|
$member->write();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($step->class == 'Page2OrganisationDetailsFormStep') {
|
if ($step->class == 'Page2OrganisationDetailsFormStep') {
|
||||||
$organisation = new Organisation();
|
$organisation = new Organisation();
|
||||||
$data = $step->loadData();
|
$data = $step->loadData();
|
||||||
if($data) {
|
if ($data) {
|
||||||
$organisation->update($data);
|
$organisation->update($data);
|
||||||
if($member && $member->ID) $organisation->MemberID = $member->ID;
|
if ($member && $member->ID) {
|
||||||
$organisation->write();
|
$organisation->MemberID = $member->ID;
|
||||||
}
|
}
|
||||||
}
|
$organisation->write();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Debug::show($step->loadData()); // Shows the step data (unserialized by loadData)
|
// Debug::show($step->loadData()); // Shows the step data (unserialized by loadData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$controller = $this->getController();
|
$controller = $this->getController();
|
||||||
$controller->redirect($controller->Link() . 'finished');
|
$controller->redirect($controller->Link() . 'finished');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page2PersonalDetailsFormStep extends MultiFormStep {
|
class Page2PersonalDetailsFormStep extends MultiFormStep
|
||||||
|
{
|
||||||
|
|
||||||
public static $next_steps = 'Page2OrganisationDetailsFormStep';
|
public static $next_steps = 'Page2OrganisationDetailsFormStep';
|
||||||
|
|
||||||
function getFields() {
|
|
||||||
return new FieldList(
|
|
||||||
new TextField('FirstName', 'First name'),
|
|
||||||
new TextField('Surname', 'Surname')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function getFields()
|
||||||
|
{
|
||||||
|
return new FieldList(
|
||||||
|
new TextField('FirstName', 'First name'),
|
||||||
|
new TextField('Surname', 'Surname')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page2OrganisationDetailsFormStep extends MultiFormStep {
|
class Page2OrganisationDetailsFormStep extends MultiFormStep
|
||||||
|
{
|
||||||
|
|
||||||
public static $is_final_step = true;
|
public static $is_final_step = true;
|
||||||
|
|
||||||
function getFields() {
|
|
||||||
return new FieldList(
|
|
||||||
new TextField('OrganisationName', 'Organisation Name')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function getFields()
|
||||||
|
{
|
||||||
|
return new FieldList(
|
||||||
|
new TextField('OrganisationName', 'Organisation Name')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Page2MultiFormTestPage extends Page {
|
class Page2MultiFormTestPage extends Page
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page2MultiFormTestPage_Controller extends Page_Controller {
|
class Page2MultiFormTestPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
function Page2MultiForm() {
|
public function Page2MultiForm()
|
||||||
return new Page2MultiForm($this, 'Page2MultiForm');
|
{
|
||||||
}
|
return new Page2MultiForm($this, 'Page2MultiForm');
|
||||||
|
}
|
||||||
function finished() {
|
|
||||||
return array(
|
|
||||||
'Title' => 'Thank you for your submission',
|
|
||||||
'Content' => '<p>You have successfully submitted the form. Thanks!</p>'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function finished()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'Title' => 'Thank you for your submission',
|
||||||
|
'Content' => '<p>You have successfully submitted the form. Thanks!</p>'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -1,85 +1,87 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Page3MultiForm extends MultiForm {
|
class Page3MultiForm extends MultiForm
|
||||||
|
{
|
||||||
|
|
||||||
public static $start_step = 'Page3StartFormStep';
|
public static $start_step = 'Page3StartFormStep';
|
||||||
|
|
||||||
public function finish($data, $form) {
|
public function finish($data, $form)
|
||||||
parent::finish($data, $form);
|
{
|
||||||
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
|
parent::finish($data, $form);
|
||||||
if($steps) {
|
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
|
||||||
foreach($steps as $step) {
|
if ($steps) {
|
||||||
if($step->class == 'Page3PersonalDetailsFormStep') {
|
foreach ($steps as $step) {
|
||||||
$member = new Member();
|
if ($step->class == 'Page3PersonalDetailsFormStep') {
|
||||||
$data = $step->loadData();
|
$member = new Member();
|
||||||
if($data) {
|
$data = $step->loadData();
|
||||||
$member->update($data);
|
if ($data) {
|
||||||
$member->write();
|
$member->update($data);
|
||||||
}
|
$member->write();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if($step->class == 'Page3OrganisationDetailsFormStep') {
|
|
||||||
$organisation = new Organisation();
|
|
||||||
$data = $step->loadData();
|
|
||||||
if($data) {
|
|
||||||
$organisation->update($data);
|
|
||||||
if($member && $member->ID) $organisation->MemberID = $member->ID;
|
|
||||||
$organisation->write();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debug::show($step->loadData()); // Shows the step data (unserialized by loadData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$controller = $this->getController();
|
|
||||||
$controller->redirect($controller->Link() . 'finished');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($step->class == 'Page3OrganisationDetailsFormStep') {
|
||||||
|
$organisation = new Organisation();
|
||||||
|
$data = $step->loadData();
|
||||||
|
if ($data) {
|
||||||
|
$organisation->update($data);
|
||||||
|
if ($member && $member->ID) {
|
||||||
|
$organisation->MemberID = $member->ID;
|
||||||
|
}
|
||||||
|
$organisation->write();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debug::show($step->loadData()); // Shows the step data (unserialized by loadData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$controller = $this->getController();
|
||||||
|
$controller->redirect($controller->Link() . 'finished');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page3StartFormStep extends MultiFormStep {
|
class Page3StartFormStep extends MultiFormStep
|
||||||
|
{
|
||||||
|
|
||||||
public static $next_steps = 'Page3PersonalDetailsFormStep';
|
public static $next_steps = 'Page3PersonalDetailsFormStep';
|
||||||
|
|
||||||
function getFields() {
|
public function getFields()
|
||||||
return new FieldList(
|
{
|
||||||
new LiteralField('Details', '<b>This is important</b><br />
|
return new FieldList(
|
||||||
|
new LiteralField('Details', '<b>This is important</b><br />
|
||||||
<p>You will receiving email once you participate in this survey. <br />
|
<p>You will receiving email once you participate in this survey. <br />
|
||||||
Under the new Unsolicited Electronic Messages Act 2007, we must have your consent to send emails relating to this form. <br />
|
Under the new Unsolicited Electronic Messages Act 2007, we must have your consent to send emails relating to this form. <br />
|
||||||
If you do not wish to receive these emails please use the unsubscribe checkbox at bottom of this form. <br />
|
If you do not wish to receive these emails please use the unsubscribe checkbox at bottom of this form. <br />
|
||||||
If you still wish to receive these emails, you do not have to do anything.</p><br />
|
If you still wish to receive these emails, you do not have to do anything.</p><br />
|
||||||
<p>For more information visit <a href=\"http://silverstripe.com\">http://www.silverstripe.com/</a></p>'),
|
<p>For more information visit <a href=\"http://silverstripe.com\">http://www.silverstripe.com/</a></p>'),
|
||||||
new CheckboxField('Unsubscribe', 'Tick that you confirm the above details.')
|
new CheckboxField('Unsubscribe', 'Tick that you confirm the above details.')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page3PersonalDetailsFormStep extends MultiFormStep {
|
class Page3PersonalDetailsFormStep extends MultiFormStep
|
||||||
|
{
|
||||||
public static $next_steps = 'Page3OrganisationDetailsFormStep';
|
|
||||||
|
|
||||||
function getFields() {
|
|
||||||
return new FieldList(
|
|
||||||
new TextField('FirstName', 'First name'),
|
|
||||||
new TextField('Surname', 'Surname')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public static $next_steps = 'Page3OrganisationDetailsFormStep';
|
||||||
|
|
||||||
|
public function getFields()
|
||||||
|
{
|
||||||
|
return new FieldList(
|
||||||
|
new TextField('FirstName', 'First name'),
|
||||||
|
new TextField('Surname', 'Surname')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page3OrganisationDetailsFormStep extends MultiFormStep {
|
class Page3OrganisationDetailsFormStep extends MultiFormStep
|
||||||
|
{
|
||||||
|
|
||||||
public static $is_final_step = true;
|
public static $is_final_step = true;
|
||||||
|
|
||||||
function getFields() {
|
|
||||||
return new FieldList(
|
|
||||||
new TextField('OrganisationName', 'Organisation Name')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function getFields()
|
||||||
|
{
|
||||||
|
return new FieldList(
|
||||||
|
new TextField('OrganisationName', 'Organisation Name')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Page3MultiFormTestPage extends Page {
|
class Page3MultiFormTestPage extends Page
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page3MultiFormTestPage_Controller extends Page_Controller {
|
class Page3MultiFormTestPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
function Page3MultiForm() {
|
public function Page3MultiForm()
|
||||||
return new Page3MultiForm($this, 'Page3MultiForm');
|
{
|
||||||
}
|
return new Page3MultiForm($this, 'Page3MultiForm');
|
||||||
|
}
|
||||||
function finished() {
|
|
||||||
return array(
|
|
||||||
'Title' => 'Thank you for your submission',
|
|
||||||
'Content' => '<p>You have successfully submitted the form. Thanks!</p>'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function finished()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'Title' => 'Thank you for your submission',
|
||||||
|
'Content' => '<p>You have successfully submitted the form. Thanks!</p>'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -1,77 +1,84 @@
|
|||||||
<?php
|
<?php
|
||||||
class TestMultiForm extends MultiForm {
|
class TestMultiForm extends MultiForm
|
||||||
public static $start_step = 'TestMultiFormStepOne';
|
{
|
||||||
|
public static $start_step = 'TestMultiFormStepOne';
|
||||||
|
|
||||||
function finish($data, $form) {
|
public function finish($data, $form)
|
||||||
parent::finish($data, $form);
|
{
|
||||||
|
parent::finish($data, $form);
|
||||||
|
|
||||||
$savedSteps = $this->getSavedSteps();
|
$savedSteps = $this->getSavedSteps();
|
||||||
|
|
||||||
$savedData = array();
|
$savedData = array();
|
||||||
foreach($savedSteps as $step) {
|
foreach ($savedSteps as $step) {
|
||||||
$savedData = array_merge($savedData, $step->loadData());
|
$savedData = array_merge($savedData, $step->loadData());
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = new FieldList();
|
$fields = new FieldList();
|
||||||
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
||||||
|
|
||||||
foreach($savedData as $key=>$value) {
|
foreach ($savedData as $key=>$value) {
|
||||||
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
|
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Session::set("MultiFormMessage", "Your information has been submitted.");
|
Session::set("MultiFormMessage", "Your information has been submitted.");
|
||||||
|
|
||||||
$this->Controller()->redirect(Director::BaseURL() . $this->Controller()->URLSegment);
|
$this->Controller()->redirect(Director::BaseURL() . $this->Controller()->URLSegment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestMultiFormStepOne extends MultiFormStep {
|
class TestMultiFormStepOne extends MultiFormStep
|
||||||
public static $next_steps = 'TestMultiFormStepTwo';
|
{
|
||||||
|
public static $next_steps = 'TestMultiFormStepTwo';
|
||||||
function getFields() {
|
|
||||||
return new FieldList(
|
|
||||||
new TextField('FirstName', 'First name'),
|
|
||||||
new TextField('Surname', 'Surname')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function getFields()
|
||||||
|
{
|
||||||
|
return new FieldList(
|
||||||
|
new TextField('FirstName', 'First name'),
|
||||||
|
new TextField('Surname', 'Surname')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestMultiFormStepTwo extends MultiFormStep {
|
class TestMultiFormStepTwo extends MultiFormStep
|
||||||
public static $next_steps = 'TestMultiFormStepThree';
|
{
|
||||||
|
public static $next_steps = 'TestMultiFormStepThree';
|
||||||
|
|
||||||
function getFields() {
|
public function getFields()
|
||||||
|
{
|
||||||
return new FieldList(
|
return new FieldList(
|
||||||
new TextField('Email', 'Email'),
|
new TextField('Email', 'Email'),
|
||||||
new TextField('Address', 'Address')
|
new TextField('Address', 'Address')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TestMultiFormStepThree extends MultiFormStep {
|
class TestMultiFormStepThree extends MultiFormStep
|
||||||
public static $is_final_step = true;
|
{
|
||||||
|
public static $is_final_step = true;
|
||||||
|
|
||||||
function getFields() {
|
public function getFields()
|
||||||
$form = $this->getForm();
|
{
|
||||||
$savedSteps = $form->getSavedSteps();
|
$form = $this->getForm();
|
||||||
|
$savedSteps = $form->getSavedSteps();
|
||||||
|
|
||||||
$savedData = array();
|
$savedData = array();
|
||||||
foreach($savedSteps as $step) {
|
foreach ($savedSteps as $step) {
|
||||||
$savedData = array_merge($savedData, $step->loadData());
|
$savedData = array_merge($savedData, $step->loadData());
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = new FieldList();
|
$fields = new FieldList();
|
||||||
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
||||||
|
|
||||||
foreach($savedData as $key=>$value) {
|
foreach ($savedData as $key=>$value) {
|
||||||
if(preg_match("/_copy$/", $key)) continue;
|
if (preg_match("/_copy$/", $key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
|
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
class TestMultiFormPage extends Page {
|
class TestMultiFormPage extends Page
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestMultiFormPage_Controller extends Page_Controller {
|
class TestMultiFormPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
function Form() {
|
public function Form()
|
||||||
$form = new TestMultiForm($this, 'Form', new FieldList(), new FieldList());
|
{
|
||||||
|
$form = new TestMultiForm($this, 'Form', new FieldList(), new FieldList());
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
function FormMessage() {
|
public function FormMessage()
|
||||||
if(Session::get('MultiFormMessage')) {
|
{
|
||||||
$message = Session::get('MultiFormMessage');
|
if (Session::get('MultiFormMessage')) {
|
||||||
Session::clear('MultiFormMessage');
|
$message = Session::get('MultiFormMessage');
|
||||||
|
Session::clear('MultiFormMessage');
|
||||||
|
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
class RecaptchaTestPage extends Page {
|
class RecaptchaTestPage extends Page
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class RecaptchaTestPage_Controller extends Page_Controller {
|
class RecaptchaTestPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
function Form() {
|
public function Form()
|
||||||
$fields = new FieldList(
|
{
|
||||||
new TextField('MyText')
|
$fields = new FieldList(
|
||||||
);
|
new TextField('MyText')
|
||||||
if(class_exists('RecaptchaField')) {
|
);
|
||||||
$fields->push(new RecaptchaField('MyRecaptcha'));
|
if (class_exists('RecaptchaField')) {
|
||||||
} else {
|
$fields->push(new RecaptchaField('MyRecaptcha'));
|
||||||
$fields->push(new LiteralField('<p class="message error">RecaptchaField class not found</p>'));
|
} else {
|
||||||
}
|
$fields->push(new LiteralField('<p class="message error">RecaptchaField class not found</p>'));
|
||||||
|
}
|
||||||
|
|
||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'Form',
|
'Form',
|
||||||
$fields,
|
$fields,
|
||||||
new FieldList(
|
new FieldList(
|
||||||
new FormAction('submit', 'submit')
|
new FormAction('submit', 'submit')
|
||||||
),
|
),
|
||||||
new RequiredFields(array('MyText'))
|
new RequiredFields(array('MyText'))
|
||||||
);
|
);
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
function submit($data, $form) {
|
public function submit($data, $form)
|
||||||
$form->sessionMessage('Hooray!', 'good');
|
{
|
||||||
|
$form->sessionMessage('Hooray!', 'good');
|
||||||
return Director::redirectBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return Director::redirectBack();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,24 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
class SifrPage extends Page {
|
class SifrPage extends Page
|
||||||
|
{
|
||||||
|
|
||||||
function getCMSFields() {
|
public function getCMSFields()
|
||||||
$fields = parent::getCMSFields();
|
{
|
||||||
$fields->addFieldToTab("Root.Content.SifrSampleImage", new LiteralField("SifrSampleImage", '<p><img src="frameworktest/images/sifr_sample.png"/></p>'));
|
$fields = parent::getCMSFields();
|
||||||
|
$fields->addFieldToTab("Root.Content.SifrSampleImage", new LiteralField("SifrSampleImage", '<p><img src="frameworktest/images/sifr_sample.png"/></p>'));
|
||||||
return $fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return $fields;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SifrPage_Controller extends Page_Controller {
|
class SifrPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
function init() {
|
public function init()
|
||||||
parent::init();
|
{
|
||||||
|
parent::init();
|
||||||
|
|
||||||
Sifr::add_font('blackout', 'themes/fonts/blackout.swf');
|
Sifr::add_font('blackout', 'themes/fonts/blackout.swf');
|
||||||
Sifr::replace_element('blackout', 'h2', "'.sIFR-root { text-align: left; color: red;'");
|
Sifr::replace_element('blackout', 'h2', "'.sIFR-root { text-align: left; color: red;'");
|
||||||
Sifr::replace_element('blackout', 'h3', "'.sIFR-root { text-align: left; color: red;'");
|
Sifr::replace_element('blackout', 'h3', "'.sIFR-root { text-align: left; color: red;'");
|
||||||
Sifr::replace_element('blackout', 'h4', "'.sIFR-root { text-align: left; color: red;'");
|
Sifr::replace_element('blackout', 'h4', "'.sIFR-root { text-align: left; color: red;'");
|
||||||
Sifr::activate_sifr();
|
Sifr::activate_sifr();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user