From 05e90838c066ae37b3c43b7fde4e2d18daad6fc7 Mon Sep 17 00:00:00 2001 From: Stig Lindqvist Date: Wed, 26 Oct 2011 18:35:51 +1300 Subject: [PATCH] API CHANGE Switch usage from FieldSet to FieldList --- code/controllers/AssetAdmin.php | 10 +++++----- code/controllers/CMSMain.php | 20 +++++++++---------- code/controllers/CMSPageHistoryController.php | 8 ++++---- code/controllers/StaticExporter.php | 4 ++-- code/forms/AssetTableField.php | 2 +- code/forms/FolderUnusedAssetsField.php | 4 ++-- code/model/SiteConfig.php | 6 +++--- code/model/SiteTree.php | 16 +++++++-------- code/reports/BrokenLinksReport.php | 2 +- code/reports/Report.php | 14 ++++++------- code/reports/SideReport.php | 8 ++++---- code/search/AdvancedSearchForm.php | 4 ++-- .../ContentControllerSearchExtension.php | 4 ++-- code/search/SearchForm.php | 8 ++++---- code/widgets/Widget.php | 2 +- tasks/RemoveOrphanedPagesTask.php | 4 ++-- tests/controller/CMSMainTest.php | 2 +- tests/widgets/WidgetAreaEditorTest.php | 2 +- tests/widgets/WidgetControllerTest.php | 4 ++-- 19 files changed, 62 insertions(+), 62 deletions(-) diff --git a/code/controllers/AssetAdmin.php b/code/controllers/AssetAdmin.php index 7c792873..6bfbc76c 100644 --- a/code/controllers/AssetAdmin.php +++ b/code/controllers/AssetAdmin.php @@ -135,7 +135,7 @@ JS * Return the form object shown in the uploadiframe. */ function UploadForm() { - $form = new Form($this,'UploadForm', new FieldSet( + $form = new Form($this,'UploadForm', new FieldList( new HiddenField("ID", "", $this->currentPageID()), new HiddenField("FolderID", "", $this->currentPageID()), // needed because the button-action is triggered outside the iframe @@ -148,7 +148,7 @@ JS

" . _t('AssetAdmin.FILESREADY','Files ready to upload:') ."

") - ), new FieldSet( + ), new FieldList( )); // Makes ajax easier @@ -228,7 +228,7 @@ JS if($newFile = $folder->addUploadToFolder($tmpFile)) { if(self::$metadata_upload_enabled && isset($processedData[$filePostId])) { $fileObject = DataObject::get_by_id('File', $newFile); - $metadataForm = new Form($this, 'MetadataForm', $fileObject->uploadMetadataFields(), new FieldSet()); + $metadataForm = new Form($this, 'MetadataForm', $fileObject->uploadMetadataFields(), new FieldList()); $metadataForm->loadDataFrom($processedData[$filePostId]); $metadataForm->saveInto($fileObject); $fileObject->write(); @@ -399,9 +399,9 @@ JS $form = new Form( $this, 'SyncForm', - new FieldSet( + new FieldList( ), - new FieldSet( + new FieldList( $btn = new FormAction('doSync', _t('FILESYSTEMSYNC','Look for new files')) ) ); diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index 793422a5..cd7c6543 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -160,7 +160,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr create_function('$a,$b', 'return ($a == "CMSSiteTreeFilter_Search") ? 1 : -1;') ); - $fields = new FieldSet( + $fields = new FieldList( new TextField('Term', _t('CMSSearch.FILTERLABELTEXT', 'Content')), $dateGroup = new FieldGroup( $dateFrom = new DateField('LastEditedFrom', _t('CMSSearch.FILTERDATEFROM', 'From')), @@ -185,7 +185,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr $dateFrom->setConfig('showcalendar', true); $dateTo->setConfig('showcalendar', true); - $actions = new FieldSet( + $actions = new FieldList( $resetAction = new ResetFormAction('clear', _t('CMSMain_left.ss.CLEAR', 'Clear')), $searchAction = new FormAction('doSearch', _t('CMSMain_left.ss.SEARCH', 'Search')) ); @@ -397,7 +397,7 @@ JS; /** * @param Int $id - * @param FieldSet $fields + * @param FieldList $fields * @return Form */ public function getEditForm($id = null, $fields = null) { @@ -476,8 +476,8 @@ JS; } if ($id == 0 || $id == 'root') { return $this->RootForm(); } else if($id) { - return new Form($this, "EditForm", new FieldSet( - new LabelField('PageDoesntExistLabel',_t('CMSMain.PAGENOTEXISTS',"This page doesn't exist"))), new FieldSet() + return new Form($this, "EditForm", new FieldList( + new LabelField('PageDoesntExistLabel',_t('CMSMain.PAGENOTEXISTS',"This page doesn't exist"))), new FieldList() ); } } @@ -852,12 +852,12 @@ JS; $form = new Form( $this, 'SideReportsForm', - new FieldSet( + new FieldList( $selectorField, new HiddenField('ID', false, ($record) ? $record->ID : null), new HiddenField('Locale', false, $this->Locale) ), - new FieldSet( + new FieldList( new FormAction('doShowSideReport', _t('CMSMain_left.ss.GO','Go')) ) ); @@ -1037,7 +1037,7 @@ JS; } $labelTriangle = ''; - $fields = new FieldSet( + $fields = new FieldList( // new HiddenField("ParentID", false, ($this->parentRecord) ? $this->parentRecord->ID : null), // TODO Should be part of the form attribute, but not possible in current form API $hintsField = new LiteralField('Hints', sprintf('', $this->SiteTreeHints())), @@ -1053,7 +1053,7 @@ JS; $parentField->setValue(($record) ? $record->ID : null); - $actions = new FieldSet( + $actions = new FieldList( // $resetAction = new ResetFormAction('doCancel', _t('CMSMain.Cancel', 'Cancel')), $createAction = new FormAction("doAdd", _t('CMSMain.Create',"Create")) ); @@ -1138,7 +1138,7 @@ JS; } else { $token = SecurityToken::inst(); - $fields = new FieldSet(); + $fields = new FieldList(); $token->updateFieldSet($fields); $tokenField = $fields->First(); $tokenHtml = ($tokenField) ? $tokenField->FieldHolder() : ''; diff --git a/code/controllers/CMSPageHistoryController.php b/code/controllers/CMSPageHistoryController.php index db8d60ff..07d56b53 100644 --- a/code/controllers/CMSPageHistoryController.php +++ b/code/controllers/CMSPageHistoryController.php @@ -82,7 +82,7 @@ class CMSPageHistoryController extends CMSMain { $form = parent::getEditForm($record, ($record) ? $record->getCMSFields() : null); - $form->setActions(new FieldSet( + $form->setActions(new FieldList( $revert = new FormAction('doRollback', _t('CMSPageHistoryController.REVERTTOTHISVERSION', 'Revert to this version')) )); @@ -193,7 +193,7 @@ class CMSPageHistoryController extends CMSMain { $form = new Form( $this, 'VersionsForm', - new FieldSet( + new FieldList( new CheckboxField( 'ShowUnpublished', _t('CMSPageHistoryController.SHOWUNPUBLISHED','Show unpublished versions'), @@ -207,7 +207,7 @@ class CMSPageHistoryController extends CMSMain { new LiteralField('VersionsHtml', $versionsHtml), $hiddenID = new HiddenField('ID', false, "") ), - new FieldSet( + new FieldList( new FormAction( 'doCompare', _t('CMSPageHistoryController.COMPAREVERSIONS','Compare Versions') ), @@ -408,7 +408,7 @@ class CMSPageHistoryController extends CMSMain { if($record) { $form = $this->getEditForm($id, null, null, true); - $form->setActions(new FieldSet()); + $form->setActions(new FieldList()); $form->addExtraClass('compare'); // Comparison views shouldn't be editable. diff --git a/code/controllers/StaticExporter.php b/code/controllers/StaticExporter.php index 47c6bc5a..1cd2ba9e 100644 --- a/code/controllers/StaticExporter.php +++ b/code/controllers/StaticExporter.php @@ -39,10 +39,10 @@ class StaticExporter extends Controller { } function StaticExportForm() { - return new Form($this, 'StaticExportForm', new FieldSet( + return new Form($this, 'StaticExportForm', new FieldList( // new TextField('folder', _t('StaticExporter.FOLDEREXPORT','Folder to export to')), new TextField('baseurl', _t('StaticExporter.BASEURL','Base URL')) - ), new FieldSet( + ), new FieldList( new FormAction('export', _t('StaticExporter.EXPORTTO','Export to that folder')) )); } diff --git a/code/forms/AssetTableField.php b/code/forms/AssetTableField.php index 4ed4480a..7b0f185c 100644 --- a/code/forms/AssetTableField.php +++ b/code/forms/AssetTableField.php @@ -164,7 +164,7 @@ class AssetTableField extends ComplexTableField { $urlLink .= "{$childData->RelativeLink()}"; $urlLink .= ""; - $detailFormFields = new FieldSet( + $detailFormFields = new FieldList( new TabSet("BottomRoot", $mainTab = new Tab('Main', new TextField("Title", _t('AssetTableField.TITLE','Title')), diff --git a/code/forms/FolderUnusedAssetsField.php b/code/forms/FolderUnusedAssetsField.php index 543d4665..c88ec7da 100644 --- a/code/forms/FolderUnusedAssetsField.php +++ b/code/forms/FolderUnusedAssetsField.php @@ -8,7 +8,7 @@ class Folder_UnusedAssetsField extends CompositeField { public function __construct($folder) { $this->folder = $folder; - parent::__construct(new FieldSet()); + parent::__construct(new FieldList()); } public function getChildren() { @@ -16,7 +16,7 @@ class Folder_UnusedAssetsField extends CompositeField { $inlineFormAction = new InlineFormAction("delete_unused_thumbnails", _t('Folder.DELETEUNUSEDTHUMBNAILS', 'Delete unused thumbnails')); $inlineFormAction->includeDefaultJS(false) ; - $this->children = new FieldSet( + $this->children = new FieldList( new LiteralField( "UnusedAssets", "

"._t('Folder.UNUSEDFILESTITLE', 'Unused files')."

" ), $this->getAssetList(), new FieldGroup( diff --git a/code/model/SiteConfig.php b/code/model/SiteConfig.php index 31db3761..48d158c2 100644 --- a/code/model/SiteConfig.php +++ b/code/model/SiteConfig.php @@ -44,7 +44,7 @@ class SiteConfig extends DataObject implements PermissionProvider { function getCMSFields() { Requirements::javascript(CMS_DIR . "/javascript/SitetreeAccess.js"); - $fields = new FieldSet( + $fields = new FieldList( new TabSet("Root", $tabMain = new Tab('Main', $titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")), @@ -128,11 +128,11 @@ class SiteConfig extends DataObject implements PermissionProvider { */ function getCMSActions() { if (Permission::check('ADMIN') || Permission::check('EDIT_SITECONFIG')) { - $actions = new FieldSet( + $actions = new FieldList( new FormAction('save_siteconfig', _t('CMSMain.SAVE','Save')) ); } else { - $actions = new FieldSet(); + $actions = new FieldList(); } $this->extend('updateCMSActions', $actions); diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index 1a636f9a..819ce438 100644 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -1736,16 +1736,16 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } /** - * Returns a FieldSet with which to create the main editing form. + * Returns a FieldList with which to create the main editing form. * * You can override this in your child classes to add extra fields - first * get the parent fields using parent::getCMSFields(), then use - * addFieldToTab() on the FieldSet. + * addFieldToTab() on the FieldList. * * See {@link getSettingsFields()} for a different set of fields * concerned with configuration aspects on the record, e.g. access control * - * @return FieldSet The fields to be displayed in the CMS. + * @return FieldList The fields to be displayed in the CMS. */ function getCMSFields() { require_once("forms/Form.php"); @@ -1827,7 +1827,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $url = (strlen($baseLink) > 36) ? "..." .substr($baseLink, -32) : $baseLink; $urlHelper = sprintf("%s", $url); - $fields = new FieldSet( + $fields = new FieldList( $rootTab = new TabSet("Root", $tabMain = new Tab('Main', new TextField("Title", $this->fieldLabel('Title')), @@ -1878,10 +1878,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * Returns fields related to configuration aspects on this record, e.g. access control. * See {@link getCMSFields()} for content-related fields. * - * @return FieldSet + * @return FieldList */ function getSettingsFields() { - $fields = new FieldSet( + $fields = new FieldList( $rootTab = new TabSet("Root", $tabBehaviour = new Tab('Settings', new DropdownField( @@ -2028,10 +2028,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid /** * Get the actions available in the CMS for this page - eg Save, Publish. - * @return FieldSet The available actions for this page. + * @return FieldList The available actions for this page. */ function getCMSActions() { - $actions = new FieldSet(); + $actions = new FieldList(); // "readonly"/viewing version that isn't the current version of the record $stageOrLiveRecord = Versioned::get_one_by_stage($this->class, Versioned::current_stage(), sprintf('"SiteTree"."ID" = %d', $this->ID)); diff --git a/code/reports/BrokenLinksReport.php b/code/reports/BrokenLinksReport.php index 04c7e466..76603ab7 100644 --- a/code/reports/BrokenLinksReport.php +++ b/code/reports/BrokenLinksReport.php @@ -104,7 +104,7 @@ class BrokenLinksReport extends SS_Report { return $fields; } function parameterFields() { - return new FieldSet( + return new FieldList( new DropdownField('CheckSite', _t('BrokenLinksReport.CheckSite','Check site'), array( 'Published' => _t('BrokenLinksReport.CheckSiteDropdownPublished', 'Published Site'), 'Draft' => _t('BrokenLinksReport.CheckSiteDropdownDraft', 'Draft Site') diff --git a/code/reports/Report.php b/code/reports/Report.php index ac2e02c0..0ebce497 100644 --- a/code/reports/Report.php +++ b/code/reports/Report.php @@ -11,7 +11,7 @@ * {@link description()}: Return the description - i18n is your responsibility * {@link sourceQuery()}: Return a DataObjectSet of the search results * {@link columns()}: Return information about the columns in this report. - * {@link parameterFields()}: Return a FieldSet of the fields that can be used to filter this + * {@link parameterFields()}: Return a FieldList of the fields that can be used to filter this * report. * * If you can't express your report as a query, you can implement the this method instead: @@ -29,7 +29,7 @@ * * {@link getReportField()}: Return a FormField in the place where your report's TableListField * usually appears. - * {@link getCMSFields()}: Return the FieldSet representing the complete right-hand area of the + * {@link getCMSFields()}: Return the FieldList representing the complete right-hand area of the * report, including the title, description, parameter fields, and results. * * Showing reports to the user @@ -94,7 +94,7 @@ class SS_Report extends ViewableData { } /** - * Return a FieldSet specifying the search criteria for this report. + * Return a FieldList specifying the search criteria for this report. * * Override this method to define search criteria. */ @@ -158,17 +158,17 @@ class SS_Report extends ViewableData { /** - * Returns a FieldSet with which to create the CMS editing form. + * Returns a FieldList with which to create the CMS editing form. * You can use the extend() method of FieldSet to create customised forms for your other * data objects. * * @uses getReportField() to render a table, or similar field for the report. This * method should be defined on the SS_Report subclasses. * - * @return FieldSet + * @return FieldList */ function getCMSFields() { - $fields = new FieldSet( + $fields = new FieldList( new LiteralField( 'ReportTitle', "

{$this->title()}

" @@ -200,7 +200,7 @@ class SS_Report extends ViewableData { function getCMSActions() { // getCMSActions() can be extended with updateCMSActions() on a extension - $actions = new FieldSet(); + $actions = new FieldList(); $this->extend('updateCMSActions', $actions); return $actions; } diff --git a/code/reports/SideReport.php b/code/reports/SideReport.php index d58f576a..7202f133 100644 --- a/code/reports/SideReport.php +++ b/code/reports/SideReport.php @@ -211,7 +211,7 @@ class SideReport_BrokenLinks extends SS_Report { ); } function getParameterFields() { - return new FieldSet( + return new FieldList( new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site')) ); } @@ -250,7 +250,7 @@ class SideReport_BrokenFiles extends SS_Report { } function getParameterFields() { - return new FieldSet( + return new FieldList( new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site')) ); } @@ -284,7 +284,7 @@ class SideReport_BrokenVirtualPages extends SS_Report { } function getParameterFields() { - return new FieldSet( + return new FieldList( new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site')) ); } @@ -319,7 +319,7 @@ class SideReport_BrokenRedirectorPages extends SS_Report { } function getParameterFields() { - return new FieldSet( + return new FieldList( new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site')) ); } diff --git a/code/search/AdvancedSearchForm.php b/code/search/AdvancedSearchForm.php index 30577f2c..faa473ed 100644 --- a/code/search/AdvancedSearchForm.php +++ b/code/search/AdvancedSearchForm.php @@ -11,7 +11,7 @@ class AdvancedSearchForm extends SearchForm { */ function __construct($controller, $name, $fields = null, $actions = null) { if(!$fields) { - $fields = new FieldSet( + $fields = new FieldList( $searchBy = new CompositeField( new HeaderField('SearchByHeader',_t('AdvancedSearchForm.SEARCHBY', 'SEARCH BY')), new TextField("+", _t('AdvancedSearchForm.ALLWORDS', 'All Words')), @@ -44,7 +44,7 @@ class AdvancedSearchForm extends SearchForm { } if(!$actions) { - $actions = new FieldSet( + $actions = new FieldList( new FormAction("results", _t('AdvancedSearchForm.GO', 'Go')) ); } diff --git a/code/search/ContentControllerSearchExtension.php b/code/search/ContentControllerSearchExtension.php index 47f222c2..7251ab72 100644 --- a/code/search/ContentControllerSearchExtension.php +++ b/code/search/ContentControllerSearchExtension.php @@ -21,10 +21,10 @@ class ContentControllerSearchExtension extends Extension { $searchText = $this->owner->request->getVar('Search'); } - $fields = new FieldSet( + $fields = new FieldList( new TextField('Search', false, $searchText) ); - $actions = new FieldSet( + $actions = new FieldList( new FormAction('results', _t('SearchForm.GO', 'Go')) ); $form = new SearchForm($this->owner, 'SearchForm', $fields, $actions); diff --git a/code/search/SearchForm.php b/code/search/SearchForm.php index 8a82f3fb..eb922fb8 100644 --- a/code/search/SearchForm.php +++ b/code/search/SearchForm.php @@ -31,13 +31,13 @@ class SearchForm extends Form { * * @param Controller $controller * @param string $name The name of the form (used in URL addressing) - * @param FieldSet $fields Optional, defaults to a single field named "Search". Search logic needs to be customized + * @param FieldList $fields Optional, defaults to a single field named "Search". Search logic needs to be customized * if fields are added to the form. - * @param FieldSet $actions Optional, defaults to a single field named "Go". + * @param FieldList $actions Optional, defaults to a single field named "Go". */ function __construct($controller, $name, $fields = null, $actions = null) { if(!$fields) { - $fields = new FieldSet( + $fields = new FieldList( new TextField('Search', _t('SearchForm.SEARCH', 'Search') )); } @@ -47,7 +47,7 @@ class SearchForm extends Form { } if(!$actions) { - $actions = new FieldSet( + $actions = new FieldList( new FormAction("getResults", _t('SearchForm.GO', 'Go')) ); } diff --git a/code/widgets/Widget.php b/code/widgets/Widget.php index 25104d19..6d632bc7 100644 --- a/code/widgets/Widget.php +++ b/code/widgets/Widget.php @@ -35,7 +35,7 @@ class Widget extends DataObject { static $description = "Description of what this widget does."; function getCMSFields() { - $fields = new FieldSet(); + $fields = new FieldList(); $this->extend('updateCMSFields', $fields); return $fields; } diff --git a/tasks/RemoveOrphanedPagesTask.php b/tasks/RemoveOrphanedPagesTask.php index 7a5b9d0d..e7498fae 100644 --- a/tasks/RemoveOrphanedPagesTask.php +++ b/tasks/RemoveOrphanedPagesTask.php @@ -69,7 +69,7 @@ in the other stage:
} function Form() { - $fields = new FieldSet(); + $fields = new FieldList(); $source = array(); $fields->push(new HeaderField( @@ -167,7 +167,7 @@ in the other stage:
$this, 'Form', $fields, - new FieldSet( + new FieldList( new FormAction('doSubmit', _t('RemoveOrphanedPagesTask.BUTTONRUN', 'Run')) ) ); diff --git a/tests/controller/CMSMainTest.php b/tests/controller/CMSMainTest.php index 2bf270ab..d1511756 100644 --- a/tests/controller/CMSMainTest.php +++ b/tests/controller/CMSMainTest.php @@ -113,7 +113,7 @@ class CMSMainTest extends FunctionalTest { $page->flushCache(); $page = DataObject::get_by_id("SiteTree", $page->ID); - $this->assertTrue($page->getCMSFields(null) instanceof FieldSet); + $this->assertTrue($page->getCMSFields(null) instanceof FieldList); } } diff --git a/tests/widgets/WidgetAreaEditorTest.php b/tests/widgets/WidgetAreaEditorTest.php index 67cb7825..2d258f2e 100644 --- a/tests/widgets/WidgetAreaEditorTest.php +++ b/tests/widgets/WidgetAreaEditorTest.php @@ -461,7 +461,7 @@ class WidgetAreaEditorTest_TestWidget extends Widget implements TestOnly { 'Title' => 'Varchar' ); public function getCMSFields() { - $fields = new FieldSet(); + $fields = new FieldList(); $fields->push(new TextField('Title')); return $fields; } diff --git a/tests/widgets/WidgetControllerTest.php b/tests/widgets/WidgetControllerTest.php index df695f59..3d2b03fc 100644 --- a/tests/widgets/WidgetControllerTest.php +++ b/tests/widgets/WidgetControllerTest.php @@ -68,10 +68,10 @@ class WidgetControllerTest_Widget_Controller extends Widget_Controller implement $widgetform = new Form( $this, 'Form', - new FieldSet( + new FieldList( new TextField('TestValue') ), - new FieldSet( + new FieldList( new FormAction('doAction') ) );