Merge pull request #13 from helpfulrobot/convert-to-psr-2

Converted to PSR-2
This commit is contained in:
Damian Mooyman 2015-12-21 14:22:33 +13:00
commit 13ea394f64
26 changed files with 1450 additions and 1373 deletions

View File

@ -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(
'Dropdown' => 'TestCategory', private static $has_one = array(
'GroupedDropdown' => 'TestCategory', 'Dropdown' => 'TestCategory',
'ListboxField' => 'TestCategory', 'GroupedDropdown' => 'TestCategory',
'File' => 'File', 'ListboxField' => 'TestCategory',
'AttachedFile' => 'File', 'File' => 'File',
'Image' => 'Image', 'AttachedFile' => 'File',
); '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);
}
} }
?>

View File

@ -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() { public function DynamicProperty()
return sprintf('%s (%s)', $this->Name, $this->CEO); {
} return sprintf('%s (%s)', $this->Name, $this->CEO);
}
public function requireDefaultRecords() {
parent::requireDefaultRecords(); public function requireDefaultRecords()
$companySet = DataObject::get('Company'); {
foreach ($companySet as $company) { parent::requireDefaultRecords();
$company->delete(); $companySet = DataObject::get('Company');
} foreach ($companySet as $company) {
$company->delete();
foreach($this->data() as $companyData){ }
$company = new Company();
$company->Name = $companyData[0]; foreach ($this->data() as $companyData) {
$company->Category = $companyData[1]; $company = new Company();
$company->Revenue = $companyData[2]; $company->Name = $companyData[0];
$company->CEO = $companyData[3]; $company->Category = $companyData[1];
$company->write(); $company->Revenue = $companyData[2];
} $company->CEO = $companyData[3];
DB::alteration_message("Added default records to Company table","created"); $company->write();
} }
DB::alteration_message("Added default records to Company table", "created");
}
/** /**
* Contains test data * Contains test data
* *
* @return array * @return array
*/ */
public function data() { public function data()
return array( {
0 => array("Walmart", "Retail", "421.849", "Michael Duke"), return array(
1 => array("ExxonMobil", "Oil and gas", "370.125", "Rex W. Tillerson"), 0 => array("Walmart", "Retail", "421.849", "Michael Duke"),
2 => array("Royal Dutch Shell", "Oil and gas", "368.056", "Peter Voser"), 1 => array("ExxonMobil", "Oil and gas", "370.125", "Rex W. Tillerson"),
3 => array("BP", "Oil and gas", "297.107", "Robert Dudley"), 2 => array("Royal Dutch Shell", "Oil and gas", "368.056", "Peter Voser"),
4 => array("Sinopec", "Oil and gas", "289.774", "Jiming Wang"), 3 => array("BP", "Oil and gas", "297.107", "Robert Dudley"),
5 => array("State Grid Corporation of China", "Electricity", "231.556", "Liu Zhenya"), 4 => array("Sinopec", "Oil and gas", "289.774", "Jiming Wang"),
6 => array("Toyota Motors", "Automotive", "228.247", "Fujio Cho"), 5 => array("State Grid Corporation of China", "Electricity", "231.556", "Liu Zhenya"),
7 => array("PetroChina", "Oil and gas", "221.955", "Zhou Jiping"), 6 => array("Toyota Motors", "Automotive", "228.247", "Fujio Cho"),
8 => array("Total S.A.", "Oil and gas", "212.815", "Christophe de Margerie"), 7 => array("PetroChina", "Oil and gas", "221.955", "Zhou Jiping"),
9 => array("Japan Post Holdings", "Conglomerate", "211.080", "Jiro Saito"), 8 => array("Total S.A.", "Oil and gas", "212.815", "Christophe de Margerie"),
10 => array("Chevron", "Oil and gas", "204.928", "David J. O'Reilly"), 9 => array("Japan Post Holdings", "Conglomerate", "211.080", "Jiro Saito"),
11 => array("ConocoPhillips", "Oil and gas", "198.655", "James Mulva"), 10 => array("Chevron", "Oil and gas", "204.928", "David J. O'Reilly"),
12 => array("Vitol", "Raw material", "195.0", "Ian Taylor"), 11 => array("ConocoPhillips", "Oil and gas", "198.655", "James Mulva"),
13 => array("Saudi Aramco", "Oil and gas", "182.396", "Waleed Al-Bedaiwi"), 12 => array("Vitol", "Raw material", "195.0", "Ian Taylor"),
14 => array("Volkswagen Group", "Automotive", "169.53", "Martin Winterkorn"), 13 => array("Saudi Aramco", "Oil and gas", "182.396", "Waleed Al-Bedaiwi"),
15 => array("Fannie Mae", "Financial services", "154.270", "Mike Williams"), 14 => array("Volkswagen Group", "Automotive", "169.53", "Martin Winterkorn"),
16 => array("General Electric", "Conglomerate", "150.211", "Jeffrey Immelt"), 15 => array("Fannie Mae", "Financial services", "154.270", "Mike Williams"),
17 => array("Glencore", "Raw materials", "144.978", "Ivan Glasenberg"), 16 => array("General Electric", "Conglomerate", "150.211", "Jeffrey Immelt"),
18 => array("Allianz", "Financial services", "142.24", "Michael Diekmann"), 17 => array("Glencore", "Raw materials", "144.978", "Ivan Glasenberg"),
19 => array("ING Group", "Financial services", "140.729", "Jan Hommen"), 18 => array("Allianz", "Financial services", "142.24", "Michael Diekmann"),
20 => array("Berkshire Hathaway", "Conglomerate", "136.185", "Warren Buffett"), 19 => array("ING Group", "Financial services", "140.729", "Jan Hommen"),
21 => array("Samsung Electronics", "Conglomerate", "135.772", "Lee Kun-hee"), 20 => array("Berkshire Hathaway", "Conglomerate", "136.185", "Warren Buffett"),
22 => array("General Motors", "Automotive", "135.592", "Daniel Akerson"), 21 => array("Samsung Electronics", "Conglomerate", "135.772", "Lee Kun-hee"),
23 => array("Eni", "Oil and gas", "131.292", "Paolo Scaroni"), 22 => array("General Motors", "Automotive", "135.592", "Daniel Akerson"),
24 => array("Daimler AG", "Automotive", "130.628", "Dieter Zetsche"), 23 => array("Eni", "Oil and gas", "131.292", "Paolo Scaroni"),
25 => array("Ford Motor Company", "Automotive", "128.954", "Alan Mulally"), 24 => array("Daimler AG", "Automotive", "130.628", "Dieter Zetsche"),
26 => array("Hewlett-Packard", "Information technology", "127.245", "Meg Whitman"), 25 => array("Ford Motor Company", "Automotive", "128.954", "Alan Mulally"),
27 => array("Nippon Telegraph and Telephone", "Telecommunications", "124.517", "Norio Wada"), 26 => array("Hewlett-Packard", "Information technology", "127.245", "Meg Whitman"),
28 => array("AT&T", "Telecommunications", "124.28", "Randall L. Stephenson"), 27 => array("Nippon Telegraph and Telephone", "Telecommunications", "124.517", "Norio Wada"),
29 => array("E.ON", "Electricity; gas", "124.084", "Johannes Teyssen"), 28 => array("AT&T", "Telecommunications", "124.28", "Randall L. Stephenson"),
30 => array("Carrefour", "Retailing", "122.280", "Lars Olofsson"), 29 => array("E.ON", "Electricity; gas", "124.084", "Johannes Teyssen"),
31 => array("AXA", "Financial services", "121.577", "Henri de Castries"), 30 => array("Carrefour", "Retailing", "122.280", "Lars Olofsson"),
32 => array("Assicurazioni Generali", "Insurance", "121.299", "Sergio Balbinot, Giovanni Perissinotto"), 31 => array("AXA", "Financial services", "121.577", "Henri de Castries"),
33 => array("Petrobras", "Oil and gas", "120.052", "José Sérgio Gabrielli de Azevedo"), 32 => array("Assicurazioni Generali", "Insurance", "121.299", "Sergio Balbinot, Giovanni Perissinotto"),
34 => array("Cargill", "Agriculture", "119.469", "Greg Page"), 33 => array("Petrobras", "Oil and gas", "120.052", "José Sérgio Gabrielli de Azevedo"),
35 => array("JX Holdings", "Energy", "116.414", "-"), 34 => array("Cargill", "Agriculture", "119.469", "Greg Page"),
36 => array("GDF Suez", "Public utilities", "112.88", "Gérard Mestrallet"), 35 => array("JX Holdings", "Energy", "116.414", "-"),
37 => array("Hitachi, Ltd.", "Conglomerate", "112.239", "Etsuhiko Shoyama"), 36 => array("GDF Suez", "Public utilities", "112.88", "Gérard Mestrallet"),
38 => array("McKesson Corporation", "Health care", "112.084", "John Hammergren"), 37 => array("Hitachi, Ltd.", "Conglomerate", "112.239", "Etsuhiko Shoyama"),
39 => array("Gazprom", "Oil and Gas", "111.808", "Alexei Miller"), 38 => array("McKesson Corporation", "Health care", "112.084", "John Hammergren"),
40 => array("Bank of America", "Banking", "111.39", "Brian Moynihan"), 39 => array("Gazprom", "Oil and Gas", "111.808", "Alexei Miller"),
41 => array("Tesco", "Retailing", "110.85", "Philip Clarke"), 40 => array("Bank of America", "Banking", "111.39", "Brian Moynihan"),
42 => array("Federal Home Loan Mortgage Corporation", "Financial services", "109.956", "Richard F. Syron"), 41 => array("Tesco", "Retailing", "110.85", "Philip Clarke"),
43 => array("Apple Inc.", "Electronics", "108.249", "Tim Cook"), 42 => array("Federal Home Loan Mortgage Corporation", "Financial services", "109.956", "Richard F. Syron"),
44 => array("Honda", "Automotive", "107.985", "Takanobu Ito"), 43 => array("Apple Inc.", "Electronics", "108.249", "Tim Cook"),
45 => array("Verizon", "Telecommunications", "106.565", "Ivan Seidenberg"), 44 => array("Honda", "Automotive", "107.985", "Takanobu Ito"),
46 => array("Nissan Motors", "Automotive", "105.523", "Carlos Ghosn"), 45 => array("Verizon", "Telecommunications", "106.565", "Ivan Seidenberg"),
47 => array("Panasonic Corporation", "Electronics", "105.035", "Kunio Nakamura"), 46 => array("Nissan Motors", "Automotive", "105.523", "Carlos Ghosn"),
48 => array("Nestlé", "Food processing", "104.972", "Paul Bulcke"), 47 => array("Panasonic Corporation", "Electronics", "105.035", "Kunio Nakamura"),
49 => array("LUKoil", "Oil and Gas", "104.956", "Vagit Alekperov"), 48 => array("Nestlé", "Food processing", "104.972", "Paul Bulcke"),
50 => array("Pemex", "Oil and gas", "103.538", "Juan José Suárez Coppel"), 49 => array("LUKoil", "Oil and Gas", "104.956", "Vagit Alekperov"),
51 => array("JPMorgan Chase", "Financial Services", "102.694", "Jamie Dimon"), 50 => array("Pemex", "Oil and gas", "103.538", "Juan José Suárez Coppel"),
52 => array("Cardinal Health", "Health care", "102.644", "George Barrett"), 51 => array("JPMorgan Chase", "Financial Services", "102.694", "Jamie Dimon"),
53 => array("Koch Industries", "Conglomerate", "100.0", "Charles Koch"), 52 => array("Cardinal Health", "Health care", "102.644", "George Barrett"),
54 => array("Petróleos de Venezuela", "Oil and gas", "94.929", "Rafael Ramírez"), 53 => array("Koch Industries", "Conglomerate", "100.0", "Charles Koch"),
55 => array("IBM", "Information technology", "99.87", "Virginia Rometty"), 54 => array("Petróleos de Venezuela", "Oil and gas", "94.929", "Rafael Ramírez"),
56 => array("Siemens AG", "Conglomerate", "98.870", "Peter Löscher"), 55 => array("IBM", "Information technology", "99.87", "Virginia Rometty"),
57 => array("Hyundai Motors", "Automotive", "98.858", "Chung Mong-Koo"), 56 => array("Siemens AG", "Conglomerate", "98.870", "Peter Löscher"),
58 => array("Enel", "Electricity generation", "97.782", "Fulvio Conti"), 57 => array("Hyundai Motors", "Automotive", "98.858", "Chung Mong-Koo"),
59 => array("CVS Caremark", "Retailing", "96.413", "Tom Ryan"), 58 => array("Enel", "Electricity generation", "97.782", "Fulvio Conti"),
60 => array("Lloyds Banking Group", "Financial Services", "95.342", "António Horta-Osório"), 59 => array("CVS Caremark", "Retailing", "96.413", "Tom Ryan"),
61 => array("UnitedHealth Group", "Health care", "94.155", "Stephen Hemsley"), 60 => array("Lloyds Banking Group", "Financial Services", "95.342", "António Horta-Osório"),
62 => array("Statoil", "Oil and gas", "90.733", "Helge Lund"), 61 => array("UnitedHealth Group", "Health care", "94.155", "Stephen Hemsley"),
63 => array("Metro AG", "Retailing", "89.87", "Eckhard Cordes"), 62 => array("Statoil", "Oil and gas", "90.733", "Helge Lund"),
64 => array("Aviva", "Financial services", "89.890", "Andrew Moss"), 63 => array("Metro AG", "Retailing", "89.87", "Eckhard Cordes"),
65 => array("Electricité de France", "Electricity generation", "87.073", "Henri Proglio"), 64 => array("Aviva", "Financial services", "89.890", "Andrew Moss"),
66 => array("Costco", "Retailing", "87.048", "Jim Sinegal"), 65 => array("Electricité de France", "Electricity generation", "87.073", "Henri Proglio"),
67 => array("Citigroup", "Financial services", "86.601", "Vikram Pandit"), 66 => array("Costco", "Retailing", "87.048", "Jim Sinegal"),
68 => array("Sony", "Electronics", "86.521", "Howard Stringer"), 67 => array("Citigroup", "Financial services", "86.601", "Vikram Pandit"),
69 => array("BASF", "Chemical industry", "85.347", "Kurt Bock"), 68 => array("Sony", "Electronics", "86.521", "Howard Stringer"),
70 => array("Wells Fargo", "Banking / Financial services", "85.21", "John Stumpf"), 69 => array("BASF", "Chemical industry", "85.347", "Kurt Bock"),
71 => array("Société Générale", "Financial Services", "84.868", "Frédéric Oudéa"), 70 => array("Wells Fargo", "Banking / Financial services", "85.21", "John Stumpf"),
72 => array("Kuwait Petroleum Corporation", "Oil and gas", "84.594", "Saad Al Shuwaib"), 71 => array("Société Générale", "Financial Services", "84.868", "Frédéric Oudéa"),
73 => array("Deutsche Telekom", "Telecommunications", "83.407", "René Obermann"), 72 => array("Kuwait Petroleum Corporation", "Oil and gas", "84.594", "Saad Al Shuwaib"),
74 => array("Procter & Gamble", "Consumer goods", "82.559", "Robert A. \"Bob\" McDonald"), 73 => array("Deutsche Telekom", "Telecommunications", "83.407", "René Obermann"),
75 => array("Industrial and Commercial Bank of China", "Banking", "82.536", "Jiang Jianqing"), 74 => array("Procter & Gamble", "Consumer goods", "82.559", "Robert A. \"Bob\" McDonald"),
76 => array("Valero Energy", "Oil and gas", "82.233", "Bill Klesse"), 75 => array("Industrial and Commercial Bank of China", "Banking", "82.536", "Jiang Jianqing"),
77 => array("Kroger", "Retailing", "82.189", "David Dillon"), 76 => array("Valero Energy", "Oil and gas", "82.233", "Bill Klesse"),
78 => array("Nippon Life Insurance", "Insurance", "81.315", "Kunie Okamoto"), 77 => array("Kroger", "Retailing", "82.189", "David Dillon"),
79 => array("Telefónica", "Telecommunications", "80.938", "César Alierta"), 78 => array("Nippon Life Insurance", "Insurance", "81.315", "Kunie Okamoto"),
80 => array("BMW", "Automotive", "80.809", "Norbert Reithofer"), 79 => array("Telefónica", "Telecommunications", "80.938", "César Alierta"),
81 => array("Repsol YPF", "Oil and Gas", "80.747", "Antonio Brufau"), 80 => array("BMW", "Automotive", "80.809", "Norbert Reithofer"),
82 => array("Archer Daniels Midland", "Agriculture, Food processing", "80.676", "Patricia A. Woertz"), 81 => array("Repsol YPF", "Oil and Gas", "80.747", "Antonio Brufau"),
83 => array("AmerisourceBergen", "Health care", "80.218", "R. David Yost"), 82 => array("Archer Daniels Midland", "Agriculture, Food processing", "80.676", "Patricia A. Woertz"),
84 => array("HSBC", "Financial services", "80.014", "Stuart Gulliver"), 83 => array("AmerisourceBergen", "Health care", "80.218", "R. David Yost"),
85 => array("SK Group", "Conglomerate", "79.603", "Choi Tae-Won"), 84 => array("HSBC", "Financial services", "80.014", "Stuart Gulliver"),
86 => array("National Iranian Oil Company", "Oil and gas", "79.277", "Masoud Mir Kazemi"), 85 => array("SK Group", "Conglomerate", "79.603", "Choi Tae-Won"),
87 => array("Trafigura", "Raw materials", "79.2", " ?"), 86 => array("National Iranian Oil Company", "Oil and gas", "79.277", "Masoud Mir Kazemi"),
88 => array("ArcelorMittal", "Steel", "78.025", "Lakshmi Mittal"), 87 => array("Trafigura", "Raw materials", "79.2", " ?"),
89 => array("American International Group", "Financial services", "77.301", "Robert Benmosche"), 88 => array("ArcelorMittal", "Steel", "78.025", "Lakshmi Mittal"),
90 => array("Toshiba", "Conglomerate", "77.090", "Tadashi Okamura"), 89 => array("American International Group", "Financial services", "77.301", "Robert Benmosche"),
91 => array("Petronas", "Oil and gas", "76.822", "Tan Sri Dato Sri Mohd Hassan Marican"), 90 => array("Toshiba", "Conglomerate", "77.090", "Tadashi Okamura"),
92 => array("Indian Oil Corporation", "Oil and Gas", "75.632", "B.M.Bansal"), 91 => array("Petronas", "Oil and gas", "76.822", "Tan Sri Dato Sri Mohd Hassan Marican"),
93 => array("Fiat", "Conglomerate", "75.172", "Sergio Marchionne"), 92 => array("Indian Oil Corporation", "Oil and Gas", "75.632", "B.M.Bansal"),
94 => array("ZEN-NOH", "Agricultural marketing", "75.111", "Katsuyoshi Kitajima"), 93 => array("Fiat", "Conglomerate", "75.172", "Sergio Marchionne"),
95 => array("PSA Peugeot Citroën", "Automotive", "74.909", "Philippe Varin"), 94 => array("ZEN-NOH", "Agricultural marketing", "75.111", "Katsuyoshi Kitajima"),
96 => array("Vodafone", "Telecommunications", "73.635", "Vittorio Colao"), 95 => array("PSA Peugeot Citroën", "Automotive", "74.909", "Philippe Varin"),
97 => array("Marathon Oil", "Oil and gas", "73.621", "Clarence Cazalot, Jr."), 96 => array("Vodafone", "Telecommunications", "73.635", "Vittorio Colao"),
98 => array("China Mobile", "Telecommunications", "73.520", "Li Yue"), 97 => array("Marathon Oil", "Oil and gas", "73.621", "Clarence Cazalot, Jr."),
99 => array("Prudential plc", "Banking", "73.337", "Tidjane Thiam"), 98 => array("China Mobile", "Telecommunications", "73.520", "Li Yue"),
100 => array("Walgreens", "Retailing", "72.184", "Jeff Rein"), 99 => array("Prudential plc", "Banking", "73.337", "Tidjane Thiam"),
101 => array("Deutsche Post", "Courier", "71.751", "Frank Appel"), 100 => array("Walgreens", "Retailing", "72.184", "Jeff Rein"),
102 => array("BHP Billiton", "Mining", "71.739", "Marius Kloppers"), 101 => array("Deutsche Post", "Courier", "71.751", "Frank Appel"),
103 => array("RWE", "Public utilities", "71.246", "Jürgen Großmann"), 102 => array("BHP Billiton", "Mining", "71.739", "Marius Kloppers"),
104 => array("Aegon", "Insurance", "71.148", "Alex Wynaendts"), 103 => array("RWE", "Public utilities", "71.246", "Jürgen Großmann"),
105 => array("REWE Group", "Retailing", "70.872", "Alain Caparros"), 104 => array("Aegon", "Insurance", "71.148", "Alex Wynaendts"),
106 => array("Dexia", "Banking", "70.106", "Pierre Mariani"), 105 => array("REWE Group", "Retailing", "70.872", "Alain Caparros"),
107 => array("Microsoft", "Information technology", "69.943", "Steve Ballmer"), 106 => array("Dexia", "Banking", "70.106", "Pierre Mariani"),
108 => array("China Railway Construction Corporation", "Infrastructure", "69.118", "Meng Fengchao"), 107 => array("Microsoft", "Information technology", "69.943", "Steve Ballmer"),
109 => array("China Railway Engineering Corporation", "Infrastructure", "69.082", "Shi Dahua"), 108 => array("China Railway Construction Corporation", "Infrastructure", "69.118", "Meng Fengchao"),
110 => array("Toyota Tsusho", "Sogo shosha", "69.076", "Masaaki Furukawa"), 109 => array("China Railway Engineering Corporation", "Infrastructure", "69.082", "Shi Dahua"),
111 => array("China Construction Bank", "Banking", "68.777", "Guo Shuqing"), 110 => array("Toyota Tsusho", "Sogo shosha", "69.076", "Masaaki Furukawa"),
112 => array("Home Depot, Inc.", "Retailing", "67.997", "Frank Blake"), 111 => array("China Construction Bank", "Banking", "68.777", "Guo Shuqing"),
113 => array("Zurich Financial Services", "Insurance", "67.85", "Martin Senn"), 112 => array("Home Depot, Inc.", "Retailing", "67.997", "Frank Blake"),
114 => array("Pfizer", "Health care", "67.809", "Jeff Kindler"), 113 => array("Zurich Financial Services", "Insurance", "67.85", "Martin Senn"),
115 => array("Philip Morris International", "Tobacco industry", "67.713", "Louis C. Camilleri"), 114 => array("Pfizer", "Health care", "67.809", "Jeff Kindler"),
116 => array("Groupe BPCE", "Banking", "67.303", "François Pérol"), 115 => array("Philip Morris International", "Tobacco industry", "67.713", "Louis C. Camilleri"),
117 => array("Target Corporation", "Retailing", "67.390", "Gregg Steinhafel"), 116 => array("Groupe BPCE", "Banking", "67.303", "François Pérol"),
118 => array("Temasek Holdings", "Sovereign Wealth Fund", "66.285", "Suppiah Dhanabalan"), 117 => array("Target Corporation", "Retailing", "67.390", "Gregg Steinhafel"),
119 => array("Medco Health Solutions", "Health care", "65.968", "David B. Snow, Jr."), 118 => array("Temasek Holdings", "Sovereign Wealth Fund", "66.285", "Suppiah Dhanabalan"),
120 => array("United States Postal Service", "Courier", "65.711", "John E. Potter"), 119 => array("Medco Health Solutions", "Health care", "65.968", "David B. Snow, Jr."),
121 => array("Gunvor", "Raw material", "65.0", "-"), 120 => array("United States Postal Service", "Courier", "65.711", "John E. Potter"),
122 => array("Crédit Agricole", "Financial Services", "64.800", "Jean-Paul Chifflet"), 121 => array("Gunvor", "Raw material", "65.0", "-"),
123 => array("Tokyo Electric Power", "Electricity generation", "64.964", "Tsunehisa Katsumata"), 122 => array("Crédit Agricole", "Financial Services", "64.800", "Jean-Paul Chifflet"),
124 => array("Boeing", "Aerospace", "64.306", "Jim McNerney"), 123 => array("Tokyo Electric Power", "Electricity generation", "64.964", "Tsunehisa Katsumata"),
125 => array("Barclays Bank", "Banking", "63.978", "Bob Diamond"), 124 => array("Boeing", "Aerospace", "64.306", "Jim McNerney"),
126 => array("State Farm Insurance", "Insurance", "63.2", "Edward B. Rust Jr."), 125 => array("Barclays Bank", "Banking", "63.978", "Bob Diamond"),
127 => array("Bosch Group", "Automotive", "63.147", "-"), 126 => array("State Farm Insurance", "Insurance", "63.2", "Edward B. Rust Jr."),
128 => array("PTT Public Company Limited", "Oil and Gas", "62.998", "Prasert Bunsumpun"), 127 => array("Bosch Group", "Automotive", "63.147", "-"),
129 => array("Royal Bank of Scotland", "Financial services", "62.770", "Stephen Hester"), 128 => array("PTT Public Company Limited", "Oil and Gas", "62.998", "Prasert Bunsumpun"),
130 => array("Mitsubishi Corporation", "Sogo shosha", "62.733", "Mikio Sasaki"), 129 => array("Royal Bank of Scotland", "Financial services", "62.770", "Stephen Hester"),
131 => array("Seven & I Holdings Co.", "Retailing", "62.436", "Toshifumi Suzuki"), 130 => array("Mitsubishi Corporation", "Sogo shosha", "62.733", "Mikio Sasaki"),
132 => array("ÆON", "Retailing", "62.153", "-"), 131 => array("Seven & I Holdings Co.", "Retailing", "62.436", "Toshifumi Suzuki"),
133 => array("Agricultural Bank of China", "Banking", "62.151", "Xiang Junbo"), 132 => array("ÆON", "Retailing", "62.153", "-"),
134 => array("Johnson & Johnson", "Health care", "61.587", "William C. Weldon"), 133 => array("Agricultural Bank of China", "Banking", "62.151", "Xiang Junbo"),
135 => array("Dell", "Information technology", "61.494", "Michael Dell"), 134 => array("Johnson & Johnson", "Health care", "61.587", "William C. Weldon"),
136 => array("EADS", "Aerospace", "60.969", "Louis Gallois"), 135 => array("Dell", "Information technology", "61.494", "Michael Dell"),
137 => array("Munich Re", "Financial services", "60.851", "Nikolaus von Bomhard"), 136 => array("EADS", "Aerospace", "60.969", "Louis Gallois"),
138 => array("France Télécom", "Telecommunications", "60.801", "Stéphane Richard"), 137 => array("Munich Re", "Financial services", "60.851", "Nikolaus von Bomhard"),
139 => array("Rio Tinto", "Mining", "60.323", "Tom Albanese"), 138 => array("France Télécom", "Telecommunications", "60.801", "Stéphane Richard"),
140 => array("CNP Assurances", "Insurance", "59.846", "Gilles Benoist"), 139 => array("Rio Tinto", "Mining", "60.323", "Tom Albanese"),
141 => array("Reliance Industries", "Conglomerate", "59.679", "Mukesh Ambani"), 140 => array("CNP Assurances", "Insurance", "59.846", "Gilles Benoist"),
142 => array("Legal & General", "Financial services", "59.673", "Tim Breedon"), 141 => array("Reliance Industries", "Conglomerate", "59.679", "Mukesh Ambani"),
143 => array("Bank of China", "Banking", "59.668", "Xiao Gang"), 142 => array("Legal & General", "Financial services", "59.673", "Tim Breedon"),
144 => array("Unilever", "Consumer goods", "59.143", "Paul Polman"), 143 => array("Bank of China", "Banking", "59.668", "Xiao Gang"),
145 => array("WellPoint", "Health care", "58.802", "Angela Braly"), 144 => array("Unilever", "Consumer goods", "59.143", "Paul Polman"),
146 => array("BNP Paribas", "Financial Services", "58.632", "Baudouin Prot"), 145 => array("WellPoint", "Health care", "58.802", "Angela Braly"),
147 => array("China Life Insurance", "Insurance", "58.460", "-"), 146 => array("BNP Paribas", "Financial Services", "58.632", "Baudouin Prot"),
148 => array("Edeka Group", "Retailing", "57.968", "-"), 147 => array("China Life Insurance", "Insurance", "58.460", "-"),
149 => array("PepsiCo", "Food", "57.838", "Indra Nooyi"), 148 => array("Edeka Group", "Retailing", "57.968", "-"),
150 => array("Grupo Santander", "Banking", "57.388", "Emilio Botín"), 149 => array("PepsiCo", "Food", "57.838", "Indra Nooyi"),
151 => array("Auchan", "Retailing", "56.778", "Christophe Dubrulle"), 150 => array("Grupo Santander", "Banking", "57.388", "Emilio Botín"),
152 => array("Noble Group", "Raw materials", "56.696", "Ricardo Leiman"), 151 => array("Auchan", "Retailing", "56.778", "Christophe Dubrulle"),
153 => array("China State Construction Engineering Corp", "Infrastructure", "56.104", "Sun Wenjie"), 152 => array("Noble Group", "Raw materials", "56.696", "Ricardo Leiman"),
154 => array("Banco Bradesco", "Banking", "56.104", "Luiz Carlos Trabuco Cappi"), 153 => array("China State Construction Engineering Corp", "Infrastructure", "56.104", "Sun Wenjie"),
155 => array("A. P. Møller - Mærsk", "Transport", "56.090", "Nils Andersen"), 154 => array("Banco Bradesco", "Banking", "56.104", "Luiz Carlos Trabuco Cappi"),
156 => array("Dongfeng Motor", "Automotive", "55.864", "Xu Ping"), 155 => array("A. P. Møller - Mærsk", "Transport", "56.090", "Nils Andersen"),
157 => array("China Southern Power Grid Company", "Electricity", "55.825", "Yuan Maozhen"), 156 => array("Dongfeng Motor", "Automotive", "55.864", "Xu Ping"),
158 => array("Deutsche Bank", "Banking", "55.804", "Josef Ackermann"), 157 => array("China Southern Power Grid Company", "Electricity", "55.825", "Yuan Maozhen"),
159 => array("Shanghai Automotive Industry Corporation", "Automotive", "55.689", "Shen Jianhua"), 158 => array("Deutsche Bank", "Banking", "55.804", "Josef Ackermann"),
160 => array("Fujitsu", "Electronics", "54.559", "Hiroaki Kurokawa"), 159 => array("Shanghai Automotive Industry Corporation", "Automotive", "55.689", "Shen Jianhua"),
161 => array("United Technologies", "Conglomerate", "54.326", "Louis R. Chênevert"), 160 => array("Fujitsu", "Electronics", "54.559", "Hiroaki Kurokawa"),
162 => array("Credit Suisse", "Financial services", "53.771", "Brady Dougan"), 161 => array("United Technologies", "Conglomerate", "54.326", "Louis R. Chênevert"),
163 => array("China National Offshore Oil Corporation", "Oil and gas", "53.733", "Wang Yilin"), 162 => array("Credit Suisse", "Financial services", "53.771", "Brady Dougan"),
164 => array("Dow Chemical", "Manufacturing", "53.674", "Andrew N. Liveris"), 163 => array("China National Offshore Oil Corporation", "Oil and gas", "53.733", "Wang Yilin"),
165 => array("Saint-Gobain", "Construction", "53.607", "Pierre-André de Chalendar"), 164 => array("Dow Chemical", "Manufacturing", "53.674", "Andrew N. Liveris"),
166 => array("UniCredit", "Banking", "53.332", "Federico Ghizzoni"), 165 => array("Saint-Gobain", "Construction", "53.607", "Pierre-André de Chalendar"),
167 => array("Nokia", "Telecommunications", "53.322", "Stephen Elop"), 166 => array("UniCredit", "Banking", "53.332", "Federico Ghizzoni"),
168 => array("MetLife", "Insurance", "52.717", "C. Robert Henrikson"), 167 => array("Nokia", "Telecommunications", "53.322", "Stephen Elop"),
169 => array("Renault", "Automotive", "52.073", "Carlos Ghosn"), 168 => array("MetLife", "Insurance", "52.717", "C. Robert Henrikson"),
170 => array("Mitsubishi UFJ Financial Group", "Banking", "51.479", "Nobuo Kuroyanagi"), 169 => array("Renault", "Automotive", "52.073", "Carlos Ghosn"),
171 => array("ThyssenKrupp", "Conglomerate", "50.717", "Heinrich Hiesinger"), 170 => array("Mitsubishi UFJ Financial Group", "Banking", "51.479", "Nobuo Kuroyanagi"),
172 => array("Sinochem Group", "Conglomerate", "50.632", "Liu Deschu"), 171 => array("ThyssenKrupp", "Conglomerate", "50.717", "Heinrich Hiesinger"),
173 => array("Hoffmann-La Roche", "Health care", "50.632", "Severin Schwan"), 172 => array("Sinochem Group", "Conglomerate", "50.632", "Liu Deschu"),
174 => array("Novartis", "Health care", "50.624", "Joseph Jimenez"), 173 => array("Hoffmann-La Roche", "Health care", "50.632", "Severin Schwan"),
175 => array("Best Buy", "Retailing", "50.272", "Brian J. Dunn"), 174 => array("Novartis", "Health care", "50.624", "Joseph Jimenez"),
176 => array("United Parcel Service", "Transportation", "49.545", "Scott Davis"), 175 => array("Best Buy", "Retailing", "50.272", "Brian J. Dunn"),
177 => array("Pertamina", "Oil and gas", "48.717", "Karen Agustiawan"), 176 => array("United Parcel Service", "Transportation", "49.545", "Scott Davis"),
178 => array("Dai-ichi Life", "Insurance", "47.855", "-"), 177 => array("Pertamina", "Oil and gas", "48.717", "Karen Agustiawan"),
179 => array("Banco Bilbao Vizcaya Argentaria", "Banking", "47.429", "Francisco González"), 178 => array("Dai-ichi Life", "Insurance", "47.855", "-"),
180 => array("Lowe's", "Retailing", "47.22", "Robert Niblock"), 179 => array("Banco Bilbao Vizcaya Argentaria", "Banking", "47.429", "Francisco González"),
181 => array("Rosneft", "Oil and gas", "46.826", "-"), 180 => array("Lowe's", "Retailing", "47.22", "Robert Niblock"),
182 => array("National Mutual Insurance Federation of Agricultural Cooperatives (Zenkyoren or JA Kyosai)", "Insurance", "46.8", "-"), 181 => array("Rosneft", "Oil and gas", "46.826", "-"),
183 => array("VINCI", "Construction", "46.762", "Xavier Huillard"), 182 => array("National Mutual Insurance Federation of Agricultural Cooperatives (Zenkyoren or JA Kyosai)", "Insurance", "46.8", "-"),
184 => array("Veolia Environnement", "Public utilities", "46.482", "Antoine Frérot"), 183 => array("VINCI", "Construction", "46.762", "Xavier Huillard"),
185 => array("Vale", "Mining", "46.481", "Murilo Ferreira"), 184 => array("Veolia Environnement", "Public utilities", "46.482", "Antoine Frérot"),
186 => array("Woori Financial Group", "Financial services", "46.459", "Lee Pal Seung"), 185 => array("Vale", "Mining", "46.481", "Murilo Ferreira"),
187 => array("Sonatrach", "Oil and gas", "46.420", "Djenane El Malik"), 186 => array("Woori Financial Group", "Financial services", "46.459", "Lee Pal Seung"),
188 => array("GlaxoSmithKline", "Health care", "46.016", "Andrew Witty"), 187 => array("Sonatrach", "Oil and gas", "46.420", "Djenane El Malik"),
189 => array("Deutsche Bahn", "Transportation", "45.979", "Rüdiger Grube"), 188 => array("GlaxoSmithKline", "Health care", "46.016", "Andrew Witty"),
190 => array("Goldman Sachs", "Financial services", "45.976", "Lloyd Blankfein"), 189 => array("Deutsche Bahn", "Transportation", "45.979", "Rüdiger Grube"),
191 => array("Hon Hai Precision Industry", "Electronics", "45.899", "Terry Gou"), 190 => array("Goldman Sachs", "Financial services", "45.976", "Lloyd Blankfein"),
192 => array("Lockheed Martin", "Aerospace", "45.803", "Robert J. Stevens"), 191 => array("Hon Hai Precision Industry", "Electronics", "45.899", "Terry Gou"),
193 => array("Woolworths Limited", "Retailing", "45.170", "Michael Luscombe"), 192 => array("Lockheed Martin", "Aerospace", "45.803", "Robert J. Stevens"),
194 => array("Bouygues", "Conglomerate", "45.167", "Martin Bouygues"), 193 => array("Woolworths Limited", "Retailing", "45.170", "Michael Luscombe"),
195 => array("Bayer", "Health care", "44.901", "Marijn Dekkers"), 194 => array("Bouygues", "Conglomerate", "45.167", "Martin Bouygues"),
196 => array("China Investment Corporation", "Sovereign wealth fund", "44.876", "Lou Jiwei"), 195 => array("Bayer", "Health care", "44.901", "Marijn Dekkers"),
197 => array("Imperial Tobacco", "Tobacco industry", "44.713", "Gareth Davis"), 196 => array("China Investment Corporation", "Sovereign wealth fund", "44.876", "Lou Jiwei"),
198 => array("Mitsui & Co.", "Sogo shosha", "44.048", "-"), 197 => array("Imperial Tobacco", "Tobacco industry", "44.713", "Gareth Davis"),
199 => array("Sears Holdings", "Retailing", "44.043", "Louis D'Ambrosio"), 198 => array("Mitsui & Co.", "Sogo shosha", "44.048", "-"),
200 => array("LG Electronics", "Conglomerate", "44.000", "Koo Bon-joon"), 199 => array("Sears Holdings", "Retailing", "44.043", "Louis D'Ambrosio"),
201 => array("Shinhan Financial Group", "Financial services", "43.975", "Sang Hoon Shin"), 200 => array("LG Electronics", "Conglomerate", "44.000", "Koo Bon-joon"),
202 => array("Wesfarmers", "Retailing", "43.949", "Bob Every"), 201 => array("Shinhan Financial Group", "Financial services", "43.975", "Sang Hoon Shin"),
203 => array("Intel", "Semiconductors", "43.623", "Paul S. Otellini"), 202 => array("Wesfarmers", "Retailing", "43.949", "Bob Every"),
204 => array("Sumitomo Life Insurance", "Insurance", "43.272", "-"), 203 => array("Intel", "Semiconductors", "43.623", "Paul S. Otellini"),
205 => array("Caterpillar", "Heavy equipment", "42.588", "Douglas R. Oberhelman"), 204 => array("Sumitomo Life Insurance", "Insurance", "43.272", "-"),
206 => array("Sanofi", "Health care", "42.218", "Chris Viehbacher"), 205 => array("Caterpillar", "Heavy equipment", "42.588", "Douglas R. Oberhelman"),
207 => array("Chrysler", "Automotive", "41.946", "Sergio Marchionne"), 206 => array("Sanofi", "Health care", "42.218", "Chris Viehbacher"),
208 => array("Bunge Limited", "Agriculture", "41.926", "Alberto Weisser"), 207 => array("Chrysler", "Automotive", "41.946", "Sergio Marchionne"),
209 => array("Sojitz", "Sogo shosha", "41.338", "Yutaka Kase"), 208 => array("Bunge Limited", "Agriculture", "41.926", "Alberto Weisser"),
210 => array("Safeway", "Retailing", "40.8507", "Steven Burd"), 209 => array("Sojitz", "Sogo shosha", "41.338", "Yutaka Kase"),
211 => array("SuperValu", "Retailing", "40.597", "Craig Herkert"), 210 => array("Safeway", "Retailing", "40.8507", "Steven Burd"),
212 => array("UBS", "Financial services", "40.561", "Oswald Grübel"), 211 => array("SuperValu", "Retailing", "40.597", "Craig Herkert"),
213 => array("Kraft Foods", "Food", "40.386", "Irene Rosenfeld"), 212 => array("UBS", "Financial services", "40.561", "Oswald Grübel"),
214 => array("Ahold", "Retailing", "40.229", "Dick Boer"), 213 => array("Kraft Foods", "Food", "40.386", "Irene Rosenfeld"),
215 => array("Cisco", "Information technology", "40.04", "John T. Chambers"), 214 => array("Ahold", "Retailing", "40.229", "Dick Boer"),
); 215 => array("Cisco", "Information technology", "40.04", "John T. Chambers"),
} );
}
} }

