本文整理匯總了PHP中FieldSet::addFieldsToTab方法的典型用法代碼示例。如果您正苦於以下問題:PHP FieldSet::addFieldsToTab方法的具體用法?PHP FieldSet::addFieldsToTab怎麽用?PHP FieldSet::addFieldsToTab使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FieldSet
的用法示例。
在下文中一共展示了FieldSet::addFieldsToTab方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: updateCMSFields
/**
* Add custom form fields into the CMS Main tab
*
* @return void
*/
public function updateCMSFields(FieldSet &$fields)
{
$fields->addFieldsToTab('Root.GoogleSEO', array(new HeaderField('Google Codes', 1), new HeaderField('SiteWide', 2), new TextField('GoogleVerificationCode', 'Verification Code (code only)'), new TextField('GoogleAnalyticsCode', 'Analytics Code (code only, starting with UA-)')));
$fields->addFieldsToTab('Root.DefaultLinks', array(new HeaderField('Links & Messages for site users', 1), new TextField('HelpEmail', 'Help Email, used in footer and cross site'), new TextField('LearnLink', 'Link for Learn Site Section'), new TextField('CreateLink', 'Link for Create Site Section'), new TextField('FindLink', 'Link for Find Site Section'), new TextField('ShareLink', 'Link for Share Site Section'), new TextField('MyEventsLink', 'Link for Account Menu -> Events Site Section'), new TextField('MyEventsTitle', 'Title for Account Menu -> Events Site Section'), new TextField('MyResultsLink', 'Link for Account Menu -> Results Site Section'), new TextField('MyResultsTitle', 'Title for Account Menu -> Results Site Section'), new TextField('MyAccountLink', 'Link for Account Menu -> Account Site Section')));
$fields->addFieldsToTab('Root.UserMessages', array(new HtmlEditorField('CreateAccountContent', 'Prompt Member to Create an Account', 4, 20), new HtmlEditorField('LoginContent', 'Prompt Member to Login', 4, 20), new HtmlEditorField('MyEventsContent', 'User Account Content', 4, 20), new HtmlEditorField('MemberDefaultMessage', 'Message Shown on Incorrect Login, Admin Login and Permissions Error', 4, 20), new TextField('MemberFormTitle', 'Title Shown on Incorrect Login, Admin Login and Permissions Error')));
$fields->addFieldsToTab('Root.FooterContent', array(new TextField('FooterFAQLink', 'URL Segement for FAQ link in footer e.g about/'), new TextField('FooterCol1title', 'Title Col1'), new TextareaField('FooterSocialMediaMessage', 'Social Media Message'), new HtmlEditorField('FooterCol1content', 'Footer Column 1 Content', 4, 20), new TextField('FooterCol2title', 'Title Col1'), new HtmlEditorField('FooterCol2content', 'Footer Column 1 Content', 4, 20), new TextField('FooterCol3title', 'Title Col1'), new HtmlEditorField('FooterCol3content', 'Footer Column 1 Content', 4, 20)));
}
示例2: updateCMSFields
public function updateCMSFields(FieldSet &$fields)
{
$fields->addFieldsToTab('Root.SocialMedia', new TextField('FacebookAccessToken', 'Facebook access token'));
$fields->addFieldsToTab('Root.SocialMedia', new TextField('FacebookAppId', 'Facebook app ID'));
$fields->addFieldsToTab('Root.SocialMedia', new PasswordField('FacebookAppSecret', 'Facebook app Secret'));
$fields->addFieldsToTab('Root.SocialMedia', new TextField('FacebookUserId', 'Facebook user/page ID'));
return $fields;
}
開發者ID:helpfulrobot,項目名稱:pitchandtone-silverstripe-facebookpush,代碼行數:8,代碼來源:FacebookSiteConfigMixin.php
示例3: updateCMSFields
/**
*
* @param FieldSet $fields
*/
public function updateCMSFields($fields)
{
$fields->addFieldsToTab('Root.Schedule', array($dt = new Datetimefield('FirstExecution', _t('ScheduledExecution.FIRST_EXECUTION', 'First Execution')), new DropdownField('ExecuteEvery', _t('ScheduledExecution.EXECUTE_EVERY', 'Execute every'), $this->owner->dbObject('ExecuteEvery')->enumValues()), new TextField('ExecuteFree', _t('ScheduledExecution.EXECUTE_FREE', 'Scheduled (in strtotime format from first execution)'))));
if ($this->owner->ScheduledJobID) {
$jobTime = $this->owner->ScheduledJob()->StartAfter;
$fields->addFieldsToTab('Root.Schedule', array(new ReadonlyField('NextRunDate', _t('ScheduledExecution.NEXT_RUN_DATE', 'Next run date'), $jobTime)));
}
$dt->getDateField()->setConfig('showcalendar', true);
$dt->getTimeField()->setConfig('showdropdown', true);
}
示例4: updateCMSFields
/**
* Update SiteConfig with the top level fields
*
* @param FieldSet $fields
* @return void
*/
function updateCMSFields(&$fields)
{
$fields->addFieldsToTab("Root.Access", array(new HeaderField(_t('SiteTreeCMSWorkflow.APPROVEHEADER', "Who can approve requests inside the CMS?"), 2), $approveTypeField = new OptionsetField("CanApproveType", "", array("LoggedInUsers" => _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS"), "OnlyTheseUsers" => _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)")), "OnlyTheseUsers"), $approverGroupsField = new TreeMultiselectField("ApproverGroups", "Approver groups")));
$fields->addFieldsToTab("Root.Access", array(new HeaderField(_t('SiteTreeCMSWorkflow.PUBLISHAPPROVEDHEADER', "Who can publish approved requests inside the CMS?"), 2), $actionTypeField = new OptionsetField("CanPublishType", "", array("LoggedInUsers" => _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS"), "OnlyTheseUsers" => _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)")), "OnlyTheseUsers"), $actionerGroupsField = new TreeMultiselectField("PublisherGroups", "Publisher groups")));
if (!Permission::check('EDIT_SITECONFIG')) {
$fields->replaceField('CanApproveType', $approveTypeField->performReadonlyTransformation());
$fields->replaceField('ApproverGroups', $approverGroupsField->performReadonlyTransformation());
$fields->replaceField('CanPublishType', $actionTypeField->performReadonlyTransformation());
$fields->replaceField('PublisherGroups', $actionerGroupsField->performReadonlyTransformation());
}
}
示例5: updateCMSFields
public function updateCMSFields(FieldSet &$fields)
{
$tablefield = new DataObjectManager($this->owner, 'Places', 'Place', array('Name' => 'Nombre', 'Lng' => 'Longitud', 'Lat' => 'Latitud'), 'getCMSFields_forPopUp');
$tablefield->setPageSize(100);
$contactDetailsTab = _t('HomePage.CONTACTDETAILSTAB', "ContactDetails");
$fields->addFieldsToTab('Root.' . $contactDetailsTab, $tablefield);
}
示例6: updateCMSFields
/**
* @param FieldSet $fields
*/
public function updateCMSFields($fields)
{
$fields->addFieldsToTab('Root.Content.PublishingSchedule', array($dt = new Datetimefield('PublishOnDate', _t('AdvancedWorkflow.PUBLISH_ON', 'Publish on')), $ut = new Datetimefield('UnPublishOnDate', _t('AdvancedWorkflow.UNPUBLISH_ON', 'Un-publish on'))));
$dt->getDateField()->setConfig('showcalendar', true);
$dt->getTimeField()->setConfig('showdropdown', true);
$ut->getDateField()->setConfig('showcalendar', true);
$ut->getTimeField()->setConfig('showdropdown', true);
}
示例7: updateCMSFields
public function updateCMSFields(FieldSet $fields)
{
$fields->replaceField('TrackedLinks', $tracked = new TableListField('LinkViews', 'NewsletterLinkView', null, '"NewsletterID" = ' . $this->owner->ID, '"Created" DESC'));
$tracked->setPermissions(array('show', 'export'));
$viewers = new TableListField('Views', 'NewsletterView', null, '"NewsletterID" = ' . $this->owner->ID, '"Created" DESC');
$viewers->setPermissions(array('show', 'export'));
$fields->addFieldsToTab('Root.ViewedBy', array(new LiteralField('ViewsNote', '<p>The viewed by list may not be ' . 'accurate, as many email clients block images used for ' . 'tracking by default.</p>'), $viewers));
}
示例8: testRemoveMultipleFieldsFromTab
/**
* Test removing an array of fields from a tab in a set.
*/
function testRemoveMultipleFieldsFromTab()
{
$fields = new FieldSet();
$tab = new Tab('Root');
$fields->push($tab);
/* We add an array of fields, using addFieldsToTab() */
$fields->addFieldsToTab('Root', array(new TextField('Name', 'Your name'), new EmailField('Email', 'Email address'), new NumericField('Number', 'Insert a number')));
/* We have 3 fields inside the tab, which we just created */
$this->assertEquals(3, $tab->Fields()->Count());
/* We remove the 3 fields from the tab */
$fields->removeFieldsFromTab('Root', array('Name', 'Email', 'Number'));
/* We have no fields in the tab now */
$this->assertEquals(0, $tab->Fields()->Count());
}
示例9: updateCMSFields
/**
* Change the member dialog in the CMS
*
* This method updates the forms in the cms to allow the translations for
* the defined translatable fields.
*/
function updateCMSFields(FieldSet &$fields)
{
if (!$this->stat('enabled')) {
return false;
}
$creating = false;
$baseClass = $this->owner->class;
while (($p = get_parent_class($baseClass)) != "DataObject") {
$baseClass = $p;
}
$allFields = $this->owner->getAllFields();
if (!self::is_default_lang()) {
// Get the original version record, to show the original values
if (!is_numeric($allFields['ID'])) {
$originalLangID = Session::get($this->owner->ID . '_originalLangID');
$creating = true;
} else {
$originalLangID = $allFields['ID'];
}
$originalRecord = self::get_one_by_lang($this->owner->class, self::$default_lang, "`{$baseClass}`.ID = " . $originalLangID);
$this->original_values = $originalRecord->getAllFields();
$alltasks = array('dup' => array());
foreach ($fields as $field) {
if ($field->isComposite()) {
$innertasks = $this->duplicateOrReplaceFields($field->FieldSet());
// more efficient and safe than array_merge_recursive
$alltasks['dup'] = array_merge($alltasks['dup'], $innertasks['dup']);
}
}
foreach ($alltasks['dup'] as $fieldname => $newfield) {
// Duplicate the field
$fields->replaceField($fieldname, $newfield);
}
} else {
$alreadyTranslatedLangs = null;
if (is_numeric($allFields['ID'])) {
$alreadyTranslatedLangs = self::get_langs_by_id($baseClass, $allFields['ID']);
}
if (!$alreadyTranslatedLangs) {
$alreadyTranslatedLangs = array();
}
foreach ($alreadyTranslatedLangs as $i => $langCode) {
$alreadyTranslatedLangs[$i] = i18n::get_language_name($langCode);
}
$fields->addFieldsToTab('Root', new Tab(_t('Translatable.TRANSLATIONS', 'Translations'), new HeaderField(_t('Translatable.CREATE', 'Create new translation'), 2), $langDropdown = new LanguageDropdownField("NewTransLang", _t('Translatable.NEWLANGUAGE', 'New language'), $alreadyTranslatedLangs), $createButton = new InlineFormAction('createtranslation', _t('Translatable.CREATEBUTTON', 'Create'))));
if (count($alreadyTranslatedLangs)) {
$fields->addFieldsToTab('Root.Translations', new FieldSet(new HeaderField(_t('Translatable.EXISTING', 'Existing translations:'), 3), new LiteralField('existingtrans', implode(', ', $alreadyTranslatedLangs))));
}
$langDropdown->addExtraClass('languageDropdown');
$createButton->addExtraClass('createTranslationButton');
$createButton->includeDefaultJS(false);
}
}
示例10: updateCMSFields
/**
* If the record is not shown in the default language, this method
* will try to autoselect a master language which is shown alongside
* the normal formfields as a readonly representation.
* This gives translators a powerful tool for their translation workflow
* without leaving the translated page interface.
* Translatable also adds a new tab "Translation" which shows existing
* translations, as well as a formaction to create new translations based
* on a dropdown with available languages.
*
* @todo This is specific to SiteTree and CMSMain
* @todo Implement a special "translation mode" which triggers display of the
* readonly fields, so you can translation INTO the "default language" while
* seeing readonly fields as well.
*/
function updateCMSFields(FieldSet &$fields)
{
// Don't apply these modifications for normal DataObjects - they rely on CMSMain logic
if (!$this->owner instanceof SiteTree) {
return;
}
// used in CMSMain->init() to set language state when reading/writing record
$fields->push(new HiddenField("Locale", "Locale", $this->owner->Locale));
// Don't allow translation of virtual pages because of data inconsistencies (see #5000)
$excludedPageTypes = array('VirtualPage');
foreach ($excludedPageTypes as $excludedPageType) {
if (is_a($this->owner, $excludedPageType)) {
return;
}
}
$excludeFields = array('ViewerGroups', 'EditorGroups', 'CanViewType', 'CanEditType');
// if a language other than default language is used, we're in "translation mode",
// hence have to modify the original fields
$creating = false;
$baseClass = $this->owner->class;
$allFields = $fields->toArray();
while (($p = get_parent_class($baseClass)) != "DataObject") {
$baseClass = $p;
}
// try to get the record in "default language"
$originalRecord = $this->owner->getTranslation(Translatable::default_locale());
// if no translation in "default language", fall back to first translation
if (!$originalRecord) {
$translations = $this->owner->getTranslations();
$originalRecord = $translations ? $translations->First() : null;
}
$isTranslationMode = $this->owner->Locale != Translatable::default_locale();
// Show a dropdown to create a new translation.
// This action is possible both when showing the "default language"
// and a translation. Include the current locale (record might not be saved yet).
$alreadyTranslatedLocales = $this->getTranslatedLocales();
$alreadyTranslatedLocales[$this->owner->Locale] = $this->owner->Locale;
if ($originalRecord && $isTranslationMode) {
$originalLangID = Session::get($this->owner->ID . '_originalLangID');
// Remove parent page dropdown
$fields->removeByName("ParentType");
$fields->removeByName("ParentID");
$translatableFieldNames = $this->getTranslatableFields();
$allDataFields = $fields->dataFields();
$transformation = new Translatable_Transformation($originalRecord);
// iterate through sequential list of all datafields in fieldset
// (fields are object references, so we can replace them with the translatable CompositeField)
foreach ($allDataFields as $dataField) {
if ($dataField instanceof HiddenField) {
continue;
}
if (in_array($dataField->Name(), $excludeFields)) {
continue;
}
if (in_array($dataField->Name(), $translatableFieldNames)) {
// if the field is translatable, perform transformation
$fields->replaceField($dataField->Name(), $transformation->transformFormField($dataField));
} else {
// else field shouldn't be editable in translation-mode, make readonly
$fields->replaceField($dataField->Name(), $dataField->performReadonlyTransformation());
}
}
} elseif ($this->owner->isNew()) {
$fields->addFieldsToTab('Root', new Tab(_t('Translatable.TRANSLATIONS', 'Translations'), new LiteralField('SaveBeforeCreatingTranslationNote', sprintf('<p class="message">%s</p>', _t('Translatable.NOTICENEWPAGE', 'Please save this page before creating a translation')))));
}
$fields->addFieldsToTab('Root', new Tab('Translations', _t('Translatable.TRANSLATIONS', 'Translations'), new HeaderField('CreateTransHeader', _t('Translatable.CREATE', 'Create new translation'), 2), $langDropdown = new LanguageDropdownField("NewTransLang", _t('Translatable.NEWLANGUAGE', 'New language'), $alreadyTranslatedLocales, 'SiteTree', 'Locale-English', $this->owner), $createButton = new InlineFormAction('createtranslation', _t('Translatable.CREATEBUTTON', 'Create'))));
$createButton->includeDefaultJS(false);
if ($alreadyTranslatedLocales) {
$fields->addFieldToTab('Root.Translations', new HeaderField('ExistingTransHeader', _t('Translatable.EXISTING', 'Existing translations:'), 3));
$existingTransHTML = '<ul>';
foreach ($alreadyTranslatedLocales as $i => $langCode) {
$existingTranslation = $this->owner->getTranslation($langCode);
if ($existingTranslation) {
$existingTransHTML .= sprintf('<li><a href="%s">%s</a></li>', sprintf('admin/show/%d/?locale=%s', $existingTranslation->ID, $langCode), i18n::get_locale_name($langCode));
}
}
$existingTransHTML .= '</ul>';
$fields->addFieldToTab('Root.Translations', new LiteralField('existingtrans', $existingTransHTML));
}
$langDropdown->addExtraClass('languageDropdown');
$createButton->addExtraClass('createTranslationButton');
}
示例11: RootForm
/**
* @return FieldSet
*/
function RootForm()
{
$memberList = new MemberTableField($this, "Members");
// unset 'inlineadd' permission, we don't want inline addition
$memberList->setPermissions(array('edit', 'delete', 'add'));
$memberList->setRelationAutoSetting(false);
$fields = new FieldSet(new TabSet('Root', new Tab('Members', singleton('Member')->i18n_plural_name(), $memberList, new LiteralField('MembersCautionText', sprintf('<p class="caution-remove"><strong>%s</strong></p>', _t('SecurityAdmin.MemberListCaution', 'Caution: Removing members from this list will remove them from all groups and the database'))))), new HiddenField('ID', false, 0));
// Add import capabilities. Limit to admin since the import logic can affect assigned permissions
if (Permission::check('ADMIN')) {
$fields->addFieldsToTab('Root', new Tab('Import', _t('SecurityAdmin.TABIMPORT', 'Import'), new LiteralField('GroupImportFormIframe', sprintf('<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="400px" border="0"></iframe>', $this->Link('groupimport')))));
}
// Add roles editing interface
if (Permission::check('APPLY_ROLES')) {
$rolesCTF = new ComplexTableField($this, 'Roles', 'PermissionRole');
$rolesCTF->setPermissions(array('add', 'edit', 'delete'));
$rolesTab = $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.TABROLES', 'Roles'));
$rolesTab->push(new LiteralField('RolesDescription', ''));
$rolesTab->push($rolesCTF);
}
$actions = new FieldSet(new FormAction('addmember', _t('SecurityAdmin.ADDMEMBER', 'Add Member')));
$this->extend('updateRootFormFields', $fields, $actions);
$form = new Form($this, 'EditForm', $fields, $actions);
return $form;
}
示例12: updateCMSFields
function updateCMSFields(FieldSet &$fields) {
if(!$this->stat('enabled', true)) return false;
// add hidden fields for the used language and original record
$fields->push(new HiddenField("Lang", "Lang", $this->getLang()) );
$fields->push(new HiddenField("OriginalID", "OriginalID", $this->owner->OriginalID) );
// if a language other than default language is used, we're in "translation mode",
// hence have to modify the original fields
$isTranslationMode = (Translatable::default_lang() != $this->getLang() && $this->getLang());
if($isTranslationMode) {
$originalLangID = Session::get($this->owner->ID . '_originalLangID');
$translatableFieldNames = $this->getTranslatableFields();
$allDataFields = $fields->dataFields();
$transformation = new Translatable_Transformation(Translatable::get_original($this->owner->class, $this->owner->ID));
// iterate through sequential list of all datafields in fieldset
// (fields are object references, so we can replace them with the translatable CompositeField)
foreach($allDataFields as $dataField) {
if(in_array($dataField->Name(), $translatableFieldNames)) {
//var_dump($dataField->Name());
// if the field is translatable, perform transformation
$fields->replaceField($dataField->Name(), $transformation->transformFormField($dataField));
} else {
// else field shouldn't be editable in translation-mode, make readonly
$fields->replaceField($dataField->Name(), $dataField->performReadonlyTransformation());
}
}
} else {
// if we're not in "translation mode", show a dropdown to create a new translation.
// this action should just be possible when showing the default language,
// you can't create new translations from within a "translation mode" form.
$alreadyTranslatedLangs = array();
foreach ($alreadyTranslatedLangs as $i => $langCode) {
$alreadyTranslatedLangs[$i] = i18n::get_language_name($langCode);
}
$fields->addFieldsToTab(
'Root',
new Tab(_t('Translatable.TRANSLATIONS', 'Translations'),
new HeaderField('CreateTransHeader', _t('Translatable.CREATE', 'Create new translation'), 2),
$langDropdown = new LanguageDropdownField("NewTransLang", _t('Translatable.NEWLANGUAGE', 'New language'), $alreadyTranslatedLangs),
$createButton = new InlineFormAction('createtranslation',_t('Translatable.CREATEBUTTON', 'Create'))
)
);
if (count($alreadyTranslatedLangs)) {
$fields->addFieldsToTab(
'Root.Translations',
new FieldSet(
new HeaderField('ExistingTransHeader', _t('Translatable.EXISTING', 'Existing translations:'), 3),
new LiteralField('existingtrans',implode(', ',$alreadyTranslatedLangs))
)
);
}
$langDropdown->addExtraClass('languageDropdown');
$createButton->addExtraClass('createTranslationButton');
$createButton->includeDefaultJS(false);
}
}
示例13: updateCMSFields
/**
* Standard SS method
*
*/
function updateCMSFields(FieldSet &$fields)
{
if ($this->owner->isCorporateAccount()) {
$fields->addFieldsToTab('Root.Addresses', $this->owner->CorporateAddressFieldsArray($forCMS = true));
$header = _t("EcommerceCorporateGroup.NOTAPPROVEDACCOUNT", "NB: This is an approved account group.");
} else {
$header = _t("EcommerceCorporateGroup.NOTAPPROVEDACCOUNT", "NB: This is NOT an approved account group");
}
$fields->addFieldToTab('Root.Members', new HeaderField("ApprovedAccountGroup", $header), "Title");
}
開發者ID:helpfulrobot,項目名稱:sunnysideup-ecommerce-corporate-account,代碼行數:14,代碼來源:EcommerceCorporateGroupGroupDecorator.php
示例14: getInstanceManagementFields
/**
* Get fields to update a workflow instance directly. Will attempt to allow the user to modify the current
* step if possible
*
* @return FieldSet
*/
public function getInstanceManagementFields()
{
$fields = new FieldSet(new TabSet('Root', new Tab('Main', new HeaderField('AssignedToHeader', _t('WorkflowInstance.ASSIGNEDTO', 'Assigned To')), new TreeMultiselectField('Users', _t('WorkflowDefinition.USERS', 'Users'), 'Member'), new TreeMultiselectField('Groups', _t('WorkflowDefinition.GROUPS', 'Groups'), 'Group'))));
$target = $this->getTarget();
if ($target && $target->canEditWorkflow()) {
$wfFields = $this->getWorkflowFields();
$tmpForm = new Form($this, 'dummy', $wfFields, new FieldSet());
$wfFields->push(new HiddenField('DirectUpdate', 'Direct Update', true));
$tmpForm->loadDataFrom($this->CurrentAction());
$wfFields = $tmpForm->Fields();
$fields->addFieldsToTab('Root.WorkflowActions', $wfFields);
}
return $fields;
}
示例15: testInsertBeforeMultipleFields
function testInsertBeforeMultipleFields()
{
$fields = new FieldSet($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'));
}