当前位置: 首页>>代码示例>>PHP>>正文


PHP FieldList::dataFields方法代码示例

本文整理汇总了PHP中FieldList::dataFields方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldList::dataFields方法的具体用法?PHP FieldList::dataFields怎么用?PHP FieldList::dataFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FieldList的用法示例。


在下文中一共展示了FieldList::dataFields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCMSFields

 public function getCMSFields()
 {
     $conf = SiteConfig::current_site_config();
     $themes = $conf->getAvailableThemes();
     $theme = new DropdownField('Theme', _t('Multisites.THEME', 'Theme'), $themes);
     $theme->setEmptyString(_t('Multisites.DEFAULTTHEME', '(Default theme)'));
     $fields = new FieldList(new TabSet('Root', new Tab('Main', new HeaderField('SiteConfHeader', _t('Multisites.SITECONF', 'Site Configuration')), new TextField('Title', _t('Multisites.TITLE', 'Title')), new TextField('Tagline', _t('Multisites.TAGLINE', 'Tagline/Slogan')), $theme, new HeaderField('SiteURLHeader', _t('Multisites.SITEURL', 'Site URL')), new OptionsetField('Scheme', _t('Multisites.SCHEME', 'Scheme'), array('any' => _t('Multisites.ANY', 'Any'), 'http' => _t('Multisites.HTTP', 'HTTP'), 'https' => _t('Multisites.HTTPS', 'HTTPS (HTTP Secure)'))), new TextField('Host', _t('Multisites.HOST', 'Host')), new MultiValueTextField('HostAliases', _t('Multisites.HOSTALIASES', 'Host Aliases')), new CheckboxField('IsDefault', _t('Multisites.ISDEFAULT', 'Is this the default site?')), new HeaderField('SiteAdvancedHeader', _t('Multisites.SiteAdvancedHeader', 'Advanced Settings')), TextareaField::create('RobotsTxt', _t('Multisites.ROBOTSTXT', 'Robots.txt'))->setDescription(_t('Multisites.ROBOTSTXTUSAGE', '<p>Please consult <a href="http://www.robotstxt.org/robotstxt.html" target="_blank">http://www.robotstxt.org/robotstxt.html</a> for usage of the robots.txt file.</p>')))));
     $devIDs = Config::inst()->get('Multisites', 'developer_identifiers');
     if (is_array($devIDs)) {
         if (!ArrayLib::is_associative($devIDs)) {
             $devIDs = ArrayLib::valuekey($devIDs);
         }
         $fields->addFieldToTab('Root.Main', DropdownField::create('DevID', _t('Multisites.DeveloperIdentifier', 'Developer Identifier'), $devIDs));
     }
     if (Multisites::inst()->assetsSubfolderPerSite()) {
         $fields->addFieldToTab('Root.Main', new TreeDropdownField('FolderID', _t('Multisites.ASSETSFOLDER', 'Assets Folder'), 'Folder'), 'SiteURLHeader');
     }
     if (!Permission::check('SITE_EDIT_CONFIGURATION')) {
         foreach ($fields->dataFields() as $field) {
             $fields->makeFieldReadonly($field);
         }
     }
     $this->extend('updateSiteCMSFields', $fields);
     return $fields;
 }
开发者ID:silverstripe-australia,项目名称:silverstripe-multisites,代码行数:25,代码来源:Site.php

示例2: buttonClicked

 /**
  * @return FormAction
  */
 public function buttonClicked()
 {
     foreach ($this->actions->dataFields() as $action) {
         if ($action->hasMethod('actionname') && $this->buttonClickedFunc == $action->actionName()) {
             return $action;
         }
     }
 }
开发者ID:tcaiger,项目名称:mSupplyNZ,代码行数:11,代码来源:Form.php