View File

@ -4,81 +4,88 @@
* Description of Employees * Description of Employees
* *
*/ */
class Employee extends DataObject { class Employee extends DataObject
{
private static $db = array(
'Name' => 'Varchar', private static $db = array(
'Biography' => 'HTMLText' 'Name' => 'Varchar',
); 'Biography' => 'HTMLText'
);
private static $has_one = array(
'Company' => 'Company', private static $has_one = array(
'ProfileImage' => 'Image' 'Company' => 'Company',
); '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){
$employee = new Employee(); foreach ($this->data() as $employeeName) {
$employee->Name = $employeeName; $employee = new Employee();
$employee->write(); $employee->Name = $employeeName;
} $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 }
*
* @return array /**
*/ * Contains test data
public function data() { *
return array( * @return array
'Hayley', 'Octavius', 'Walker', 'Gary','Elton','Janna','Ursa','Lars','Moses','Lareina', */
'Elmo','Cara','Shea','Duncan','Velma','Acton','Galena','Heidi','Troy','Elliott','Cara', public function data()
'Whitney','Summer','Olga','Tatum','Zeph','Jared','Hilda','Quinlan','Chaim','Xenos', {
'Cara','Tatiana','Tyrone','Juliet','Chester','Hannah','Imani','Quinn','Ariel','Abel', return array(
'Aretha','Courtney ','Shellie','Garrett','Camilla','Simon','Mohammad','Kirby','Rae', 'Hayley', 'Octavius', 'Walker', 'Gary','Elton','Janna','Ursa','Lars','Moses','Lareina',
'Xena','Noel','Omar','Shannon','Iola','Maia','Serina','Taylor','Alice','Lucy','Austin', 'Elmo','Cara','Shea','Duncan','Velma','Acton','Galena','Heidi','Troy','Elliott','Cara',
'Abel','Quinn','Yetta','Ulysses','Donovan','Castor','Emmanuel','Nero','Virginia', 'Whitney','Summer','Olga','Tatum','Zeph','Jared','Hilda','Quinlan','Chaim','Xenos',
'Gregory','Neville','Abel','Len','Knox','Gavin','Pascale','Hyatt','Alden','Emerald', 'Cara','Tatiana','Tyrone','Juliet','Chester','Hannah','Imani','Quinn','Ariel','Abel',
'Cherokee','Zeph','Adam','Uma','Serena','Isabelle','Kieran','Moses','Gay','Lavinia', 'Aretha','Courtney ','Shellie','Garrett','Camilla','Simon','Mohammad','Kirby','Rae',
'Elvis','Illana','Lee','Ariana','Hilel','Juliet','Gage','Larissa','Richard','Allen' 'Xena','Noel','Omar','Shannon','Iola','Maia','Serina','Taylor','Alice','Lucy','Austin',
); 'Abel','Quinn','Yetta','Ulysses','Donovan','Castor','Emmanuel','Nero','Virginia',
} 'Gregory','Neville','Abel','Len','Knox','Gavin','Pascale','Hyatt','Alden','Emerald',
'Cherokee','Zeph','Adam','Uma','Serena','Isabelle','Kieran','Moses','Gay','Lavinia',
'Elvis','Illana','Lee','Ariana','Hilel','Juliet','Gage','Larissa','Richard','Allen'
);
}
} }

