mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
Merge pull request #13 from helpfulrobot/convert-to-psr-2
Converted to PSR-2
This commit is contained in:
commit
13ea394f64
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class BasicFieldsTestPage extends TestPage {
|
class BasicFieldsTestPage extends TestPage
|
||||||
|
{
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'Required' => 'Text',
|
'Required' => 'Text',
|
||||||
'Validated' => 'Text',
|
'Validated' => 'Text',
|
||||||
@ -58,19 +59,23 @@ class BasicFieldsTestPage extends TestPage {
|
|||||||
'Validated' => 2
|
'Validated' => 2
|
||||||
);
|
);
|
||||||
|
|
||||||
function requireDefaultRecords() {
|
public function requireDefaultRecords()
|
||||||
|
{
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
|
|
||||||
if($inst = DataObject::get_one('BasicFieldsTestPage')) {
|
if ($inst = DataObject::get_one('BasicFieldsTestPage')) {
|
||||||
$data = $this->getDefaultData();
|
$data = $this->getDefaultData();
|
||||||
$inst->update($data);
|
$inst->update($data);
|
||||||
$inst->write();
|
$inst->write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultData() {
|
public function getDefaultData()
|
||||||
|
{
|
||||||
$cats = TestCategory::get();
|
$cats = TestCategory::get();
|
||||||
if(!$cats->Count()) return array(); // not initialized yet
|
if (!$cats->Count()) {
|
||||||
|
return array();
|
||||||
|
} // not initialized yet
|
||||||
|
|
||||||
$firstCat = $cats->offsetGet(0);
|
$firstCat = $cats->offsetGet(0);
|
||||||
$thirdCat = $cats->offsetGet(2);
|
$thirdCat = $cats->offsetGet(2);
|
||||||
@ -108,7 +113,8 @@ class BasicFieldsTestPage extends TestPage {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCMSFields() {
|
public function getCMSFields()
|
||||||
|
{
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$description = 'This is <strong>bold</strong> help text';
|
$description = 'This is <strong>bold</strong> help text';
|
||||||
@ -157,11 +163,11 @@ class BasicFieldsTestPage extends TestPage {
|
|||||||
|
|
||||||
// All these date/time fields generally have issues saving directly in the CMS
|
// All these date/time fields generally have issues saving directly in the CMS
|
||||||
$fields->addFieldsToTab('Root.DateTime', array(
|
$fields->addFieldsToTab('Root.DateTime', array(
|
||||||
$calendarDateField = Object::create('DateField', 'CalendarDate','DateField with calendar'),
|
$calendarDateField = Object::create('DateField', 'CalendarDate', 'DateField with calendar'),
|
||||||
Object::create('DateField', 'Date','DateField'),
|
Object::create('DateField', 'Date', 'DateField'),
|
||||||
$dmyDateField = Object::create('DateField', 'DMYDate','DateField with separate fields'),
|
$dmyDateField = Object::create('DateField', 'DMYDate', 'DateField with separate fields'),
|
||||||
Object::create('TimeField', 'Time','TimeField'),
|
Object::create('TimeField', 'Time', 'TimeField'),
|
||||||
$timeFieldDropdown = Object::create('TimeField', 'TimeWithDropdown','TimeField with dropdown'),
|
$timeFieldDropdown = Object::create('TimeField', 'TimeWithDropdown', 'TimeField with dropdown'),
|
||||||
Object::create('DatetimeField', 'DateTime', 'DateTime'),
|
Object::create('DatetimeField', 'DateTime', 'DateTime'),
|
||||||
$dateTimeShowCalendar = Object::create('DatetimeField', 'DateTimeWithCalendar', 'DateTime with calendar')
|
$dateTimeShowCalendar = Object::create('DatetimeField', 'DateTimeWithCalendar', 'DateTime with calendar')
|
||||||
));
|
));
|
||||||
@ -172,25 +178,25 @@ class BasicFieldsTestPage extends TestPage {
|
|||||||
$dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true);
|
$dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true);
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.File', array(
|
$fields->addFieldsToTab('Root.File', array(
|
||||||
$bla = UploadField::create('File','FileUploadField')
|
$bla = UploadField::create('File', 'FileUploadField')
|
||||||
->setDescription($description)
|
->setDescription($description)
|
||||||
->setConfig('allowedMaxFileNumber', 1)
|
->setConfig('allowedMaxFileNumber', 1)
|
||||||
->setConfig('canPreviewFolder', false),
|
->setConfig('canPreviewFolder', false),
|
||||||
UploadField::create('AttachedFile','UploadField with canUpload=false')
|
UploadField::create('AttachedFile', 'UploadField with canUpload=false')
|
||||||
->setDescription($description)
|
->setDescription($description)
|
||||||
->setConfig('canUpload', false),
|
->setConfig('canUpload', false),
|
||||||
UploadField::create('Image','UploadField for image')
|
UploadField::create('Image', 'UploadField for image')
|
||||||
->setDescription($description),
|
->setDescription($description),
|
||||||
UploadField::create('HasManyFiles','UploadField for has_many')
|
UploadField::create('HasManyFiles', 'UploadField for has_many')
|
||||||
->setDescription($description),
|
->setDescription($description),
|
||||||
UploadField::create('ManyManyFiles','UploadField for many_many')
|
UploadField::create('ManyManyFiles', 'UploadField for many_many')
|
||||||
->setDescription($description)
|
->setDescription($description)
|
||||||
));
|
));
|
||||||
|
|
||||||
$data = $this->getDefaultData();
|
$data = $this->getDefaultData();
|
||||||
foreach($fields->dataFields() as $field) {
|
foreach ($fields->dataFields() as $field) {
|
||||||
$name = $field->getName();
|
$name = $field->getName();
|
||||||
if(isset($data[$name])) {
|
if (isset($data[$name])) {
|
||||||
$field->setValue($data[$name]);
|
$field->setValue($data[$name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,14 +206,16 @@ class BasicFieldsTestPage extends TestPage {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$tabs = array('Root.Text', 'Root.Numeric', 'Root.Option', 'Root.DateTime', 'Root.File');
|
$tabs = array('Root.Text', 'Root.Numeric', 'Root.Option', 'Root.DateTime', 'Root.File');
|
||||||
foreach($tabs as $tab) {
|
foreach ($tabs as $tab) {
|
||||||
$tabObj = $fields->fieldByName($tab);
|
$tabObj = $fields->fieldByName($tab);
|
||||||
foreach($tabObj->FieldList() as $field) {
|
foreach ($tabObj->FieldList() as $field) {
|
||||||
$field
|
$field
|
||||||
->setDescription($description);
|
->setDescription($description);
|
||||||
// ->addExtraClass('cms-description-tooltip');
|
// ->addExtraClass('cms-description-tooltip');
|
||||||
|
|
||||||
if(in_array($field->getName(), $blacklist)) continue;
|
if (in_array($field->getName(), $blacklist)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$disabledField = $field->performDisabledTransformation();
|
$disabledField = $field->performDisabledTransformation();
|
||||||
$disabledField->setTitle($disabledField->Title() . ' (disabled)');
|
$disabledField->setTitle($disabledField->Title() . ' (disabled)');
|
||||||
@ -244,24 +252,27 @@ class BasicFieldsTestPage extends TestPage {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCMSValidator() {
|
public function getCMSValidator()
|
||||||
|
{
|
||||||
return new RequiredFields('Required');
|
return new RequiredFields('Required');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate() {
|
public function validate()
|
||||||
|
{
|
||||||
$result = parent::validate();
|
$result = parent::validate();
|
||||||
if(!$this->Validated || $this->Validated < 1 || $this->Validated > 3) {
|
if (!$this->Validated || $this->Validated < 1 || $this->Validated > 3) {
|
||||||
$result->error('"Validated" field needs to be between 1 and 3');
|
$result->error('"Validated" field needs to be between 1 and 3');
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BasicFieldsTestPage_Controller extends TestPage_Controller {
|
class BasicFieldsTestPage_Controller extends TestPage_Controller
|
||||||
function AutoCompleteItems() {
|
{
|
||||||
|
public function AutoCompleteItems()
|
||||||
|
{
|
||||||
$items = array(
|
$items = array(
|
||||||
'TestItem1',
|
'TestItem1',
|
||||||
'TestItem2',
|
'TestItem2',
|
||||||
@ -271,5 +282,3 @@ class BasicFieldsTestPage_Controller extends TestPage_Controller {
|
|||||||
return implode(',', $items);
|
return implode(',', $items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Company extends DataObject {
|
class Company extends DataObject
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -55,39 +56,42 @@ class Company extends DataObject {
|
|||||||
'CEO',
|
'CEO',
|
||||||
);
|
);
|
||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields()
|
||||||
|
{
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
$fields->addFieldToTab('Root.Main',
|
$fields->addFieldToTab('Root.Main',
|
||||||
$uploadField = UploadField::create('GroupPhotos')
|
$uploadField = UploadField::create('GroupPhotos')
|
||||||
);
|
);
|
||||||
if(method_exists('UploadField', 'setAllowedFileCategories')) {
|
if (method_exists('UploadField', 'setAllowedFileCategories')) {
|
||||||
$uploadField->setAllowedFileCategories('image');
|
$uploadField->setAllowedFileCategories('image');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
function validate() {
|
public function validate()
|
||||||
if(!$this->Title) {
|
{
|
||||||
|
if (!$this->Title) {
|
||||||
return new ValidationResult(false, 'Title is required');
|
return new ValidationResult(false, 'Title is required');
|
||||||
} else {
|
} else {
|
||||||
return parent::validate();
|
return parent::validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DynamicProperty() {
|
public function DynamicProperty()
|
||||||
|
{
|
||||||
return sprintf('%s (%s)', $this->Name, $this->CEO);
|
return sprintf('%s (%s)', $this->Name, $this->CEO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function requireDefaultRecords() {
|
public function requireDefaultRecords()
|
||||||
|
{
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
$companySet = DataObject::get('Company');
|
$companySet = DataObject::get('Company');
|
||||||
foreach ($companySet as $company) {
|
foreach ($companySet as $company) {
|
||||||
$company->delete();
|
$company->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->data() as $companyData){
|
foreach ($this->data() as $companyData) {
|
||||||
$company = new Company();
|
$company = new Company();
|
||||||
$company->Name = $companyData[0];
|
$company->Name = $companyData[0];
|
||||||
$company->Category = $companyData[1];
|
$company->Category = $companyData[1];
|
||||||
@ -95,7 +99,7 @@ class Company extends DataObject {
|
|||||||
$company->CEO = $companyData[3];
|
$company->CEO = $companyData[3];
|
||||||
$company->write();
|
$company->write();
|
||||||
}
|
}
|
||||||
DB::alteration_message("Added default records to Company table","created");
|
DB::alteration_message("Added default records to Company table", "created");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,7 +107,8 @@ class Company extends DataObject {
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function data() {
|
public function data()
|
||||||
|
{
|
||||||
return array(
|
return array(
|
||||||
0 => array("Walmart", "Retail", "421.849", "Michael Duke"),
|
0 => array("Walmart", "Retail", "421.849", "Michael Duke"),
|
||||||
1 => array("ExxonMobil", "Oil and gas", "370.125", "Rex W. Tillerson"),
|
1 => array("ExxonMobil", "Oil and gas", "370.125", "Rex W. Tillerson"),
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
* Description of Employees
|
* Description of Employees
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Employee extends DataObject {
|
class Employee extends DataObject
|
||||||
|
{
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'Name' => 'Varchar',
|
'Name' => 'Varchar',
|
||||||
@ -20,10 +21,11 @@ class Employee extends DataObject {
|
|||||||
'PastCompanies' => 'Company'
|
'PastCompanies' => 'Company'
|
||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
public function getCMSFields()
|
||||||
|
{
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
if(method_exists('ManyManyList', 'getExtraFields')) {
|
if (method_exists('ManyManyList', 'getExtraFields')) {
|
||||||
$fields->addFieldToTab('Root.Main',
|
$fields->addFieldToTab('Root.Main',
|
||||||
new NumericField('ManyMany[YearStart]', 'Year started (3.1, many-many only)')
|
new NumericField('ManyMany[YearStart]', 'Year started (3.1, many-many only)')
|
||||||
);
|
);
|
||||||
@ -33,7 +35,7 @@ class Employee extends DataObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3.1 only
|
// 3.1 only
|
||||||
if(method_exists('UploadField', 'setAllowedFileCategories')) {
|
if (method_exists('UploadField', 'setAllowedFileCategories')) {
|
||||||
$fields->dataFieldByName('ProfileImage')->setAllowedFileCategories('image');
|
$fields->dataFieldByName('ProfileImage')->setAllowedFileCategories('image');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,24 +43,28 @@ class Employee extends DataObject {
|
|||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function requireDefaultRecords() {
|
public function requireDefaultRecords()
|
||||||
|
{
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
$employeeSet = DataObject::get('Employee');
|
$employeeSet = DataObject::get('Employee');
|
||||||
foreach ($employeeSet as $employee) {
|
foreach ($employeeSet as $employee) {
|
||||||
$employee->delete();
|
$employee->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->data() as $employeeName){
|
foreach ($this->data() as $employeeName) {
|
||||||
$employee = new Employee();
|
$employee = new Employee();
|
||||||
$employee->Name = $employeeName;
|
$employee->Name = $employeeName;
|
||||||
$employee->write();
|
$employee->write();
|
||||||
}
|
}
|
||||||
DB::alteration_message("Added default records to Employee table","created");
|
DB::alteration_message("Added default records to Employee table", "created");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate() {
|
public function validate()
|
||||||
|
{
|
||||||
$result = parent::validate();
|
$result = parent::validate();
|
||||||
if(!$this->Name) $result->error('"Name" can\'t be blank');
|
if (!$this->Name) {
|
||||||
|
$result->error('"Name" can\'t be blank');
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +73,8 @@ class Employee extends DataObject {
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function data() {
|
public function data()
|
||||||
|
{
|
||||||
return array(
|
return array(
|
||||||
'Hayley', 'Octavius', 'Walker', 'Gary','Elton','Janna','Ursa','Lars','Moses','Lareina',
|
'Hayley', 'Octavius', 'Walker', 'Gary','Elton','Janna','Ursa','Lars','Moses','Lareina',
|
||||||
'Elmo','Cara','Shea','Duncan','Velma','Acton','Galena','Heidi','Troy','Elliott','Cara',
|
'Elmo','Cara','Shea','Duncan','Velma','Acton','Galena','Heidi','Troy','Elliott','Cara',
|
||||||
|
@ -5,17 +5,20 @@
|
|||||||
*
|
*
|
||||||
* @todo Allow passing in counts
|
* @todo Allow passing in counts
|
||||||
*/
|
*/
|
||||||
class FTPageMakerTask extends BuildTask {
|
class FTPageMakerTask extends BuildTask
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
function run($request) {
|
public function run($request)
|
||||||
|
{
|
||||||
echo "<h1>Making pages</h1>";
|
echo "<h1>Making pages</h1>";
|
||||||
// Creates 3^5 pages
|
// Creates 3^5 pages
|
||||||
$this->makePages(3,5);
|
$this->makePages(3, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function makePages($count, $depth, $prefix = "", $parentID = 0) {
|
protected function makePages($count, $depth, $prefix = "", $parentID = 0)
|
||||||
for($i=1;$i<=$count;$i++) {
|
{
|
||||||
|
for ($i=1;$i<=$count;$i++) {
|
||||||
$page = new Page();
|
$page = new Page();
|
||||||
$page->ParentID = $parentID;
|
$page->ParentID = $parentID;
|
||||||
$page->Title = "Test page $prefix$i";
|
$page->Title = "Test page $prefix$i";
|
||||||
@ -23,7 +26,9 @@ class FTPageMakerTask extends BuildTask {
|
|||||||
$page->publish('Stage', 'Live');
|
$page->publish('Stage', 'Live');
|
||||||
|
|
||||||
echo "<li>Created '$page->Title'";
|
echo "<li>Created '$page->Title'";
|
||||||
if($depth > 1) $this->makePages($count, $depth-1, $prefix."$i.", $page->ID);
|
if ($depth > 1) {
|
||||||
|
$this->makePages($count, $depth-1, $prefix."$i.", $page->ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
class FileUploadRole extends DataExtension{
|
class FileUploadRole extends DataExtension
|
||||||
|
{
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'AFile' => 'File',
|
'AFile' => 'File',
|
||||||
'AImage' => 'Image',
|
'AImage' => 'Image',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
class FrameworkTestFileExtension extends DataExtension {
|
class FrameworkTestFileExtension extends DataExtension
|
||||||
|
{
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Company' => 'Company',
|
'Company' => 'Company',
|
||||||
'BasicFieldsTestPage' => 'BasicFieldsTestPage'
|
'BasicFieldsTestPage' => 'BasicFieldsTestPage'
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class FrameworkTestRole extends DataExtension {
|
class FrameworkTestRole extends DataExtension
|
||||||
|
{
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'FavouritePage' => 'SiteTree',
|
'FavouritePage' => 'SiteTree',
|
||||||
);
|
);
|
||||||
|
|
||||||
function updateCMSFields(FieldList $fields) {
|
public function updateCMSFields(FieldList $fields)
|
||||||
|
{
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
'Root.Main',
|
'Root.Main',
|
||||||
new TreeDropdownField("FavouritePageID", "Favourite page", "SiteTree")
|
new TreeDropdownField("FavouritePageID", "Favourite page", "SiteTree")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function requireDefaultRecords() {
|
public function requireDefaultRecords()
|
||||||
|
{
|
||||||
$hasTestMembers = DataObject::get('Member')->find('Email', 'hayley@test.com');
|
$hasTestMembers = DataObject::get('Member')->find('Email', 'hayley@test.com');
|
||||||
if(!$hasTestMembers) {
|
if (!$hasTestMembers) {
|
||||||
|
foreach ($this->data() as $name) {
|
||||||
foreach($this->data() as $name) {
|
|
||||||
$member = new Member(array(
|
$member = new Member(array(
|
||||||
'FirstName' => $name,
|
'FirstName' => $name,
|
||||||
'FirstName' => 'Smith',
|
'FirstName' => 'Smith',
|
||||||
@ -26,7 +28,7 @@ class FrameworkTestRole extends DataExtension {
|
|||||||
$member->write();
|
$member->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::alteration_message("Added default records to Member table","created");
|
DB::alteration_message("Added default records to Member table", "created");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +37,8 @@ class FrameworkTestRole extends DataExtension {
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function data() {
|
public function data()
|
||||||
|
{
|
||||||
return array(
|
return array(
|
||||||
'Hayley', 'Octavius', 'Walker', 'Gary', 'Elton', 'Janna', 'Ursa', 'Lars', 'Moses', 'Lareina', 'Elmo', 'Shea', 'Duncan', 'Velma', 'Acton', 'Galena', 'Heidi', 'Troy', 'Elliott', 'Whitney', 'Summer', 'Olga', 'Tatum', 'Zeph', 'Jared', 'Hilda', 'Quinlan', 'Chaim', 'Xenos', 'Cara', 'Tatiana', 'Tyrone', 'Juliet', 'Chester', 'Hannah', 'Imani', 'Quinn', 'Ariel', 'Aretha', 'Courtney ', 'Shellie', 'Garrett', 'Camilla', 'Simon', 'Mohammad', 'Kirby', 'Rae', 'Xena', 'Noel', 'Omar', 'Shannon', 'Iola', 'Maia', 'Serina', 'Taylor', 'Alice', 'Lucy', 'Austin', 'Abel', 'Yetta', 'Ulysses', 'Donovan', 'Castor', 'Emmanuel', 'Nero', 'Virginia', 'Gregory', 'Neville', 'Len', 'Knox', 'Gavin', 'Pascale', 'Hyatt', 'Alden', 'Emerald', 'Cherokee', 'Adam', 'Uma', 'Serena', 'Isabelle', 'Kieran', 'Gay', 'Lavinia', 'Elvis', 'Illana', 'Lee', 'Ariana', 'Hilel', 'Gage', 'Larissa', 'Richard', 'Allen'
|
'Hayley', 'Octavius', 'Walker', 'Gary', 'Elton', 'Janna', 'Ursa', 'Lars', 'Moses', 'Lareina', 'Elmo', 'Shea', 'Duncan', 'Velma', 'Acton', 'Galena', 'Heidi', 'Troy', 'Elliott', 'Whitney', 'Summer', 'Olga', 'Tatum', 'Zeph', 'Jared', 'Hilda', 'Quinlan', 'Chaim', 'Xenos', 'Cara', 'Tatiana', 'Tyrone', 'Juliet', 'Chester', 'Hannah', 'Imani', 'Quinn', 'Ariel', 'Aretha', 'Courtney ', 'Shellie', 'Garrett', 'Camilla', 'Simon', 'Mohammad', 'Kirby', 'Rae', 'Xena', 'Noel', 'Omar', 'Shannon', 'Iola', 'Maia', 'Serina', 'Taylor', 'Alice', 'Lucy', 'Austin', 'Abel', 'Yetta', 'Ulysses', 'Donovan', 'Castor', 'Emmanuel', 'Nero', 'Virginia', 'Gregory', 'Neville', 'Len', 'Knox', 'Gavin', 'Pascale', 'Hyatt', 'Alden', 'Emerald', 'Cherokee', 'Adam', 'Uma', 'Serena', 'Isabelle', 'Kieran', 'Gay', 'Lavinia', 'Elvis', 'Illana', 'Lee', 'Ariana', 'Hilel', 'Gage', 'Larissa', 'Richard', 'Allen'
|
||||||
);
|
);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
class FrameworkTestSiteTreeExtension extends DataExtension {
|
class FrameworkTestSiteTreeExtension extends DataExtension
|
||||||
|
{
|
||||||
|
|
||||||
private static $has_one = array('RelationFieldsTestPage' => 'RelationFieldsTestPage');
|
private static $has_one = array('RelationFieldsTestPage' => 'RelationFieldsTestPage');
|
||||||
private static $belongs_many_many = array('RelationFieldsTestPages' => 'RelationFieldsTestPage');
|
private static $belongs_many_many = array('RelationFieldsTestPages' => 'RelationFieldsTestPage');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,24 +4,30 @@
|
|||||||
* These configurations are assumed to be evaluated in mysite/_config.php,
|
* These configurations are assumed to be evaluated in mysite/_config.php,
|
||||||
* with custom switches for the different options.
|
* with custom switches for the different options.
|
||||||
*/
|
*/
|
||||||
class FrameworktestRegressSessionAdmin extends Controller {
|
class FrameworktestRegressSessionAdmin extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
protected $template = 'BlankPage';
|
protected $template = 'BlankPage';
|
||||||
|
|
||||||
function init() {
|
public function init()
|
||||||
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
if(!Permission::check('ADMIN')) return Security::permissionFailure($this);
|
if (!Permission::check('ADMIN')) {
|
||||||
|
return Security::permissionFailure($this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Link($action = null) {
|
public function Link($action = null)
|
||||||
|
{
|
||||||
return Controller::join_links('dev', 'regress', $action);
|
return Controller::join_links('dev', 'regress', $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Form() {
|
public function Form()
|
||||||
|
{
|
||||||
$isRunning = (Session::get('db'));
|
$isRunning = (Session::get('db'));
|
||||||
|
|
||||||
if($isRunning) {
|
if ($isRunning) {
|
||||||
$actions = new FieldList(
|
$actions = new FieldList(
|
||||||
new FormAction('endsession', 'End Session')
|
new FormAction('endsession', 'End Session')
|
||||||
);
|
);
|
||||||
@ -60,8 +66,8 @@ class FrameworktestRegressSessionAdmin extends Controller {
|
|||||||
);
|
);
|
||||||
$dbField->setHasEmptyDefault(false);
|
$dbField->setHasEmptyDefault(false);
|
||||||
|
|
||||||
if($isRunning) {
|
if ($isRunning) {
|
||||||
foreach($form->Fields() as $field) {
|
foreach ($form->Fields() as $field) {
|
||||||
$form->Fields()->replaceField($field->Name(),
|
$form->Fields()->replaceField($field->Name(),
|
||||||
$field->performReadonlyTransformation()
|
$field->performReadonlyTransformation()
|
||||||
);
|
);
|
||||||
@ -71,18 +77,19 @@ class FrameworktestRegressSessionAdmin extends Controller {
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
function startsession($data, $form) {
|
public function startsession($data, $form)
|
||||||
|
{
|
||||||
Session::set('enabletranslatable', (isset($data['enabletranslatable'])) ? $data['enabletranslatable'] : null);
|
Session::set('enabletranslatable', (isset($data['enabletranslatable'])) ? $data['enabletranslatable'] : null);
|
||||||
Session::set('db', $data['db']);
|
Session::set('db', $data['db']);
|
||||||
|
|
||||||
return $this->redirect('dev/build/?BackURL=admin');
|
return $this->redirect('dev/build/?BackURL=admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
function endsession() {
|
public function endsession()
|
||||||
|
{
|
||||||
Session::set('enabletranslatable', null);
|
Session::set('enabletranslatable', null);
|
||||||
Session::set('db', null);
|
Session::set('db', null);
|
||||||
|
|
||||||
return $this->redirectBack();
|
return $this->redirectBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
class GridFieldTestPage extends TestPage {
|
class GridFieldTestPage extends TestPage
|
||||||
|
{
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
"HasOneCompany" => "Company",
|
"HasOneCompany" => "Company",
|
||||||
@ -13,27 +14,28 @@ class GridFieldTestPage extends TestPage {
|
|||||||
"ManyManyCompanies" => "Company",
|
"ManyManyCompanies" => "Company",
|
||||||
);
|
);
|
||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields()
|
||||||
|
{
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$grids = array();
|
$grids = array();
|
||||||
|
|
||||||
$config = new GridFieldConfig_RecordEditor();
|
$config = new GridFieldConfig_RecordEditor();
|
||||||
$grid = new GridField('Companies', 'Companies', new DataList('Company'),$config);
|
$grid = new GridField('Companies', 'Companies', new DataList('Company'), $config);
|
||||||
$fields->addFieldToTab('Root.NoRelation', $grid);
|
$fields->addFieldToTab('Root.NoRelation', $grid);
|
||||||
$grids[] = $grid;
|
$grids[] = $grid;
|
||||||
|
|
||||||
$config = new GridFieldConfig_RelationEditor();
|
$config = new GridFieldConfig_RelationEditor();
|
||||||
$grid = new GridField('HasManyCompanies', 'HasManyCompanies', $this->HasManyCompanies(),$config);
|
$grid = new GridField('HasManyCompanies', 'HasManyCompanies', $this->HasManyCompanies(), $config);
|
||||||
$fields->addFieldToTab('Root.HasMany', $grid);
|
$fields->addFieldToTab('Root.HasMany', $grid);
|
||||||
$grids[] = $grid;
|
$grids[] = $grid;
|
||||||
|
|
||||||
$config = new GridFieldConfig_RelationEditor();
|
$config = new GridFieldConfig_RelationEditor();
|
||||||
$grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', $this->ManyManyCompanies(),$config);
|
$grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', $this->ManyManyCompanies(), $config);
|
||||||
$fields->addFieldToTab('Root.ManyMany', $grid);
|
$fields->addFieldToTab('Root.ManyMany', $grid);
|
||||||
$grids[] = $grid;
|
$grids[] = $grid;
|
||||||
|
|
||||||
foreach($grids as $grid) {
|
foreach ($grids as $grid) {
|
||||||
$grid
|
$grid
|
||||||
->setDescription('This is <strong>bold</strong> help text');
|
->setDescription('This is <strong>bold</strong> help text');
|
||||||
// ->addExtraClass('cms-description-tooltip');
|
// ->addExtraClass('cms-description-tooltip');
|
||||||
@ -41,11 +43,10 @@ class GridFieldTestPage extends TestPage {
|
|||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class GridFieldTestPage_Controller extends Page_Controller {
|
class GridFieldTestPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'Form',
|
'Form',
|
||||||
@ -57,19 +58,21 @@ class GridFieldTestPage_Controller extends Page_Controller {
|
|||||||
*/
|
*/
|
||||||
public $Title = "GridFieldTestPage";
|
public $Title = "GridFieldTestPage";
|
||||||
|
|
||||||
public function init(){
|
public function init()
|
||||||
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
Requirements::css('frameworktest/css/gridfieldtest.css','screen');
|
Requirements::css('frameworktest/css/gridfieldtest.css', 'screen');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
public function Form(){
|
public function Form()
|
||||||
|
{
|
||||||
$config = new GridFieldConfig_RecordEditor();
|
$config = new GridFieldConfig_RecordEditor();
|
||||||
|
|
||||||
$grid = new GridField('Companies', 'Companies', new DataList('Company'),$config);
|
$grid = new GridField('Companies', 'Companies', new DataList('Company'), $config);
|
||||||
return new Form($this,'Form',new FieldList($grid),new FieldList());
|
return new Form($this, 'Form', new FieldList($grid), new FieldList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Organisation extends DataObject {
|
class Organisation extends DataObject
|
||||||
|
{
|
||||||
|
|
||||||
// Used to test the Multiform module
|
// Used to test the Multiform module
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'OrganisationName' => 'Text'
|
'OrganisationName' => 'Text'
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class RelationFieldsTestPage extends TestPage {
|
class RelationFieldsTestPage extends TestPage
|
||||||
|
{
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
"HasOneCompany" => "Company",
|
"HasOneCompany" => "Company",
|
||||||
@ -20,7 +21,8 @@ class RelationFieldsTestPage extends TestPage {
|
|||||||
'Title' => 'Relational Fields'
|
'Title' => 'Relational Fields'
|
||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
public function getCMSFields()
|
||||||
|
{
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$allFields = array();
|
$allFields = array();
|
||||||
@ -40,7 +42,7 @@ class RelationFieldsTestPage extends TestPage {
|
|||||||
$fields->addFieldsToTab('Root.Tree', $treeFields);
|
$fields->addFieldsToTab('Root.Tree', $treeFields);
|
||||||
$allFields += $treeFields;
|
$allFields += $treeFields;
|
||||||
|
|
||||||
foreach($allFields as $field) {
|
foreach ($allFields as $field) {
|
||||||
$field
|
$field
|
||||||
->setDescription('This is <strong>bold</strong> help text')
|
->setDescription('This is <strong>bold</strong> help text')
|
||||||
->addExtraClass('cms-help');
|
->addExtraClass('cms-help');
|
||||||
@ -51,6 +53,6 @@ class RelationFieldsTestPage extends TestPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RelationFieldsTestPage_Controller extends TestPage_Controller {
|
class RelationFieldsTestPage_Controller extends TestPage_Controller
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
/**
|
/**
|
||||||
* A data type that is related many-many to RelationFieldsTestPage, for testing purposes
|
* A data type that is related many-many to RelationFieldsTestPage, for testing purposes
|
||||||
*/
|
*/
|
||||||
class TestCategory extends DataObject {
|
class TestCategory extends DataObject
|
||||||
|
{
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
"Title" => "Varchar",
|
"Title" => "Varchar",
|
||||||
);
|
);
|
||||||
@ -14,23 +15,25 @@ class TestCategory extends DataObject {
|
|||||||
/**
|
/**
|
||||||
* Returns a dropdown map of all objects of this class
|
* Returns a dropdown map of all objects of this class
|
||||||
*/
|
*/
|
||||||
static function map() {
|
public static function map()
|
||||||
|
{
|
||||||
$categories = DataObject::get('TestCategory');
|
$categories = DataObject::get('TestCategory');
|
||||||
if($categories) return $categories->map('ID', 'Title')->toArray();
|
if ($categories) {
|
||||||
else return array();
|
return $categories->map('ID', 'Title')->toArray();
|
||||||
|
} else {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function requireDefaultRecords(){
|
public function requireDefaultRecords()
|
||||||
|
{
|
||||||
$class = $this->class;
|
$class = $this->class;
|
||||||
if(!DataObject::get_one($class)) {
|
if (!DataObject::get_one($class)) {
|
||||||
foreach(array("A","B","C","D") as $item) {
|
foreach (array("A", "B", "C", "D") as $item) {
|
||||||
$page = new $class();
|
$page = new $class();
|
||||||
$page->Title = "Test Category $item";
|
$page->Title = "Test Category $item";
|
||||||
$page->write();
|
$page->write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -1,20 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class TestFileUploadPage extends TestPage{
|
class TestFileUploadPage extends TestPage
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestFileUploadPage_Controller extends TestPage_Controller{
|
class TestFileUploadPage_Controller extends TestPage_Controller
|
||||||
|
{
|
||||||
|
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'Form'
|
'Form'
|
||||||
);
|
);
|
||||||
|
|
||||||
function Form(){
|
public function Form()
|
||||||
|
{
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
new EmailField('Email', 'EmailField'),
|
new EmailField('Email', 'EmailField'),
|
||||||
new FileField('AFile','FileField'),
|
new FileField('AFile', 'FileField'),
|
||||||
$aImage = new UploadField('AImage','SimpleImageField')
|
$aImage = new UploadField('AImage', 'SimpleImageField')
|
||||||
);
|
);
|
||||||
|
|
||||||
$aImage->allowedExtensions = array('jpg', 'gif', 'png');
|
$aImage->allowedExtensions = array('jpg', 'gif', 'png');
|
||||||
@ -25,7 +27,8 @@ class TestFileUploadPage_Controller extends TestPage_Controller{
|
|||||||
return new Form($this, "Form", $fields, $actions);
|
return new Form($this, "Form", $fields, $actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMember($data, $form){
|
public function addMember($data, $form)
|
||||||
|
{
|
||||||
$member = new Member();
|
$member = new Member();
|
||||||
$form->saveInto($member);
|
$form->saveInto($member);
|
||||||
$member->write();
|
$member->write();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class TestModelAdmin extends ModelAdmin {
|
class TestModelAdmin extends ModelAdmin
|
||||||
|
{
|
||||||
private static $url_segment = 'test';
|
private static $url_segment = 'test';
|
||||||
private static $menu_title = 'Test ModelAdmin';
|
private static $menu_title = 'Test ModelAdmin';
|
||||||
|
|
||||||
@ -8,7 +9,4 @@ class TestModelAdmin extends ModelAdmin {
|
|||||||
"Company",
|
"Company",
|
||||||
"Employee",
|
"Employee",
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -3,27 +3,32 @@
|
|||||||
/**
|
/**
|
||||||
* Parent class of all test pages
|
* Parent class of all test pages
|
||||||
*/
|
*/
|
||||||
class TestPage extends Page {
|
class TestPage extends Page
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We can only create subclasses of TestPage
|
* We can only create subclasses of TestPage
|
||||||
*/
|
*/
|
||||||
function canCreate($member = null) {
|
public function canCreate($member = null)
|
||||||
|
{
|
||||||
// Don't allow creation other than through requireDefaultRecords
|
// Don't allow creation other than through requireDefaultRecords
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function requireDefaultRecords(){
|
public function requireDefaultRecords()
|
||||||
if($this->class == 'TestPage') return;
|
{
|
||||||
|
if ($this->class == 'TestPage') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$class = $this->class;
|
$class = $this->class;
|
||||||
if(!DataObject::get_one($class)) {
|
if (!DataObject::get_one($class)) {
|
||||||
// Try to create common parent
|
// Try to create common parent
|
||||||
$parent = SiteTree::get()
|
$parent = SiteTree::get()
|
||||||
->filter('URLSegment', 'feature-test-pages')
|
->filter('URLSegment', 'feature-test-pages')
|
||||||
->First();
|
->First();
|
||||||
|
|
||||||
if(!$parent) {
|
if (!$parent) {
|
||||||
$parent = new Page(array(
|
$parent = new Page(array(
|
||||||
'Title' => 'Feature Test Pages',
|
'Title' => 'Feature Test Pages',
|
||||||
'Content' => 'A collection of pages for testing various features in the SilverStripe CMS',
|
'Content' => 'A collection of pages for testing various features in the SilverStripe CMS',
|
||||||
@ -35,20 +40,22 @@ class TestPage extends Page {
|
|||||||
|
|
||||||
// Create actual page
|
// Create actual page
|
||||||
$page = new $class();
|
$page = new $class();
|
||||||
$page->Title = str_replace("TestPage","",$class);
|
$page->Title = str_replace("TestPage", "", $class);
|
||||||
$page->ShowInMenus = 0;
|
$page->ShowInMenus = 0;
|
||||||
if($parent) $page->ParentID = $parent->ID;
|
if ($parent) {
|
||||||
|
$page->ParentID = $parent->ID;
|
||||||
|
}
|
||||||
$page->write();
|
$page->write();
|
||||||
$page->publish('Stage', 'Live');
|
$page->publish('Stage', 'Live');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent class of all test page controllers
|
* Parent class of all test page controllers
|
||||||
*/
|
*/
|
||||||
class TestPage_Controller extends Page_Controller {
|
class TestPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'Form',
|
'Form',
|
||||||
'save',
|
'save',
|
||||||
@ -57,7 +64,8 @@ class TestPage_Controller extends Page_Controller {
|
|||||||
/**
|
/**
|
||||||
* This form is exactly like the CMS form. It gives us an opportunity to test the fields outside of the CMS context
|
* This form is exactly like the CMS form. It gives us an opportunity to test the fields outside of the CMS context
|
||||||
*/
|
*/
|
||||||
function Form() {
|
public function Form()
|
||||||
|
{
|
||||||
$fields = $this->getCMSFields();
|
$fields = $this->getCMSFields();
|
||||||
$actions = new FieldList(
|
$actions = new FieldList(
|
||||||
new FormAction("save", "Save"),
|
new FormAction("save", "Save"),
|
||||||
@ -69,17 +77,20 @@ class TestPage_Controller extends Page_Controller {
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save($data, $form) {
|
public function save($data, $form)
|
||||||
|
{
|
||||||
$form->saveInto($this->dataRecord);
|
$form->saveInto($this->dataRecord);
|
||||||
$this->dataRecord->write();
|
$this->dataRecord->write();
|
||||||
$this->redirectBack();
|
$this->redirectBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
function gohome() {
|
public function gohome()
|
||||||
|
{
|
||||||
$this->redirect("./");
|
$this->redirect("./");
|
||||||
}
|
}
|
||||||
|
|
||||||
function EmailForm() {
|
public function EmailForm()
|
||||||
|
{
|
||||||
return new Form($this, "EmailForm", new FieldList(
|
return new Form($this, "EmailForm", new FieldList(
|
||||||
new TextField("Email", "Email address")
|
new TextField("Email", "Email address")
|
||||||
), new FieldList(
|
), new FieldList(
|
||||||
@ -87,14 +98,16 @@ class TestPage_Controller extends Page_Controller {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function email() {
|
public function email()
|
||||||
|
{
|
||||||
return array(
|
return array(
|
||||||
'Content' => '<p>Use this form to send a test email</p>',
|
'Content' => '<p>Use this form to send a test email</p>',
|
||||||
'Form' => $this->EmailForm()
|
'Form' => $this->EmailForm()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendEmail($data, $form) {
|
public function sendEmail($data, $form)
|
||||||
|
{
|
||||||
$email = new Email();
|
$email = new Email();
|
||||||
$email->setTo($data['Email']);
|
$email->setTo($data['Email']);
|
||||||
$email->setFrom($data['Email']);
|
$email->setFrom($data['Email']);
|
||||||
@ -105,4 +118,3 @@ class TestPage_Controller extends Page_Controller {
|
|||||||
echo "<p>email sent to " . $data['Email'] . "</p>";
|
echo "<p>email sent to " . $data['Email'] . "</p>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
@ -1,29 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Page2MultiForm extends MultiForm {
|
class Page2MultiForm extends MultiForm
|
||||||
|
{
|
||||||
|
|
||||||
public static $start_step = 'Page2PersonalDetailsFormStep';
|
public static $start_step = 'Page2PersonalDetailsFormStep';
|
||||||
|
|
||||||
public function finish($data, $form) {
|
public function finish($data, $form)
|
||||||
|
{
|
||||||
parent::finish($data, $form);
|
parent::finish($data, $form);
|
||||||
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
|
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
|
||||||
if($steps) {
|
if ($steps) {
|
||||||
foreach($steps as $step) {
|
foreach ($steps as $step) {
|
||||||
if($step->class == 'Page2PersonalDetailsFormStep') {
|
if ($step->class == 'Page2PersonalDetailsFormStep') {
|
||||||
$member = new Member();
|
$member = new Member();
|
||||||
$data = $step->loadData();
|
$data = $step->loadData();
|
||||||
if($data) {
|
if ($data) {
|
||||||
$member->update($data);
|
$member->update($data);
|
||||||
$member->write();
|
$member->write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($step->class == 'Page2OrganisationDetailsFormStep') {
|
if ($step->class == 'Page2OrganisationDetailsFormStep') {
|
||||||
$organisation = new Organisation();
|
$organisation = new Organisation();
|
||||||
$data = $step->loadData();
|
$data = $step->loadData();
|
||||||
if($data) {
|
if ($data) {
|
||||||
$organisation->update($data);
|
$organisation->update($data);
|
||||||
if($member && $member->ID) $organisation->MemberID = $member->ID;
|
if ($member && $member->ID) {
|
||||||
|
$organisation->MemberID = $member->ID;
|
||||||
|
}
|
||||||
$organisation->write();
|
$organisation->write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,29 +40,29 @@ class Page2MultiForm extends MultiForm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page2PersonalDetailsFormStep extends MultiFormStep {
|
class Page2PersonalDetailsFormStep extends MultiFormStep
|
||||||
|
{
|
||||||
|
|
||||||
public static $next_steps = 'Page2OrganisationDetailsFormStep';
|
public static $next_steps = 'Page2OrganisationDetailsFormStep';
|
||||||
|
|
||||||
function getFields() {
|
public function getFields()
|
||||||
|
{
|
||||||
return new FieldList(
|
return new FieldList(
|
||||||
new TextField('FirstName', 'First name'),
|
new TextField('FirstName', 'First name'),
|
||||||
new TextField('Surname', 'Surname')
|
new TextField('Surname', 'Surname')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page2OrganisationDetailsFormStep extends MultiFormStep {
|
class Page2OrganisationDetailsFormStep extends MultiFormStep
|
||||||
|
{
|
||||||
|
|
||||||
public static $is_final_step = true;
|
public static $is_final_step = true;
|
||||||
|
|
||||||
function getFields() {
|
public function getFields()
|
||||||
|
{
|
||||||
return new FieldList(
|
return new FieldList(
|
||||||
new TextField('OrganisationName', 'Organisation Name')
|
new TextField('OrganisationName', 'Organisation Name')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Page2MultiFormTestPage extends Page {
|
class Page2MultiFormTestPage extends Page
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page2MultiFormTestPage_Controller extends Page_Controller {
|
class Page2MultiFormTestPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
function Page2MultiForm() {
|
public function Page2MultiForm()
|
||||||
|
{
|
||||||
return new Page2MultiForm($this, 'Page2MultiForm');
|
return new Page2MultiForm($this, 'Page2MultiForm');
|
||||||
}
|
}
|
||||||
|
|
||||||
function finished() {
|
public function finished()
|
||||||
|
{
|
||||||
return array(
|
return array(
|
||||||
'Title' => 'Thank you for your submission',
|
'Title' => 'Thank you for your submission',
|
||||||
'Content' => '<p>You have successfully submitted the form. Thanks!</p>'
|
'Content' => '<p>You have successfully submitted the form. Thanks!</p>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -1,29 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Page3MultiForm extends MultiForm {
|
class Page3MultiForm extends MultiForm
|
||||||
|
{
|
||||||
|
|
||||||
public static $start_step = 'Page3StartFormStep';
|
public static $start_step = 'Page3StartFormStep';
|
||||||
|
|
||||||
public function finish($data, $form) {
|
public function finish($data, $form)
|
||||||
|
{
|
||||||
parent::finish($data, $form);
|
parent::finish($data, $form);
|
||||||
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
|
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
|
||||||
if($steps) {
|
if ($steps) {
|
||||||
foreach($steps as $step) {
|
foreach ($steps as $step) {
|
||||||
if($step->class == 'Page3PersonalDetailsFormStep') {
|
if ($step->class == 'Page3PersonalDetailsFormStep') {
|
||||||
$member = new Member();
|
$member = new Member();
|
||||||
$data = $step->loadData();
|
$data = $step->loadData();
|
||||||
if($data) {
|
if ($data) {
|
||||||
$member->update($data);
|
$member->update($data);
|
||||||
$member->write();
|
$member->write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($step->class == 'Page3OrganisationDetailsFormStep') {
|
if ($step->class == 'Page3OrganisationDetailsFormStep') {
|
||||||
$organisation = new Organisation();
|
$organisation = new Organisation();
|
||||||
$data = $step->loadData();
|
$data = $step->loadData();
|
||||||
if($data) {
|
if ($data) {
|
||||||
$organisation->update($data);
|
$organisation->update($data);
|
||||||
if($member && $member->ID) $organisation->MemberID = $member->ID;
|
if ($member && $member->ID) {
|
||||||
|
$organisation->MemberID = $member->ID;
|
||||||
|
}
|
||||||
$organisation->write();
|
$organisation->write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,15 +38,15 @@ class Page3MultiForm extends MultiForm {
|
|||||||
$controller = $this->getController();
|
$controller = $this->getController();
|
||||||
$controller->redirect($controller->Link() . 'finished');
|
$controller->redirect($controller->Link() . 'finished');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page3StartFormStep extends MultiFormStep {
|
class Page3StartFormStep extends MultiFormStep
|
||||||
|
{
|
||||||
|
|
||||||
public static $next_steps = 'Page3PersonalDetailsFormStep';
|
public static $next_steps = 'Page3PersonalDetailsFormStep';
|
||||||
|
|
||||||
function getFields() {
|
public function getFields()
|
||||||
|
{
|
||||||
return new FieldList(
|
return new FieldList(
|
||||||
new LiteralField('Details', '<b>This is important</b><br />
|
new LiteralField('Details', '<b>This is important</b><br />
|
||||||
<p>You will receiving email once you participate in this survey. <br />
|
<p>You will receiving email once you participate in this survey. <br />
|
||||||
@ -53,33 +57,31 @@ class Page3StartFormStep extends MultiFormStep {
|
|||||||
new CheckboxField('Unsubscribe', 'Tick that you confirm the above details.')
|
new CheckboxField('Unsubscribe', 'Tick that you confirm the above details.')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page3PersonalDetailsFormStep extends MultiFormStep {
|
class Page3PersonalDetailsFormStep extends MultiFormStep
|
||||||
|
{
|
||||||
|
|
||||||
public static $next_steps = 'Page3OrganisationDetailsFormStep';
|
public static $next_steps = 'Page3OrganisationDetailsFormStep';
|
||||||
|
|
||||||
function getFields() {
|
public function getFields()
|
||||||
|
{
|
||||||
return new FieldList(
|
return new FieldList(
|
||||||
new TextField('FirstName', 'First name'),
|
new TextField('FirstName', 'First name'),
|
||||||
new TextField('Surname', 'Surname')
|
new TextField('Surname', 'Surname')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page3OrganisationDetailsFormStep extends MultiFormStep {
|
class Page3OrganisationDetailsFormStep extends MultiFormStep
|
||||||
|
{
|
||||||
|
|
||||||
public static $is_final_step = true;
|
public static $is_final_step = true;
|
||||||
|
|
||||||
function getFields() {
|
public function getFields()
|
||||||
|
{
|
||||||
return new FieldList(
|
return new FieldList(
|
||||||
new TextField('OrganisationName', 'Organisation Name')
|
new TextField('OrganisationName', 'Organisation Name')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Page3MultiFormTestPage extends Page {
|
class Page3MultiFormTestPage extends Page
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class Page3MultiFormTestPage_Controller extends Page_Controller {
|
class Page3MultiFormTestPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
function Page3MultiForm() {
|
public function Page3MultiForm()
|
||||||
|
{
|
||||||
return new Page3MultiForm($this, 'Page3MultiForm');
|
return new Page3MultiForm($this, 'Page3MultiForm');
|
||||||
}
|
}
|
||||||
|
|
||||||
function finished() {
|
public function finished()
|
||||||
|
{
|
||||||
return array(
|
return array(
|
||||||
'Title' => 'Thank you for your submission',
|
'Title' => 'Thank you for your submission',
|
||||||
'Content' => '<p>You have successfully submitted the form. Thanks!</p>'
|
'Content' => '<p>You have successfully submitted the form. Thanks!</p>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -1,21 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
class TestMultiForm extends MultiForm {
|
class TestMultiForm extends MultiForm
|
||||||
|
{
|
||||||
public static $start_step = 'TestMultiFormStepOne';
|
public static $start_step = 'TestMultiFormStepOne';
|
||||||
|
|
||||||
function finish($data, $form) {
|
public function finish($data, $form)
|
||||||
|
{
|
||||||
parent::finish($data, $form);
|
parent::finish($data, $form);
|
||||||
|
|
||||||
$savedSteps = $this->getSavedSteps();
|
$savedSteps = $this->getSavedSteps();
|
||||||
|
|
||||||
$savedData = array();
|
$savedData = array();
|
||||||
foreach($savedSteps as $step) {
|
foreach ($savedSteps as $step) {
|
||||||
$savedData = array_merge($savedData, $step->loadData());
|
$savedData = array_merge($savedData, $step->loadData());
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = new FieldList();
|
$fields = new FieldList();
|
||||||
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
||||||
|
|
||||||
foreach($savedData as $key=>$value) {
|
foreach ($savedData as $key=>$value) {
|
||||||
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
|
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,23 +27,25 @@ class TestMultiForm extends MultiForm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestMultiFormStepOne extends MultiFormStep {
|
class TestMultiFormStepOne extends MultiFormStep
|
||||||
|
{
|
||||||
public static $next_steps = 'TestMultiFormStepTwo';
|
public static $next_steps = 'TestMultiFormStepTwo';
|
||||||
|
|
||||||
function getFields() {
|
public function getFields()
|
||||||
|
{
|
||||||
return new FieldList(
|
return new FieldList(
|
||||||
new TextField('FirstName', 'First name'),
|
new TextField('FirstName', 'First name'),
|
||||||
new TextField('Surname', 'Surname')
|
new TextField('Surname', 'Surname')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestMultiFormStepTwo extends MultiFormStep {
|
class TestMultiFormStepTwo extends MultiFormStep
|
||||||
|
{
|
||||||
public static $next_steps = 'TestMultiFormStepThree';
|
public static $next_steps = 'TestMultiFormStepThree';
|
||||||
|
|
||||||
function getFields() {
|
public function getFields()
|
||||||
|
{
|
||||||
return new FieldList(
|
return new FieldList(
|
||||||
new TextField('Email', 'Email'),
|
new TextField('Email', 'Email'),
|
||||||
new TextField('Address', 'Address')
|
new TextField('Address', 'Address')
|
||||||
@ -50,23 +54,27 @@ class TestMultiFormStepTwo extends MultiFormStep {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TestMultiFormStepThree extends MultiFormStep {
|
class TestMultiFormStepThree extends MultiFormStep
|
||||||
|
{
|
||||||
public static $is_final_step = true;
|
public static $is_final_step = true;
|
||||||
|
|
||||||
function getFields() {
|
public function getFields()
|
||||||
|
{
|
||||||
$form = $this->getForm();
|
$form = $this->getForm();
|
||||||
$savedSteps = $form->getSavedSteps();
|
$savedSteps = $form->getSavedSteps();
|
||||||
|
|
||||||
$savedData = array();
|
$savedData = array();
|
||||||
foreach($savedSteps as $step) {
|
foreach ($savedSteps as $step) {
|
||||||
$savedData = array_merge($savedData, $step->loadData());
|
$savedData = array_merge($savedData, $step->loadData());
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = new FieldList();
|
$fields = new FieldList();
|
||||||
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
||||||
|
|
||||||
foreach($savedData as $key=>$value) {
|
foreach ($savedData as $key=>$value) {
|
||||||
if(preg_match("/_copy$/", $key)) continue;
|
if (preg_match("/_copy$/", $key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
|
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
|
||||||
}
|
}
|
||||||
@ -74,4 +82,3 @@ class TestMultiFormStepThree extends MultiFormStep {
|
|||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
class TestMultiFormPage extends Page {
|
class TestMultiFormPage extends Page
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestMultiFormPage_Controller extends Page_Controller {
|
class TestMultiFormPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
function Form() {
|
public function Form()
|
||||||
|
{
|
||||||
$form = new TestMultiForm($this, 'Form', new FieldList(), new FieldList());
|
$form = new TestMultiForm($this, 'Form', new FieldList(), new FieldList());
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
function FormMessage() {
|
public function FormMessage()
|
||||||
if(Session::get('MultiFormMessage')) {
|
{
|
||||||
|
if (Session::get('MultiFormMessage')) {
|
||||||
$message = Session::get('MultiFormMessage');
|
$message = Session::get('MultiFormMessage');
|
||||||
Session::clear('MultiFormMessage');
|
Session::clear('MultiFormMessage');
|
||||||
|
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
class RecaptchaTestPage extends Page {
|
class RecaptchaTestPage extends Page
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class RecaptchaTestPage_Controller extends Page_Controller {
|
class RecaptchaTestPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
function Form() {
|
public function Form()
|
||||||
|
{
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
new TextField('MyText')
|
new TextField('MyText')
|
||||||
);
|
);
|
||||||
if(class_exists('RecaptchaField')) {
|
if (class_exists('RecaptchaField')) {
|
||||||
$fields->push(new RecaptchaField('MyRecaptcha'));
|
$fields->push(new RecaptchaField('MyRecaptcha'));
|
||||||
} else {
|
} else {
|
||||||
$fields->push(new LiteralField('<p class="message error">RecaptchaField class not found</p>'));
|
$fields->push(new LiteralField('<p class="message error">RecaptchaField class not found</p>'));
|
||||||
@ -28,10 +30,10 @@ class RecaptchaTestPage_Controller extends Page_Controller {
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
function submit($data, $form) {
|
public function submit($data, $form)
|
||||||
|
{
|
||||||
$form->sessionMessage('Hooray!', 'good');
|
$form->sessionMessage('Hooray!', 'good');
|
||||||
|
|
||||||
return Director::redirectBack();
|
return Director::redirectBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,18 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
class SifrPage extends Page {
|
class SifrPage extends Page
|
||||||
|
{
|
||||||
|
|
||||||
function getCMSFields() {
|
public function getCMSFields()
|
||||||
|
{
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
$fields->addFieldToTab("Root.Content.SifrSampleImage", new LiteralField("SifrSampleImage", '<p><img src="frameworktest/images/sifr_sample.png"/></p>'));
|
$fields->addFieldToTab("Root.Content.SifrSampleImage", new LiteralField("SifrSampleImage", '<p><img src="frameworktest/images/sifr_sample.png"/></p>'));
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SifrPage_Controller extends Page_Controller {
|
class SifrPage_Controller extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
function init() {
|
public function init()
|
||||||
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
Sifr::add_font('blackout', 'themes/fonts/blackout.swf');
|
Sifr::add_font('blackout', 'themes/fonts/blackout.swf');
|
||||||
|
Loading…
Reference in New Issue
Block a user