From a18cb30402a09f4df0991ea2f67ac18bf9c10596 Mon Sep 17 00:00:00 2001 From: helpfulrobot Date: Fri, 18 Dec 2015 09:20:49 +1300 Subject: [PATCH] Converted to PSR-2 --- code/BasicFieldsTestPage.php | 503 ++++++++--------- code/Company.php | 627 +++++++++++----------- code/Employee.php | 149 ++--- code/FTPageMakerTask.php | 45 +- code/FileUploadRole.php | 12 +- code/FrameworkTestFileExtension.php | 13 +- code/FrameworkTestRole.php | 79 +-- code/FrameworkTestSiteTreeExtension.php | 10 +- code/FrameworktestRegressSessionAdmin.php | 169 +++--- code/GridFieldTestPage.php | 125 ++--- code/Organisation.php | 18 +- code/RelationFieldsTestPage.php | 94 ++-- code/TestCategory.php | 61 ++- code/TestFileUploadPage.php | 59 +- code/TestModelAdmin.php | 18 +- code/TestPage.php | 198 +++---- code/multiform/Page2MultiForm.php | 112 ++-- code/multiform/Page2MultiFormTestPage.php | 32 +- code/multiform/Page3MultiForm.php | 138 ++--- code/multiform/Page3MultiFormTestPage.php | 32 +- code/multiform/TestMultiForm.php | 143 ++--- code/multiform/TestMultiFormPage.php | 41 +- code/recaptcha/RecaptchaTestPage.php | 70 +-- code/sifr/SifrPage.php | 45 +- code/tagfield/TestTag.php | 10 +- code/tagfield/TestTagFieldPage.php | 20 +- 26 files changed, 1450 insertions(+), 1373 deletions(-) diff --git a/code/BasicFieldsTestPage.php b/code/BasicFieldsTestPage.php index 7fe355c..4723dff 100644 --- a/code/BasicFieldsTestPage.php +++ b/code/BasicFieldsTestPage.php @@ -1,275 +1,284 @@ 'Text', - 'Validated' => 'Text', - 'Checkbox' => 'Boolean', - 'Readonly' => 'Varchar', - 'Textarea' => 'Text', - 'Text' => 'Varchar', - 'CalendarDate' => 'Date', - 'CompositeDate' => 'Date', - 'Date' => 'Date', - 'DMYCalendarDate' => 'Date', - 'DMYDate' => 'Date', - 'DateTime' => 'Datetime', - 'DateTimeWithCalendar' => 'Datetime', - 'Time' => 'Time', - 'TimeWithDropdown' => 'Time', - 'Money' => 'Money', - 'Number' => 'Int', - 'Price' => 'Double', - 'Email' => 'Varchar', - 'Password' => 'Varchar', - 'ConfirmedPassword' => 'Varchar', - 'HTMLField' => 'HTMLText', - 'HTMLOneLine' => 'HTMLVarchar', - 'UniqueText' => 'Varchar', - 'AjaxUniqueText' => 'Varchar', - 'UniqueRestrictedText' => 'Varchar', - 'BankNumber' => 'Varchar', - 'PhoneNumber' => 'Varchar', - 'Autocomplete' => 'Varchar', - 'CreditCard' => 'Varchar', - 'GSTNumber' => 'Varchar', - 'OptionSet' => 'Int', - ); - - private static $has_one = array( - 'Dropdown' => 'TestCategory', - 'GroupedDropdown' => 'TestCategory', - 'ListboxField' => 'TestCategory', - 'File' => 'File', - 'AttachedFile' => 'File', - 'Image' => 'Image', - ); +class BasicFieldsTestPage extends TestPage +{ + private static $db = array( + 'Required' => 'Text', + 'Validated' => 'Text', + 'Checkbox' => 'Boolean', + 'Readonly' => 'Varchar', + 'Textarea' => 'Text', + 'Text' => 'Varchar', + 'CalendarDate' => 'Date', + 'CompositeDate' => 'Date', + 'Date' => 'Date', + 'DMYCalendarDate' => 'Date', + 'DMYDate' => 'Date', + 'DateTime' => 'Datetime', + 'DateTimeWithCalendar' => 'Datetime', + 'Time' => 'Time', + 'TimeWithDropdown' => 'Time', + 'Money' => 'Money', + 'Number' => 'Int', + 'Price' => 'Double', + 'Email' => 'Varchar', + 'Password' => 'Varchar', + 'ConfirmedPassword' => 'Varchar', + 'HTMLField' => 'HTMLText', + 'HTMLOneLine' => 'HTMLVarchar', + 'UniqueText' => 'Varchar', + 'AjaxUniqueText' => 'Varchar', + 'UniqueRestrictedText' => 'Varchar', + 'BankNumber' => 'Varchar', + 'PhoneNumber' => 'Varchar', + 'Autocomplete' => 'Varchar', + 'CreditCard' => 'Varchar', + 'GSTNumber' => 'Varchar', + 'OptionSet' => 'Int', + ); + + private static $has_one = array( + 'Dropdown' => 'TestCategory', + 'GroupedDropdown' => 'TestCategory', + 'ListboxField' => 'TestCategory', + 'File' => 'File', + 'AttachedFile' => 'File', + 'Image' => 'Image', + ); - private static $has_many = array( - 'HasManyFiles' => 'File', - ); + private static $has_many = array( + 'HasManyFiles' => 'File', + ); - private static $many_many = array( - 'ManyManyFiles' => 'File', - 'MultipleListboxField' => 'TestCategory', - ); + private static $many_many = array( + 'ManyManyFiles' => 'File', + 'MultipleListboxField' => 'TestCategory', + ); - private static $defaults = array( - 'Validated' => 2 - ); + private static $defaults = array( + 'Validated' => 2 + ); - function requireDefaultRecords() { - parent::requireDefaultRecords(); + public function requireDefaultRecords() + { + parent::requireDefaultRecords(); - if($inst = DataObject::get_one('BasicFieldsTestPage')) { - $data = $this->getDefaultData(); - $inst->update($data); - $inst->write(); - } - } + if ($inst = DataObject::get_one('BasicFieldsTestPage')) { + $data = $this->getDefaultData(); + $inst->update($data); + $inst->write(); + } + } - function getDefaultData() { - $cats = TestCategory::get(); - if(!$cats->Count()) return array(); // not initialized yet + public function getDefaultData() + { + $cats = TestCategory::get(); + if (!$cats->Count()) { + return array(); + } // not initialized yet - $firstCat = $cats->offsetGet(0); - $thirdCat = $cats->offsetGet(2); + $firstCat = $cats->offsetGet(0); + $thirdCat = $cats->offsetGet(2); - return array( - 'Readonly' => 'My value (ä!)', - 'Textarea' => 'My value (ä!)', - 'Required' => 'My required value (delete to test)', - 'Validated' => '1', - 'Text' => 'My value (ä!)', - 'Textarea' => 'My value (ä!)', - 'HTMLField' => 'My value (ä!)', - 'Email' => 'test@test.com', - 'Password' => 'My value (ä!)', - 'Number' => 99, - 'Price' => 99.99, - 'MoneyAmount' => 99.99, - 'MoneyCurrency' => 'EUR', - 'PhoneNumber' => '021 1235', - 'CreditCard' => '4000400040004111', - 'Checkbox' => 1, - 'CheckboxSetID' => $firstCat->ID, - 'DropdownID' => $firstCat->ID, - 'GroupedDropdownID' => $firstCat->ID, - 'ListboxFieldID' => $firstCat->ID, - 'MultipleListboxFieldID' => join(',', array($thirdCat->ID, $firstCat->ID)), - 'OptionSet' => join(',', array($thirdCat->ID, $firstCat->ID)), - 'Date' => "2002-10-23", - 'CalendarDate' => "2002-10-23", - 'DMYDate' => "2002-10-23", - 'Time' => "23:59", - 'TimeWithDropdown' => "23:59", - 'DateTime' => "2002-10-23 23:59", - 'DateTimeWithCalendar' => "2002-10-23 23:59", - ); - } - - function getCMSFields() { - $fields = parent::getCMSFields(); + return array( + 'Readonly' => 'My value (ä!)', + 'Textarea' => 'My value (ä!)', + 'Required' => 'My required value (delete to test)', + 'Validated' => '1', + 'Text' => 'My value (ä!)', + 'Textarea' => 'My value (ä!)', + 'HTMLField' => 'My value (ä!)', + 'Email' => 'test@test.com', + 'Password' => 'My value (ä!)', + 'Number' => 99, + 'Price' => 99.99, + 'MoneyAmount' => 99.99, + 'MoneyCurrency' => 'EUR', + 'PhoneNumber' => '021 1235', + 'CreditCard' => '4000400040004111', + 'Checkbox' => 1, + 'CheckboxSetID' => $firstCat->ID, + 'DropdownID' => $firstCat->ID, + 'GroupedDropdownID' => $firstCat->ID, + 'ListboxFieldID' => $firstCat->ID, + 'MultipleListboxFieldID' => join(',', array($thirdCat->ID, $firstCat->ID)), + 'OptionSet' => join(',', array($thirdCat->ID, $firstCat->ID)), + 'Date' => "2002-10-23", + 'CalendarDate' => "2002-10-23", + 'DMYDate' => "2002-10-23", + 'Time' => "23:59", + 'TimeWithDropdown' => "23:59", + 'DateTime' => "2002-10-23 23:59", + 'DateTimeWithCalendar' => "2002-10-23 23:59", + ); + } + + public function getCMSFields() + { + $fields = parent::getCMSFields(); - $description = 'This is bold help text'; - - $fields->addFieldsToTab('Root.Text', array( - Object::create('TextField', 'Required', 'Required field'), - Object::create('TextField', 'Validated', 'Validated field (checks range between 1 and 3)'), - Object::create('ReadonlyField', 'Readonly', 'ReadonlyField'), - Object::create('TextareaField', 'Textarea', 'TextareaField - 8 rows') - ->setRows(8), - Object::create('TextField', 'Text', 'TextField'), - Object::create('HtmlEditorField', 'HTMLField', 'HtmlEditorField'), - Object::create('EmailField', 'Email', 'EmailField'), - Object::create('PasswordField', 'Password', 'PasswordField') - )); + $description = 'This is bold help text'; + + $fields->addFieldsToTab('Root.Text', array( + Object::create('TextField', 'Required', 'Required field'), + Object::create('TextField', 'Validated', 'Validated field (checks range between 1 and 3)'), + Object::create('ReadonlyField', 'Readonly', 'ReadonlyField'), + Object::create('TextareaField', 'Textarea', 'TextareaField - 8 rows') + ->setRows(8), + Object::create('TextField', 'Text', 'TextField'), + Object::create('HtmlEditorField', 'HTMLField', 'HtmlEditorField'), + Object::create('EmailField', 'Email', 'EmailField'), + Object::create('PasswordField', 'Password', 'PasswordField') + )); - $fields->addFieldsToTab('Root.Numeric', array( - Object::create('NumericField', 'Number', 'NumericField'), - Object::create('CurrencyField', 'Price', 'CurrencyField'), - Object::create('MoneyField', 'Money', 'MoneyField', array('Amount' => 99.99, 'Currency' => 'EUR')), - Object::create('PhoneNumberField', 'PhoneNumber', 'PhoneNumberField'), - Object::create('CreditCardField', 'CreditCard', 'CreditCardField') - )); - - $fields->addFieldsToTab('Root.Option', array( - Object::create('CheckboxField', 'Checkbox', 'CheckboxField'), - Object::create('CheckboxSetField', 'CheckboxSet', 'CheckboxSetField', TestCategory::map()), - Object::create('DropdownField', 'DropdownID', 'DropdownField', TestCategory::map()) - ->setHasEmptyDefault(true), - Object::create('GroupedDropdownField', 'GroupedDropdownID', - 'GroupedDropdown', array('Test Categorys' => TestCategory::map()) - ), - Object::create('ListboxField', 'ListboxFieldID', 'ListboxField', TestCategory::map()) - ->setSize(3), - Object::create('ListboxField', 'MultipleListboxFieldID', 'ListboxField (multiple)', TestCategory::map()) - ->setMultiple(true) - ->setSize(3), - Object::create('OptionsetField', 'OptionSet', 'OptionSetField', TestCategory::map()), - Object::create('ToggleCompositeField', 'ToggleCompositeField', 'ToggleCompositeField', new FieldList( - Object::create('TextField', 'ToggleCompositeTextField1'), - Object::create('TextField', 'ToggleCompositeTextField2'), - Object::create('DropdownField', 'ToggleCompositeDropdownField', 'ToggleCompositeDropdownField', TestCategory::map()), - Object::create('TextField', 'ToggleCompositeTextField3') - )) - )); + $fields->addFieldsToTab('Root.Numeric', array( + Object::create('NumericField', 'Number', 'NumericField'), + Object::create('CurrencyField', 'Price', 'CurrencyField'), + Object::create('MoneyField', 'Money', 'MoneyField', array('Amount' => 99.99, 'Currency' => 'EUR')), + Object::create('PhoneNumberField', 'PhoneNumber', 'PhoneNumberField'), + Object::create('CreditCardField', 'CreditCard', 'CreditCardField') + )); + + $fields->addFieldsToTab('Root.Option', array( + Object::create('CheckboxField', 'Checkbox', 'CheckboxField'), + Object::create('CheckboxSetField', 'CheckboxSet', 'CheckboxSetField', TestCategory::map()), + Object::create('DropdownField', 'DropdownID', 'DropdownField', TestCategory::map()) + ->setHasEmptyDefault(true), + Object::create('GroupedDropdownField', 'GroupedDropdownID', + 'GroupedDropdown', array('Test Categorys' => TestCategory::map()) + ), + Object::create('ListboxField', 'ListboxFieldID', 'ListboxField', TestCategory::map()) + ->setSize(3), + Object::create('ListboxField', 'MultipleListboxFieldID', 'ListboxField (multiple)', TestCategory::map()) + ->setMultiple(true) + ->setSize(3), + Object::create('OptionsetField', 'OptionSet', 'OptionSetField', TestCategory::map()), + Object::create('ToggleCompositeField', 'ToggleCompositeField', 'ToggleCompositeField', new FieldList( + Object::create('TextField', 'ToggleCompositeTextField1'), + Object::create('TextField', 'ToggleCompositeTextField2'), + Object::create('DropdownField', 'ToggleCompositeDropdownField', 'ToggleCompositeDropdownField', TestCategory::map()), + Object::create('TextField', 'ToggleCompositeTextField3') + )) + )); - // All these date/time fields generally have issues saving directly in the CMS - $fields->addFieldsToTab('Root.DateTime', array( - $calendarDateField = Object::create('DateField', 'CalendarDate','DateField with calendar'), - Object::create('DateField', 'Date','DateField'), - $dmyDateField = Object::create('DateField', 'DMYDate','DateField with separate fields'), - Object::create('TimeField', 'Time','TimeField'), - $timeFieldDropdown = Object::create('TimeField', 'TimeWithDropdown','TimeField with dropdown'), - Object::create('DatetimeField', 'DateTime', 'DateTime'), - $dateTimeShowCalendar = Object::create('DatetimeField', 'DateTimeWithCalendar', 'DateTime with calendar') - )); - $calendarDateField->setConfig('showcalendar', true); - $dmyDateField->setConfig('dmyfields', true); - $timeFieldDropdown->setConfig('showdropdown', true); - $dateTimeShowCalendar->getDateField()->setConfig('showcalendar', true); - $dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true); + // All these date/time fields generally have issues saving directly in the CMS + $fields->addFieldsToTab('Root.DateTime', array( + $calendarDateField = Object::create('DateField', 'CalendarDate', 'DateField with calendar'), + Object::create('DateField', 'Date', 'DateField'), + $dmyDateField = Object::create('DateField', 'DMYDate', 'DateField with separate fields'), + Object::create('TimeField', 'Time', 'TimeField'), + $timeFieldDropdown = Object::create('TimeField', 'TimeWithDropdown', 'TimeField with dropdown'), + Object::create('DatetimeField', 'DateTime', 'DateTime'), + $dateTimeShowCalendar = Object::create('DatetimeField', 'DateTimeWithCalendar', 'DateTime with calendar') + )); + $calendarDateField->setConfig('showcalendar', true); + $dmyDateField->setConfig('dmyfields', true); + $timeFieldDropdown->setConfig('showdropdown', true); + $dateTimeShowCalendar->getDateField()->setConfig('showcalendar', true); + $dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true); - $fields->addFieldsToTab('Root.File', array( - $bla = UploadField::create('File','FileUploadField') - ->setDescription($description) - ->setConfig('allowedMaxFileNumber', 1) - ->setConfig('canPreviewFolder', false), - UploadField::create('AttachedFile','UploadField with canUpload=false') - ->setDescription($description) - ->setConfig('canUpload', false), - UploadField::create('Image','UploadField for image') - ->setDescription($description), - UploadField::create('HasManyFiles','UploadField for has_many') - ->setDescription($description), - UploadField::create('ManyManyFiles','UploadField for many_many') - ->setDescription($description) - )); + $fields->addFieldsToTab('Root.File', array( + $bla = UploadField::create('File', 'FileUploadField') + ->setDescription($description) + ->setConfig('allowedMaxFileNumber', 1) + ->setConfig('canPreviewFolder', false), + UploadField::create('AttachedFile', 'UploadField with canUpload=false') + ->setDescription($description) + ->setConfig('canUpload', false), + UploadField::create('Image', 'UploadField for image') + ->setDescription($description), + UploadField::create('HasManyFiles', 'UploadField for has_many') + ->setDescription($description), + UploadField::create('ManyManyFiles', 'UploadField for many_many') + ->setDescription($description) + )); - $data = $this->getDefaultData(); - foreach($fields->dataFields() as $field) { - $name = $field->getName(); - if(isset($data[$name])) { - $field->setValue($data[$name]); - } - } + $data = $this->getDefaultData(); + foreach ($fields->dataFields() as $field) { + $name = $field->getName(); + if (isset($data[$name])) { + $field->setValue($data[$name]); + } + } - $blacklist = array( - 'DMYDate', 'Required', 'Validated', 'ToggleCompositeField', - ); + $blacklist = array( + 'DMYDate', 'Required', 'Validated', 'ToggleCompositeField', + ); - $tabs = array('Root.Text', 'Root.Numeric', 'Root.Option', 'Root.DateTime', 'Root.File'); - foreach($tabs as $tab) { - $tabObj = $fields->fieldByName($tab); - foreach($tabObj->FieldList() as $field) { - $field - ->setDescription($description); - // ->addExtraClass('cms-description-tooltip'); + $tabs = array('Root.Text', 'Root.Numeric', 'Root.Option', 'Root.DateTime', 'Root.File'); + foreach ($tabs as $tab) { + $tabObj = $fields->fieldByName($tab); + foreach ($tabObj->FieldList() as $field) { + $field + ->setDescription($description); + // ->addExtraClass('cms-description-tooltip'); - if(in_array($field->getName(), $blacklist)) continue; + if (in_array($field->getName(), $blacklist)) { + continue; + } - $disabledField = $field->performDisabledTransformation(); - $disabledField->setTitle($disabledField->Title() . ' (disabled)'); - $disabledField->setName($disabledField->getName() . '_disabled'); - $tabObj->insertAfter($disabledField, $field->getName()); + $disabledField = $field->performDisabledTransformation(); + $disabledField->setTitle($disabledField->Title() . ' (disabled)'); + $disabledField->setName($disabledField->getName() . '_disabled'); + $tabObj->insertAfter($disabledField, $field->getName()); - $readonlyField = $field->performReadonlyTransformation(); - $readonlyField->setTitle($readonlyField->Title() . ' (readonly)'); - $readonlyField->setName($readonlyField->getName() . '_readonly'); - $tabObj->insertAfter($readonlyField, $field->getName()); - } - } + $readonlyField = $field->performReadonlyTransformation(); + $readonlyField->setTitle($readonlyField->Title() . ' (readonly)'); + $readonlyField->setName($readonlyField->getName() . '_readonly'); + $tabObj->insertAfter($readonlyField, $field->getName()); + } + } - $noLabelField = new TextField('Text_NoLabel', false, 'TextField without label'); - $noLabelField->setDescription($description); - $fields->addFieldToTab('Root.Text', $noLabelField, 'Text_disabled'); + $noLabelField = new TextField('Text_NoLabel', false, 'TextField without label'); + $noLabelField->setDescription($description); + $fields->addFieldToTab('Root.Text', $noLabelField, 'Text_disabled'); - $fields->addFieldToTab('Root.Text', - FieldGroup::create( - TextField::create('MyFieldGroup1'), - TextField::create('MyFieldGroup2'), - DropdownField::create('MyFieldGroup3', false, TestCategory::map()) - ) - ); - $fields->addFieldToTab('Root.Text', - FieldGroup::create( - 'MyLabelledFieldGroup', - array( - TextField::create('MyLabelledFieldGroup1'), - TextField::create('MyLabelledFieldGroup2'), - DropdownField::create('MyLabelledFieldGroup3', null, TestCategory::map()) - ) - )->setTitle('My Labelled Field Group') - ); + $fields->addFieldToTab('Root.Text', + FieldGroup::create( + TextField::create('MyFieldGroup1'), + TextField::create('MyFieldGroup2'), + DropdownField::create('MyFieldGroup3', false, TestCategory::map()) + ) + ); + $fields->addFieldToTab('Root.Text', + FieldGroup::create( + 'MyLabelledFieldGroup', + array( + TextField::create('MyLabelledFieldGroup1'), + TextField::create('MyLabelledFieldGroup2'), + DropdownField::create('MyLabelledFieldGroup3', null, TestCategory::map()) + ) + )->setTitle('My Labelled Field Group') + ); - return $fields; + return $fields; + } - } + public function getCMSValidator() + { + return new RequiredFields('Required'); + } - public function getCMSValidator() { - return new RequiredFields('Required'); - } - - public function validate() { - $result = parent::validate(); - if(!$this->Validated || $this->Validated < 1 || $this->Validated > 3) { - $result->error('"Validated" field needs to be between 1 and 3'); - } - return $result; - } + public function validate() + { + $result = parent::validate(); + if (!$this->Validated || $this->Validated < 1 || $this->Validated > 3) { + $result->error('"Validated" field needs to be between 1 and 3'); + } + return $result; + } } -class BasicFieldsTestPage_Controller extends TestPage_Controller { - function AutoCompleteItems() { - $items = array( - 'TestItem1', - 'TestItem2', - 'TestItem3', - 'TestItem4', - ); - return implode(',', $items); - } +class BasicFieldsTestPage_Controller extends TestPage_Controller +{ + public function AutoCompleteItems() + { + $items = array( + 'TestItem1', + 'TestItem2', + 'TestItem3', + 'TestItem4', + ); + return implode(',', $items); + } } - -?> \ No newline at end of file diff --git a/code/Company.php b/code/Company.php index 0bacebf..3590248 100644 --- a/code/Company.php +++ b/code/Company.php @@ -1,326 +1,331 @@ 'Varchar(255)', - 'Category'=>'Varchar(255)', - 'Revenue'=>'Float', - 'CEO'=>'Varchar(255)', - ); + /** + * + * @var array + */ + private static $db = array( + 'Name'=>'Varchar(255)', + 'Category'=>'Varchar(255)', + 'Revenue'=>'Float', + 'CEO'=>'Varchar(255)', + ); - private static $has_one = array( - 'RelationFieldsTestPage' => 'RelationFieldsTestPage', - 'GridFieldTestPageHasOne' => 'GridFieldTestPage' - ); - - private static $has_many = array( - 'Employees' => 'Employee', - 'GroupPhotos' => 'Image' - ); + private static $has_one = array( + 'RelationFieldsTestPage' => 'RelationFieldsTestPage', + 'GridFieldTestPageHasOne' => 'GridFieldTestPage' + ); + + private static $has_many = array( + 'Employees' => 'Employee', + 'GroupPhotos' => 'Image' + ); - private static $many_many = array( - 'PastEmployees' => 'Employee' - ); + private static $many_many = array( + 'PastEmployees' => 'Employee' + ); - private static $many_many_extraFields = array( - 'PastEmployees' => array( - 'YearStart' => 'Int', - 'YearEnd' => 'Int', - 'Role' => 'Text', - ) - ); + private static $many_many_extraFields = array( + 'PastEmployees' => array( + 'YearStart' => 'Int', + 'YearEnd' => 'Int', + 'Role' => 'Text', + ) + ); - private static $belongs_many_many = array( - 'RelationFieldsTestPages' => 'RelationFieldsTestPage', - 'GridFieldTestPage' => 'GridFieldTestPage' - ); + private static $belongs_many_many = array( + 'RelationFieldsTestPages' => 'RelationFieldsTestPage', + 'GridFieldTestPage' => 'GridFieldTestPage' + ); - private static $summary_fields = array( - 'Name', - 'Category', - 'Revenue', - 'CEO', - 'DynamicProperty' - ); + private static $summary_fields = array( + 'Name', + 'Category', + 'Revenue', + 'CEO', + 'DynamicProperty' + ); - private static $searchable_fields = array( - 'Name', - 'Category', - 'Revenue', - 'CEO', - ); + private static $searchable_fields = array( + 'Name', + 'Category', + 'Revenue', + 'CEO', + ); - public function getCMSFields() { - $fields = parent::getCMSFields(); - $fields->addFieldToTab('Root.Main', - $uploadField = UploadField::create('GroupPhotos') - ); - if(method_exists('UploadField', 'setAllowedFileCategories')) { - $uploadField->setAllowedFileCategories('image'); - } + public function getCMSFields() + { + $fields = parent::getCMSFields(); + $fields->addFieldToTab('Root.Main', + $uploadField = UploadField::create('GroupPhotos') + ); + if (method_exists('UploadField', 'setAllowedFileCategories')) { + $uploadField->setAllowedFileCategories('image'); + } - return $fields; - } + return $fields; + } - function validate() { - if(!$this->Title) { - return new ValidationResult(false, 'Title is required'); - } else { - return parent::validate(); - } - - } + public function validate() + { + if (!$this->Title) { + return new ValidationResult(false, 'Title is required'); + } else { + return parent::validate(); + } + } - public function DynamicProperty() { - return sprintf('%s (%s)', $this->Name, $this->CEO); - } - - public function requireDefaultRecords() { - parent::requireDefaultRecords(); - $companySet = DataObject::get('Company'); - foreach ($companySet as $company) { - $company->delete(); - } - - foreach($this->data() as $companyData){ - $company = new Company(); - $company->Name = $companyData[0]; - $company->Category = $companyData[1]; - $company->Revenue = $companyData[2]; - $company->CEO = $companyData[3]; - $company->write(); - } - DB::alteration_message("Added default records to Company table","created"); - } + public function DynamicProperty() + { + return sprintf('%s (%s)', $this->Name, $this->CEO); + } + + public function requireDefaultRecords() + { + parent::requireDefaultRecords(); + $companySet = DataObject::get('Company'); + foreach ($companySet as $company) { + $company->delete(); + } + + foreach ($this->data() as $companyData) { + $company = new Company(); + $company->Name = $companyData[0]; + $company->Category = $companyData[1]; + $company->Revenue = $companyData[2]; + $company->CEO = $companyData[3]; + $company->write(); + } + DB::alteration_message("Added default records to Company table", "created"); + } - /** - * Contains test data - * - * @return array - */ - public function data() { - return array( - 0 => array("Walmart", "Retail", "421.849", "Michael Duke"), - 1 => array("ExxonMobil", "Oil and gas", "370.125", "Rex W. Tillerson"), - 2 => array("Royal Dutch Shell", "Oil and gas", "368.056", "Peter Voser"), - 3 => array("BP", "Oil and gas", "297.107", "Robert Dudley"), - 4 => array("Sinopec", "Oil and gas", "289.774", "Jiming Wang"), - 5 => array("State Grid Corporation of China", "Electricity", "231.556", "Liu Zhenya"), - 6 => array("Toyota Motors", "Automotive", "228.247", "Fujio Cho"), - 7 => array("PetroChina", "Oil and gas", "221.955", "Zhou Jiping"), - 8 => array("Total S.A.", "Oil and gas", "212.815", "Christophe de Margerie"), - 9 => array("Japan Post Holdings", "Conglomerate", "211.080", "Jiro Saito"), - 10 => array("Chevron", "Oil and gas", "204.928", "David J. O'Reilly"), - 11 => array("ConocoPhillips", "Oil and gas", "198.655", "James Mulva"), - 12 => array("Vitol", "Raw material", "195.0", "Ian Taylor"), - 13 => array("Saudi Aramco", "Oil and gas", "182.396", "Waleed Al-Bedaiwi"), - 14 => array("Volkswagen Group", "Automotive", "169.53", "Martin Winterkorn"), - 15 => array("Fannie Mae", "Financial services", "154.270", "Mike Williams"), - 16 => array("General Electric", "Conglomerate", "150.211", "Jeffrey Immelt"), - 17 => array("Glencore", "Raw materials", "144.978", "Ivan Glasenberg"), - 18 => array("Allianz", "Financial services", "142.24", "Michael Diekmann"), - 19 => array("ING Group", "Financial services", "140.729", "Jan Hommen"), - 20 => array("Berkshire Hathaway", "Conglomerate", "136.185", "Warren Buffett"), - 21 => array("Samsung Electronics", "Conglomerate", "135.772", "Lee Kun-hee"), - 22 => array("General Motors", "Automotive", "135.592", "Daniel Akerson"), - 23 => array("Eni", "Oil and gas", "131.292", "Paolo Scaroni"), - 24 => array("Daimler AG", "Automotive", "130.628", "Dieter Zetsche"), - 25 => array("Ford Motor Company", "Automotive", "128.954", "Alan Mulally"), - 26 => array("Hewlett-Packard", "Information technology", "127.245", "Meg Whitman"), - 27 => array("Nippon Telegraph and Telephone", "Telecommunications", "124.517", "Norio Wada"), - 28 => array("AT&T", "Telecommunications", "124.28", "Randall L. Stephenson"), - 29 => array("E.ON", "Electricity; gas", "124.084", "Johannes Teyssen"), - 30 => array("Carrefour", "Retailing", "122.280", "Lars Olofsson"), - 31 => array("AXA", "Financial services", "121.577", "Henri de Castries"), - 32 => array("Assicurazioni Generali", "Insurance", "121.299", "Sergio Balbinot, Giovanni Perissinotto"), - 33 => array("Petrobras", "Oil and gas", "120.052", "José Sérgio Gabrielli de Azevedo"), - 34 => array("Cargill", "Agriculture", "119.469", "Greg Page"), - 35 => array("JX Holdings", "Energy", "116.414", "-"), - 36 => array("GDF Suez", "Public utilities", "112.88", "Gérard Mestrallet"), - 37 => array("Hitachi, Ltd.", "Conglomerate", "112.239", "Etsuhiko Shoyama"), - 38 => array("McKesson Corporation", "Health care", "112.084", "John Hammergren"), - 39 => array("Gazprom", "Oil and Gas", "111.808", "Alexei Miller"), - 40 => array("Bank of America", "Banking", "111.39", "Brian Moynihan"), - 41 => array("Tesco", "Retailing", "110.85", "Philip Clarke"), - 42 => array("Federal Home Loan Mortgage Corporation", "Financial services", "109.956", "Richard F. Syron"), - 43 => array("Apple Inc.", "Electronics", "108.249", "Tim Cook"), - 44 => array("Honda", "Automotive", "107.985", "Takanobu Ito"), - 45 => array("Verizon", "Telecommunications", "106.565", "Ivan Seidenberg"), - 46 => array("Nissan Motors", "Automotive", "105.523", "Carlos Ghosn"), - 47 => array("Panasonic Corporation", "Electronics", "105.035", "Kunio Nakamura"), - 48 => array("Nestlé", "Food processing", "104.972", "Paul Bulcke"), - 49 => array("LUKoil", "Oil and Gas", "104.956", "Vagit Alekperov"), - 50 => array("Pemex", "Oil and gas", "103.538", "Juan José Suárez Coppel"), - 51 => array("JPMorgan Chase", "Financial Services", "102.694", "Jamie Dimon"), - 52 => array("Cardinal Health", "Health care", "102.644", "George Barrett"), - 53 => array("Koch Industries", "Conglomerate", "100.0", "Charles Koch"), - 54 => array("Petróleos de Venezuela", "Oil and gas", "94.929", "Rafael Ramírez"), - 55 => array("IBM", "Information technology", "99.87", "Virginia Rometty"), - 56 => array("Siemens AG", "Conglomerate", "98.870", "Peter Löscher"), - 57 => array("Hyundai Motors", "Automotive", "98.858", "Chung Mong-Koo"), - 58 => array("Enel", "Electricity generation", "97.782", "Fulvio Conti"), - 59 => array("CVS Caremark", "Retailing", "96.413", "Tom Ryan"), - 60 => array("Lloyds Banking Group", "Financial Services", "95.342", "António Horta-Osório"), - 61 => array("UnitedHealth Group", "Health care", "94.155", "Stephen Hemsley"), - 62 => array("Statoil", "Oil and gas", "90.733", "Helge Lund"), - 63 => array("Metro AG", "Retailing", "89.87", "Eckhard Cordes"), - 64 => array("Aviva", "Financial services", "89.890", "Andrew Moss"), - 65 => array("Electricité de France", "Electricity generation", "87.073", "Henri Proglio"), - 66 => array("Costco", "Retailing", "87.048", "Jim Sinegal"), - 67 => array("Citigroup", "Financial services", "86.601", "Vikram Pandit"), - 68 => array("Sony", "Electronics", "86.521", "Howard Stringer"), - 69 => array("BASF", "Chemical industry", "85.347", "Kurt Bock"), - 70 => array("Wells Fargo", "Banking / Financial services", "85.21", "John Stumpf"), - 71 => array("Société Générale", "Financial Services", "84.868", "Frédéric Oudéa"), - 72 => array("Kuwait Petroleum Corporation", "Oil and gas", "84.594", "Saad Al Shuwaib"), - 73 => array("Deutsche Telekom", "Telecommunications", "83.407", "René Obermann"), - 74 => array("Procter & Gamble", "Consumer goods", "82.559", "Robert A. \"Bob\" McDonald"), - 75 => array("Industrial and Commercial Bank of China", "Banking", "82.536", "Jiang Jianqing"), - 76 => array("Valero Energy", "Oil and gas", "82.233", "Bill Klesse"), - 77 => array("Kroger", "Retailing", "82.189", "David Dillon"), - 78 => array("Nippon Life Insurance", "Insurance", "81.315", "Kunie Okamoto"), - 79 => array("Telefónica", "Telecommunications", "80.938", "César Alierta"), - 80 => array("BMW", "Automotive", "80.809", "Norbert Reithofer"), - 81 => array("Repsol YPF", "Oil and Gas", "80.747", "Antonio Brufau"), - 82 => array("Archer Daniels Midland", "Agriculture, Food processing", "80.676", "Patricia A. Woertz"), - 83 => array("AmerisourceBergen", "Health care", "80.218", "R. David Yost"), - 84 => array("HSBC", "Financial services", "80.014", "Stuart Gulliver"), - 85 => array("SK Group", "Conglomerate", "79.603", "Choi Tae-Won"), - 86 => array("National Iranian Oil Company", "Oil and gas", "79.277", "Masoud Mir Kazemi"), - 87 => array("Trafigura", "Raw materials", "79.2", " ?"), - 88 => array("ArcelorMittal", "Steel", "78.025", "Lakshmi Mittal"), - 89 => array("American International Group", "Financial services", "77.301", "Robert Benmosche"), - 90 => array("Toshiba", "Conglomerate", "77.090", "Tadashi Okamura"), - 91 => array("Petronas", "Oil and gas", "76.822", "Tan Sri Dato Sri Mohd Hassan Marican"), - 92 => array("Indian Oil Corporation", "Oil and Gas", "75.632", "B.M.Bansal"), - 93 => array("Fiat", "Conglomerate", "75.172", "Sergio Marchionne"), - 94 => array("ZEN-NOH", "Agricultural marketing", "75.111", "Katsuyoshi Kitajima"), - 95 => array("PSA Peugeot Citroën", "Automotive", "74.909", "Philippe Varin"), - 96 => array("Vodafone", "Telecommunications", "73.635", "Vittorio Colao"), - 97 => array("Marathon Oil", "Oil and gas", "73.621", "Clarence Cazalot, Jr."), - 98 => array("China Mobile", "Telecommunications", "73.520", "Li Yue"), - 99 => array("Prudential plc", "Banking", "73.337", "Tidjane Thiam"), - 100 => array("Walgreens", "Retailing", "72.184", "Jeff Rein"), - 101 => array("Deutsche Post", "Courier", "71.751", "Frank Appel"), - 102 => array("BHP Billiton", "Mining", "71.739", "Marius Kloppers"), - 103 => array("RWE", "Public utilities", "71.246", "Jürgen Großmann"), - 104 => array("Aegon", "Insurance", "71.148", "Alex Wynaendts"), - 105 => array("REWE Group", "Retailing", "70.872", "Alain Caparros"), - 106 => array("Dexia", "Banking", "70.106", "Pierre Mariani"), - 107 => array("Microsoft", "Information technology", "69.943", "Steve Ballmer"), - 108 => array("China Railway Construction Corporation", "Infrastructure", "69.118", "Meng Fengchao"), - 109 => array("China Railway Engineering Corporation", "Infrastructure", "69.082", "Shi Dahua"), - 110 => array("Toyota Tsusho", "Sogo shosha", "69.076", "Masaaki Furukawa"), - 111 => array("China Construction Bank", "Banking", "68.777", "Guo Shuqing"), - 112 => array("Home Depot, Inc.", "Retailing", "67.997", "Frank Blake"), - 113 => array("Zurich Financial Services", "Insurance", "67.85", "Martin Senn"), - 114 => array("Pfizer", "Health care", "67.809", "Jeff Kindler"), - 115 => array("Philip Morris International", "Tobacco industry", "67.713", "Louis C. Camilleri"), - 116 => array("Groupe BPCE", "Banking", "67.303", "François Pérol"), - 117 => array("Target Corporation", "Retailing", "67.390", "Gregg Steinhafel"), - 118 => array("Temasek Holdings", "Sovereign Wealth Fund", "66.285", "Suppiah Dhanabalan"), - 119 => array("Medco Health Solutions", "Health care", "65.968", "David B. Snow, Jr."), - 120 => array("United States Postal Service", "Courier", "65.711", "John E. Potter"), - 121 => array("Gunvor", "Raw material", "65.0", "-"), - 122 => array("Crédit Agricole", "Financial Services", "64.800", "Jean-Paul Chifflet"), - 123 => array("Tokyo Electric Power", "Electricity generation", "64.964", "Tsunehisa Katsumata"), - 124 => array("Boeing", "Aerospace", "64.306", "Jim McNerney"), - 125 => array("Barclays Bank", "Banking", "63.978", "Bob Diamond"), - 126 => array("State Farm Insurance", "Insurance", "63.2", "Edward B. Rust Jr."), - 127 => array("Bosch Group", "Automotive", "63.147", "-"), - 128 => array("PTT Public Company Limited", "Oil and Gas", "62.998", "Prasert Bunsumpun"), - 129 => array("Royal Bank of Scotland", "Financial services", "62.770", "Stephen Hester"), - 130 => array("Mitsubishi Corporation", "Sogo shosha", "62.733", "Mikio Sasaki"), - 131 => array("Seven & I Holdings Co.", "Retailing", "62.436", "Toshifumi Suzuki"), - 132 => array("ÆON", "Retailing", "62.153", "-"), - 133 => array("Agricultural Bank of China", "Banking", "62.151", "Xiang Junbo"), - 134 => array("Johnson & Johnson", "Health care", "61.587", "William C. Weldon"), - 135 => array("Dell", "Information technology", "61.494", "Michael Dell"), - 136 => array("EADS", "Aerospace", "60.969", "Louis Gallois"), - 137 => array("Munich Re", "Financial services", "60.851", "Nikolaus von Bomhard"), - 138 => array("France Télécom", "Telecommunications", "60.801", "Stéphane Richard"), - 139 => array("Rio Tinto", "Mining", "60.323", "Tom Albanese"), - 140 => array("CNP Assurances", "Insurance", "59.846", "Gilles Benoist"), - 141 => array("Reliance Industries", "Conglomerate", "59.679", "Mukesh Ambani"), - 142 => array("Legal & General", "Financial services", "59.673", "Tim Breedon"), - 143 => array("Bank of China", "Banking", "59.668", "Xiao Gang"), - 144 => array("Unilever", "Consumer goods", "59.143", "Paul Polman"), - 145 => array("WellPoint", "Health care", "58.802", "Angela Braly"), - 146 => array("BNP Paribas", "Financial Services", "58.632", "Baudouin Prot"), - 147 => array("China Life Insurance", "Insurance", "58.460", "-"), - 148 => array("Edeka Group", "Retailing", "57.968", "-"), - 149 => array("PepsiCo", "Food", "57.838", "Indra Nooyi"), - 150 => array("Grupo Santander", "Banking", "57.388", "Emilio Botín"), - 151 => array("Auchan", "Retailing", "56.778", "Christophe Dubrulle"), - 152 => array("Noble Group", "Raw materials", "56.696", "Ricardo Leiman"), - 153 => array("China State Construction Engineering Corp", "Infrastructure", "56.104", "Sun Wenjie"), - 154 => array("Banco Bradesco", "Banking", "56.104", "Luiz Carlos Trabuco Cappi"), - 155 => array("A. P. Møller - Mærsk", "Transport", "56.090", "Nils Andersen"), - 156 => array("Dongfeng Motor", "Automotive", "55.864", "Xu Ping"), - 157 => array("China Southern Power Grid Company", "Electricity", "55.825", "Yuan Maozhen"), - 158 => array("Deutsche Bank", "Banking", "55.804", "Josef Ackermann"), - 159 => array("Shanghai Automotive Industry Corporation", "Automotive", "55.689", "Shen Jianhua"), - 160 => array("Fujitsu", "Electronics", "54.559", "Hiroaki Kurokawa"), - 161 => array("United Technologies", "Conglomerate", "54.326", "Louis R. Chênevert"), - 162 => array("Credit Suisse", "Financial services", "53.771", "Brady Dougan"), - 163 => array("China National Offshore Oil Corporation", "Oil and gas", "53.733", "Wang Yilin"), - 164 => array("Dow Chemical", "Manufacturing", "53.674", "Andrew N. Liveris"), - 165 => array("Saint-Gobain", "Construction", "53.607", "Pierre-André de Chalendar"), - 166 => array("UniCredit", "Banking", "53.332", "Federico Ghizzoni"), - 167 => array("Nokia", "Telecommunications", "53.322", "Stephen Elop"), - 168 => array("MetLife", "Insurance", "52.717", "C. Robert Henrikson"), - 169 => array("Renault", "Automotive", "52.073", "Carlos Ghosn"), - 170 => array("Mitsubishi UFJ Financial Group", "Banking", "51.479", "Nobuo Kuroyanagi"), - 171 => array("ThyssenKrupp", "Conglomerate", "50.717", "Heinrich Hiesinger"), - 172 => array("Sinochem Group", "Conglomerate", "50.632", "Liu Deschu"), - 173 => array("Hoffmann-La Roche", "Health care", "50.632", "Severin Schwan"), - 174 => array("Novartis", "Health care", "50.624", "Joseph Jimenez"), - 175 => array("Best Buy", "Retailing", "50.272", "Brian J. Dunn"), - 176 => array("United Parcel Service", "Transportation", "49.545", "Scott Davis"), - 177 => array("Pertamina", "Oil and gas", "48.717", "Karen Agustiawan"), - 178 => array("Dai-ichi Life", "Insurance", "47.855", "-"), - 179 => array("Banco Bilbao Vizcaya Argentaria", "Banking", "47.429", "Francisco González"), - 180 => array("Lowe's", "Retailing", "47.22", "Robert Niblock"), - 181 => array("Rosneft", "Oil and gas", "46.826", "-"), - 182 => array("National Mutual Insurance Federation of Agricultural Cooperatives (Zenkyoren or JA Kyosai)", "Insurance", "46.8", "-"), - 183 => array("VINCI", "Construction", "46.762", "Xavier Huillard"), - 184 => array("Veolia Environnement", "Public utilities", "46.482", "Antoine Frérot"), - 185 => array("Vale", "Mining", "46.481", "Murilo Ferreira"), - 186 => array("Woori Financial Group", "Financial services", "46.459", "Lee Pal Seung"), - 187 => array("Sonatrach", "Oil and gas", "46.420", "Djenane El Malik"), - 188 => array("GlaxoSmithKline", "Health care", "46.016", "Andrew Witty"), - 189 => array("Deutsche Bahn", "Transportation", "45.979", "Rüdiger Grube"), - 190 => array("Goldman Sachs", "Financial services", "45.976", "Lloyd Blankfein"), - 191 => array("Hon Hai Precision Industry", "Electronics", "45.899", "Terry Gou"), - 192 => array("Lockheed Martin", "Aerospace", "45.803", "Robert J. Stevens"), - 193 => array("Woolworths Limited", "Retailing", "45.170", "Michael Luscombe"), - 194 => array("Bouygues", "Conglomerate", "45.167", "Martin Bouygues"), - 195 => array("Bayer", "Health care", "44.901", "Marijn Dekkers"), - 196 => array("China Investment Corporation", "Sovereign wealth fund", "44.876", "Lou Jiwei"), - 197 => array("Imperial Tobacco", "Tobacco industry", "44.713", "Gareth Davis"), - 198 => array("Mitsui & Co.", "Sogo shosha", "44.048", "-"), - 199 => array("Sears Holdings", "Retailing", "44.043", "Louis D'Ambrosio"), - 200 => array("LG Electronics", "Conglomerate", "44.000", "Koo Bon-joon"), - 201 => array("Shinhan Financial Group", "Financial services", "43.975", "Sang Hoon Shin"), - 202 => array("Wesfarmers", "Retailing", "43.949", "Bob Every"), - 203 => array("Intel", "Semiconductors", "43.623", "Paul S. Otellini"), - 204 => array("Sumitomo Life Insurance", "Insurance", "43.272", "-"), - 205 => array("Caterpillar", "Heavy equipment", "42.588", "Douglas R. Oberhelman"), - 206 => array("Sanofi", "Health care", "42.218", "Chris Viehbacher"), - 207 => array("Chrysler", "Automotive", "41.946", "Sergio Marchionne"), - 208 => array("Bunge Limited", "Agriculture", "41.926", "Alberto Weisser"), - 209 => array("Sojitz", "Sogo shosha", "41.338", "Yutaka Kase"), - 210 => array("Safeway", "Retailing", "40.8507", "Steven Burd"), - 211 => array("SuperValu", "Retailing", "40.597", "Craig Herkert"), - 212 => array("UBS", "Financial services", "40.561", "Oswald Grübel"), - 213 => array("Kraft Foods", "Food", "40.386", "Irene Rosenfeld"), - 214 => array("Ahold", "Retailing", "40.229", "Dick Boer"), - 215 => array("Cisco", "Information technology", "40.04", "John T. Chambers"), - ); - } + /** + * Contains test data + * + * @return array + */ + public function data() + { + return array( + 0 => array("Walmart", "Retail", "421.849", "Michael Duke"), + 1 => array("ExxonMobil", "Oil and gas", "370.125", "Rex W. Tillerson"), + 2 => array("Royal Dutch Shell", "Oil and gas", "368.056", "Peter Voser"), + 3 => array("BP", "Oil and gas", "297.107", "Robert Dudley"), + 4 => array("Sinopec", "Oil and gas", "289.774", "Jiming Wang"), + 5 => array("State Grid Corporation of China", "Electricity", "231.556", "Liu Zhenya"), + 6 => array("Toyota Motors", "Automotive", "228.247", "Fujio Cho"), + 7 => array("PetroChina", "Oil and gas", "221.955", "Zhou Jiping"), + 8 => array("Total S.A.", "Oil and gas", "212.815", "Christophe de Margerie"), + 9 => array("Japan Post Holdings", "Conglomerate", "211.080", "Jiro Saito"), + 10 => array("Chevron", "Oil and gas", "204.928", "David J. O'Reilly"), + 11 => array("ConocoPhillips", "Oil and gas", "198.655", "James Mulva"), + 12 => array("Vitol", "Raw material", "195.0", "Ian Taylor"), + 13 => array("Saudi Aramco", "Oil and gas", "182.396", "Waleed Al-Bedaiwi"), + 14 => array("Volkswagen Group", "Automotive", "169.53", "Martin Winterkorn"), + 15 => array("Fannie Mae", "Financial services", "154.270", "Mike Williams"), + 16 => array("General Electric", "Conglomerate", "150.211", "Jeffrey Immelt"), + 17 => array("Glencore", "Raw materials", "144.978", "Ivan Glasenberg"), + 18 => array("Allianz", "Financial services", "142.24", "Michael Diekmann"), + 19 => array("ING Group", "Financial services", "140.729", "Jan Hommen"), + 20 => array("Berkshire Hathaway", "Conglomerate", "136.185", "Warren Buffett"), + 21 => array("Samsung Electronics", "Conglomerate", "135.772", "Lee Kun-hee"), + 22 => array("General Motors", "Automotive", "135.592", "Daniel Akerson"), + 23 => array("Eni", "Oil and gas", "131.292", "Paolo Scaroni"), + 24 => array("Daimler AG", "Automotive", "130.628", "Dieter Zetsche"), + 25 => array("Ford Motor Company", "Automotive", "128.954", "Alan Mulally"), + 26 => array("Hewlett-Packard", "Information technology", "127.245", "Meg Whitman"), + 27 => array("Nippon Telegraph and Telephone", "Telecommunications", "124.517", "Norio Wada"), + 28 => array("AT&T", "Telecommunications", "124.28", "Randall L. Stephenson"), + 29 => array("E.ON", "Electricity; gas", "124.084", "Johannes Teyssen"), + 30 => array("Carrefour", "Retailing", "122.280", "Lars Olofsson"), + 31 => array("AXA", "Financial services", "121.577", "Henri de Castries"), + 32 => array("Assicurazioni Generali", "Insurance", "121.299", "Sergio Balbinot, Giovanni Perissinotto"), + 33 => array("Petrobras", "Oil and gas", "120.052", "José Sérgio Gabrielli de Azevedo"), + 34 => array("Cargill", "Agriculture", "119.469", "Greg Page"), + 35 => array("JX Holdings", "Energy", "116.414", "-"), + 36 => array("GDF Suez", "Public utilities", "112.88", "Gérard Mestrallet"), + 37 => array("Hitachi, Ltd.", "Conglomerate", "112.239", "Etsuhiko Shoyama"), + 38 => array("McKesson Corporation", "Health care", "112.084", "John Hammergren"), + 39 => array("Gazprom", "Oil and Gas", "111.808", "Alexei Miller"), + 40 => array("Bank of America", "Banking", "111.39", "Brian Moynihan"), + 41 => array("Tesco", "Retailing", "110.85", "Philip Clarke"), + 42 => array("Federal Home Loan Mortgage Corporation", "Financial services", "109.956", "Richard F. Syron"), + 43 => array("Apple Inc.", "Electronics", "108.249", "Tim Cook"), + 44 => array("Honda", "Automotive", "107.985", "Takanobu Ito"), + 45 => array("Verizon", "Telecommunications", "106.565", "Ivan Seidenberg"), + 46 => array("Nissan Motors", "Automotive", "105.523", "Carlos Ghosn"), + 47 => array("Panasonic Corporation", "Electronics", "105.035", "Kunio Nakamura"), + 48 => array("Nestlé", "Food processing", "104.972", "Paul Bulcke"), + 49 => array("LUKoil", "Oil and Gas", "104.956", "Vagit Alekperov"), + 50 => array("Pemex", "Oil and gas", "103.538", "Juan José Suárez Coppel"), + 51 => array("JPMorgan Chase", "Financial Services", "102.694", "Jamie Dimon"), + 52 => array("Cardinal Health", "Health care", "102.644", "George Barrett"), + 53 => array("Koch Industries", "Conglomerate", "100.0", "Charles Koch"), + 54 => array("Petróleos de Venezuela", "Oil and gas", "94.929", "Rafael Ramírez"), + 55 => array("IBM", "Information technology", "99.87", "Virginia Rometty"), + 56 => array("Siemens AG", "Conglomerate", "98.870", "Peter Löscher"), + 57 => array("Hyundai Motors", "Automotive", "98.858", "Chung Mong-Koo"), + 58 => array("Enel", "Electricity generation", "97.782", "Fulvio Conti"), + 59 => array("CVS Caremark", "Retailing", "96.413", "Tom Ryan"), + 60 => array("Lloyds Banking Group", "Financial Services", "95.342", "António Horta-Osório"), + 61 => array("UnitedHealth Group", "Health care", "94.155", "Stephen Hemsley"), + 62 => array("Statoil", "Oil and gas", "90.733", "Helge Lund"), + 63 => array("Metro AG", "Retailing", "89.87", "Eckhard Cordes"), + 64 => array("Aviva", "Financial services", "89.890", "Andrew Moss"), + 65 => array("Electricité de France", "Electricity generation", "87.073", "Henri Proglio"), + 66 => array("Costco", "Retailing", "87.048", "Jim Sinegal"), + 67 => array("Citigroup", "Financial services", "86.601", "Vikram Pandit"), + 68 => array("Sony", "Electronics", "86.521", "Howard Stringer"), + 69 => array("BASF", "Chemical industry", "85.347", "Kurt Bock"), + 70 => array("Wells Fargo", "Banking / Financial services", "85.21", "John Stumpf"), + 71 => array("Société Générale", "Financial Services", "84.868", "Frédéric Oudéa"), + 72 => array("Kuwait Petroleum Corporation", "Oil and gas", "84.594", "Saad Al Shuwaib"), + 73 => array("Deutsche Telekom", "Telecommunications", "83.407", "René Obermann"), + 74 => array("Procter & Gamble", "Consumer goods", "82.559", "Robert A. \"Bob\" McDonald"), + 75 => array("Industrial and Commercial Bank of China", "Banking", "82.536", "Jiang Jianqing"), + 76 => array("Valero Energy", "Oil and gas", "82.233", "Bill Klesse"), + 77 => array("Kroger", "Retailing", "82.189", "David Dillon"), + 78 => array("Nippon Life Insurance", "Insurance", "81.315", "Kunie Okamoto"), + 79 => array("Telefónica", "Telecommunications", "80.938", "César Alierta"), + 80 => array("BMW", "Automotive", "80.809", "Norbert Reithofer"), + 81 => array("Repsol YPF", "Oil and Gas", "80.747", "Antonio Brufau"), + 82 => array("Archer Daniels Midland", "Agriculture, Food processing", "80.676", "Patricia A. Woertz"), + 83 => array("AmerisourceBergen", "Health care", "80.218", "R. David Yost"), + 84 => array("HSBC", "Financial services", "80.014", "Stuart Gulliver"), + 85 => array("SK Group", "Conglomerate", "79.603", "Choi Tae-Won"), + 86 => array("National Iranian Oil Company", "Oil and gas", "79.277", "Masoud Mir Kazemi"), + 87 => array("Trafigura", "Raw materials", "79.2", " ?"), + 88 => array("ArcelorMittal", "Steel", "78.025", "Lakshmi Mittal"), + 89 => array("American International Group", "Financial services", "77.301", "Robert Benmosche"), + 90 => array("Toshiba", "Conglomerate", "77.090", "Tadashi Okamura"), + 91 => array("Petronas", "Oil and gas", "76.822", "Tan Sri Dato Sri Mohd Hassan Marican"), + 92 => array("Indian Oil Corporation", "Oil and Gas", "75.632", "B.M.Bansal"), + 93 => array("Fiat", "Conglomerate", "75.172", "Sergio Marchionne"), + 94 => array("ZEN-NOH", "Agricultural marketing", "75.111", "Katsuyoshi Kitajima"), + 95 => array("PSA Peugeot Citroën", "Automotive", "74.909", "Philippe Varin"), + 96 => array("Vodafone", "Telecommunications", "73.635", "Vittorio Colao"), + 97 => array("Marathon Oil", "Oil and gas", "73.621", "Clarence Cazalot, Jr."), + 98 => array("China Mobile", "Telecommunications", "73.520", "Li Yue"), + 99 => array("Prudential plc", "Banking", "73.337", "Tidjane Thiam"), + 100 => array("Walgreens", "Retailing", "72.184", "Jeff Rein"), + 101 => array("Deutsche Post", "Courier", "71.751", "Frank Appel"), + 102 => array("BHP Billiton", "Mining", "71.739", "Marius Kloppers"), + 103 => array("RWE", "Public utilities", "71.246", "Jürgen Großmann"), + 104 => array("Aegon", "Insurance", "71.148", "Alex Wynaendts"), + 105 => array("REWE Group", "Retailing", "70.872", "Alain Caparros"), + 106 => array("Dexia", "Banking", "70.106", "Pierre Mariani"), + 107 => array("Microsoft", "Information technology", "69.943", "Steve Ballmer"), + 108 => array("China Railway Construction Corporation", "Infrastructure", "69.118", "Meng Fengchao"), + 109 => array("China Railway Engineering Corporation", "Infrastructure", "69.082", "Shi Dahua"), + 110 => array("Toyota Tsusho", "Sogo shosha", "69.076", "Masaaki Furukawa"), + 111 => array("China Construction Bank", "Banking", "68.777", "Guo Shuqing"), + 112 => array("Home Depot, Inc.", "Retailing", "67.997", "Frank Blake"), + 113 => array("Zurich Financial Services", "Insurance", "67.85", "Martin Senn"), + 114 => array("Pfizer", "Health care", "67.809", "Jeff Kindler"), + 115 => array("Philip Morris International", "Tobacco industry", "67.713", "Louis C. Camilleri"), + 116 => array("Groupe BPCE", "Banking", "67.303", "François Pérol"), + 117 => array("Target Corporation", "Retailing", "67.390", "Gregg Steinhafel"), + 118 => array("Temasek Holdings", "Sovereign Wealth Fund", "66.285", "Suppiah Dhanabalan"), + 119 => array("Medco Health Solutions", "Health care", "65.968", "David B. Snow, Jr."), + 120 => array("United States Postal Service", "Courier", "65.711", "John E. Potter"), + 121 => array("Gunvor", "Raw material", "65.0", "-"), + 122 => array("Crédit Agricole", "Financial Services", "64.800", "Jean-Paul Chifflet"), + 123 => array("Tokyo Electric Power", "Electricity generation", "64.964", "Tsunehisa Katsumata"), + 124 => array("Boeing", "Aerospace", "64.306", "Jim McNerney"), + 125 => array("Barclays Bank", "Banking", "63.978", "Bob Diamond"), + 126 => array("State Farm Insurance", "Insurance", "63.2", "Edward B. Rust Jr."), + 127 => array("Bosch Group", "Automotive", "63.147", "-"), + 128 => array("PTT Public Company Limited", "Oil and Gas", "62.998", "Prasert Bunsumpun"), + 129 => array("Royal Bank of Scotland", "Financial services", "62.770", "Stephen Hester"), + 130 => array("Mitsubishi Corporation", "Sogo shosha", "62.733", "Mikio Sasaki"), + 131 => array("Seven & I Holdings Co.", "Retailing", "62.436", "Toshifumi Suzuki"), + 132 => array("ÆON", "Retailing", "62.153", "-"), + 133 => array("Agricultural Bank of China", "Banking", "62.151", "Xiang Junbo"), + 134 => array("Johnson & Johnson", "Health care", "61.587", "William C. Weldon"), + 135 => array("Dell", "Information technology", "61.494", "Michael Dell"), + 136 => array("EADS", "Aerospace", "60.969", "Louis Gallois"), + 137 => array("Munich Re", "Financial services", "60.851", "Nikolaus von Bomhard"), + 138 => array("France Télécom", "Telecommunications", "60.801", "Stéphane Richard"), + 139 => array("Rio Tinto", "Mining", "60.323", "Tom Albanese"), + 140 => array("CNP Assurances", "Insurance", "59.846", "Gilles Benoist"), + 141 => array("Reliance Industries", "Conglomerate", "59.679", "Mukesh Ambani"), + 142 => array("Legal & General", "Financial services", "59.673", "Tim Breedon"), + 143 => array("Bank of China", "Banking", "59.668", "Xiao Gang"), + 144 => array("Unilever", "Consumer goods", "59.143", "Paul Polman"), + 145 => array("WellPoint", "Health care", "58.802", "Angela Braly"), + 146 => array("BNP Paribas", "Financial Services", "58.632", "Baudouin Prot"), + 147 => array("China Life Insurance", "Insurance", "58.460", "-"), + 148 => array("Edeka Group", "Retailing", "57.968", "-"), + 149 => array("PepsiCo", "Food", "57.838", "Indra Nooyi"), + 150 => array("Grupo Santander", "Banking", "57.388", "Emilio Botín"), + 151 => array("Auchan", "Retailing", "56.778", "Christophe Dubrulle"), + 152 => array("Noble Group", "Raw materials", "56.696", "Ricardo Leiman"), + 153 => array("China State Construction Engineering Corp", "Infrastructure", "56.104", "Sun Wenjie"), + 154 => array("Banco Bradesco", "Banking", "56.104", "Luiz Carlos Trabuco Cappi"), + 155 => array("A. P. Møller - Mærsk", "Transport", "56.090", "Nils Andersen"), + 156 => array("Dongfeng Motor", "Automotive", "55.864", "Xu Ping"), + 157 => array("China Southern Power Grid Company", "Electricity", "55.825", "Yuan Maozhen"), + 158 => array("Deutsche Bank", "Banking", "55.804", "Josef Ackermann"), + 159 => array("Shanghai Automotive Industry Corporation", "Automotive", "55.689", "Shen Jianhua"), + 160 => array("Fujitsu", "Electronics", "54.559", "Hiroaki Kurokawa"), + 161 => array("United Technologies", "Conglomerate", "54.326", "Louis R. Chênevert"), + 162 => array("Credit Suisse", "Financial services", "53.771", "Brady Dougan"), + 163 => array("China National Offshore Oil Corporation", "Oil and gas", "53.733", "Wang Yilin"), + 164 => array("Dow Chemical", "Manufacturing", "53.674", "Andrew N. Liveris"), + 165 => array("Saint-Gobain", "Construction", "53.607", "Pierre-André de Chalendar"), + 166 => array("UniCredit", "Banking", "53.332", "Federico Ghizzoni"), + 167 => array("Nokia", "Telecommunications", "53.322", "Stephen Elop"), + 168 => array("MetLife", "Insurance", "52.717", "C. Robert Henrikson"), + 169 => array("Renault", "Automotive", "52.073", "Carlos Ghosn"), + 170 => array("Mitsubishi UFJ Financial Group", "Banking", "51.479", "Nobuo Kuroyanagi"), + 171 => array("ThyssenKrupp", "Conglomerate", "50.717", "Heinrich Hiesinger"), + 172 => array("Sinochem Group", "Conglomerate", "50.632", "Liu Deschu"), + 173 => array("Hoffmann-La Roche", "Health care", "50.632", "Severin Schwan"), + 174 => array("Novartis", "Health care", "50.624", "Joseph Jimenez"), + 175 => array("Best Buy", "Retailing", "50.272", "Brian J. Dunn"), + 176 => array("United Parcel Service", "Transportation", "49.545", "Scott Davis"), + 177 => array("Pertamina", "Oil and gas", "48.717", "Karen Agustiawan"), + 178 => array("Dai-ichi Life", "Insurance", "47.855", "-"), + 179 => array("Banco Bilbao Vizcaya Argentaria", "Banking", "47.429", "Francisco González"), + 180 => array("Lowe's", "Retailing", "47.22", "Robert Niblock"), + 181 => array("Rosneft", "Oil and gas", "46.826", "-"), + 182 => array("National Mutual Insurance Federation of Agricultural Cooperatives (Zenkyoren or JA Kyosai)", "Insurance", "46.8", "-"), + 183 => array("VINCI", "Construction", "46.762", "Xavier Huillard"), + 184 => array("Veolia Environnement", "Public utilities", "46.482", "Antoine Frérot"), + 185 => array("Vale", "Mining", "46.481", "Murilo Ferreira"), + 186 => array("Woori Financial Group", "Financial services", "46.459", "Lee Pal Seung"), + 187 => array("Sonatrach", "Oil and gas", "46.420", "Djenane El Malik"), + 188 => array("GlaxoSmithKline", "Health care", "46.016", "Andrew Witty"), + 189 => array("Deutsche Bahn", "Transportation", "45.979", "Rüdiger Grube"), + 190 => array("Goldman Sachs", "Financial services", "45.976", "Lloyd Blankfein"), + 191 => array("Hon Hai Precision Industry", "Electronics", "45.899", "Terry Gou"), + 192 => array("Lockheed Martin", "Aerospace", "45.803", "Robert J. Stevens"), + 193 => array("Woolworths Limited", "Retailing", "45.170", "Michael Luscombe"), + 194 => array("Bouygues", "Conglomerate", "45.167", "Martin Bouygues"), + 195 => array("Bayer", "Health care", "44.901", "Marijn Dekkers"), + 196 => array("China Investment Corporation", "Sovereign wealth fund", "44.876", "Lou Jiwei"), + 197 => array("Imperial Tobacco", "Tobacco industry", "44.713", "Gareth Davis"), + 198 => array("Mitsui & Co.", "Sogo shosha", "44.048", "-"), + 199 => array("Sears Holdings", "Retailing", "44.043", "Louis D'Ambrosio"), + 200 => array("LG Electronics", "Conglomerate", "44.000", "Koo Bon-joon"), + 201 => array("Shinhan Financial Group", "Financial services", "43.975", "Sang Hoon Shin"), + 202 => array("Wesfarmers", "Retailing", "43.949", "Bob Every"), + 203 => array("Intel", "Semiconductors", "43.623", "Paul S. Otellini"), + 204 => array("Sumitomo Life Insurance", "Insurance", "43.272", "-"), + 205 => array("Caterpillar", "Heavy equipment", "42.588", "Douglas R. Oberhelman"), + 206 => array("Sanofi", "Health care", "42.218", "Chris Viehbacher"), + 207 => array("Chrysler", "Automotive", "41.946", "Sergio Marchionne"), + 208 => array("Bunge Limited", "Agriculture", "41.926", "Alberto Weisser"), + 209 => array("Sojitz", "Sogo shosha", "41.338", "Yutaka Kase"), + 210 => array("Safeway", "Retailing", "40.8507", "Steven Burd"), + 211 => array("SuperValu", "Retailing", "40.597", "Craig Herkert"), + 212 => array("UBS", "Financial services", "40.561", "Oswald Grübel"), + 213 => array("Kraft Foods", "Food", "40.386", "Irene Rosenfeld"), + 214 => array("Ahold", "Retailing", "40.229", "Dick Boer"), + 215 => array("Cisco", "Information technology", "40.04", "John T. Chambers"), + ); + } } diff --git a/code/Employee.php b/code/Employee.php index 04d1ee6..40e58ba 100644 --- a/code/Employee.php +++ b/code/Employee.php @@ -4,81 +4,88 @@ * Description of Employees * */ -class Employee extends DataObject { - - private static $db = array( - 'Name' => 'Varchar', - 'Biography' => 'HTMLText' - ); - - private static $has_one = array( - 'Company' => 'Company', - 'ProfileImage' => 'Image' - ); +class Employee extends DataObject +{ + + private static $db = array( + 'Name' => 'Varchar', + 'Biography' => 'HTMLText' + ); + + private static $has_one = array( + 'Company' => 'Company', + 'ProfileImage' => 'Image' + ); - private static $belongs_many_many = array( - 'PastCompanies' => 'Company' - ); + private static $belongs_many_many = array( + 'PastCompanies' => 'Company' + ); - function getCMSFields() { - $fields = parent::getCMSFields(); + public function getCMSFields() + { + $fields = parent::getCMSFields(); - if(method_exists('ManyManyList', 'getExtraFields')) { - $fields->addFieldToTab('Root.Main', - new NumericField('ManyMany[YearStart]', 'Year started (3.1, many-many only)') - ); - $fields->addFieldToTab('Root.Main', - new TextField('ManyMany[Role]', 'Role (3.1, many-many only)') - ); - } + if (method_exists('ManyManyList', 'getExtraFields')) { + $fields->addFieldToTab('Root.Main', + new NumericField('ManyMany[YearStart]', 'Year started (3.1, many-many only)') + ); + $fields->addFieldToTab('Root.Main', + new TextField('ManyMany[Role]', 'Role (3.1, many-many only)') + ); + } - // 3.1 only - if(method_exists('UploadField', 'setAllowedFileCategories')) { - $fields->dataFieldByName('ProfileImage')->setAllowedFileCategories('image'); - } - + // 3.1 only + if (method_exists('UploadField', 'setAllowedFileCategories')) { + $fields->dataFieldByName('ProfileImage')->setAllowedFileCategories('image'); + } + - return $fields; - } - - public function requireDefaultRecords() { - parent::requireDefaultRecords(); - $employeeSet = DataObject::get('Employee'); - foreach ($employeeSet as $employee) { - $employee->delete(); - } - - foreach($this->data() as $employeeName){ - $employee = new Employee(); - $employee->Name = $employeeName; - $employee->write(); - } - DB::alteration_message("Added default records to Employee table","created"); - } + return $fields; + } + + public function requireDefaultRecords() + { + parent::requireDefaultRecords(); + $employeeSet = DataObject::get('Employee'); + foreach ($employeeSet as $employee) { + $employee->delete(); + } + + foreach ($this->data() as $employeeName) { + $employee = new Employee(); + $employee->Name = $employeeName; + $employee->write(); + } + DB::alteration_message("Added default records to Employee table", "created"); + } - public function validate() { - $result = parent::validate(); - if(!$this->Name) $result->error('"Name" can\'t be blank'); - return $result; - } - - /** - * Contains test data - * - * @return array - */ - public function data() { - return array( - 'Hayley', 'Octavius', 'Walker', 'Gary','Elton','Janna','Ursa','Lars','Moses','Lareina', - 'Elmo','Cara','Shea','Duncan','Velma','Acton','Galena','Heidi','Troy','Elliott','Cara', - 'Whitney','Summer','Olga','Tatum','Zeph','Jared','Hilda','Quinlan','Chaim','Xenos', - 'Cara','Tatiana','Tyrone','Juliet','Chester','Hannah','Imani','Quinn','Ariel','Abel', - 'Aretha','Courtney ','Shellie','Garrett','Camilla','Simon','Mohammad','Kirby','Rae', - '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' - ); - } + public function validate() + { + $result = parent::validate(); + if (!$this->Name) { + $result->error('"Name" can\'t be blank'); + } + return $result; + } + + /** + * Contains test data + * + * @return array + */ + public function data() + { + return array( + 'Hayley', 'Octavius', 'Walker', 'Gary','Elton','Janna','Ursa','Lars','Moses','Lareina', + 'Elmo','Cara','Shea','Duncan','Velma','Acton','Galena','Heidi','Troy','Elliott','Cara', + 'Whitney','Summer','Olga','Tatum','Zeph','Jared','Hilda','Quinlan','Chaim','Xenos', + 'Cara','Tatiana','Tyrone','Juliet','Chester','Hannah','Imani','Quinn','Ariel','Abel', + 'Aretha','Courtney ','Shellie','Garrett','Camilla','Simon','Mohammad','Kirby','Rae', + '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' + ); + } } diff --git a/code/FTPageMakerTask.php b/code/FTPageMakerTask.php index e0ae805..5c663de 100644 --- a/code/FTPageMakerTask.php +++ b/code/FTPageMakerTask.php @@ -5,25 +5,30 @@ * * @todo Allow passing in counts */ -class FTPageMakerTask extends BuildTask { - +class FTPageMakerTask extends BuildTask +{ + - function run($request) { - echo "

Making pages

"; - // Creates 3^5 pages - $this->makePages(3,5); - } - - protected function makePages($count, $depth, $prefix = "", $parentID = 0) { - for($i=1;$i<=$count;$i++) { - $page = new Page(); - $page->ParentID = $parentID; - $page->Title = "Test page $prefix$i"; - $page->write(); - $page->publish('Stage', 'Live'); + public function run($request) + { + echo "

Making pages

"; + // Creates 3^5 pages + $this->makePages(3, 5); + } + + protected function makePages($count, $depth, $prefix = "", $parentID = 0) + { + for ($i=1;$i<=$count;$i++) { + $page = new Page(); + $page->ParentID = $parentID; + $page->Title = "Test page $prefix$i"; + $page->write(); + $page->publish('Stage', 'Live'); - echo "
  • Created '$page->Title'"; - if($depth > 1) $this->makePages($count, $depth-1, $prefix."$i.", $page->ID); - } - } -} \ No newline at end of file + echo "
  • Created '$page->Title'"; + if ($depth > 1) { + $this->makePages($count, $depth-1, $prefix."$i.", $page->ID); + } + } + } +} diff --git a/code/FileUploadRole.php b/code/FileUploadRole.php index a53a7c4..850772a 100644 --- a/code/FileUploadRole.php +++ b/code/FileUploadRole.php @@ -1,8 +1,8 @@ 'File', - 'AImage' => 'Image', - ); +class FileUploadRole extends DataExtension +{ + private static $has_one = array( + 'AFile' => 'File', + 'AImage' => 'Image', + ); } -?> diff --git a/code/FrameworkTestFileExtension.php b/code/FrameworkTestFileExtension.php index b4c4fbe..da3f68f 100644 --- a/code/FrameworkTestFileExtension.php +++ b/code/FrameworkTestFileExtension.php @@ -1,7 +1,8 @@ 'Company', - 'BasicFieldsTestPage' => 'BasicFieldsTestPage' - ); -} \ No newline at end of file +class FrameworkTestFileExtension extends DataExtension +{ + private static $has_one = array( + 'Company' => 'Company', + 'BasicFieldsTestPage' => 'BasicFieldsTestPage' + ); +} diff --git a/code/FrameworkTestRole.php b/code/FrameworkTestRole.php index 77c606d..ca6ab48 100644 --- a/code/FrameworkTestRole.php +++ b/code/FrameworkTestRole.php @@ -1,43 +1,46 @@ 'SiteTree', - ); - - function updateCMSFields(FieldList $fields) { - $fields->addFieldToTab( - 'Root.Main', - new TreeDropdownField("FavouritePageID", "Favourite page", "SiteTree") - ); - } - - function requireDefaultRecords() { - $hasTestMembers = DataObject::get('Member')->find('Email', 'hayley@test.com'); - if(!$hasTestMembers) { +class FrameworkTestRole extends DataExtension +{ + + private static $has_one = array( + 'FavouritePage' => 'SiteTree', + ); + + public function updateCMSFields(FieldList $fields) + { + $fields->addFieldToTab( + 'Root.Main', + new TreeDropdownField("FavouritePageID", "Favourite page", "SiteTree") + ); + } + + 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) { - $member = new Member(array( - 'FirstName' => $name, - 'FirstName' => 'Smith', - 'Email' => "{$name}@test.com", - )); - $member->write(); - } + DB::alteration_message("Added default records to Member table", "created"); + } + } - DB::alteration_message("Added default records to Member table","created"); - } - } - - /** - * Contains test data - * - * @return array - */ - 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' - ); - } + /** + * Contains test data + * + * @return array + */ + 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' + ); + } } diff --git a/code/FrameworkTestSiteTreeExtension.php b/code/FrameworkTestSiteTreeExtension.php index 16094bb..3c7e767 100644 --- a/code/FrameworkTestSiteTreeExtension.php +++ b/code/FrameworkTestSiteTreeExtension.php @@ -1,7 +1,7 @@ 'RelationFieldsTestPage'); - private static $belongs_many_many = array('RelationFieldsTestPages' => 'RelationFieldsTestPage'); - +class FrameworkTestSiteTreeExtension extends DataExtension +{ + + private static $has_one = array('RelationFieldsTestPage' => 'RelationFieldsTestPage'); + private static $belongs_many_many = array('RelationFieldsTestPages' => 'RelationFieldsTestPage'); } diff --git a/code/FrameworktestRegressSessionAdmin.php b/code/FrameworktestRegressSessionAdmin.php index e8719f7..866d3f6 100644 --- a/code/FrameworktestRegressSessionAdmin.php +++ b/code/FrameworktestRegressSessionAdmin.php @@ -4,85 +4,92 @@ * These configurations are assumed to be evaluated in mysite/_config.php, * with custom switches for the different options. */ -class FrameworktestRegressSessionAdmin extends Controller { - - protected $template = 'BlankPage'; - - function init() { - parent::init(); - - if(!Permission::check('ADMIN')) return Security::permissionFailure($this); - } - - function Link($action = null) { - return Controller::join_links('dev', 'regress', $action); - } - - function Form() { - $isRunning = (Session::get('db')); - - if($isRunning) { - $actions = new FieldList( - new FormAction('endsession', 'End Session') - ); - } else { - $actions = new FieldList( - new FormAction('startsession', 'Start Session') - ); - } - - $form = new Form( - $this, - 'Form', - new FieldList( - new HeaderField('Header1', ($isRunning) ? 'Session is already running' : 'Start new regress session'), - new LiteralField('Lit1', - '

    Use this form to set configuration prior to starting a regress.silverstripe.com test session (manual testing).

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

    Use this form to set configuration prior to starting a regress.silverstripe.com test session (manual testing).

    ' + ), + $dbField = new DropdownField( + 'db', + 'Database', + array( + 'mysql' => 'MySQL', + 'postgresql' => 'Postgres', + 'mssql' => 'MSSQL', + 'sqlite3' => 'SQLite3', + ), + Session::get('db') + ), + $chkField = new CheckboxField( + 'enabletranslatable', + 'Translatable?', + Session::get('enabletranslatable') + ) + ), + $actions + ); + $dbField->setHasEmptyDefault(false); + + if ($isRunning) { + foreach ($form->Fields() as $field) { + $form->Fields()->replaceField($field->Name(), + $field->performReadonlyTransformation() + ); + } + } + + return $form; + } - function startsession($data, $form) { - Session::set('enabletranslatable', (isset($data['enabletranslatable'])) ? $data['enabletranslatable'] : null); - Session::set('db', $data['db']); - - return $this->redirect('dev/build/?BackURL=admin'); - } - - function endsession() { - Session::set('enabletranslatable', null); - Session::set('db', null); - - return $this->redirectBack(); - } - -} \ No newline at end of file + public function startsession($data, $form) + { + Session::set('enabletranslatable', (isset($data['enabletranslatable'])) ? $data['enabletranslatable'] : null); + Session::set('db', $data['db']); + + return $this->redirect('dev/build/?BackURL=admin'); + } + + public function endsession() + { + Session::set('enabletranslatable', null); + Session::set('db', null); + + return $this->redirectBack(); + } +} diff --git a/code/GridFieldTestPage.php b/code/GridFieldTestPage.php index 2170322..b2be83d 100644 --- a/code/GridFieldTestPage.php +++ b/code/GridFieldTestPage.php @@ -1,75 +1,78 @@ "Company", - ); + private static $has_one = array( + "HasOneCompany" => "Company", + ); - private static $has_many = array( - "HasManyCompanies" => "Company", - ); + private static $has_many = array( + "HasManyCompanies" => "Company", + ); - private static $many_many = array( - "ManyManyCompanies" => "Company", - ); - - public function getCMSFields() { - $fields = parent::getCMSFields(); + private static $many_many = array( + "ManyManyCompanies" => "Company", + ); + + public function getCMSFields() + { + $fields = parent::getCMSFields(); - $grids = array(); + $grids = array(); - $config = new GridFieldConfig_RecordEditor(); - $grid = new GridField('Companies', 'Companies', new DataList('Company'),$config); - $fields->addFieldToTab('Root.NoRelation', $grid); - $grids[] = $grid; + $config = new GridFieldConfig_RecordEditor(); + $grid = new GridField('Companies', 'Companies', new DataList('Company'), $config); + $fields->addFieldToTab('Root.NoRelation', $grid); + $grids[] = $grid; - $config = new GridFieldConfig_RelationEditor(); - $grid = new GridField('HasManyCompanies', 'HasManyCompanies', $this->HasManyCompanies(),$config); - $fields->addFieldToTab('Root.HasMany', $grid); - $grids[] = $grid; + $config = new GridFieldConfig_RelationEditor(); + $grid = new GridField('HasManyCompanies', 'HasManyCompanies', $this->HasManyCompanies(), $config); + $fields->addFieldToTab('Root.HasMany', $grid); + $grids[] = $grid; - $config = new GridFieldConfig_RelationEditor(); - $grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', $this->ManyManyCompanies(),$config); - $fields->addFieldToTab('Root.ManyMany', $grid); - $grids[] = $grid; + $config = new GridFieldConfig_RelationEditor(); + $grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', $this->ManyManyCompanies(), $config); + $fields->addFieldToTab('Root.ManyMany', $grid); + $grids[] = $grid; - foreach($grids as $grid) { - $grid - ->setDescription('This is bold help text'); - // ->addExtraClass('cms-description-tooltip'); - } + foreach ($grids as $grid) { + $grid + ->setDescription('This is bold help text'); + // ->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( - 'Form', - ); - - /** - * - * @var string - */ - public $Title = "GridFieldTestPage"; - - public function init(){ - parent::init(); - Requirements::css('frameworktest/css/gridfieldtest.css','screen'); - } - - /** - * - * @return Form - */ - public function Form(){ - $config = new GridFieldConfig_RecordEditor(); - - $grid = new GridField('Companies', 'Companies', new DataList('Company'),$config); - return new Form($this,'Form',new FieldList($grid),new FieldList()); - } + private static $allowed_actions = array( + 'Form', + ); + + /** + * + * @var string + */ + public $Title = "GridFieldTestPage"; + + public function init() + { + parent::init(); + Requirements::css('frameworktest/css/gridfieldtest.css', 'screen'); + } + + /** + * + * @return Form + */ + public function Form() + { + $config = new GridFieldConfig_RecordEditor(); + + $grid = new GridField('Companies', 'Companies', new DataList('Company'), $config); + return new Form($this, 'Form', new FieldList($grid), new FieldList()); + } } diff --git a/code/Organisation.php b/code/Organisation.php index b497ab4..966663e 100644 --- a/code/Organisation.php +++ b/code/Organisation.php @@ -1,12 +1,10 @@ 'Text' - ); - + +class Organisation extends DataObject +{ + + // Used to test the Multiform module + private static $db = array( + 'OrganisationName' => 'Text' + ); } - -?> \ No newline at end of file diff --git a/code/RelationFieldsTestPage.php b/code/RelationFieldsTestPage.php index d50ac93..0a68927 100644 --- a/code/RelationFieldsTestPage.php +++ b/code/RelationFieldsTestPage.php @@ -1,56 +1,58 @@ "Company", - "HasOnePage" => "SiteTree", - "HasOnePageWithSearch" => "SiteTree", - ); - private static $has_many = array( - "HasManyCompanies" => "Company", - "HasManyPages" => "SiteTree", - ); - private static $many_many = array( - "ManyManyCompanies" => "Company", - "ManyManyPages" => "SiteTree", - ); +class RelationFieldsTestPage extends TestPage +{ + + private static $has_one = array( + "HasOneCompany" => "Company", + "HasOnePage" => "SiteTree", + "HasOnePageWithSearch" => "SiteTree", + ); + private static $has_many = array( + "HasManyCompanies" => "Company", + "HasManyPages" => "SiteTree", + ); + private static $many_many = array( + "ManyManyCompanies" => "Company", + "ManyManyPages" => "SiteTree", + ); - private static $defaults = array( - 'Title' => 'Relational Fields' - ); - - function getCMSFields() { - $fields = parent::getCMSFields(); + private static $defaults = array( + 'Title' => 'Relational Fields' + ); + + public function getCMSFields() + { + $fields = parent::getCMSFields(); - $allFields = array(); - - $checkboxFields = array( - new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()) - ); - $fields->addFieldsToTab("Root.CheckboxSet", $checkboxFields); - $allFields += $checkboxFields; + $allFields = array(); + + $checkboxFields = array( + new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()) + ); + $fields->addFieldsToTab("Root.CheckboxSet", $checkboxFields); + $allFields += $checkboxFields; - $treeFields = array( - TreeDropdownField::create('HasOnePageID', 'HasOnePage', 'SiteTree'), - TreeDropdownField::create('HasOnePageWithSearchID', 'HasOnePageWithSearch', 'SiteTree')->setShowSearch(true), - TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'), - TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true) - ); - $fields->addFieldsToTab('Root.Tree', $treeFields); - $allFields += $treeFields; + $treeFields = array( + TreeDropdownField::create('HasOnePageID', 'HasOnePage', 'SiteTree'), + TreeDropdownField::create('HasOnePageWithSearchID', 'HasOnePageWithSearch', 'SiteTree')->setShowSearch(true), + TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'), + TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true) + ); + $fields->addFieldsToTab('Root.Tree', $treeFields); + $allFields += $treeFields; - foreach($allFields as $field) { - $field - ->setDescription('This is bold help text') - ->addExtraClass('cms-help'); - // ->addExtraClass('cms-help cms-help-tooltip'); - } + foreach ($allFields as $field) { + $field + ->setDescription('This is bold help text') + ->addExtraClass('cms-help'); + // ->addExtraClass('cms-help cms-help-tooltip'); + } - return $fields; - } + return $fields; + } } -class RelationFieldsTestPage_Controller extends TestPage_Controller { - +class RelationFieldsTestPage_Controller extends TestPage_Controller +{ } diff --git a/code/TestCategory.php b/code/TestCategory.php index b3e57b0..0c0339d 100644 --- a/code/TestCategory.php +++ b/code/TestCategory.php @@ -3,34 +3,37 @@ /** * A data type that is related many-many to RelationFieldsTestPage, for testing purposes */ -class TestCategory extends DataObject { - private static $db = array( - "Title" => "Varchar", - ); - private static $belongs_many_many = array( - "RelationPages" => "RelationFieldsTestPage", - ); - - /** - * Returns a dropdown map of all objects of this class - */ - static function map() { - $categories = DataObject::get('TestCategory'); - if($categories) return $categories->map('ID', 'Title')->toArray(); - else return array(); - } - - 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(); - } - } - } +class TestCategory extends DataObject +{ + private static $db = array( + "Title" => "Varchar", + ); + private static $belongs_many_many = array( + "RelationPages" => "RelationFieldsTestPage", + ); + + /** + * Returns a dropdown map of all objects of this class + */ + public static function map() + { + $categories = DataObject::get('TestCategory'); + if ($categories) { + return $categories->map('ID', 'Title')->toArray(); + } else { + return array(); + } + } + 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(); + } + } + } } - -?> \ No newline at end of file diff --git a/code/TestFileUploadPage.php b/code/TestFileUploadPage.php index 525c2d9..bb3f1f8 100644 --- a/code/TestFileUploadPage.php +++ b/code/TestFileUploadPage.php @@ -1,34 +1,37 @@ allowedExtensions = array('jpg', 'gif', 'png'); - - $actions = new FieldList( - new FormAction('addMember', "Add a member with two Files uploaded") - ); - return new Form($this, "Form", $fields, $actions); - } - - function addMember($data, $form){ - $member = new Member(); - $form->saveInto($member); - $member->write(); - $this->redirectBack(); - } + private static $allowed_actions = array( + 'Form' + ); + + public function Form() + { + $fields = new FieldList( + new EmailField('Email', 'EmailField'), + new FileField('AFile', 'FileField'), + $aImage = new UploadField('AImage', 'SimpleImageField') + ); + + $aImage->allowedExtensions = array('jpg', 'gif', 'png'); + + $actions = new FieldList( + new FormAction('addMember', "Add a member with two Files uploaded") + ); + return new Form($this, "Form", $fields, $actions); + } + + public function addMember($data, $form) + { + $member = new Member(); + $form->saveInto($member); + $member->write(); + $this->redirectBack(); + } } diff --git a/code/TestModelAdmin.php b/code/TestModelAdmin.php index a432016..f85d1a4 100644 --- a/code/TestModelAdmin.php +++ b/code/TestModelAdmin.php @@ -1,14 +1,12 @@ \ No newline at end of file diff --git a/code/TestPage.php b/code/TestPage.php index 0251cf7..56e6914 100644 --- a/code/TestPage.php +++ b/code/TestPage.php @@ -3,106 +3,118 @@ /** * Parent class of all test pages */ -class TestPage extends Page { - - /** - * We can only create subclasses of TestPage - */ - function canCreate($member = null) { - // Don't allow creation other than through requireDefaultRecords - return false; - } +class TestPage extends Page +{ + + /** + * We can only create subclasses of TestPage + */ + public function canCreate($member = null) + { + // Don't allow creation other than through requireDefaultRecords + return false; + } - function requireDefaultRecords(){ - if($this->class == 'TestPage') return; + public function requireDefaultRecords() + { + if ($this->class == 'TestPage') { + return; + } - $class = $this->class; - if(!DataObject::get_one($class)) { - // Try to create common parent - $parent = SiteTree::get() - ->filter('URLSegment', 'feature-test-pages') - ->First(); - - if(!$parent) { - $parent = new Page(array( - 'Title' => 'Feature Test Pages', - 'Content' => 'A collection of pages for testing various features in the SilverStripe CMS', - 'ShowInMenus' => 0 - )); - $parent->write(); - $parent->doPublish(); - } + $class = $this->class; + if (!DataObject::get_one($class)) { + // Try to create common parent + $parent = SiteTree::get() + ->filter('URLSegment', 'feature-test-pages') + ->First(); + + if (!$parent) { + $parent = new Page(array( + 'Title' => 'Feature Test Pages', + 'Content' => 'A collection of pages for testing various features in the SilverStripe CMS', + 'ShowInMenus' => 0 + )); + $parent->write(); + $parent->doPublish(); + } - // Create actual page - $page = new $class(); - $page->Title = str_replace("TestPage","",$class); - $page->ShowInMenus = 0; - if($parent) $page->ParentID = $parent->ID; - $page->write(); - $page->publish('Stage', 'Live'); - } - } - + // Create actual page + $page = new $class(); + $page->Title = str_replace("TestPage", "", $class); + $page->ShowInMenus = 0; + if ($parent) { + $page->ParentID = $parent->ID; + } + $page->write(); + $page->publish('Stage', 'Live'); + } + } } /** * Parent class of all test page controllers */ -class TestPage_Controller extends Page_Controller { - private static $allowed_actions = array( - 'Form', - 'save', - ); - - /** - * 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(); - $actions = new FieldList( - new FormAction("save", "Save"), - $gohome = new FormAction("gohome", "Go home") - ); - $gohome->setAttribute('src', 'frameworktest/images/test-button.png'); - $form = new Form($this, "Form", $fields, $actions); - $form->loadDataFrom($this->dataRecord); - return $form; - } - - function save($data, $form) { - $form->saveInto($this->dataRecord); - $this->dataRecord->write(); - $this->redirectBack(); - } - - function gohome() { - $this->redirect("./"); - } +class TestPage_Controller extends Page_Controller +{ + private static $allowed_actions = array( + 'Form', + 'save', + ); + + /** + * This form is exactly like the CMS form. It gives us an opportunity to test the fields outside of the CMS context + */ + public function Form() + { + $fields = $this->getCMSFields(); + $actions = new FieldList( + new FormAction("save", "Save"), + $gohome = new FormAction("gohome", "Go home") + ); + $gohome->setAttribute('src', 'frameworktest/images/test-button.png'); + $form = new Form($this, "Form", $fields, $actions); + $form->loadDataFrom($this->dataRecord); + return $form; + } + + public function save($data, $form) + { + $form->saveInto($this->dataRecord); + $this->dataRecord->write(); + $this->redirectBack(); + } + + public function gohome() + { + $this->redirect("./"); + } - function EmailForm() { - return new Form($this, "EmailForm", new FieldList( - new TextField("Email", "Email address") - ), new FieldList( - new FormAction("sendEmail", "Send test email to this address") - )); - } - - function email() { - return array( - 'Content' => '

    Use this form to send a test email

    ', - 'Form' => $this->EmailForm() - ); - } - - function sendEmail($data, $form) { - $email = new Email(); - $email->setTo($data['Email']); - $email->setFrom($data['Email']); - $email->setSubject('A subject with some umlauts: öäüß'); - $email->setBody('A body with some umlauts: öäüß'); - $email->send(); - - echo "

    email sent to " . $data['Email'] . "

    "; - } + public function EmailForm() + { + return new Form($this, "EmailForm", new FieldList( + new TextField("Email", "Email address") + ), new FieldList( + new FormAction("sendEmail", "Send test email to this address") + )); + } + + public function email() + { + return array( + 'Content' => '

    Use this form to send a test email

    ', + 'Form' => $this->EmailForm() + ); + } + + public function sendEmail($data, $form) + { + $email = new Email(); + $email->setTo($data['Email']); + $email->setFrom($data['Email']); + $email->setSubject('A subject with some umlauts: öäüß'); + $email->setBody('A body with some umlauts: öäüß'); + $email->send(); + + echo "

    email sent to " . $data['Email'] . "

    "; + } } -?> diff --git a/code/multiform/Page2MultiForm.php b/code/multiform/Page2MultiForm.php index f97f809..45093ea 100644 --- a/code/multiform/Page2MultiForm.php +++ b/code/multiform/Page2MultiForm.php @@ -1,64 +1,68 @@ 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') { - $organisation = new Organisation(); - $data = $step->loadData(); - if($data) { - $organisation->update($data); - if($member && $member->ID) $organisation->MemberID = $member->ID; - $organisation->write(); - } - } +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(); + } + } - // Debug::show($step->loadData()); // Shows the step data (unserialized by loadData) - } - } - $controller = $this->getController(); - $controller->redirect($controller->Link() . 'finished'); - } + if ($step->class == 'Page2OrganisationDetailsFormStep') { + $organisation = new Organisation(); + $data = $step->loadData(); + if ($data) { + $organisation->update($data); + if ($member && $member->ID) { + $organisation->MemberID = $member->ID; + } + $organisation->write(); + } + } + + // Debug::show($step->loadData()); // Shows the step data (unserialized by loadData) + } + } + $controller = $this->getController(); + $controller->redirect($controller->Link() . 'finished'); + } } -class Page2PersonalDetailsFormStep extends MultiFormStep { - - public static $next_steps = 'Page2OrganisationDetailsFormStep'; - - function getFields() { - return new FieldList( - new TextField('FirstName', 'First name'), - new TextField('Surname', 'Surname') - ); - } - +class Page2PersonalDetailsFormStep extends MultiFormStep +{ + + public static $next_steps = 'Page2OrganisationDetailsFormStep'; + + public function getFields() + { + return new FieldList( + new TextField('FirstName', 'First name'), + new TextField('Surname', 'Surname') + ); + } } -class Page2OrganisationDetailsFormStep extends MultiFormStep { +class Page2OrganisationDetailsFormStep extends MultiFormStep +{ - public static $is_final_step = true; + public static $is_final_step = true; - function getFields() { - return new FieldList( - new TextField('OrganisationName', 'Organisation Name') - ); - } - + public function getFields() + { + return new FieldList( + new TextField('OrganisationName', 'Organisation Name') + ); + } } - -?> diff --git a/code/multiform/Page2MultiFormTestPage.php b/code/multiform/Page2MultiFormTestPage.php index 13a1403..1c752ae 100644 --- a/code/multiform/Page2MultiFormTestPage.php +++ b/code/multiform/Page2MultiFormTestPage.php @@ -1,22 +1,22 @@ 'Thank you for your submission', - 'Content' => '

    You have successfully submitted the form. Thanks!

    ' - ); - } +class Page2MultiFormTestPage_Controller extends Page_Controller +{ + + public function Page2MultiForm() + { + return new Page2MultiForm($this, 'Page2MultiForm'); + } + public function finished() + { + return array( + 'Title' => 'Thank you for your submission', + 'Content' => '

    You have successfully submitted the form. Thanks!

    ' + ); + } } - -?> diff --git a/code/multiform/Page3MultiForm.php b/code/multiform/Page3MultiForm.php index 29896e5..892e926 100644 --- a/code/multiform/Page3MultiForm.php +++ b/code/multiform/Page3MultiForm.php @@ -1,85 +1,87 @@ 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') { - $organisation = new Organisation(); - $data = $step->loadData(); - if($data) { - $organisation->update($data); - if($member && $member->ID) $organisation->MemberID = $member->ID; - $organisation->write(); - } - } +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(); + } + } - // Debug::show($step->loadData()); // Shows the step data (unserialized by loadData) - } - } - $controller = $this->getController(); - $controller->redirect($controller->Link() . 'finished'); - } - - + if ($step->class == 'Page3OrganisationDetailsFormStep') { + $organisation = new Organisation(); + $data = $step->loadData(); + if ($data) { + $organisation->update($data); + if ($member && $member->ID) { + $organisation->MemberID = $member->ID; + } + $organisation->write(); + } + } + + // Debug::show($step->loadData()); // Shows the step data (unserialized by loadData) + } + } + $controller = $this->getController(); + $controller->redirect($controller->Link() . 'finished'); + } } -class Page3StartFormStep extends MultiFormStep { - - public static $next_steps = 'Page3PersonalDetailsFormStep'; - - function getFields() { - return new FieldList( - new LiteralField('Details', 'This is important
    +class Page3StartFormStep extends MultiFormStep +{ + + public static $next_steps = 'Page3PersonalDetailsFormStep'; + + public function getFields() + { + return new FieldList( + new LiteralField('Details', 'This is important

    You will receiving email once you participate in this survey.
    Under the new Unsolicited Electronic Messages Act 2007, we must have your consent to send emails relating to this form.
    If you do not wish to receive these emails please use the unsubscribe checkbox at bottom of this form.
    If you still wish to receive these emails, you do not have to do anything.


    For more information visit http://www.silverstripe.com/

    '), - new CheckboxField('Unsubscribe', 'Tick that you confirm the above details.') - ); - } - + new CheckboxField('Unsubscribe', 'Tick that you confirm the above details.') + ); + } } -class Page3PersonalDetailsFormStep extends MultiFormStep { - - public static $next_steps = 'Page3OrganisationDetailsFormStep'; - - function getFields() { - return new FieldList( - new TextField('FirstName', 'First name'), - new TextField('Surname', 'Surname') - ); - } - - +class Page3PersonalDetailsFormStep extends MultiFormStep +{ + + public static $next_steps = 'Page3OrganisationDetailsFormStep'; + + public function getFields() + { + return new FieldList( + new TextField('FirstName', 'First name'), + new TextField('Surname', 'Surname') + ); + } } -class Page3OrganisationDetailsFormStep extends MultiFormStep { +class Page3OrganisationDetailsFormStep extends MultiFormStep +{ - public static $is_final_step = true; + public static $is_final_step = true; - function getFields() { - return new FieldList( - new TextField('OrganisationName', 'Organisation Name') - ); - } - + public function getFields() + { + return new FieldList( + new TextField('OrganisationName', 'Organisation Name') + ); + } } - -?> diff --git a/code/multiform/Page3MultiFormTestPage.php b/code/multiform/Page3MultiFormTestPage.php index 03c6761..b8ef35c 100644 --- a/code/multiform/Page3MultiFormTestPage.php +++ b/code/multiform/Page3MultiFormTestPage.php @@ -1,22 +1,22 @@ 'Thank you for your submission', - 'Content' => '

    You have successfully submitted the form. Thanks!

    ' - ); - } +class Page3MultiFormTestPage_Controller extends Page_Controller +{ + + public function Page3MultiForm() + { + return new Page3MultiForm($this, 'Page3MultiForm'); + } + public function finished() + { + return array( + 'Title' => 'Thank you for your submission', + 'Content' => '

    You have successfully submitted the form. Thanks!

    ' + ); + } } - -?> \ No newline at end of file diff --git a/code/multiform/TestMultiForm.php b/code/multiform/TestMultiForm.php index ad6c459..3886d14 100644 --- a/code/multiform/TestMultiForm.php +++ b/code/multiform/TestMultiForm.php @@ -1,77 +1,84 @@ getSavedSteps(); - - $savedData = array(); - foreach($savedSteps as $step) { - $savedData = array_merge($savedData, $step->loadData()); - } - - $fields = new FieldList(); - $fields->push(new LiteralField("Heading", "

    You have submitted the following information:

    ")); - - foreach($savedData as $key=>$value) { - $fields->push(new LiteralField($key . '_copy', "

    $key $value

    ")); - } - - Session::set("MultiFormMessage", "Your information has been submitted."); - - $this->Controller()->redirect(Director::BaseURL() . $this->Controller()->URLSegment); - } +class TestMultiForm extends MultiForm +{ + public static $start_step = 'TestMultiFormStepOne'; + + public function finish($data, $form) + { + parent::finish($data, $form); + + $savedSteps = $this->getSavedSteps(); + + $savedData = array(); + foreach ($savedSteps as $step) { + $savedData = array_merge($savedData, $step->loadData()); + } + + $fields = new FieldList(); + $fields->push(new LiteralField("Heading", "

    You have submitted the following information:

    ")); + + foreach ($savedData as $key=>$value) { + $fields->push(new LiteralField($key . '_copy', "

    $key $value

    ")); + } + + Session::set("MultiFormMessage", "Your information has been submitted."); + + $this->Controller()->redirect(Director::BaseURL() . $this->Controller()->URLSegment); + } } -class TestMultiFormStepOne extends MultiFormStep { - public static $next_steps = 'TestMultiFormStepTwo'; - - function getFields() { - return new FieldList( - new TextField('FirstName', 'First name'), - new TextField('Surname', 'Surname') - ); - } - +class TestMultiFormStepOne extends MultiFormStep +{ + public static $next_steps = 'TestMultiFormStepTwo'; + + public function getFields() + { + return new FieldList( + new TextField('FirstName', 'First name'), + new TextField('Surname', 'Surname') + ); + } } -class TestMultiFormStepTwo extends MultiFormStep { - public static $next_steps = 'TestMultiFormStepThree'; - - function getFields() { - - return new FieldList( - new TextField('Email', 'Email'), - new TextField('Address', 'Address') - ); - } +class TestMultiFormStepTwo extends MultiFormStep +{ + public static $next_steps = 'TestMultiFormStepThree'; + + public function getFields() + { + return new FieldList( + new TextField('Email', 'Email'), + new TextField('Address', 'Address') + ); + } } -class TestMultiFormStepThree extends MultiFormStep { - public static $is_final_step = true; - - function getFields() { - $form = $this->getForm(); - $savedSteps = $form->getSavedSteps(); - - $savedData = array(); - foreach($savedSteps as $step) { - $savedData = array_merge($savedData, $step->loadData()); - } - - $fields = new FieldList(); - $fields->push(new LiteralField("Heading", "

    You have submitted the following information:

    ")); - - foreach($savedData as $key=>$value) { - if(preg_match("/_copy$/", $key)) continue; - - $fields->push(new LiteralField($key . '_copy', "

    $key $value

    ")); - } - - return $fields; - } +class TestMultiFormStepThree extends MultiFormStep +{ + public static $is_final_step = true; + + public function getFields() + { + $form = $this->getForm(); + $savedSteps = $form->getSavedSteps(); + + $savedData = array(); + foreach ($savedSteps as $step) { + $savedData = array_merge($savedData, $step->loadData()); + } + + $fields = new FieldList(); + $fields->push(new LiteralField("Heading", "

    You have submitted the following information:

    ")); + + foreach ($savedData as $key=>$value) { + if (preg_match("/_copy$/", $key)) { + continue; + } + + $fields->push(new LiteralField($key . '_copy', "

    $key $value

    ")); + } + + return $fields; + } } - diff --git a/code/multiform/TestMultiFormPage.php b/code/multiform/TestMultiFormPage.php index ef425f3..aea3d08 100644 --- a/code/multiform/TestMultiFormPage.php +++ b/code/multiform/TestMultiFormPage.php @@ -1,24 +1,27 @@ push(new RecaptchaField('MyRecaptcha')); - } else { - $fields->push(new LiteralField('

    RecaptchaField class not found

    ')); - } - - $form = new Form( - $this, - 'Form', - $fields, - new FieldList( - new FormAction('submit', 'submit') - ), - new RequiredFields(array('MyText')) - ); - - return $form; - } - - function submit($data, $form) { - $form->sessionMessage('Hooray!', 'good'); - - return Director::redirectBack(); - } - -} \ No newline at end of file +class RecaptchaTestPage_Controller extends Page_Controller +{ + + public function Form() + { + $fields = new FieldList( + new TextField('MyText') + ); + if (class_exists('RecaptchaField')) { + $fields->push(new RecaptchaField('MyRecaptcha')); + } else { + $fields->push(new LiteralField('

    RecaptchaField class not found

    ')); + } + + $form = new Form( + $this, + 'Form', + $fields, + new FieldList( + new FormAction('submit', 'submit') + ), + new RequiredFields(array('MyText')) + ); + + return $form; + } + + public function submit($data, $form) + { + $form->sessionMessage('Hooray!', 'good'); + + return Director::redirectBack(); + } +} diff --git a/code/sifr/SifrPage.php b/code/sifr/SifrPage.php index 4e23cbb..601d446 100644 --- a/code/sifr/SifrPage.php +++ b/code/sifr/SifrPage.php @@ -1,24 +1,27 @@ addFieldToTab("Root.Content.SifrSampleImage", new LiteralField("SifrSampleImage", '

    ')); - - return $fields; - } - +class SifrPage extends Page +{ + + public function getCMSFields() + { + $fields = parent::getCMSFields(); + $fields->addFieldToTab("Root.Content.SifrSampleImage", new LiteralField("SifrSampleImage", '

    ')); + + return $fields; + } } -class SifrPage_Controller extends Page_Controller { - - function init() { - parent::init(); - - Sifr::add_font('blackout', 'themes/fonts/blackout.swf'); - Sifr::replace_element('blackout', 'h2', "'.sIFR-root { text-align: left; color: red;'"); - Sifr::replace_element('blackout', 'h3', "'.sIFR-root { text-align: left; color: red;'"); - Sifr::replace_element('blackout', 'h4', "'.sIFR-root { text-align: left; color: red;'"); - Sifr::activate_sifr(); - } -} \ No newline at end of file +class SifrPage_Controller extends Page_Controller +{ + + public function init() + { + parent::init(); + + Sifr::add_font('blackout', 'themes/fonts/blackout.swf'); + Sifr::replace_element('blackout', 'h2', "'.sIFR-root { text-align: left; color: red;'"); + Sifr::replace_element('blackout', 'h3', "'.sIFR-root { text-align: left; color: red;'"); + Sifr::replace_element('blackout', 'h4', "'.sIFR-root { text-align: left; color: red;'"); + Sifr::activate_sifr(); + } +} diff --git a/code/tagfield/TestTag.php b/code/tagfield/TestTag.php index c77d423..d8c8038 100644 --- a/code/tagfield/TestTag.php +++ b/code/tagfield/TestTag.php @@ -1,14 +1,14 @@ 'Text' // ); - + // private static $belongs_many_many = array( // 'Pages' => 'TestTagFieldPage' // ); - + // function requireDefaultRecords(){ // $class = $this->class; // if(!DataObject::get_one($class)) { @@ -17,7 +17,7 @@ // $tag->Title = $title; // $tag->write(); // } - + // } // } -// } \ No newline at end of file +// } diff --git a/code/tagfield/TestTagFieldPage.php b/code/tagfield/TestTagFieldPage.php index bfa8f08..b01f1e7 100644 --- a/code/tagfield/TestTagFieldPage.php +++ b/code/tagfield/TestTagFieldPage.php @@ -1,31 +1,31 @@ 'Text', // 'FixedTags' => 'Text' // ); - + // private static $many_many = array( // 'TestTags' => 'TestTag', // ); - + // function getCMSFields() { // $fields = parent::getCMSFields(); - + // $tf1 = new TagField('TestTagString', "Single column tags (try 'one', 'two', 'three', 'four')", null, 'TestTagFieldPage'); // $fields->addFieldToTab('Root.Main', $tf1); - + // $tf2 = new TagField('TestTags', "Relation tags (try 'one', 'two', 'three', 'four')"); // $fields->addFieldToTab('Root.Main', $tf2); - + // $tf3 = new TagField('FixedTags', "Fixed tags (try 'PHP', 'Ruby', 'Python')", null, 'TestTag'); // $tf3->setCustomTags(array('PHP', 'Ruby', 'Python')); // $fields->addFieldToTab('Root.Main', $tf3); - + // return $fields; // } - + // function requireDefaultRecords(){ // $class = $this->class; // if(!DataObject::get_one($class)) { @@ -34,7 +34,7 @@ // $page->write(); // } // } - + // } -// class TestTagFieldPage_Controller extends Page_Controller {} \ No newline at end of file +// class TestTagFieldPage_Controller extends Page_Controller {}