View File

@ -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) {
for($i=1;$i<=$count;$i++) { protected function makePages($count, $depth, $prefix = "", $parentID = 0)
$page = new Page(); {
$page->ParentID = $parentID; for ($i=1;$i<=$count;$i++) {
$page->Title = "Test page $prefix$i"; $page = new Page();
$page->write(); $page->ParentID = $parentID;
$page->publish('Stage', 'Live'); $page->Title = "Test page $prefix$i";
$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);
} }
} }
}
}

View File

@ -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',
);
} }
?>

View File

@ -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'
} );
}

View File

@ -1,43 +1,46 @@
<?php <?php
class FrameworkTestRole extends DataExtension { class FrameworkTestRole extends DataExtension
{
private static $has_one = array(
'FavouritePage' => 'SiteTree', private static $has_one = array(
); 'FavouritePage' => 'SiteTree',
);
function updateCMSFields(FieldList $fields) {
$fields->addFieldToTab( public function updateCMSFields(FieldList $fields)
'Root.Main', {
new TreeDropdownField("FavouritePageID", "Favourite page", "SiteTree") $fields->addFieldToTab(
); 'Root.Main',
} new TreeDropdownField("FavouritePageID", "Favourite page", "SiteTree")
);
function requireDefaultRecords() { }
$hasTestMembers = DataObject::get('Member')->find('Email', 'hayley@test.com');
if(!$hasTestMembers) { public function requireDefaultRecords()
{
$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'
);
}
} }

View File

@ -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');
} }