示例3: getAllActions

 /**
  * Get a list of all actions, including those in the main "fields" FieldList
  * 
  * @return array
  */
 protected function getAllActions()
 {
     $fields = $this->fields->dataFields() ?: array();
     $actions = $this->actions->dataFields() ?: array();
     $fieldsAndActions = array_merge($fields, $actions);
     $actions = array_filter($fieldsAndActions, function ($fieldOrAction) {
         return $fieldOrAction instanceof FormAction;
     });
     return $actions;
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:15,代码来源:Form.php

示例4: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     if (Config::inst()->get('MarkdownExtension', 'replace_html_fields')) {
         foreach ($fields->dataFields() as $field) {
             if ($field instanceof HtmlEditorField) {
                 $attributes = $field->getAttributes();
                 $fields->replaceField($field->getName(), MarkdownEditorField::create($field->getName(), $field->Title())->setRows($attributes['rows']));
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-markdown,代码行数:11,代码来源:MarkdownExtension.php

示例5: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->UserSubmissionHolder()) {
         $fields->removeByName($this->owner->config()->remove_fields);
         $whitelist_fields = $this->owner->config()->whitelist_fields;
         foreach ($fields->dataFields() as $field) {
             if (!in_array($field->getName(), $whitelist_fields)) {
                 $fields->replaceField($field->getName(), $field->performReadonlyTransformation());
             }
         }
     }
 }
开发者ID:silbinarywolf,项目名称:usersubmissionpages,代码行数:12,代码来源:SubmittedFormFieldListingExtension.php

示例6: buttonClicked

 /**
  * @return FormAction
  */
 public function buttonClicked()
 {
     $fields = $this->fields->dataFields() ?: array();
     $actions = $this->actions->dataFields() ?: array();
     if (!$actions && !$fields) {
         return null;
     }
     $fieldsAndActions = array_merge($fields, $actions);
     foreach ($fieldsAndActions as $fieldOrAction) {
         if ($fieldOrAction instanceof FormAction && $this->buttonClickedFunc === $fieldOrAction->actionName()) {
             return $fieldOrAction;
         }
     }
     return null;
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:18,代码来源:Form.php

示例7: FoundationForm

 function FoundationForm()
 {
     $fields = new FieldList(HeaderField::create('FormFieldsHeader', 'Form Fields', 3), TextField::create('TextField', 'TextField'), EmailField::create('EmailField', 'EmailField'), PasswordField::create('PasswordField', 'PasswordField'), TextareaField::create('TextareaField', 'TextareaField'), FileField::create('FileField', 'FileField'), CheckboxField::create('CheckboxField', 'CheckboxField'), DropdownField::create('DropdownField', 'DropdownField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany'))->setEmptyString(''), CheckboxsetField::create('CheckboxsetField', 'CheckboxsetField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany')), OptionsetField::create('OptionsetField', 'OptionsetField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany')), HeaderField::create('FieldGroupHeader', 'Field Groups', 3), FieldGroup::create(TextField::create('FieldGroupTextField', 'TextField')->addExtraClass('small-6 columns'), TextField::create('FieldGroupTextField1', 'TextField')->addExtraClass('small-6 columns')), FieldGroup::create(TextField::create('FieldGroupTextField2', 'TextField')->addExtraClass('small-4 columns'), TextField::create('FieldGroupTextField3', 'TextField')->addExtraClass('small-4 columns'), TextField::create('FieldGroupTextField4', 'TextField')->addExtraClass('small-4 columns')), FieldGroup::create(TextField::create('FieldGroupTextField5', 'TextField')->addExtraClass('small-3 columns'), TextField::create('FieldGroupTextField6', 'TextField')->addExtraClass('small-3 columns'), TextField::create('FieldGroupTextField7', 'TextField')->addExtraClass('small-3 columns'), TextField::create('FieldGroupTextField8', 'TextField')->addExtraClass('small-3 columns')), FieldGroup::create(TextField::create('FieldGroupTextField9', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField10', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField11', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField12', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField13', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField14', 'TextField')->addExtraClass('large-2 small-4 columns')), FieldGroup::create(TextField::create('FieldGroupTextField15', 'TextField')->addExtraClass('small-6 columns'), TextField::create('FieldGroupTextField16', 'TextField')->addExtraClass('small-4 columns'), TextField::create('FieldGroupTextField17', 'TextField')->addExtraClass('small-2 columns')), FieldGroup::create(DropdownField::create('DropdownField2', 'DropdownField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany'))->addExtraClass('large-6 small-6 columns')->setEmptyString(''), DropdownField::create('DropdownField3', 'DropdownField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany'))->addExtraClass('large-6 small-6 columns')->setEmptyString('')), HeaderField::create('SwitchFieldsHeader', 'Switch Fields', 3), FoundationSwitchField::create('SwitchField', 'SwitchField', array(0 => 'Off', 1 => 'On'))->addExtraClass('large-12'), FoundationSwitchField::create('SwitchField2', 'SwitchField', array(0 => 'Off', 1 => 'On'))->addExtraClass('large round'));
     $actions = new FieldList(new FormAction('submitFoundationForm', 'Submit'));
     // set all to required to see the validation message appearance
     $required = array();
     if ($dataFields = $fields->dataFields()) {
         foreach ($dataFields as $child) {
             $required[] = $child->getName();
         }
     }
     $validator = new RequiredFields($required);
     $form = new FoundationForm($this, __FUNCTION__, $fields, $actions, $validator);
     // load submitted data, and clear them from session
     if ($data = Session::get('FoundationForm' . $this->ID)) {
         $form->loadDataFrom($data);
         Session::clear('FoundationForm' . $this->ID);
     }
     return $form;
 }
开发者ID:helpfulrobot,项目名称:rywa-silverstripe-foundation-forms,代码行数:20,代码来源:FoundationFormPage.php

示例8: SearchForm

 /**
  * Returns a Form for page searching for use in templates.
  *
  * Can be modified from a decorator by a 'updateSearchForm' method
  *
  * @return Form
  */
 public function SearchForm()
 {
     // Create the fields
     $content = new TextField('q[Title]', _t('CMSSearch.FILTERTITLEHEADING', 'Module Name'));
     $dateHeader = new HeaderField('q[Date]', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4);
     $dateFrom = new DateField('q[LastEditedFrom]', _t('CMSSearch.FILTERDATEFROM', 'From'));
     $dateFrom->setConfig('showcalendar', true);
     $dateTo = new DateField('q[LastEditedTo]', _t('CMSSearch.FILTERDATETO', 'To'));
     $dateTo->setConfig('showcalendar', true);
     $pageClasses = new DropdownField('q[Module]', _t('ContentModule.MODULETYPEOPT', 'Module Type', 'Dropdown for limiting search to a module type'), $this->getModuleTypes());
     $pageClasses->setEmptyString(_t('ContentModule.MODULETYPEANYOPT', 'Any'));
     // Group the Datefields
     $dateGroup = new FieldGroup($dateHeader, $dateFrom, $dateTo);
     $dateGroup->setFieldHolderTemplate('FieldGroup_DefaultFieldHolder')->addExtraClass('stacked');
     // Create the Field list
     $fields = new FieldList($content, $dateGroup, $pageClasses);
     // Create the Search and Reset action
     $actions = new FieldList(FormAction::create('doSearch', _t('CMSMain_left.ss.APPLY FILTER', 'Apply Filter'))->addExtraClass('ss-ui-action-constructive'), Object::create('ResetFormAction', 'clear', _t('CMSMain_left.ss.RESET', 'Reset')));
     // Use <button> to allow full jQuery UI styling on the all of the Actions
     foreach ($actions->dataFields() as $action) {
         $action->setUseButtonTag(true);
     }
     // Create the form
     $form = Form::create($this, 'SearchForm', $fields, $actions)->addExtraClass('cms-search-form')->setFormMethod('GET')->setFormAction($this->Link())->disableSecurityToken()->unsetValidator();
     // Load the form with previously sent search data
     $form->loadDataFrom($this->request->getVars());
     // Allow decorators to modify the form
     $this->extend('updateSearchForm', $form);
     return $form;
 }
开发者ID:helpfulrobot,项目名称:webtorque7-inpage-modules,代码行数:37,代码来源:ContentModuleMain.php

示例9: filterRecordEditingFields

 /**
  * Filters a records editable fields
  * based on component's config
  * and escape each field with unique name.
  *
  * See {@link GridFieldBulkManager} component for filtering config.
  * 
  * @param  FieldList $fields Record's CMS Fields
  * @param  integer   $id     Record's ID, used fir unique name
  * @return array             Filtered record's fields
  */
 private function filterRecordEditingFields(FieldList $fields, $id)
 {
     $config = $this->component->getConfig();
     $editableFields = $config['editableFields'];
     // get all dataFields or just the ones allowed in config
     if ($editableFields) {
         $dataFields = array();
         foreach ($editableFields as $fieldName) {
             $dataFields[$fieldName] = $fields->dataFieldByName($fieldName);
         }
     } else {
         $dataFields = $fields->dataFields();
     }
     // escape field names with unique prefix
     foreach ($dataFields as $name => $field) {
         $field->Name = $this->escapeFieldName($id, $name);
         $dataFields[$name] = $field;
     }
     return $dataFields;
 }
开发者ID:8secs,项目名称:cocina,代码行数:31,代码来源:GridFieldBulkActionEditHandler.php

示例10: VersionsForm

 /**
  * Version select form. Main interface between selecting versions to view 
  * and comparing multiple versions.
  *  
  * Because we can reload the page directly to a compare view (history/compare/1/2/3)
  * this form has to adapt to those parameters as well. 
  *
  * @return Form
  */
 function VersionsForm()
 {
     $id = $this->currentPageID();
     $page = $this->getRecord($id);
     $versionsHtml = '';
     $action = $this->request->param('Action');
     $versionID = $this->request->param('VersionID');
     $otherVersionID = $this->request->param('OtherVersionID');
     $showUnpublishedChecked = 0;
     $compareModeChecked = $action == "compare";
     if ($page) {
         $versions = $page->allVersions();
         $versionID = !$versionID ? $page->Version : $versionID;
         if ($versions) {
             foreach ($versions as $k => $version) {
                 $active = false;
                 if ($version->Version == $versionID || $version->Version == $otherVersionID) {
                     $active = true;
                     if (!$version->WasPublished) {
                         $showUnpublishedChecked = 1;
                     }
                 }
                 $version->Active = $active;
             }
         }
         $vd = new ViewableData();
         $versionsHtml = $vd->customise(array('Versions' => $versions))->renderWith('CMSPageHistoryController_versions');
     }
     $fields = new FieldList(new CheckboxField('ShowUnpublished', _t('CMSPageHistoryController.SHOWUNPUBLISHED', 'Show unpublished versions'), $showUnpublishedChecked), new CheckboxField('CompareMode', _t('CMSPageHistoryController.COMPAREMODE', 'Compare mode (select two)'), $compareModeChecked), new LiteralField('VersionsHtml', $versionsHtml), $hiddenID = new HiddenField('ID', false, ""));
     $actions = new FieldList(new FormAction('doCompare', _t('CMSPageHistoryController.COMPAREVERSIONS', 'Compare Versions')), new FormAction('doShowVersion', _t('CMSPageHistoryController.SHOWVERSION', 'Show Version')));
     // Use <button> to allow full jQuery UI styling
     foreach ($actions->dataFields() as $action) {
         $action->setUseButtonTag(true);
     }
     $form = new Form($this, 'VersionsForm', $fields, $actions);
     $form->loadDataFrom($this->request->requestVars());
     $hiddenID->setValue($id);
     $form->unsetValidator();
     $form->addExtraClass('cms-versions-form')->setAttribute('data-link-tmpl-compare', Controller::join_links($this->Link('compare'), '%s', '%s', '%s'))->setAttribute('data-link-tmpl-show', Controller::join_links($this->Link('show'), '%s', '%s'));
     return $form;
 }
开发者ID:nzjoel,项目名称:silverstripe-cms,代码行数:50,代码来源:CMSPageHistoryController.php

示例11: testInsertBeforeMultipleFields

 public function testInsertBeforeMultipleFields()
 {
     $fields = new FieldList($root = new TabSet("Root", $main = new Tab("Main", $a = new TextField("A"), $b = new TextField("B"))));
     $fields->addFieldsToTab('Root.Main', array(new TextField('NewField1'), new TextField('NewField2')), 'B');
     $this->assertEquals(array_keys($fields->dataFields()), array('A', 'NewField1', 'NewField2', 'B'));
 }
开发者ID:normann,项目名称:sapphire,代码行数:6,代码来源:FieldListTest.php

示例12: getEditForm

 /**
  * Gets the form used for viewing snippets
  * @param {int} $id ID of the record to fetch
  * @param {FieldList} $fields Fields to use
  * @return {Form} Form to be used
  */
 public function getEditForm($id = null, $fields = null)
 {
     if (!$id) {
         $id = $this->currentPageID();
     }
     $form = parent::getEditForm($id);
     $record = $this->getRecord($id);
     if ($record && !$record->canView()) {
         return Security::permissionFailure($this);
     }
     if (!$fields) {
         $fields = $form->Fields();
     }
     $actions = $form->Actions();
     if ($record) {
         $fields->push($idField = new HiddenField("ID", false, $id));
         $versions = $record->Versions()->filter('ID:not', $record->CurrentVersionID)->Map('ID', 'Created');
         $actions = new FieldList(new FormAction('doCopy', _t('CodeBank.COPY', '_Copy')), new FormAction('doEditRedirect', _t('CodeBank.EDIT', '_Edit')), new FormAction('doExport', _t('CodeBank.EXPORT', '_Export')), new FormAction('doPrint', _t('CodeBank.PRINT', '_Print')), new LabelField('Revision', _t('CodeBank.REVISION', '_Revision') . ': '), DropdownField::create('RevisionID', '', $versions, $this->urlParams['OtherID'])->setEmptyString('{' . _t('CodeBank.CURRENT_REVISION', '_Current Revision') . '}')->setDisabled($record->Versions()->Count() <= 1)->addExtraClass('no-change-track'), FormAction::create('compareRevision', _t('CodeBank.COMPARE_WITH_CURRENT', '_Compare with Current'))->setDisabled($record->Versions()->Count() <= 1 || empty($this->urlParams['OtherID']) || !is_numeric($this->urlParams['OtherID'])));
         // Use <button> to allow full jQuery UI styling
         $actionsFlattened = $actions->dataFields();
         if ($actionsFlattened) {
             foreach ($actionsFlattened as $action) {
                 if ($action instanceof FormAction) {
                     $action->setUseButtonTag(true);
                 }
             }
         }
         if ($record->hasMethod('getCMSValidator')) {
             $validator = $record->getCMSValidator();
         } else {
             $validator = new RequiredFields();
         }
         if ($record->Package() && $record->Package() !== false && $record->Package()->ID != 0) {
             $package = new ArrayList(array($record->Package()));
         } else {
             $package = null;
         }
         $fields->insertBefore($fields->dataFieldByName('Title'), 'LanguageID');
         $fields->replaceField('PackageID', new PackageViewField('PackageID', _t('Snippet.PACKAGE', '_Package'), $package, $record->ID));
         $fields->replaceField('Text', HighlightedContentField::create('SnippetText', _t('Snippet.CODE', '_Code'), $record->Language()->HighlightCode)->setForm($form));
         $fields->replaceField('Tags', new TagsViewField('Tags', _t('Snippet.TAGS_COLUMN', '_Tags')));
         $fields->addFieldToTab('Root.Main', $creator = ReadonlyField::create('CreatorName', _t('CodeBank.CREATOR', '_Creator'), $record->Creator() && $record->Creator()->ID > 0 ? '<a href="' . $this->Link() . '?creator=' . $record->CreatorID . '">' . $record->Creator()->Name . '</a>' : _t('CodeBank.UNKNOWN_USER', '_Unknown User'))->setForm($form));
         $creator->dontEscape = true;
         $fields->addFieldToTab('Root.Main', ReadonlyField::create('LanguageName', _t('CodeBank.LANGUAGE', '_Language'), $record->Language()->Name)->setForm($form));
         $fields->addFieldToTab('Root.Main', DatetimeField_Readonly::create('LastModified', _t('CodeBank.LAST_MODIFIED', '_Last Modified'), $record->CurrentVersion->LastEdited)->setForm($form));
         $fields->addFieldToTab('Root.Main', ReadonlyField::create('LastEditorName', _t('CodeBank.LAST_EDITED_BY', '_Last Edited By'), $record->LastEditor() && $record->LastEditor()->ID > 0 ? $record->LastEditor()->Name : _t('CodeBank.UNKNOWN_USER', '_Unknown User'))->setForm($form));
         $fields->addFieldToTab('Root.Main', ReadonlyField::create('SnippetID', _t('CodeBank.ID', '_ID'), $record->ID));
         $fields->addFieldToTab('Root.Main', ReadonlyField::create('CurrentVersionID', _t('CodeBank.VERSION', '_Version')));
         $fields->push(new HiddenField('ID', 'ID'));
         $form = new Form($this, 'EditForm', $fields, $actions, $validator);
         $form->loadDataFrom($record);
         $form->disableDefaultAction();
         $form->addExtraClass('cms-edit-form');
         $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
         $form->addExtraClass('center ' . $this->BaseCSSClasses());
         $form->setAttribute('data-pjax-fragment', 'CurrentForm');
         //Swap content for version text
         if (!empty($this->urlParams['OtherID']) && is_numeric($this->urlParams['OtherID'])) {
             $version = $record->Version(intval($this->urlParams['OtherID']));
             if (!empty($version) && $version !== false && $version->ID != 0) {
                 $fields->dataFieldByName('SnippetText')->setValue($version->Text);
                 $fields->dataFieldByName('LastModified')->setValue($version->LastEdited);
                 $fields->dataFieldByName('CurrentVersionID')->setValue($version->ID);
             }
             $form->Fields()->insertBefore(new LiteralField('NotCurrentVersion', '<p class="message warning">' . _t('CodeBank.NOT_CURRENT_VERSION', '_You are viewing a past version of this snippet\'s content, {linkopen}click here{linkclose} to view the current version', array('linkopen' => '<a href="admin/codeBank/show/' . $record->ID . '">', 'linkclose' => '</a>')) . '</p>'), 'Title');
         }
         $readonlyFields = $form->Fields()->makeReadonly();
         $form->setFields($readonlyFields);
         $this->extend('updateEditForm', $form);
         $form->Actions()->push(new LiteralField('CodeBankVersion', '<p class="codeBankVersion">Code Bank: ' . $this->getVersion() . '</p>'));
         Requirements::add_i18n_javascript(CB_DIR . '/javascript/lang');
         Requirements::add_i18n_javascript('mysite/javascript/lang');
         Requirements::javascript(CB_DIR . '/javascript/external/jquery-zclip/jquery.zclip.min.js');
         Requirements::javascript(CB_DIR . '/javascript/CodeBank.ViewForm.js');
         //Display message telling user to run dev/build because the version numbers are out of sync
         if (CB_VERSION != '@@VERSION@@' && CodeBankConfig::CurrentConfig()->Version != CB_VERSION . ' ' . CB_BUILD_DATE) {
             $form->Fields()->insertBefore(new LiteralField('DBUpgrade', '<p class="message error">' . _t('CodeBank.UPDATE_NEEDED', '_A database upgrade is required please run {startlink}dev/build{endlink}.', array('startlink' => '<a href="dev/build?flush=all">', 'endlink' => '</a>')) . '</p>'), 'Title');
         } else {
             if ($this->hasOldTables()) {
                 $form->Fields()->insertBefore(new LiteralField('DBUpgrade', '<p class="message warning">' . _t('CodeBank.MIGRATION_AVAILABLE', '_It appears you are upgrading from Code Bank 2.2.x, your old data can be migrated {startlink}click here to begin{endlink}, though it is recommended you backup your database first.', array('startlink' => '<a href="dev/tasks/CodeBankLegacyMigrate">', 'endlink' => '</a>')) . '</p>'), 'Title');
             }
         }
         return $form;
     } else {
         if ($id) {
             $form = CMSForm::create($this, 'EditForm', new FieldList(new TabSet('Root', new Tab('Main', ' ', new LabelField('DoesntExistLabel', _t('CodeBank.SNIPPIT_NOT_EXIST', '_Snippit does not exist'))))), new FieldList())->setHTMLID('Form_EditForm');
             $form->addExtraClass('cms-edit-form');
             $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
             $form->addExtraClass('center ' . $this->BaseCSSClasses());
             $form->setAttribute('data-pjax-fragment', 'CurrentForm');
             //Display message telling user to run dev/build because the version numbers are out of sync
             if (CB_VERSION != '@@VERSION@@' && CodeBankConfig::CurrentConfig()->Version != CB_VERSION . ' ' . CB_BUILD_DATE) {
                 $form->Fields()->insertBefore(new LiteralField('DBUpgrade', '<p class="message error">' . _t('CodeBank.UPDATE_NEEDED', '_A database upgrade is required please run {startlink}dev/build{endlink}.', array('startlink' => '<a href="dev/build?flush=all">', 'endlink' => '</a>')) . '</p>'), 'DoesntExist');
             } else {
//.........这里部分代码省略.........
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:101,代码来源:CodeBank.php

示例13: SearchForm

 function SearchForm()
 {
     // get all page types in a dropdown-compatible format
     $pageTypeClasses = SiteTree::page_type_classes();
     $pageTypes = array();
     foreach ($pageTypeClasses as $pageTypeClass) {
         $pageTypes[$pageTypeClass] = _t($pageTypeClass . '.SINGULARNAME', $pageTypeClass);
     }
     asort($pageTypes);
     // get all filter instances
     $filters = ClassInfo::subclassesFor('CMSSiteTreeFilter');
     $filterMap = array();
     // remove base class
     array_shift($filters);
     // add filters to map
     foreach ($filters as $filter) {
         $filterMap[$filter] = call_user_func(array($filter, 'title'));
     }
     // ensure that 'all pages' filter is on top position
     uasort($filterMap, create_function('$a,$b', 'return ($a == "CMSSiteTreeFilter_Search") ? 1 : -1;'));
     $fields = new FieldList(new TextField('q[Term]', _t('CMSSearch.FILTERLABELTEXT', 'Content')), $dateGroup = new FieldGroup(new HeaderField('q[Date]', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4), $dateFrom = new DateField('q[LastEditedFrom]', _t('CMSSearch.FILTERDATEFROM', 'From')), $dateTo = new DateField('q[LastEditedTo]', _t('CMSSearch.FILTERDATETO', 'To'))), new DropdownField('q[FilterClass]', _t('CMSMain.PAGES', 'Pages'), $filterMap), $classDropdown = new DropdownField('q[ClassName]', _t('CMSMain.PAGETYPEOPT', 'Page Type', 'Dropdown for limiting search to a page type'), $pageTypes));
     $dateGroup->setFieldHolderTemplate('FieldGroup_DefaultFieldHolder')->addExtraClass('stacked');
     $dateFrom->setConfig('showcalendar', true);
     $dateTo->setConfig('showcalendar', true);
     $classDropdown->setEmptyString(_t('CMSMain.PAGETYPEANYOPT', 'Any'));
     $actions = new FieldList(FormAction::create('doSearch', _t('CMSMain_left.ss.APPLY FILTER', 'Apply Filter'))->addExtraClass('ss-ui-action-constructive'), Object::create('ResetFormAction', 'clear', _t('CMSMain_left.ss.RESET', 'Reset')));
     // Use <button> to allow full jQuery UI styling
     foreach ($actions->dataFields() as $action) {
         $action->setUseButtonTag(true);
     }
     $form = Form::create($this, 'SearchForm', $fields, $actions)->addExtraClass('cms-search-form')->setFormMethod('GET')->setFormAction($this->Link())->disableSecurityToken()->unsetValidator();
     $form->loadDataFrom($this->request->getVars());
     $this->extend('updateSearchForm', $form);
     return $form;
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:35,代码来源:CMSMain.php

示例14: SearchForm

 /**
  * Returns a Form for field searching for use in templates.
  * Can be modified from a decorator by a 'updateSearchForm' method
  *
  * @return CMSForm
  */
 public function SearchForm()
 {
     // Search fields
     $fields = new FieldList(new TextField('q[Term]', _t('CMSSearch.QUERY', 'Query')));
     // Submit and reset buttons
     $actions = new FieldList(FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Apply Filter'))->addExtraClass('ss-ui-action-constructive'), Object::create('ResetFormAction', 'clear', _t('CMSMain_left_ss.RESET', 'Reset')));
     // Use <button> to allow full jQuery UI styling on the all of the Actions
     foreach ($actions->dataFields() as $action) {
         $action->setUseButtonTag(true);
     }
     // Create the form
     $form = CMSForm::create($this, 'SearchForm', $fields, $actions)->addExtraClass('cms-search-form')->setFormMethod('GET')->setFormAction($this->Link('filter'))->disableSecurityToken()->unsetValidator();
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->disableDefaultAction();
     // Load the form with previously sent search data
     $form->loadDataFrom($this->request->getVars());
     // Allow decorators to modify the form
     $this->extend('updateSearchForm', $form);
     return $form;
 }
开发者ID:helpfulrobot,项目名称:satrun77-editablefield,代码行数:26,代码来源:EditableFieldAdmin.php

示例15: getEditForm

 /**
  * Gets the form used for viewing snippets
  * @param {int} $id ID of the record to fetch
  * @param {FieldList} $fields Fields to use
  * @return {Form} Form to be used
  */
 public function getEditForm($id = null, $fields = null)
 {
     if (!$id) {
         $id = $this->currentPageID();
     }
     $record = $this->getRecord($id);
     if ($record && !$record->canView()) {
         return Security::permissionFailure($this);
     }
     if ($record) {
         $fields = $record->getCMSFields();
         $actions = new FieldList(FormAction::create('doSave', _t('CodeBank.SAVE', '_Save'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'), FormAction::create('doCancel', _t('CodeBank.CANCEL', '_Cancel')));
         if ($record->canDelete()) {
             $actions->push(FormAction::create('doDelete', _t('CodeBank.DELETE', '_Delete'))->addExtraClass('ss-ui-action-destructive'));
         }
         // Use <button> to allow full jQuery UI styling
         $actionsFlattened = $actions->dataFields();
         if ($actionsFlattened) {
             foreach ($actionsFlattened as $action) {
                 if ($action instanceof FormAction) {
                     $action->setUseButtonTag(true);
                 }
             }
         }
         if ($record->hasMethod('getCMSValidator')) {
             $validator = $record->getCMSValidator();
         } else {
             $validator = new RequiredFields();
         }
         $fields->push(new HiddenField('ID', 'ID'));
         $form = CMSForm::create($this, 'EditForm', $fields, $actions, $validator)->setHTMLID('Form_EditForm');
         $form->loadDataFrom($record);
         $form->disableDefaultAction();
         $form->addExtraClass('cms-edit-form');
         $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
         $form->addExtraClass('center ' . $this->BaseCSSClasses());
         $form->setResponseNegotiator($this->getResponseNegotiator());
         $form->setAttribute('data-pjax-fragment', 'CurrentForm');
         $this->extend('updateEditForm', $form);
         //Display message telling user to run dev/build because the version numbers are out of sync
         if (CB_VERSION != '@@VERSION@@' && CodeBankConfig::CurrentConfig()->Version != CB_VERSION . ' ' . CB_BUILD_DATE) {
             $form->insertBefore(new LiteralField('<p class="message error">' . _t('CodeBank.UPDATE_NEEDED', '_A database upgrade is required please run {startlink}dev/build{endlink}.', array('startlink' => '<a href="dev/build?flush=all">', 'endlink' => '</a>')) . '</p>'), 'LanguageID');
         } else {
             if ($this->hasOldTables()) {
                 $form->insertBefore(new LiteralField('<p class="message warning">' . _t('CodeBank.MIGRATION_AVAILABLE', '_It appears you are upgrading from Code Bank 2.2.x, your old data can be migrated {startlink}click here to begin{endlink}, though it is recommended you backup your database first.', array('startlink' => '<a href="dev/tasks/CodeBankLegacyMigrate">', 'endlink' => '</a>')) . '</p>'), 'LanguageID');
             }
         }
         $form->Actions()->push(new LiteralField('CodeBankVersion', '<p class="codeBankVersion">Code Bank: ' . $this->getVersion() . '</p>'));
         Requirements::javascript(CB_DIR . '/javascript/CodeBank.EditForm.js');
         return $form;
     }
     $form = $this->EmptyForm();
     if (Session::get('CodeBank.deletedSnippetID')) {
         $form->Fields()->push(new HiddenField('ID', 'ID', Session::get('CodeBank.deletedSnippetID')));
     }
     //Display message telling user to run dev/build because the version numbers are out of sync
     if (CB_VERSION != '@@VERSION@@' && CodeBankConfig::CurrentConfig()->Version != CB_VERSION . ' ' . CB_BUILD_DATE) {
         $form->push(new LiteralField('<p class="message error">' . _t('CodeBank.UPDATE_NEEDED', '_A database upgrade is required please run {startlink}dev/build{endlink}.', array('startlink' => '<a href="dev/build?flush=all">', 'endlink' => '</a>')) . '</p>'));
     } else {
         if ($this->hasOldTables()) {
             $form->push(new LiteralField('<p class="message warning">' . _t('CodeBank.MIGRATION_AVAILABLE', '_It appears you are upgrading from Code Bank 2.2.x, your old data can be migrated {startlink}click here to begin{endlink}, though it is recommended you backup your database first.', array('startlink' => '<a href="dev/tasks/CodeBankLegacyMigrate">', 'endlink' => '</a>')) . '</p>'));
         }
     }
     $this->redirect('admin/codeBank/');
     return $form;
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:72,代码来源:CodeBankEditSnippet.php


注:本文中的FieldList::dataFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。