View File

@ -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() {
parent::init(); public function init()
{
if(!Permission::check('ADMIN')) return Security::permissionFailure($this); parent::init();
}
if (!Permission::check('ADMIN')) {
function Link($action = null) { return Security::permissionFailure($this);
return Controller::join_links('dev', 'regress', $action); }
} }
function Form() { public function Link($action = null)
$isRunning = (Session::get('db')); {
return Controller::join_links('dev', 'regress', $action);
if($isRunning) { }
$actions = new FieldList(
new FormAction('endsession', 'End Session') public function Form()
); {
} else { $isRunning = (Session::get('db'));
$actions = new FieldList(
new FormAction('startsession', 'Start Session') if ($isRunning) {
); $actions = new FieldList(
} new FormAction('endsession', 'End Session')
);
$form = new Form( } else {
$this, $actions = new FieldList(
'Form', new FormAction('startsession', 'Start Session')
new FieldList( );
new HeaderField('Header1', ($isRunning) ? 'Session is already running' : 'Start new regress session'), }
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>' $form = new Form(
), $this,
$dbField = new DropdownField( 'Form',
'db', new FieldList(
'Database', new HeaderField('Header1', ($isRunning) ? 'Session is already running' : 'Start new regress session'),
array( new LiteralField('Lit1',
'mysql' => 'MySQL', '<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>'
'postgresql' => 'Postgres', ),
'mssql' => 'MSSQL', $dbField = new DropdownField(
'sqlite3' => 'SQLite3', 'db',
), 'Database',
Session::get('db') array(
), 'mysql' => 'MySQL',
$chkField = new CheckboxField( 'postgresql' => 'Postgres',
'enabletranslatable', 'mssql' => 'MSSQL',
'Translatable?', 'sqlite3' => 'SQLite3',
Session::get('enabletranslatable') ),
) Session::get('db')
), ),
$actions $chkField = new CheckboxField(
); 'enabletranslatable',
$dbField->setHasEmptyDefault(false); 'Translatable?',
Session::get('enabletranslatable')
if($isRunning) { )
foreach($form->Fields() as $field) { ),
$form->Fields()->replaceField($field->Name(), $actions
$field->performReadonlyTransformation() );
); $dbField->setHasEmptyDefault(false);
}
} if ($isRunning) {
foreach ($form->Fields() as $field) {
return $form; $form->Fields()->replaceField($field->Name(),
} $field->performReadonlyTransformation()
);
}
}
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() {
Session::set('enabletranslatable', null); public function endsession()
Session::set('db', null); {
Session::set('enabletranslatable', null);
return $this->redirectBack(); Session::set('db', null);
}
return $this->redirectBack();
} }
}

View File

@ -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) { foreach ($grids as $grid) {
$grid $grid
->setDescription('This is <strong>bold</strong> help text'); ->setDescription('This is <strong>bold</strong> help text');
// ->addExtraClass('cms-description-tooltip'); // ->addExtraClass('cms-description-tooltip');
} }
return $fields; 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(){ */
$config = new GridFieldConfig_RecordEditor(); public function Form()
{
$grid = new GridField('Companies', 'Companies', new DataList('Company'),$config); $config = new GridFieldConfig_RecordEditor();
return new Form($this,'Form',new FieldList($grid),new FieldList());
} $grid = new GridField('Companies', 'Companies', new DataList('Company'), $config);
return new Form($this, 'Form', new FieldList($grid), new FieldList());
}
} }

View File

@ -1,12 +1,10 @@
<?php <?php
class Organisation extends DataObject { class Organisation extends DataObject
{
// Used to test the Multiform module
private static $db = array( // Used to test the Multiform module
'OrganisationName' => 'Text' private static $db = array(
); 'OrganisationName' => 'Text'
);
} }
?>

View File

@ -1,56 +1,58 @@
<?php <?php
class RelationFieldsTestPage extends TestPage { class RelationFieldsTestPage extends TestPage
{
private static $has_one = array(
"HasOneCompany" => "Company", private static $has_one = array(
"HasOnePage" => "SiteTree", "HasOneCompany" => "Company",
"HasOnePageWithSearch" => "SiteTree", "HasOnePage" => "SiteTree",
); "HasOnePageWithSearch" => "SiteTree",
private static $has_many = array( );
"HasManyCompanies" => "Company", private static $has_many = array(
"HasManyPages" => "SiteTree", "HasManyCompanies" => "Company",
); "HasManyPages" => "SiteTree",
private static $many_many = array( );
"ManyManyCompanies" => "Company", private static $many_many = array(
"ManyManyPages" => "SiteTree", "ManyManyCompanies" => "Company",
); "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
{
} }

View File

@ -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() { */
$categories = DataObject::get('TestCategory'); public static function map()
if($categories) return $categories->map('ID', 'Title')->toArray(); {
else return array(); $categories = DataObject::get('TestCategory');
} if ($categories) {
return $categories->map('ID', 'Title')->toArray();
function requireDefaultRecords(){ } else {
$class = $this->class; return array();
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();
}
}
}
} }
?>

View File

@ -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(
new FormAction('addMember', "Add a member with two Files uploaded") $actions = new FieldList(
); 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){
$member = new Member(); public function addMember($data, $form)
$form->saveInto($member); {
$member->write(); $member = new Member();
$this->redirectBack(); $form->saveInto($member);
} $member->write();
$this->redirectBack();
}
} }

View File

@ -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",
);
} }
?>

View File

@ -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) { */
// Don't allow creation other than through requireDefaultRecords public function canCreate($member = null)
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 // Create actual page
$page = new $class(); $page = new $class();
$page->Title = str_replace("TestPage","",$class); $page->Title = str_replace("TestPage", "", $class);
$page->ShowInMenus = 0; $page->ShowInMenus = 0;
if($parent) $page->ParentID = $parent->ID; if ($parent) {
$page->write(); $page->ParentID = $parent->ID;
$page->publish('Stage', 'Live'); }
} $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() { */
$fields = $this->getCMSFields(); public function Form()
$actions = new FieldList( {
new FormAction("save", "Save"), $fields = $this->getCMSFields();
$gohome = new FormAction("gohome", "Go home") $actions = new FieldList(
); new FormAction("save", "Save"),
$gohome->setAttribute('src', 'frameworktest/images/test-button.png'); $gohome = new FormAction("gohome", "Go home")
$form = new Form($this, "Form", $fields, $actions); );
$form->loadDataFrom($this->dataRecord); $gohome->setAttribute('src', 'frameworktest/images/test-button.png');
return $form; $form = new Form($this, "Form", $fields, $actions);
} $form->loadDataFrom($this->dataRecord);
return $form;
function save($data, $form) { }
$form->saveInto($this->dataRecord);
$this->dataRecord->write(); public function save($data, $form)
$this->redirectBack(); {
} $form->saveInto($this->dataRecord);
$this->dataRecord->write();
function gohome() { $this->redirectBack();
$this->redirect("./"); }
}
public function gohome()
{
$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() {
return array( public function email()
'Content' => '<p>Use this form to send a test email</p>', {
'Form' => $this->EmailForm() return array(
); 'Content' => '<p>Use this form to send a test email</p>',
} 'Form' => $this->EmailForm()
);
function sendEmail($data, $form) { }
$email = new Email();
$email->setTo($data['Email']); public function sendEmail($data, $form)
$email->setFrom($data['Email']); {
$email->setSubject('A subject with some umlauts: öäüß'); $email = new Email();
$email->setBody('A body with some umlauts: öäüß'); $email->setTo($data['Email']);
$email->send(); $email->setFrom($data['Email']);
$email->setSubject('A subject with some umlauts: öäüß');
echo "<p>email sent to " . $data['Email'] . "</p>"; $email->setBody('A body with some umlauts: öäüß');
} $email->send();
echo "<p>email sent to " . $data['Email'] . "</p>";
}
} }
?>

View File

@ -1,64 +1,68 @@
<?php <?php
class Page2MultiForm extends MultiForm {
public static $start_step = 'Page2PersonalDetailsFormStep';
public function finish($data, $form) {
parent::finish($data, $form);
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
if($steps) {
foreach($steps as $step) {
if($step->class == 'Page2PersonalDetailsFormStep') {
$member = new Member();
$data = $step->loadData();
if($data) {
$member->update($data);
$member->write();
}
}
if($step->class == 'Page2OrganisationDetailsFormStep') { class Page2MultiForm extends MultiForm
$organisation = new Organisation(); {
$data = $step->loadData();
if($data) { public static $start_step = 'Page2PersonalDetailsFormStep';
$organisation->update($data);
if($member && $member->ID) $organisation->MemberID = $member->ID; public function finish($data, $form)
$organisation->write(); {
} parent::finish($data, $form);
} $steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
if ($steps) {
foreach ($steps as $step) {
if ($step->class == 'Page2PersonalDetailsFormStep') {
$member = new Member();
$data = $step->loadData();
if ($data) {
$member->update($data);
$member->write();
}
}
// Debug::show($step->loadData()); // Shows the step data (unserialized by loadData) if ($step->class == 'Page2OrganisationDetailsFormStep') {
} $organisation = new Organisation();
} $data = $step->loadData();
$controller = $this->getController(); if ($data) {
$controller->redirect($controller->Link() . 'finished'); $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 Page2PersonalDetailsFormStep extends MultiFormStep { class Page2PersonalDetailsFormStep extends MultiFormStep
{
public static $next_steps = 'Page2OrganisationDetailsFormStep';
public static $next_steps = 'Page2OrganisationDetailsFormStep';
function getFields() {
return new FieldList( public function getFields()
new TextField('FirstName', 'First name'), {
new TextField('Surname', 'Surname') 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() { public function getFields()
return new FieldList( {
new TextField('OrganisationName', 'Organisation Name') return new FieldList(
); new TextField('OrganisationName', 'Organisation Name')
} );
}
} }
?>

View File

@ -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() {
return new Page2MultiForm($this, 'Page2MultiForm'); public function 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>'
);
}
} }
?>

View File

@ -1,85 +1,87 @@
<?php <?php
class Page3MultiForm extends MultiForm {
public static $start_step = 'Page3StartFormStep';
public function finish($data, $form) {
parent::finish($data, $form);
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
if($steps) {
foreach($steps as $step) {
if($step->class == 'Page3PersonalDetailsFormStep') {
$member = new Member();
$data = $step->loadData();
if($data) {
$member->update($data);
$member->write();
}
}
if($step->class == 'Page3OrganisationDetailsFormStep') { class Page3MultiForm extends MultiForm
$organisation = new Organisation(); {
$data = $step->loadData();
if($data) { public static $start_step = 'Page3StartFormStep';
$organisation->update($data);
if($member && $member->ID) $organisation->MemberID = $member->ID; public function finish($data, $form)
$organisation->write(); {
} parent::finish($data, $form);
} $steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
if ($steps) {
foreach ($steps as $step) {
if ($step->class == 'Page3PersonalDetailsFormStep') {
$member = new Member();
$data = $step->loadData();
if ($data) {
$member->update($data);
$member->write();
}
}
// Debug::show($step->loadData()); // Shows the step data (unserialized by loadData) if ($step->class == 'Page3OrganisationDetailsFormStep') {
} $organisation = new Organisation();
} $data = $step->loadData();
$controller = $this->getController(); if ($data) {
$controller->redirect($controller->Link() . 'finished'); $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() {
return new FieldList( public function getFields()
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';
public static $next_steps = 'Page3OrganisationDetailsFormStep';
function getFields() {
return new FieldList( public function getFields()
new TextField('FirstName', 'First name'), {
new TextField('Surname', 'Surname') 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() { public function getFields()
return new FieldList( {
new TextField('OrganisationName', 'Organisation Name') return new FieldList(
); new TextField('OrganisationName', 'Organisation Name')
} );
}
} }
?>

View File

@ -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() {
return new Page3MultiForm($this, 'Page3MultiForm'); public function 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>'
);
}
} }
?>

View File

@ -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) {
parent::finish($data, $form); public function finish($data, $form)
{
$savedSteps = $this->getSavedSteps(); parent::finish($data, $form);
$savedData = array(); $savedSteps = $this->getSavedSteps();
foreach($savedSteps as $step) {
$savedData = array_merge($savedData, $step->loadData()); $savedData = array();
} foreach ($savedSteps as $step) {
$savedData = array_merge($savedData, $step->loadData());
$fields = new FieldList(); }
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
$fields = new FieldList();
foreach($savedData as $key=>$value) { $fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
} foreach ($savedData as $key=>$value) {
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
Session::set("MultiFormMessage", "Your information has been submitted."); }
$this->Controller()->redirect(Director::BaseURL() . $this->Controller()->URLSegment); Session::set("MultiFormMessage", "Your information has been submitted.");
}
$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( public function getFields()
new TextField('FirstName', 'First name'), {
new TextField('Surname', 'Surname') 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( {
new TextField('Email', 'Email'), return new FieldList(
new TextField('Address', 'Address') new TextField('Email', 'Email'),
); 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() {
$form = $this->getForm(); public function getFields()
$savedSteps = $form->getSavedSteps(); {
$form = $this->getForm();
$savedData = array(); $savedSteps = $form->getSavedSteps();
foreach($savedSteps as $step) {
$savedData = array_merge($savedData, $step->loadData()); $savedData = array();
} foreach ($savedSteps as $step) {
$savedData = array_merge($savedData, $step->loadData());
$fields = new FieldList(); }
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
$fields = new FieldList();
foreach($savedData as $key=>$value) { $fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
if(preg_match("/_copy$/", $key)) continue;
foreach ($savedData as $key=>$value) {
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>")); if (preg_match("/_copy$/", $key)) {
} continue;
}
return $fields;
} $fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
}
return $fields;
}
} }

View File

@ -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() {
$form = new TestMultiForm($this, 'Form', new FieldList(), new FieldList()); public function Form()
{
$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;
}
} }

View File

@ -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() {
$fields = new FieldList( public function Form()
new TextField('MyText') {
); $fields = new FieldList(
if(class_exists('RecaptchaField')) { new TextField('MyText')
$fields->push(new RecaptchaField('MyRecaptcha')); );
} else { if (class_exists('RecaptchaField')) {
$fields->push(new LiteralField('<p class="message error">RecaptchaField class not found</p>')); $fields->push(new RecaptchaField('MyRecaptcha'));
} } else {
$fields->push(new LiteralField('<p class="message error">RecaptchaField class not found</p>'));
$form = new Form( }
$this,
'Form', $form = new Form(
$fields, $this,
new FieldList( 'Form',
new FormAction('submit', 'submit') $fields,
), new FieldList(
new RequiredFields(array('MyText')) new FormAction('submit', 'submit')
); ),
new RequiredFields(array('MyText'))
return $form; );
}
return $form;
function submit($data, $form) { }
$form->sessionMessage('Hooray!', 'good');
public function submit($data, $form)
return Director::redirectBack(); {
} $form->sessionMessage('Hooray!', 'good');
} return Director::redirectBack();
}
}

View File

@ -1,24 +1,27 @@
<?php <?php
class SifrPage extends Page { class SifrPage extends Page
{
function getCMSFields() {
$fields = parent::getCMSFields(); public function getCMSFields()
$fields->addFieldToTab("Root.Content.SifrSampleImage", new LiteralField("SifrSampleImage", '<p><img src="frameworktest/images/sifr_sample.png"/></p>')); {
$fields = parent::getCMSFields();
return $fields; $fields->addFieldToTab("Root.Content.SifrSampleImage", new LiteralField("SifrSampleImage", '<p><img src="frameworktest/images/sifr_sample.png"/></p>'));
}
return $fields;
}
} }
class SifrPage_Controller extends Page_Controller { class SifrPage_Controller extends Page_Controller
{
function init() {
parent::init(); public function init()
{
Sifr::add_font('blackout', 'themes/fonts/blackout.swf'); parent::init();
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::add_font('blackout', 'themes/fonts/blackout.swf');
Sifr::replace_element('blackout', 'h4', "'.sIFR-root { text-align: left; color: red;'"); Sifr::replace_element('blackout', 'h2', "'.sIFR-root { text-align: left; color: red;'");
Sifr::activate_sifr(); 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::activate_sifr();
}
}

View File

@ -1,14 +1,14 @@
<?php <?php
// class TestTag extends DataObject { // class TestTag extends DataObject {
// private static $db = array( // private static $db = array(
// 'Title' => 'Text' // 'Title' => 'Text'
// ); // );
// private static $belongs_many_many = array( // private static $belongs_many_many = array(
// 'Pages' => 'TestTagFieldPage' // 'Pages' => 'TestTagFieldPage'
// ); // );
// function requireDefaultRecords(){ // function requireDefaultRecords(){
// $class = $this->class; // $class = $this->class;
// if(!DataObject::get_one($class)) { // if(!DataObject::get_one($class)) {
@ -17,7 +17,7 @@
// $tag->Title = $title; // $tag->Title = $title;
// $tag->write(); // $tag->write();
// } // }
// } // }
// } // }
// } // }

View File

@ -1,31 +1,31 @@
<?php <?php
// class TestTagFieldPage extends Page { // class TestTagFieldPage extends Page {
// private static $db = array( // private static $db = array(
// 'TestTagString' => 'Text', // 'TestTagString' => 'Text',
// 'FixedTags' => 'Text' // 'FixedTags' => 'Text'
// ); // );
// private static $many_many = array( // private static $many_many = array(
// 'TestTags' => 'TestTag', // 'TestTags' => 'TestTag',
// ); // );
// function getCMSFields() { // function getCMSFields() {
// $fields = parent::getCMSFields(); // $fields = parent::getCMSFields();
// $tf1 = new TagField('TestTagString', "Single column tags (try 'one', 'two', 'three', 'four')", null, 'TestTagFieldPage'); // $tf1 = new TagField('TestTagString', "Single column tags (try 'one', 'two', 'three', 'four')", null, 'TestTagFieldPage');
// $fields->addFieldToTab('Root.Main', $tf1); // $fields->addFieldToTab('Root.Main', $tf1);
// $tf2 = new TagField('TestTags', "Relation tags (try 'one', 'two', 'three', 'four')"); // $tf2 = new TagField('TestTags', "Relation tags (try 'one', 'two', 'three', 'four')");
// $fields->addFieldToTab('Root.Main', $tf2); // $fields->addFieldToTab('Root.Main', $tf2);
// $tf3 = new TagField('FixedTags', "Fixed tags (try 'PHP', 'Ruby', 'Python')", null, 'TestTag'); // $tf3 = new TagField('FixedTags', "Fixed tags (try 'PHP', 'Ruby', 'Python')", null, 'TestTag');
// $tf3->setCustomTags(array('PHP', 'Ruby', 'Python')); // $tf3->setCustomTags(array('PHP', 'Ruby', 'Python'));
// $fields->addFieldToTab('Root.Main', $tf3); // $fields->addFieldToTab('Root.Main', $tf3);
// return $fields; // return $fields;
// } // }
// function requireDefaultRecords(){ // function requireDefaultRecords(){
// $class = $this->class; // $class = $this->class;
// if(!DataObject::get_one($class)) { // if(!DataObject::get_one($class)) {
@ -34,7 +34,7 @@
// $page->write(); // $page->write();
// } // }
// } // }
// } // }
// class TestTagFieldPage_Controller extends Page_Controller {} // class TestTagFieldPage_Controller extends Page_Controller {}