/**
  * Gets the form fields as defined through the metadata
  * on {@link $obj} and the custom parameters passed to FormScaffolder.
  * Depending on those parameters, the fields can be used in ajax-context,
  * contain {@link TabSet}s etc.
  * 
  * @return FieldList
  */
 public function getFieldList()
 {
     $fields = new FieldList();
     // tabbed or untabbed
     if ($this->tabbed) {
         $fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
         $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     }
     //var_dump($this->obj->db());exit();
     // add database fields
     foreach ($this->obj->db() as $fieldName => $fieldType) {
         if ($this->restrictFields && !in_array($fieldName, $this->restrictFields)) {
             continue;
         }
         // @todo Pass localized title
         if ($this->fieldClasses && isset($this->fieldClasses[$fieldName])) {
             $fieldClass = $this->fieldClasses[$fieldName];
             $fieldObject = new $fieldClass($fieldName);
         } else {
             $fieldObject = $this->obj->dbObject($fieldName)->scaffoldFormField(null, $this->getParamsArray());
         }
         $fieldObject->setTitle($this->obj->fieldLabel($fieldName));
         if ($this->tabbed) {
             $fields->addFieldToTab("Root.Main", $fieldObject);
         } else {
             $fields->push($fieldObject);
         }
     }
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->insertBefore($shoptab = new Tab('Shop', 'Shop'), 'Access');
     $fields->addFieldsToTab("Root.Shop", new TabSet("ShopTabs", $maintab = new Tab("Main", TreeDropdownField::create('TermsPageID', _t("ShopConfig.TERMSPAGE", 'Terms and Conditions Page'), 'SiteTree'), TreeDropdownField::create("CustomerGroupID", _t("ShopConfig.CUSTOMERGROUP", "Group to add new customers to"), "Group"), UploadField::create('DefaultProductImage', _t('ShopConfig.DEFAULTIMAGE', 'Default Product Image'))), $countriestab = new Tab("Countries", CheckboxSetField::create('AllowedCountries', 'Allowed Ordering and Shipping Countries', self::config()->iso_3166_country_codes))));
     $fields->removeByName("CreateTopLevelGroups");
     $countriestab->setTitle("Allowed Countries");
 }
Beispiel #3
0
 /**
  * Get the fields that are sent to the CMS. In
  * your decorators: updateCMSFields(&$fields)
  *
  * @return Fieldset
  */
 function getCMSFields()
 {
     Requirements::javascript(CMS_DIR . "/javascript/SitetreeAccess.js");
     $fields = new FieldSet(new TabSet("Root", $tabMain = new Tab('Main', $titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")), $taglineField = new TextField("Tagline", _t('SiteConfig.SITETAGLINE', "Site Tagline/Slogan")), new DropdownField("Theme", _t('SiteConfig.THEME', 'Theme'), $this->getAvailableThemes(), '', null, _t('SiteConfig.DEFAULTTHEME', '(Use default theme)'))), $tabAccess = new Tab('Access', new HeaderField('WhoCanViewHeader', _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?"), 2), $viewersOptionsField = new OptionsetField("CanViewType"), $viewerGroupsField = new TreeMultiselectField("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups")), new HeaderField('WhoCanEditHeader', _t('SiteConfig.EDITHEADER', "Who can edit pages on this site?"), 2), $editorsOptionsField = new OptionsetField("CanEditType"), $editorGroupsField = new TreeMultiselectField("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups")), new HeaderField('WhoCanCreateTopLevelHeader', _t('SiteConfig.TOPLEVELCREATE', "Who can create pages in the root of the site?"), 2), $topLevelCreatorsOptionsField = new OptionsetField("CanCreateTopLevelType"), $topLevelCreatorsGroupsField = new TreeMultiselectField("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators")))));
     $viewersOptionsSource = array();
     $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
     $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
     $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
     $viewersOptionsField->setSource($viewersOptionsSource);
     $editorsOptionsSource = array();
     $editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
     $editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
     $editorsOptionsField->setSource($editorsOptionsSource);
     $topLevelCreatorsOptionsField->setSource($editorsOptionsSource);
     // Translatable doesn't handle updateCMSFields on DataObjects,
     // so add it here to save the current Locale,
     // because onBeforeWrite does not work.
     if (Object::has_extension('SiteConfig', "Translatable")) {
         $fields->push(new HiddenField("Locale"));
     }
     if (!Permission::check('EDIT_SITECONFIG')) {
         $fields->makeFieldReadonly($viewersOptionsField);
         $fields->makeFieldReadonly($viewerGroupsField);
         $fields->makeFieldReadonly($editorsOptionsField);
         $fields->makeFieldReadonly($editorGroupsField);
         $fields->makeFieldReadonly($topLevelCreatorsOptionsField);
         $fields->makeFieldReadonly($topLevelCreatorsGroupsField);
         $fields->makeFieldReadonly($taglineField);
         $fields->makeFieldReadonly($titleField);
     }
     $tabMain->setTitle(_t('SiteConfig.TABMAIN', "Main"));
     $tabAccess->setTitle(_t('SiteConfig.TABACCESS', "Access"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 function updateCMSFields(&$fields)
 {
     /*
      * don't want slideshow on a redirector page
      */
     if ($this->owner->ClassName == 'RedirectorPage') {
         return $fields;
     }
     /*
      * if this is a new page set defaults 
      */
     if ($this->owner->Version == 1) {
         $this->set_defaults();
     }
     $tabSlides = new Tab('Slides');
     $tabSlides->setTitle(_t('Slideshow.SLIDESTABTITLE', 'Slides'));
     $tabSettings = new Tab('Settings');
     $tabSettings->setTitle(_t('Slideshow.SETTINGSTABTITLE', 'Settings'));
     $tabSlideShow = new TabSet('SlideshowTabs', $tabSlides, $tabSettings);
     $tabSlideShow->setTitle(_t('Slideshow.SLIDESHOWTABTITLE', 'Slideshow'));
     $fields->addFieldToTab('Root.Content', $tabSlideShow);
     $image_manager = new ImageDataObjectManager($this->owner, 'SlideshowSlides', 'SlideshowSlide', 'SlideImage', array(), 'getCMSFields_forPopup');
     $image_manager->copyOnImport = false;
     $fields->addFieldToTab('Root.Content.SlideshowTabs.Slides', $image_manager);
     /*
      * settings
      */
     if (count(self::$effects) > 1) {
         $fields->addFieldToTab('Root.Content.SlideshowTabs.Settings', new DropdownField($name = 'SlideEffect', $title = _t('Slideshow.EFFECT', 'Slide effect'), $source = array_combine(array_keys(self::$effects), array_keys(self::$effects))));
     } else {
         $fields->addFieldToTab('Root.Content.SlideshowTabs.Settings', new HiddenField($name = 'SlideEffect', $title = 'Slide Effect', $value = key(self::$effects)));
     }
     $fields->addFieldsToTab('Root.Content.SlideshowTabs.Settings', array(new TextField($name = 'SlideDuration', $title = _t('Slideshow.SLIDEDURATIOM', 'Duration of Each Slide (milliseconds)')), new TextField($name = 'TransitionDuration', $title = _t('Slideshow.TRANSITIONDURATION', 'Duration of Transition Between Slides (milliseconds)')), new CheckboxField($name = 'AutoPlay', $title = _t('Slideshow.AUTOPLAY', 'Start slideshow automatically')), new CheckboxField($name = 'Loop', $title = _t('Slideshow.LOOP', 'Loop slides')), new CheckboxField($name = 'PauseOnHover', $title = _t('Slideshow.PAUSEONHOVER', 'Pause the slideshow when the mouse hovers over it')), new OptionsetField($name = 'UpdateSlideshows', $title = _t('Slideshow.UPDATE', 'Update slideshows'), $source = array('page' => _t('Slideshow.UPDATEPAGEONLY', 'Apply to this page only'), 'section' => _t('Slideshow.UPDATESECTION', 'Apply to all slideshows in this section'), 'site' => _t('Slideshow.UPDATEALL', 'Apply to all slideshows on this site')), $value = 'page')));
 }
Beispiel #5
0
 function getCMSFields()
 {
     Requirements::javascript("sapphire/javascript/RedirectorPage.js");
     $fields = new FieldSet(new TabSet("Root", $tabContent = new Tab("Content", new TextField("Title", _t('SiteTree.PAGETITLE')), new TextField("MenuTitle", _t('SiteTree.MENUTITLE')), new FieldGroup(_t('SiteTree.URL'), new LabelField("http://www.yoursite.com/"), new TextField("URLSegment", ""), new LabelField("/")), new HeaderField(_t('RedirectorPage.HEADER', "This page will redirect users to another page")), new OptionsetField("RedirectionType", _t('RedirectorPage.REDIRECTTO', "Redirect to"), array("Internal" => _t('RedirectorPage.REDIRECTTOPAGE', "A page on your website"), "External" => _t('RedirectorPage.REDIRECTTOEXTERNAL', "Another website")), "Internal"), new TreeDropdownField("LinkToID", _t('RedirectorPage.YOURPAGE', "Page on your website"), "SiteTree"), new TextField("ExternalURL", _t('RedirectorPage.OTHERURL', "Other website URL")), new TextareaField("MetaDescription", _t('SiteTree.METADESC'))), $tabBehaviour = new Tab("Behaviour", new DropdownField("ClassName", _t('SiteTree.PAGETYPE'), $this->getClassDropdown()), new CheckboxField("ShowInMenus", _t('SiteTree.SHOWINMENUS')), new CheckboxField("ShowInSearch", _t('SiteTree.SHOWINSEARCH')))));
     $tabContent->setTitle(_t('SiteTree.TABCONTENT'));
     $tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR'));
     return $fields;
 }
Beispiel #6
0
 public function getCMSFields()
 {
     $fields = FieldList::create();
     $fields->push(TabSet::create('Root', $mainTab = new Tab('Main')));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $fields->addFieldsToTab('Root.Main', array(TextField::create('Title', _t('Block.TITLE', 'Title'))));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
        Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
        Requirements::javascript('memberprofiles/javascript/MemberProfilePageCms.js');
        // Setup tabs
        $fields->addFieldToTab('Root', $profile = new TabSet('Profile'), 'Content');
        $fields->addFieldToTab('Root', $email = new Tab('Email'), 'Behaviour');
        $profile->setTitle(_t('MemberProfiles.PROFILE', 'Profile'));
        $email->setTitle(_t('MemberProfiles.EMAIL', 'Email'));
        $fields->findOrMakeTab('Root.Profile.Fields', _t('MemberProfiles.FIELDS', 'Fields'));
        $fields->findOrMakeTab('Root.Profile.Groups', _t('MemberProfiles.GROUPS', 'Groups'));
        $fields->findOrMakeTab('Root.Profile.PublicProfile', _t('MemberProfiles.PUBLICPROFILE', 'Public Profile'));
        // Profile fields
        $fields->addFieldsToTab('Root.Profile.Fields', array(new HeaderField('ProfileFieldsHeader', _t('MemberProfiles.PROFILEFIELDS', 'Profile Fields')), $table = new OrderableComplexTableField($this, 'Fields', 'MemberProfileField')));
        $table->setPermissions(array('show', 'edit'));
        $table->setCustomSourceItems($this->getProfileFields());
        // Groups
        $fields->addFieldsToTab('Root.Profile.Groups', array(new HeaderField('GroupsHeader', _t('MemberProfiles.GROUPASSIGNMENT', 'Group Assignment')), new LiteralField('GroupsNote', '<p>' . _t('MemberProfiles.GROUPSNOTE', 'Any users registering via this page will always be added to ' . 'the below groups (if registration is enabled). Conversely, a ' . 'member must belong to these groups in order to edit their ' . 'profile on this page.') . '</p>'), new CheckboxSetField('Groups', '', DataObject::get('Group')->map()), new HeaderField('SelectableGroupsHeader', _t('MemberProfiles.USERSELECTABLE', 'User Selectable')), new LiteralField('SelectableGroupsNote', '<p>' . _t('MemberProfiles.SELECTABLEGROUPSNOTE', 'Users can choose to belong to the following groups, if the ' . '"Groups" field is enabled in the "Fields" tab.') . '</p>'), new CheckboxSetField('SelectableGroups', '', DataObject::get('Group')->map())));
        // Public profile
        $fields->addFieldsToTab('Root.Profile.PublicProfile', array(new HeaderField('PublicProfileHeader', _t('MemberProfiles.PUBLICPROFILE', 'Public Profile')), new CheckboxField('AllowProfileViewing', _t('MemberProfiles.ALLOWPROFILEVIEWING', 'Allow people to view user profiles.')), new HeaderField('ProfileSectionsHeader', _t('MemberProfiles.PROFILESECTIONS', 'Profile Sections')), new MemberProfileSectionField($this, 'Sections', 'MemberProfileSection')));
        // Email confirmation and validation
        $fields->addFieldsToTab('Root.Email', array(new HeaderField('EmailHeader', 'Email Confirmation and Validation'), new OptionSetField('EmailType', '', array('Validation' => 'Require email validation to activate an account', 'Confirmation' => 'Send a confirmation email after a user registers', 'None' => 'Do not send any emails')), new ToggleCompositeField('EmailContent', 'Email Content', array(new TextField('EmailSubject', 'Email subject'), new TextField('EmailFrom', 'Email from'), new TextareaField('EmailTemplate', 'Email template'), new LiteralField('TemplateNote', MemberConfirmationEmail::TEMPLATE_NOTE))), new ToggleCompositeField('ConfirmationContent', 'Confirmation Content', array(new LiteralField('ConfirmationNote', '<p>This content is dispayed when
					a user confirms their account.</p>'), new TextField('ConfirmationTitle', 'Title'), new HtmlEditorField('ConfirmationContent', 'Content')))));
        // Content
        $fields->removeFieldFromTab('Root.Content.Main', 'Content');
        $fields->addFieldToTab('Root.Content', $profileContent = new Tab('Profile'), 'Metadata');
        $fields->addFieldToTab('Root.Content', $regContent = new Tab('Registration'), 'Metadata');
        $fields->addFieldToTab('Root.Content', $afterReg = new Tab('AfterRegistration'), 'Metadata');
        $profileContent->setTitle(_t('MemberProfiles.PROFILE', 'Profile'));
        $regContent->setTitle(_t('MemberProfiles.REGISTRATION', 'Registration'));
        $afterReg->setTitle(_t('MemberProfiles.AFTERREG', 'After Registration'));
        $tabs = array('Profile', 'Registration', 'AfterRegistration');
        foreach ($tabs as $tab) {
            $fields->addFieldsToTab("Root.Content.{$tab}", array(new TextField("{$tab}Title", _t('MemberProfiles.TITLE', 'Title')), new HtmlEditorField("{$tab}Content", _t('MemberProfiles.CONTENT', 'Content'))));
        }
        $fields->addFieldToTab('Root.Content.AfterRegistration', new CheckboxField('RegistrationRedirect', _t('MemberProfiles.REDIRECT_AFTER_REG', 'Redirect after registration?')), 'AfterRegistrationContent');
        $fields->addFieldToTab('Root.Content.AfterRegistration', new TreeDropdownField('PostRegistrationTargetID', _t('MemberProfiles.REDIRECT_TARGET', 'Redirect to page'), 'SiteTree'), 'AfterRegistrationContent');
        // Behaviour
        $fields->addFieldToTab('Root.Behaviour', new HeaderField('ProfileBehaviour', _t('MemberProfiles.PROFILEBEHAVIOUR', 'Profile Behaviour')), 'ClassName');
        $fields->addFieldToTab('Root.Behaviour', new CheckboxField('AllowRegistration', _t('MemberProfiles.ALLOWREG', 'Allow registration via this page')), 'ClassName');
        $fields->addFieldToTab('Root.Behaviour', new CheckboxField('AllowProfileEditing', _t('MemberProfiles.ALLOWEDITING', 'Allow users to edit their own profile on this page')), 'ClassName');
        $fields->addFieldToTab('Root.Behaviour', new CheckboxField('AllowAdding', _t('MemberProfiles.ALLOWADD', 'Allow members with member creation permissions to add members via this page')), 'ClassName');
        $requireApproval = new CheckboxField('RequireApproval', _t('MemberProfiles.REQUIREREGAPPROVAL', 'Require registration approval by an administrator?'));
        $fields->addFieldToTab('Root.Behaviour', $requireApproval, 'ClassName');
        $approvalGroups = _t('MemberProfiles.NOTIFYTHESEGROUPS', 'Notify these groups to approve new registrations');
        $approvalGroups = new TreeMultiselectField('ApprovalGroups', $approvalGroups, 'Group');
        $fields->addFieldToTab('Root.Behaviour', $approvalGroups, 'ClassName');
        $pageSettings = new HeaderField('PageSettingsHeader', _t('MemberProfiles.PAGEBEHAVIOUR', 'Page Behaviour'));
        $fields->addFieldToTab('Root.Behaviour', $pageSettings, 'ClassName');
        return $fields;
    }
 public function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $fields->addFieldToTab('Root.Main', new TextField('Email', $this->fieldLabel('Email')));
     $fields->addFieldsToTab('Root.Main', array(Object::create('TextField', 'Salutation', $this->fieldLabel('Salutation')), Object::create('TextField', 'FirstName', $this->fieldLabel('First Name')), Object::create('TextField', 'MiddleName', $this->fieldLabel('Middle Name')), Object::create('TextField', 'Surname', $this->fieldLabel('Surname'))));
     if (!empty($this->ID)) {
         $fields->addFieldToTab('Root.Main', Object::create('CheckboxSetField', 'MailingLists', $this->fieldLabel('MailingLists'), MailingList::get()->map('ID', 'FullTitle')));
     }
     $fields->addFieldsToTab('Root.Main', array(Object::create('ReadonlyField', 'BouncedCount', $this->fieldLabel('BouncedCount')), Object::create('CheckboxField', 'Verified', $this->fieldLabel('Verified'))->setDescription(_t('Newsletter.VerifiedDesc', 'Has this user verified his subscription?')), Object::create('CheckboxField', 'Blacklisted', $this->fieldLabel('Blacklisted'))->setDescription(_t('Newsletter.BlacklistedDesc', 'Excluded from emails, either by automated process or manually. ' . 'An invalid address or undeliverable email will eventually result in blacklisting.')), Object::create('ReadonlyField', 'ReceivedCount', $this->fieldLabel('ReceivedCount'))->setDescription(_t('Newsletter.ReceivedCountDesc', 'Number of emails sent without undeliverable errors. ' . 'Only one indication that an email has actually been received and read.'))));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = FieldList::create();
     $fields->push(TabSet::create('Root', $mainTab = new Tab('Main')));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $sort = 'ParentID';
     if ($this->has_extension('Sortable')) {
         $sort .= ', SortOrder';
     }
     $source = Block::get()->exclude('ClassName', 'VirtualBlock')->sort($sort)->map('ID', 'FullTitle');
     $fields->addFieldsToTab('Root.Main', array(ReadonlyField::create('Title', _t('Block.TITLE', 'Title'), $this->getTitle()), DropdownField::create('OriginalBlockID', _t('VirtualBlock.SELECT_ORIGINAL', 'Select original'), $source)));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 /**
  * Returns a FieldSet 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.
  *
  * @param Controller
  * @return FieldSet
  */
 function getCMSFields($controller = null)
 {
     $group = DataObject::get_by_id("Group", $this->Parent()->GroupID);
     $sentReport = $this->renderWith("Newsletter_SentStatusReport");
     $previewLink = Director::absoluteBaseURL() . 'admin/newsletter/preview/' . $this->ID;
     $ret = new FieldSet(new TabSet("Root", $mailTab = new Tab(_t('Newsletter.NEWSLETTER', 'Newsletter'), new TextField("Subject", _t('Newsletter.SUBJECT', 'Subject'), $this->Subject), new HtmlEditorField("Content", _t('Newsletter.CONTENT', 'Content')), new LiteralField('PreviewNewsletter', "<p><a href=\"{$previewLink}\" target=\"_blank\">" . _t('PREVIEWNEWSLETTER', 'Preview this newsletter') . "</a></p>")), $sentToTab = new Tab(_t('Newsletter.SENTREPORT', 'Sent Status Report'), new LiteralField("SentStatusReport", $sentReport)), $tracked = new Tab('TrackedLinks', $trackedTable = new TableListField('TrackedLinks', 'Newsletter_TrackedLink', array('Original' => 'Link', 'Visits' => 'Visits'), '"NewsletterID" = ' . $this->ID, '"Visits" DESC'))));
     $tracked->setTitle(_t('Newsletter.TRACKEDLINKS', 'Tracked Links'));
     $trackedTable->setPermissions(array('show'));
     if ($this->Status != 'Draft') {
         $mailTab->push(new ReadonlyField("SentDate", _t('Newsletter.SENTAT', 'Sent at'), $this->SentDate));
     }
     $this->extend("updateCMSFields", $ret);
     return $ret;
 }
 public function getCMSFields()
 {
     $fields = FieldList::create();
     $fields->push(TabSet::create('Root', $mainTab = new Tab('Main')));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $blockList = Block::get()->exclude('ClassName', 'VirtualBlock');
     // Apply the allowed blocks config to the virtual-block
     $allowed = $this->Parent()->config()->get('allowed_blocks');
     if (is_array($allowed)) {
         $blockList = $blockList->filter(array('ClassName' => $allowed));
     }
     $source = $blockList->sort('ParentID, SortOrder')->map('ID', 'FullTitle');
     $fields->addFieldsToTab('Root.Main', array(ReadonlyField::create('Title', _t('Block.TITLE', 'Title'), $this->getTitle()), DropdownField::create('OriginalBlockID', _t('VirtualBlock.SELECT_ORIGINAL', 'Select original'), $source)));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $fields->addFieldToTab('Root.Main', new TextField('Title', _t('NewsletterAdmin.MailingListTitle', 'Mailing List Title')));
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldSortableHeader(), $dataColumns = new GridFieldDataColumns(), new GridFieldFilterHeader(), new GridFieldDeleteAction(true), new GridFieldPaginator(30), new GridFieldAddNewButton(), new GridFieldDetailForm(), new GridFieldEditButton(), $autocompelete = new GridFieldAutocompleterWithFilter('before', array('FirstName', 'MiddleName', 'Surname', 'Email')));
     $dataColumns->setFieldCasting(array("Blacklisted" => "Boolean->Nice", "Verified" => "Boolean->Nice"));
     $autocompelete->filters = array("Blacklisted" => false);
     $recipientsGrid = GridField::create('Recipients', _t('NewsletterAdmin.Recipients', 'Mailing list recipients'), $this->Recipients(), $gridFieldConfig);
     $fields->addFieldToTab('Root.Main', new FieldGroup($recipientsGrid));
     $this->extend("updateCMSFields", $fields);
     if (!$this->ID) {
         $fields->removeByName('Recipients');
     }
     return $fields;
 }
 public function getCMSFields($params = null)
 {
     $fields = new FieldList();
     // tabbed or untabbed
     $fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $reports = array();
     $reportObjs = AdvancedReport::get()->filter(array('ReportID' => 0));
     if ($reportObjs && $reportObjs->count()) {
         foreach ($reportObjs as $obj) {
             if ($obj instanceof CombinedReport) {
                 continue;
             }
             $reports[$obj->ID] = $obj->Title . '(' . $obj->ClassName . ')';
         }
     }
     $fields->addFieldsToTab('Root.Main', array(new DropdownField('ReportID', 'Related report', $reports), new TextField('Title'), new KeyValueField('Parameters', 'Parameters to pass to the report'), new NumericField('Sort')));
     return $fields;
 }
 /**
  * Get the fields that are sent to the CMS. In
  * your extensions: updateCMSFields($fields)
  *
  * @return FieldList
  */
 public function getCMSFields()
 {
     $groupsMap = array();
     foreach (Group::get() as $group) {
         // Listboxfield values are escaped, use ASCII char instead of &raquo;
         $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
     }
     asort($groupsMap);
     $fields = new FieldList(new TabSet("Root", $tabMain = new Tab('Main', $titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")), $taglineField = new TextField("Tagline", _t('SiteConfig.SITETAGLINE', "Site Tagline/Slogan")))), new HiddenField('ID'));
     if (!Permission::check('EDIT_SITECONFIG')) {
         $fields->makeFieldReadonly($taglineField);
         $fields->makeFieldReadonly($titleField);
     }
     if (file_exists(BASE_PATH . '/install.php')) {
         $fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader", "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING", "Warning: You should remove install.php from this SilverStripe install for security reasons.") . "</p>"), "Title");
     }
     $tabMain->setTitle(_t('SiteConfig.TABMAIN', "Main"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 function getCMSFields()
 {
     Requirements::javascript(FLICKR_EDIT_TOOLS_PATH . '/javascript/flickredit.js');
     Requirements::css(FLICKR_EDIT_TOOLS_PATH . '/css/flickredit.css');
     $fields = new FieldList();
     $fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $fields->addFieldToTab('Root.Main', new TextField('Title', 'Title'));
     $fields->addFieldToTab('Root.Main', new TextAreaField('Description', 'Description'));
     $fields->addFieldToTab('Root.Main', new TextField('ImageFooter', 'Text to be added to each image in this album when saving'));
     $fields->addFieldToTab('Root.Main', new CheckBoxField('LockGeo', 'If the map positions were calculated by GPS, tick this to hide map editing features'));
     $gridConfig = GridFieldConfig_RelationEditor::create();
     // need to add sort order in many to many I think // ->addComponent( new GridFieldSortableRows( 'SortOrder' ) );
     $gridConfig->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('Title', 'Description'));
     $gridConfig->getComponentByType('GridFieldPaginator')->setItemsPerPage(100);
     $gridField = new GridField("Flickr Photos", "List of Photos:", $this->FlickrPhotos(), $gridConfig);
     $fields->addFieldToTab("Root.FlickrPhotos", $gridField);
     $gridConfig2 = GridFieldConfig_RelationEditor::create();
     $gridConfig2->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('Title', 'Description'));
     $gridConfig2->getComponentByType('GridFieldPaginator')->setItemsPerPage(100);
     $bucketsByDate = $this->FlickrBucketsByDate();
     if ($bucketsByDate->count() > 0) {
         $gridField2 = new GridField("Flickr Buckets", "List of Buckets:", $bucketsByDate, $gridConfig2);
         $fields->addFieldToTab("Root.SavedBuckets", $gridField2);
     }
     $forTemplate = new ArrayData(array('Title' => $this->Title, 'ID' => $this->ID, 'FlickrPhotosNotInBucket' => $this->FlickrPhotosNotInBucket()));
     $html = $forTemplate->renderWith('GridFieldFlickrBuckets');
     $bucketTimeField = new NumericField('BucketTime');
     // $fields->addFieldToTab( 'Root.Buckets', $bucketTimeField );
     $lfImage = new LiteralField('BucketEdit', $html);
     $fields->addFieldToTab('Root.Buckets', $lfImage);
     $this->extend('updateCMSFields', $fields);
     $fields->addFieldToTab('Root.Batch', new TextField('BatchTitle', 'Batch Title'));
     $fields->addFieldToTab('Root.Batch', new TextAreaField('BatchDescription', 'Batch Description'));
     $fields->addFieldToTab('Root.Batch', new TextAreaField('BatchTags', 'Batch Tags'));
     $htmlBatch = "<p>Click on the batch update button to update the description and title of all of the images, and add tags to each image</p>";
     $htmlBatch .= '<input type="button" id="batchUpdatePhotographs" value="Batch Update"></input>';
     $lf = new LiteralField('BatchUpdate', $htmlBatch);
     $fields->addFieldToTab('Root.Batch', $lf);
     return $fields;
 }
Beispiel #16
0
 /**
  * Get the fields that are sent to the CMS. In
  * your extensions: updateCMSFields($fields)
  *
  * @return FieldList
  */
 function getCMSFields()
 {
     Requirements::javascript(CMS_DIR . "/javascript/SitetreeAccess.js");
     $groupsMap = Group::get()->map('ID', 'Breadcrumbs')->toArray();
     asort($groupsMap);
     $fields = new FieldList(new TabSet("Root", $tabMain = new Tab('Main', $titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")), $taglineField = new TextField("Tagline", _t('SiteConfig.SITETAGLINE', "Site Tagline/Slogan")), $themeDropdownField = new DropdownField("Theme", _t('SiteConfig.THEME', 'Theme'), $this->getAvailableThemes())), $tabAccess = new Tab('Access', $viewersOptionsField = new OptionsetField("CanViewType", _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?")), $viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))->setMultiple(true)->setSource($groupsMap), $editorsOptionsField = new OptionsetField("CanEditType", _t('SiteConfig.EDITHEADER', "Who can edit pages on this site?")), $editorGroupsField = ListboxField::create("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups"))->setMultiple(true)->setSource($groupsMap), $topLevelCreatorsOptionsField = new OptionsetField("CanCreateTopLevelType", _t('SiteConfig.TOPLEVELCREATE', "Who can create pages in the root of the site?")), $topLevelCreatorsGroupsField = ListboxField::create("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators"))->setMultiple(true)->setSource($groupsMap))));
     $themeDropdownField->setEmptyString(_t('SiteConfig.DEFAULTTHEME', '(Use default theme)'));
     $viewersOptionsSource = array();
     $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
     $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
     $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
     $viewersOptionsField->setSource($viewersOptionsSource);
     $editorsOptionsSource = array();
     $editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
     $editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
     $editorsOptionsField->setSource($editorsOptionsSource);
     $topLevelCreatorsOptionsField->setSource($editorsOptionsSource);
     // Translatable doesn't handle updateCMSFields on DataObjects,
     // so add it here to save the current Locale,
     // because onBeforeWrite does not work.
     if (class_exists('Translatable') && Object::has_extension('SiteConfig', "Translatable")) {
         $fields->push(new HiddenField("Locale"));
     }
     if (!Permission::check('EDIT_SITECONFIG')) {
         $fields->makeFieldReadonly($viewersOptionsField);
         $fields->makeFieldReadonly($viewerGroupsField);
         $fields->makeFieldReadonly($editorsOptionsField);
         $fields->makeFieldReadonly($editorGroupsField);
         $fields->makeFieldReadonly($topLevelCreatorsOptionsField);
         $fields->makeFieldReadonly($topLevelCreatorsGroupsField);
         $fields->makeFieldReadonly($taglineField);
         $fields->makeFieldReadonly($titleField);
     }
     if (file_exists(BASE_PATH . '/install.php')) {
         $fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader", "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING", "Warning: You should remove install.php from this SilverStripe install for security reasons.") . "</p>"), "Title");
     }
     $tabMain->setTitle(_t('SiteConfig.TABMAIN', "Main"));
     $tabAccess->setTitle(_t('SiteConfig.TABACCESS', "Access"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 public function getCMSFields()
 {
     // Get list of UI options
     $popupMap = array();
     foreach (ClassInfo::subclassesFor("ImageGalleryUI") as $ui) {
         if ($ui == "ImageGalleryUI") {
             continue;
         }
         $uiLabel = $ui::$label;
         $demoURL = $ui::$link_to_demo;
         $demoLink = !empty($demoURL) ? sprintf('<a href="%s" target="_blank">%s</a>', $demoURL, _t('ImageGalleryPage.VIEWDEMO', 'view demo')) : "";
         $popupMap[$ui] = "{$uiLabel} {$demoLink}";
     }
     $fields = parent::getCMSFields();
     // Build configuration fields
     $fields->addFieldToTab('Root', $configTab = new Tab('Configuration'));
     $configTab->setTitle(_t('ImageGalleryPage.CONFIGURATION', 'Configuration'));
     $fields->addFieldsToTab("Root.Configuration", array($coverImages = new FieldGroup(new NumericField('CoverImageWidth', _t('ImageGalleryPage.WIDTH', 'Width')), new NumericField('CoverImageHeight', _t('ImageGalleryPage.HEIGHT', 'Height'))), new NumericField('ThumbnailSize', _t('ImageGalleryPage.THUMBNAILHEIGHT', 'Thumbnail height (pixels)')), new CheckboxField('Square', _t('ImageGalleryPage.CROPTOSQUARE', 'Crop thumbnails to square')), new NumericField('MediumSize', _t('ImageGalleryPage.MEDIUMSIZE', 'Medium size (pixels)')), new NumericField('NormalSize', _t('ImageGalleryPage.NORMALSIZE', 'Normal width (pixels)')), new NumericField('NormalHeight', _t('ImageGalleryPage.NORMALHEIGHT', 'Normal height (pixels)')), new NumericField('MediaPerPage', _t('ImageGalleryPage.IMAGESPERPAGE', 'Number of images per page')), new OptionsetField('GalleryUI', _t('ImageGalleryPage.POPUPSTYLE', 'Popup style'), $popupMap), new NumericField('UploadLimit', _t('ImageGalleryPage.MAXFILES', 'Max files allowed in upload queue'))));
     $coverImages->setTitle(_t('ImageGalleryPage.ALBUMCOVERIMAGES', 'Album cover images'));
     // Build albums tab
     $fields->addFieldToTab('Root', $albumTab = new Tab('Albums'));
     $albumTab->setTitle(_t('ImageGalleryPage.ALBUMS', 'Albums'));
     if ($rootFolder = $this->RootFolder()) {
         $albumConfig = GridFieldConfig_RecordEditor::create();
         // Enable bulk image loading if necessary module is installed
         // @see composer.json/suggests
         if (class_exists('GridFieldBulkManager')) {
             $albumConfig->addComponent(new GridFieldBulkManager());
         }
         // Enable album sorting if necessary module is installed
         // @see composer.json/suggests
         if (class_exists('GridFieldSortableRows')) {
             $albumConfig->addComponent(new GridFieldSortableRows('SortOrder'));
         }
         $albumField = new GridField('Albums', 'Albums', $this->Albums(), $albumConfig);
         $fields->addFieldToTab("Root.Albums", $albumField);
     } else {
         $fields->addFieldToTab("Root.Albums", new HeaderField(_t("ImageGalleryPage.ALBUMSNOTSAVED", "You may add albums to your gallery once you have saved the page for the first time."), $headingLevel = "3"));
     }
     return $fields;
 }
Beispiel #18
0
 /**
  * Get the fields that are sent to the CMS. In
  * your extensions: updateCMSFields($fields)
  *
  * @return FieldList
  */
 public function getCMSFields()
 {
     $groupsMap = array();
     foreach (Group::get() as $group) {
         // Listboxfield values are escaped, use ASCII char instead of &raquo;
         $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
     }
     asort($groupsMap);
     $fields = new FieldList(new TabSet("Root", $tabMain = new Tab('Main', $titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")), $taglineField = new TextField("Tagline", _t('SiteConfig.SITETAGLINE', "Site Tagline/Slogan")), $themeDropdownField = new DropdownField("Theme", _t('SiteConfig.THEME', 'Theme'), $this->getAvailableThemes())), $tabAccess = new Tab('Access', $viewersOptionsField = new OptionsetField("CanViewType", _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?")), $viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('SiteTree.GroupPlaceholder', 'Click to select group')), $editorsOptionsField = new OptionsetField("CanEditType", _t('SiteConfig.EDITHEADER', "Who can edit pages on this site?")), $editorGroupsField = ListboxField::create("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('SiteTree.GroupPlaceholder', 'Click to select group')), $topLevelCreatorsOptionsField = new OptionsetField("CanCreateTopLevelType", _t('SiteConfig.TOPLEVELCREATE', "Who can create pages in the root of the site?")), $topLevelCreatorsGroupsField = ListboxField::create("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('SiteTree.GroupPlaceholder', 'Click to select group')))), new HiddenField('ID'));
     $themeDropdownField->setEmptyString(_t('SiteConfig.DEFAULTTHEME', '(Use default theme)'));
     $viewersOptionsSource = array();
     $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
     $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
     $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
     $viewersOptionsField->setSource($viewersOptionsSource);
     $editorsOptionsSource = array();
     $editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
     $editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
     $editorsOptionsField->setSource($editorsOptionsSource);
     $topLevelCreatorsOptionsField->setSource($editorsOptionsSource);
     if (!Permission::check('EDIT_SITECONFIG')) {
         $fields->makeFieldReadonly($viewersOptionsField);
         $fields->makeFieldReadonly($viewerGroupsField);
         $fields->makeFieldReadonly($editorsOptionsField);
         $fields->makeFieldReadonly($editorGroupsField);
         $fields->makeFieldReadonly($topLevelCreatorsOptionsField);
         $fields->makeFieldReadonly($topLevelCreatorsGroupsField);
         $fields->makeFieldReadonly($taglineField);
         $fields->makeFieldReadonly($titleField);
     }
     if (file_exists(BASE_PATH . '/install.php')) {
         $fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader", "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING", "Warning: You should remove install.php from this SilverStripe install for security reasons.") . "</p>"), "Title");
     }
     $tabMain->setTitle(_t('SiteConfig.TABMAIN', "Main"));
     $tabAccess->setTitle(_t('SiteConfig.TABACCESS', "Access"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $lf = new LiteralField('<p>Instructions', 'All of the images in this bucket will have the same information that you enter here</p>');
     $fields->push($lf);
     $fields->addFieldToTab('Root.Main', $lf);
     $fields->addFieldToTab('Root.Main', new TextField('Title', 'Bucket Title'));
     $fields->addFieldToTab('Root.Main', new TextAreaField('Description', 'Bucket Description'));
     // quick tags, faster than the grid editor - these are processed prior to save to create/assign tags
     $fields->addFieldToTab('Root.Main', new TextField('QuickTags', 'Quick tags - enter tags here separated by commas'));
     $lf2 = new LiteralField('ImageStrip', $this->getImageStrip());
     $fields->push($lf2);
     $lockgeo = $this->GeoLocked();
     if (!$lockgeo) {
         $mapField = new LatLongField(array(new TextField('Lat', 'Latitude'), new TextField('Lon', 'Longitude'), new TextField('ZoomLevel', 'Zoom')), array('Address'));
         $guidePoints = array();
         foreach ($this->FlickrSet()->FlickrPhotos()->where('Lat != 0 and Lon != 0') as $fp) {
             if ($fp->Lat != 0 && $fp->Lon != 0) {
                 array_push($guidePoints, array('latitude' => $fp->Lat, 'longitude' => $fp->Lon));
             }
         }
         if (count($guidePoints) > 0) {
             $mapField->setGuidePoints($guidePoints);
         }
         $locationTab = $fields->findOrMakeTab('Root.Location');
         $locationTab->extraClass('mappableLocationTab');
         $fields->addFieldToTab('Root.Location', $mapField);
     }
     $gridConfig = GridFieldConfig_RelationEditor::create();
     //->addComponent( new GridFieldSortableRows( 'Value' ) );
     $gridConfig->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('Value', 'RawValue'));
     $gridField = new GridField("Tags", "List of Tags", $this->FlickrTags(), $gridConfig);
     // keep in the main tab to avoid wasting time tab switching
     $fields->addFieldToTab("Root.Main", $gridField);
     return $fields;
 }
	/**
	 * Gets the form fields as defined through the metadata
	 * on {@link $obj} and the custom parameters passed to FormScaffolder.
	 * Depending on those parameters, the fields can be used in ajax-context,
	 * contain {@link TabSet}s etc.
	 * 
	 * @return FieldSet
	 */
	public function getFieldSet() {
		$fields = new FieldSet();
		
		// tabbed or untabbed
		if($this->tabbed) {
			$fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
			$mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
		}
		
		// add database fields
		foreach($this->obj->db() as $fieldName => $fieldType) {
			if($this->restrictFields && !in_array($fieldName, $this->restrictFields)) continue;
			
			// @todo Pass localized title
			if($this->fieldClasses && isset($this->fieldClasses[$fieldName])) {
				$fieldClass = $this->fieldClasses[$fieldName];
				$fieldObject = new $fieldClass($fieldName);
			} else {
				$fieldObject = $this->obj->dbObject($fieldName)->scaffoldFormField(null, $this->getParamsArray());
			}
			$fieldObject->setTitle($this->obj->fieldLabel($fieldName));
			if($this->tabbed) {
				$fields->addFieldToTab("Root.Main", $fieldObject);
			} else {
				$fields->push($fieldObject);
			}
		}
		
		// add has_one relation fields
		if($this->obj->has_one()) {
			foreach($this->obj->has_one() as $relationship => $component) {
				if($this->restrictFields && !in_array($relationship, $this->restrictFields)) continue;
				$hasOneField = $this->obj->dbObject("{$relationship}ID")->scaffoldFormField(null, $this->getParamsArray());
				$hasOneField->setTitle($this->obj->fieldLabel($relationship));
				if($this->tabbed) {
					$fields->addFieldToTab("Root.Main", $hasOneField);
				} else {
					$fields->push($hasOneField);
				}
			}
		}
		
		// only add relational fields if an ID is present
		if($this->obj->ID) {
			// add has_many relation fields
			if($this->obj->has_many() && ($this->includeRelations === true || isset($this->includeRelations['has_many']))) {
				foreach($this->obj->has_many() as $relationship => $component) {
					if($this->tabbed) {
						$relationTab = $fields->findOrMakeTab(
							"Root.$relationship", 
							$this->obj->fieldLabel($relationship)
						);
					}
					$relationshipFields = singleton($component)->summaryFields();
					$foreignKey = $this->obj->getComponentJoinField($relationship);
					$ctf = new ComplexTableField(
						$this,
						$relationship,
						$component,
						$relationshipFields,
						"getCMSFields", 
						"$foreignKey = " . $this->obj->ID
					);
					$ctf->setPermissions(TableListField::permissions_for_object($component));
					if($this->tabbed) {
						$fields->addFieldToTab("Root.$relationship", $ctf);
					} else {
						$fields->push($ctf);
					}
				}
			}

			if($this->obj->many_many() && ($this->includeRelations === true || isset($this->includeRelations['many_many']))) {
				foreach($this->obj->many_many() as $relationship => $component) {
					if($this->tabbed) {
						$relationTab = $fields->findOrMakeTab(
							"Root.$relationship", 
							$this->obj->fieldLabel($relationship)
						);
					}

					$relationshipFields = singleton($component)->summaryFields();
					$filterWhere = $this->obj->getManyManyFilter($relationship, $component);
					$filterJoin = $this->obj->getManyManyJoin($relationship, $component);
					$ctf =  new ComplexTableField(
						$this,
						$relationship,
						$component,
						$relationshipFields,
						"getCMSFields", 
						$filterWhere,
						'', 
						$filterJoin
					);
					$ctf->setPermissions(TableListField::permissions_for_object($component));
					$ctf->popupClass = "ScaffoldingComplexTableField_Popup";
					if($this->tabbed) {
						$fields->addFieldToTab("Root.$relationship", $ctf);
					} else {
						$fields->push($ctf);
					}
				}
			}
		}
		
		return $fields;
	}
 /**
  * Gets the form fields as defined through the metadata
  * on {@link $obj} and the custom parameters passed to FormScaffolder.
  * Depending on those parameters, the fields can be used in ajax-context,
  * contain {@link TabSet}s etc.
  * 
  * Uses SilvercartGridFieldConfig_RelationEditor and 
  * SilvercartGridFieldConfig_ExclusiveRelationEditor instead of
  * GridFieldConfig_RelationEditor.
  * 
  * @return FieldList
  */
 public function getFieldList()
 {
     $fields = new FieldList();
     $excludeFromScaffolding = array();
     if ($this->obj->hasMethod('excludeFromScaffolding')) {
         $excludeFromScaffolding = $this->obj->excludeFromScaffolding();
     }
     // tabbed or untabbed
     if ($this->tabbed) {
         $fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
         $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     }
     // add database fields
     foreach ($this->obj->db() as $fieldName => $fieldType) {
         if (in_array($fieldName, $excludeFromScaffolding) || $this->restrictFields && !in_array($fieldName, $this->restrictFields)) {
             continue;
         }
         // @todo Pass localized title
         if ($this->fieldClasses && isset($this->fieldClasses[$fieldName])) {
             $fieldClass = $this->fieldClasses[$fieldName];
             $fieldObject = new $fieldClass($fieldName);
         } else {
             $fieldObject = $this->obj->dbObject($fieldName)->scaffoldFormField(null, $this->getParamsArray());
         }
         $fieldObject->setTitle($this->obj->fieldLabel($fieldName));
         if ($this->tabbed) {
             $fields->addFieldToTab("Root.Main", $fieldObject);
         } else {
             $fields->push($fieldObject);
         }
     }
     // add has_one relation fields
     if ($this->obj->has_one()) {
         foreach ($this->obj->has_one() as $relationship => $component) {
             if (in_array($relationship, $excludeFromScaffolding) || $this->restrictFields && !in_array($relationship, $this->restrictFields)) {
                 continue;
             }
             $fieldName = "{$relationship}ID";
             if ($this->fieldClasses && isset($this->fieldClasses[$fieldName])) {
                 $fieldClass = $this->fieldClasses[$fieldName];
                 $hasOneField = new $fieldClass($fieldName);
             } else {
                 $hasOneField = $this->obj->dbObject($fieldName)->scaffoldFormField(null, $this->getParamsArray());
             }
             $hasOneField->setTitle($this->obj->fieldLabel($relationship));
             if ($this->tabbed) {
                 $fields->addFieldToTab("Root.Main", $hasOneField);
             } else {
                 $fields->push($hasOneField);
             }
         }
     }
     // only add relational fields if an ID is present
     if ($this->obj->ID) {
         // add has_many relation fields
         if ($this->obj->has_many() && ($this->includeRelations === true || isset($this->includeRelations['has_many']))) {
             foreach ($this->obj->has_many() as $relationship => $component) {
                 if (in_array($relationship, $excludeFromScaffolding)) {
                     continue;
                 }
                 if ($this->tabbed) {
                     $relationTab = $fields->findOrMakeTab("Root.{$relationship}", $this->obj->fieldLabel($relationship));
                 }
                 $fieldClass = isset($this->fieldClasses[$relationship]) ? $this->fieldClasses[$relationship] : 'GridField';
                 if (singleton($component) instanceof SilvercartModelAdmin_ReadonlyInterface) {
                     $config = SilvercartGridFieldConfig_Readonly::create();
                 } elseif (singleton($component) instanceof SilvercartModelAdmin_ExclusiveRelationInterface || $this->obj->has_extension($this->obj->{$relationship}()->dataClass(), 'SilvercartLanguageDecorator')) {
                     $config = SilvercartGridFieldConfig_ExclusiveRelationEditor::create();
                 } else {
                     $config = SilvercartGridFieldConfig_RelationEditor::create();
                 }
                 $grid = Object::create($fieldClass, $relationship, $this->obj->fieldLabel($relationship), $this->obj->{$relationship}(), $config);
                 if ($this->tabbed) {
                     $fields->addFieldToTab("Root.{$relationship}", $grid);
                 } else {
                     $fields->push($grid);
                 }
             }
         }
         if ($this->obj->many_many() && ($this->includeRelations === true || isset($this->includeRelations['many_many']))) {
             foreach ($this->obj->many_many() as $relationship => $component) {
                 if (in_array($relationship, $excludeFromScaffolding)) {
                     continue;
                 }
                 if ($this->tabbed) {
                     $relationTab = $fields->findOrMakeTab("Root.{$relationship}", $this->obj->fieldLabel($relationship));
                 }
                 $fieldClass = isset($this->fieldClasses[$relationship]) ? $this->fieldClasses[$relationship] : 'GridField';
                 $grid = Object::create($fieldClass, $relationship, $this->obj->fieldLabel($relationship), $this->obj->{$relationship}(), SilvercartGridFieldConfig_RelationEditor::create());
                 if ($this->tabbed) {
                     $fields->addFieldToTab("Root.{$relationship}", $grid);
                 } else {
                     $fields->push($grid);
                 }
             }
         }
     }
     return $fields;
 }
Beispiel #22
0
 /**
  * Returns a FieldSet with which to create the CMS 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.
  *
  * @return FieldSet The fields to be displayed in the CMS.
  */
 function getCMSFields()
 {
     require_once "forms/Form.php";
     Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
     Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
     Requirements::javascript(CMS_DIR . "/javascript/SitetreeAccess.js");
     Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
     Requirements::javascript(SAPPHIRE_DIR . '/javascript/UpdateURL.js');
     // Status / message
     // Create a status message for multiple parents
     if ($this->ID && is_numeric($this->ID)) {
         $linkedPages = $this->VirtualPages();
     }
     $parentPageLinks = array();
     if (isset($linkedPages)) {
         foreach ($linkedPages as $linkedPage) {
             $parentPage = $linkedPage->Parent;
             if ($parentPage) {
                 if ($parentPage->ID) {
                     $parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/{$linkedPage->ID}\">{$parentPage->Title}</a>";
                 } else {
                     $parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/{$linkedPage->ID}\">" . _t('SiteTree.TOPLEVEL', 'Site Content (Top Level)') . "</a>";
                 }
             }
         }
         $lastParent = array_pop($parentPageLinks);
         $parentList = "'{$lastParent}'";
         if (count($parentPageLinks) > 0) {
             $parentList = "'" . implode("', '", $parentPageLinks) . "' and " . $parentList;
         }
         $statusMessage[] = sprintf(_t('SiteTree.APPEARSVIRTUALPAGES', "This content also appears on the virtual pages in the %s sections."), $parentList);
     }
     if ($this->HasBrokenLink || $this->HasBrokenFile) {
         $statusMessage[] = _t('SiteTree.HASBROKENLINKS', "This page has broken links.");
     }
     $message = "STATUS: {$this->Status}<br />";
     if (isset($statusMessage)) {
         $message .= "NOTE: " . implode("<br />", $statusMessage);
     }
     $dependentNote = '';
     $dependentTable = new LiteralField('DependentNote', '<p></p>');
     // Create a table for showing pages linked to this one
     $dependentPagesCount = $this->DependentPagesCount();
     if ($dependentPagesCount) {
         $dependentColumns = array('Title' => $this->fieldLabel('Title'), 'AbsoluteLink' => _t('SiteTree.DependtPageColumnURL', 'URL'), 'DependentLinkType' => _t('SiteTree.DependtPageColumnLinkType', 'Link type'));
         if (class_exists('Subsite')) {
             $dependentColumns['Subsite.Title'] = singleton('Subsite')->i18n_singular_name();
         }
         $dependentNote = new LiteralField('DependentNote', '<p>' . _t('SiteTree.DEPENDENT_NOTE', 'The following pages depend on this page. This includes virtual pages, redirector pages, and pages with content links.') . '</p>');
         $dependentTable = new TableListField('DependentPages', 'SiteTree', $dependentColumns);
         $dependentTable->setCustomSourceItems($this->DependentPages());
         $dependentTable->setFieldFormatting(array('Title' => '<a href=\\"admin/show/$ID\\">$Title</a>', 'AbsoluteLink' => '<a href=\\"$value\\">$value</a>'));
         $dependentTable->setPermissions(array('show', 'export'));
     }
     // Lay out the fields
     $fields = new FieldSet($rootTab = new TabSet("Root", $tabContent = new TabSet('Content', $tabMain = new Tab('Main', new TextField("Title", $this->fieldLabel('Title')), new TextField("MenuTitle", $this->fieldLabel('MenuTitle')), new HtmlEditorField("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", PR_MEDIUM, 'HTML editor title'))), $tabMeta = new Tab('Metadata', new FieldGroup(_t('SiteTree.URL', "URL"), new LabelField('BaseUrlLabel', Controller::join_links(Director::absoluteBaseURL(), self::nested_urls() && $this->ParentID ? $this->Parent()->RelativeLink(true) : null)), new UniqueRestrictedTextField("URLSegment", "URLSegment", "SiteTree", _t('SiteTree.VALIDATIONURLSEGMENT1', "Another page is using that URL. URL must be unique for each page"), "[^A-Za-z0-9-]+", "-", _t('SiteTree.VALIDATIONURLSEGMENT2', "URLs can only be made up of letters, digits and hyphens."), "", "", "", 50), new LabelField('TrailingSlashLabel', "/")), new LiteralField('LinkChangeNote', self::nested_urls() && count($this->Children()) ? '<p>' . $this->fieldLabel('LinkChangeNote') . '</p>' : null), new HeaderField('MetaTagsHeader', $this->fieldLabel('MetaTagsHeader')), new TextField("MetaTitle", $this->fieldLabel('MetaTitle')), new TextareaField("MetaKeywords", $this->fieldLabel('MetaKeywords'), 1), new TextareaField("MetaDescription", $this->fieldLabel('MetaDescription')), new TextareaField("ExtraMeta", $this->fieldLabel('ExtraMeta')))), $tabBehaviour = new Tab('Behaviour', new DropdownField("ClassName", $this->fieldLabel('ClassName'), $this->getClassDropdown()), new OptionsetField("ParentType", _t("SiteTree.PAGELOCATION", "Page location"), array("root" => _t("SiteTree.PARENTTYPE_ROOT", "Top-level page"), "subpage" => _t("SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page (choose below)"))), $parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), 'SiteTree'), new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')), new CheckboxField("ShowInSearch", $this->fieldLabel('ShowInSearch')), new CheckboxField("ProvideComments", $this->fieldLabel('ProvideComments')), new LiteralField("HomepageForDomainInfo", "<p>" . _t('SiteTree.NOTEUSEASHOMEPAGE', "Use this page as the 'home page' for the following domains: \n\t\t\t\t\t\t\t(separate multiple domains with commas)") . "</p>"), new TextField("HomepageForDomain", _t('SiteTree.HOMEPAGEFORDOMAIN', "Domain(s)", PR_MEDIUM, 'Listing domains that should be used as homepage'))), $tabToDo = new Tab(_t('SiteTree.TABTODO', 'To-do') . ($this->ToDo ? '**' : ''), new LiteralField("ToDoHelp", _t('SiteTree.TODOHELP', "<p>You can use this to keep track of work that needs to be done to the content of your site.  To see all your pages with to do information, open the 'Site Reports' window on the left and select 'To Do'</p>")), new TextareaField("ToDo", "", 10)), $tabDependent = new Tab('Dependent', $dependentNote, $dependentTable), $tabAccess = new Tab('Access', new HeaderField('WhoCanViewHeader', _t('SiteTree.ACCESSHEADER', "Who can view this page?"), 2), $viewersOptionsField = new OptionsetField("CanViewType", ""), $viewerGroupsField = new TreeMultiselectField("ViewerGroups", $this->fieldLabel('ViewerGroups')), new HeaderField('WhoCanEditHeader', _t('SiteTree.EDITHEADER', "Who can edit this page?"), 2), $editorsOptionsField = new OptionsetField("CanEditType", ""), $editorGroupsField = new TreeMultiselectField("EditorGroups", $this->fieldLabel('EditorGroups')))));
     /*
      * This filter ensures that the ParentID dropdown selection does not show this node,
      * or its descendents, as this causes vanishing bugs.
      */
     $parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};"));
     // Conditional dependent pages tab
     if ($dependentPagesCount) {
         $tabDependent->setTitle(_t('SiteTree.TABDEPENDENT', "Dependent pages") . " ({$dependentPagesCount})");
     } else {
         $fields->removeFieldFromTab('Root', 'Dependent');
     }
     // Make page location fields read-only if the user doesn't have the appropriate permission
     if (!Permission::check("SITETREE_REORGANISE")) {
         $fields->makeFieldReadonly('ParentType');
         if ($this->ParentType == 'root') {
             $fields->removeByName('ParentID');
         } else {
             $fields->makeFieldReadonly('ParentID');
         }
     }
     $viewersOptionsSource = array();
     $viewersOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
     $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
     $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
     $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
     $viewersOptionsField->setSource($viewersOptionsSource);
     $editorsOptionsSource = array();
     $editorsOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
     $editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
     $editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
     $editorsOptionsField->setSource($editorsOptionsSource);
     if (!Permission::check('SITETREE_GRANT_ACCESS')) {
         $fields->makeFieldReadonly($viewersOptionsField);
         if ($this->CanViewType == 'OnlyTheseUsers') {
             $fields->makeFieldReadonly($viewerGroupsField);
         } else {
             $fields->removeByName('ViewerGroups');
         }
         $fields->makeFieldReadonly($editorsOptionsField);
         if ($this->CanEditType == 'OnlyTheseUsers') {
             $fields->makeFieldReadonly($editorGroupsField);
         } else {
             $fields->removeByName('EditorGroups');
         }
     }
     $tabContent->setTitle(_t('SiteTree.TABCONTENT', "Content"));
     $tabMain->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $tabMeta->setTitle(_t('SiteTree.TABMETA', "Metadata"));
     $tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behavior"));
     $tabAccess->setTitle(_t('SiteTree.TABACCESS', "Access"));
     if (file_exists(BASE_PATH . '/install.php')) {
         $fields->addFieldToTab("Root.Content.Main", new LiteralField("InstallWarningHeader", "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING", "Warning: You should remove install.php from this SilverStripe install for security reasons.") . "</p>"), "Title");
     }
     if (self::$runCMSFieldsExtensions) {
         $this->extend('updateCMSFields', $fields);
     }
     return $fields;
 }
Beispiel #23
0
 /**
  * Returns fields related to configuration aspects on this record, e.g. access control.
  * See {@link getCMSFields()} for content-related fields.
  * 
  * @return FieldSet
  */
 function getSettingsFields()
 {
     $fields = new FieldSet($rootTab = new TabSet("Root", $tabBehaviour = new Tab('Settings', new DropdownField("ClassName", $this->fieldLabel('ClassName'), $this->getClassDropdown()), new OptionsetField("ParentType", _t("SiteTree.PAGELOCATION", "Page location"), array("root" => _t("SiteTree.PARENTTYPE_ROOT", "Top-level page"), "subpage" => _t("SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page (choose below)"))), $parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), 'SiteTree', 'ID', 'MenuTitle'), new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')), new CheckboxField("ShowInSearch", $this->fieldLabel('ShowInSearch')), new LiteralField("HomepageForDomainInfo", "<p>" . _t('SiteTree.NOTEUSEASHOMEPAGE', "Use this page as the 'home page' for the following domains: \n\t\t\t\t\t\t\t(separate multiple domains with commas)") . "</p>"), new TextField("HomepageForDomain", _t('SiteTree.HOMEPAGEFORDOMAIN', "Domain(s)", PR_MEDIUM, 'Listing domains that should be used as homepage'))), $tabAccess = new Tab('Access', $viewersOptionsField = new OptionsetField("CanViewType", _t('SiteTree.ACCESSHEADER', "Who can view this page?")), $viewerGroupsField = new TreeMultiselectField("ViewerGroups", $this->fieldLabel('ViewerGroups')), $editorsOptionsField = new OptionsetField("CanEditType", _t('SiteTree.EDITHEADER', "Who can edit this page?")), $editorGroupsField = new TreeMultiselectField("EditorGroups", $this->fieldLabel('EditorGroups')))));
     /*
      * This filter ensures that the ParentID dropdown selection does not show this node,
      * or its descendents, as this causes vanishing bugs.
      */
     $parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};"));
     $tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behavior"));
     $tabAccess->setTitle(_t('SiteTree.TABACCESS', "Access"));
     // Make page location fields read-only if the user doesn't have the appropriate permission
     if (!Permission::check("SITETREE_REORGANISE")) {
         $fields->makeFieldReadonly('ParentType');
         if ($this->ParentType == 'root') {
             $fields->removeByName('ParentID');
         } else {
             $fields->makeFieldReadonly('ParentID');
         }
     }
     $viewersOptionsSource = array();
     $viewersOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
     $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
     $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
     $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
     $viewersOptionsField->setSource($viewersOptionsSource);
     $editorsOptionsSource = array();
     $editorsOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
     $editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
     $editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
     $editorsOptionsField->setSource($editorsOptionsSource);
     if (!Permission::check('SITETREE_GRANT_ACCESS')) {
         $fields->makeFieldReadonly($viewersOptionsField);
         if ($this->CanViewType == 'OnlyTheseUsers') {
             $fields->makeFieldReadonly($viewerGroupsField);
         } else {
             $fields->removeByName('ViewerGroups');
         }
         $fields->makeFieldReadonly($editorsOptionsField);
         if ($this->CanEditType == 'OnlyTheseUsers') {
             $fields->makeFieldReadonly($editorGroupsField);
         } else {
             $fields->removeByName('EditorGroups');
         }
     }
     if (self::$runCMSFieldsExtensions) {
         $this->extend('updateSettingsFields', $fields);
     }
     return $fields;
 }
Beispiel #24
0
 /**
  * Returns fields related to configuration aspects on this record, e.g. access control. See {@link getCMSFields()}
  * for content-related fields.
  * 
  * @return FieldList
  */
 public function getSettingsFields()
 {
     $groupsMap = array();
     foreach (Group::get() as $group) {
         // Listboxfield values are escaped, use ASCII char instead of &raquo;
         $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
     }
     asort($groupsMap);
     $fields = new FieldList($rootTab = new TabSet("Root", $tabBehaviour = new Tab('Settings', new DropdownField("ClassName", $this->fieldLabel('ClassName'), $this->getClassDropdown()), $parentTypeSelector = new CompositeField(new OptionsetField("ParentType", _t("SiteTree.PAGELOCATION", "Page location"), array("root" => _t("SiteTree.PARENTTYPE_ROOT", "Top-level page"), "subpage" => _t("SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page"))), $parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), 'SiteTree', 'ID', 'MenuTitle')), $visibility = new FieldGroup(new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')), new CheckboxField("ShowInSearch", $this->fieldLabel('ShowInSearch'))), $viewersOptionsField = new OptionsetField("CanViewType", _t('SiteTree.ACCESSHEADER', "Who can view this page?")), $viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('SiteTree.GroupPlaceholder', 'Click to select group')), $editorsOptionsField = new OptionsetField("CanEditType", _t('SiteTree.EDITHEADER', "Who can edit this page?")), $editorGroupsField = ListboxField::create("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('SiteTree.GroupPlaceholder', 'Click to select group')))));
     $visibility->setTitle($this->fieldLabel('Visibility'));
     // This filter ensures that the ParentID dropdown selection does not show this node,
     // or its descendents, as this causes vanishing bugs
     $parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};"));
     $parentTypeSelector->addExtraClass('parentTypeSelector');
     $tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behavior"));
     // Make page location fields read-only if the user doesn't have the appropriate permission
     if (!Permission::check("SITETREE_REORGANISE")) {
         $fields->makeFieldReadonly('ParentType');
         if ($this->ParentType == 'root') {
             $fields->removeByName('ParentID');
         } else {
             $fields->makeFieldReadonly('ParentID');
         }
     }
     $viewersOptionsSource = array();
     $viewersOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
     $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
     $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
     $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
     $viewersOptionsField->setSource($viewersOptionsSource);
     $editorsOptionsSource = array();
     $editorsOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
     $editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
     $editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
     $editorsOptionsField->setSource($editorsOptionsSource);
     if (!Permission::check('SITETREE_GRANT_ACCESS')) {
         $fields->makeFieldReadonly($viewersOptionsField);
         if ($this->CanViewType == 'OnlyTheseUsers') {
             $fields->makeFieldReadonly($viewerGroupsField);
         } else {
             $fields->removeByName('ViewerGroups');
         }
         $fields->makeFieldReadonly($editorsOptionsField);
         if ($this->CanEditType == 'OnlyTheseUsers') {
             $fields->makeFieldReadonly($editorGroupsField);
         } else {
             $fields->removeByName('EditorGroups');
         }
     }
     if (self::$runCMSFieldsExtensions) {
         $this->extend('updateSettingsFields', $fields);
     }
     return $fields;
 }
 function getCMSFields()
 {
     Requirements::css(FLICKR_EDIT_TOOLS_PATH . '/css/flickredit.js');
     $flickrSetID = Controller::curr()->request->param('ID');
     $params = Controller::curr()->request->params();
     $url = $_GET['url'];
     $splits = explode('/FlickrSet/item/', $url);
     $setid = null;
     if (sizeof($splits) == 2) {
         $splits = explode('/', $splits[1]);
         $setid = $splits[0];
     }
     $fields = new FieldList();
     $fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $forTemplate = new ArrayData(array('FlickrPhoto' => $this, 'FlickrSetID' => $setid));
     $imageHtml = $forTemplate->renderWith('FlickrImageEditing');
     $lfImage = new LiteralField('FlickrImage', $imageHtml);
     $fields->addFieldToTab('Root.Main', $lfImage);
     $fields->addFieldToTab('Root.Main', new TextField('Title', 'Title'));
     $fields->addFieldToTab('Root.Main', new TextAreaField('Description', 'Description'));
     // only show a map for editing if no sets have geolock on them
     $lockgeo = false;
     foreach ($this->FlickrSets() as $set) {
         if ($set->LockGeo == true) {
             $lockgeo = true;
             break;
         }
     }
     if (!$lockgeo) {
         $fields->addFieldToTab("Root.Location", $mapField = new LatLongField(array(new TextField('Lat', 'Latitude'), new TextField('Lon', 'Longitude'), new TextField('ZoomLevel', 'Zoom')), array('Address')));
         $guidePoints = array();
         foreach ($this->FlickrSets() as $set) {
             foreach ($set->FlickrPhotos()->where('Lat != 0 and Lon != 0') as $fp) {
                 if ($fp->Lat != 0 && $fp->Lon != 0) {
                     array_push($guidePoints, array('latitude' => $fp->Lat, 'longitude' => $fp->Lon));
                 }
             }
         }
         if (count($guidePoints) > 0) {
             $mapField->setGuidePoints($guidePoints);
         }
     }
     // quick tags, faster than the grid editor - these are processed prior to save to create/assign tags
     $fields->addFieldToTab('Root.Main', new TextField('QuickTags', 'Enter tags here separated by commas'));
     $gridConfig = GridFieldConfig_RelationEditor::create();
     //->addComponent( new GridFieldSortableRows( 'Value' ) );
     $gridConfig->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('Value', 'RawValue'));
     $gridField = new GridField("Tags", "List of Tags", $this->FlickrTags(), $gridConfig);
     $fields->addFieldToTab("Root.Main", $gridField);
     $fields->addFieldToTab("Root.Main", new CheckboxField('PromoteToHomePage', 'Promote to Home Page'));
     return $fields;
 }
	function getCMSFields() {
		Requirements::javascript(SAPPHIRE_DIR . "/javascript/RedirectorPage.js");
		
    	$fields = new FieldSet(
			new TabSet("Root",
				$tabContent = new Tab("Content",
					new TextField("Title", $this->fieldLabel('Title')),
					new TextField("MenuTitle", $this->fieldLabel('MenuTitle')),
					new FieldGroup(_t('SiteTree.URL'),
						new LabelField('BaseUrlLabel',Director::absoluteBaseURL()),
						new UniqueRestrictedTextField("URLSegment",
							"URLSegment",
							"SiteTree",
							_t('SiteTree.VALIDATIONURLSEGMENT1', "Another page is using that URL. URL must be unique for each page"),
							"[^A-Za-z0-9-]+",
							"-",
							_t('SiteTree.VALIDATIONURLSEGMENT2', "URLs can only be made up of letters, digits and hyphens."),
							"",
							"",
							"",
							50
						),
						new LabelField('TrailingSlashLabel',"/")
					),
					new HeaderField('RedirectorDescHeader',_t('RedirectorPage.HEADER', "This page will redirect users to another page")),
					new OptionsetField(
						"RedirectionType", 
						_t('RedirectorPage.REDIRECTTO', "Redirect to"), 
						array(
							"Internal" => _t('RedirectorPage.REDIRECTTOPAGE', "A page on your website"),
							"External" => _t('RedirectorPage.REDIRECTTOEXTERNAL', "Another website"),
						), 
						"Internal"
					),
					new TreeDropdownField(	
						"LinkToID", 
						_t('RedirectorPage.YOURPAGE', "Page on your website"), 
						"SiteTree"
					),
					new TextField("ExternalURL", _t('RedirectorPage.OTHERURL', "Other website URL")),
					new TextareaField("MetaDescription", _t('SiteTree.METADESC'))
				),
				$tabBehaviour = new Tab("Behaviour",
					new DropdownField("ClassName",$this->fieldLabel('ClassName'), $this->getClassDropdown()),
					new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')),
					new CheckboxField("ShowInSearch", $this->fieldLabel('ShowInSearch'))
				)
			)
		);
		
		$tabContent->setTitle(_t('SiteTree.TABCONTENT'));
		$tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR'));
		
		return $fields;
	}
Beispiel #27
0
 /**
  * Gets the form fields as defined through the metadata
  * on {@link $obj} and the custom parameters passed to FormScaffolder.
  * Depending on those parameters, the fields can be used in ajax-context,
  * contain {@link TabSet}s etc.
  *
  * @return FieldList
  */
 public function getFieldList()
 {
     $fields = new FieldList();
     // tabbed or untabbed
     if ($this->tabbed) {
         $fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
         $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     }
     // add database fields
     foreach ($this->obj->db() as $fieldName => $fieldType) {
         if ($this->restrictFields && !in_array($fieldName, $this->restrictFields)) {
             continue;
         }
         // @todo Pass localized title
         if ($this->fieldClasses && isset($this->fieldClasses[$fieldName])) {
             $fieldClass = $this->fieldClasses[$fieldName];
             $fieldObject = new $fieldClass($fieldName);
         } else {
             $fieldObject = $this->obj->dbObject($fieldName)->scaffoldFormField(null, $this->getParamsArray());
         }
         $fieldObject->setTitle($this->obj->fieldLabel($fieldName));
         if ($this->tabbed) {
             $fields->addFieldToTab("Root.Main", $fieldObject);
         } else {
             $fields->push($fieldObject);
         }
     }
     // add has_one relation fields
     if ($this->obj->hasOne()) {
         foreach ($this->obj->hasOne() as $relationship => $component) {
             if ($this->restrictFields && !in_array($relationship, $this->restrictFields)) {
                 continue;
             }
             $fieldName = $component === 'DataObject' ? $relationship : "{$relationship}ID";
             if ($this->fieldClasses && isset($this->fieldClasses[$fieldName])) {
                 $fieldClass = $this->fieldClasses[$fieldName];
                 $hasOneField = new $fieldClass($fieldName);
             } else {
                 $hasOneField = $this->obj->dbObject($fieldName)->scaffoldFormField(null, $this->getParamsArray());
             }
             if (empty($hasOneField)) {
                 continue;
             }
             // Allow fields to opt out of scaffolding
             $hasOneField->setTitle($this->obj->fieldLabel($relationship));
             if ($this->tabbed) {
                 $fields->addFieldToTab("Root.Main", $hasOneField);
             } else {
                 $fields->push($hasOneField);
             }
         }
     }
     // only add relational fields if an ID is present
     if ($this->obj->ID) {
         // add has_many relation fields
         if ($this->obj->hasMany() && ($this->includeRelations === true || isset($this->includeRelations['has_many']))) {
             foreach ($this->obj->hasMany() as $relationship => $component) {
                 if ($this->tabbed) {
                     $relationTab = $fields->findOrMakeTab("Root.{$relationship}", $this->obj->fieldLabel($relationship));
                 }
                 $fieldClass = isset($this->fieldClasses[$relationship]) ? $this->fieldClasses[$relationship] : 'GridField';
                 $grid = Object::create($fieldClass, $relationship, $this->obj->fieldLabel($relationship), $this->obj->{$relationship}(), GridFieldConfig_RelationEditor::create());
                 if ($this->tabbed) {
                     $fields->addFieldToTab("Root.{$relationship}", $grid);
                 } else {
                     $fields->push($grid);
                 }
             }
         }
         if ($this->obj->manyMany() && ($this->includeRelations === true || isset($this->includeRelations['many_many']))) {
             foreach ($this->obj->manyMany() as $relationship => $component) {
                 if ($this->tabbed) {
                     $relationTab = $fields->findOrMakeTab("Root.{$relationship}", $this->obj->fieldLabel($relationship));
                 }
                 $fieldClass = isset($this->fieldClasses[$relationship]) ? $this->fieldClasses[$relationship] : 'GridField';
                 $grid = Object::create($fieldClass, $relationship, $this->obj->fieldLabel($relationship), $this->obj->{$relationship}(), GridFieldConfig_RelationEditor::create());
                 if ($this->tabbed) {
                     $fields->addFieldToTab("Root.{$relationship}", $grid);
                 } else {
                     $fields->push($grid);
                 }
             }
         }
     }
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Build albums tab
     $fields->addFieldToTab('Root', $albumTab = new Tab('Albums'), 'Main');
     $albumTab->setTitle(_t('MagnificGalleryPage.ALBUMS', 'Albums'));
     if ($rootFolder = $this->RootFolder()) {
         $albumConfig = GridFieldConfig_RecordEditor::create();
         // Enable bulk image loading if necessary module is installed
         // @see composer.json/suggests
         if (class_exists('GridFieldBulkManager')) {
             $albumConfig->addComponent(new GridFieldBulkManager());
         }
         // Enable album sorting if necessary module is installed
         // @see composer.json/suggests
         if (class_exists('GridFieldSortableRows')) {
             $albumConfig->addComponent(new GridFieldSortableRows('SortOrder'));
         } else {
             if (class_exists('GridFieldOrderableRows')) {
                 $albumConfig->addComponent(new GridFieldOrderableRows('SortOrder'));
             }
         }
         $albumField = new GridField('Albums', 'Albums', $this->Albums(), $albumConfig);
         $fields->addFieldToTab("Root.Albums", $albumField);
     } else {
         $fields->addFieldToTab("Root.Albums", new HeaderField(_t("MagnificGalleryPage.ALBUMSNOTSAVED", "You may add albums to your gallery once you have saved the page for the first time."), $headingLevel = "3"));
     }
     // Build configuration fields
     $fields->addFieldToTab('Root', $configTab = new Tab('Configuration'));
     $configTab->setTitle(_t('MagnificGalleryPage.CONFIGURATION', 'Configuration'));
     $fields->addFieldsToTab("Root.Configuration", array($albumEffects = new DropdownField('AlbumEffect', _t('MagnificGalleryPage.ALBUMEFFECT', 'Album Effect'), array_combine(self::listEffects(), self::listEffects())), new NumericField('MediaPerPage', _t('MagnificGalleryPage.IMAGESPERPAGE', 'Number of images per page')), new LiteralField('FolderUsed', '<div class="message">' . _t('MagnificGalleryPage.FOLDERUSED', 'Images will be saved in : %s', array($this->RootFolder()->Filename)) . '</div>')));
     $albumEffects->setDescription(_t('MagnificGalleryPage.PREVIEWPAGE', 'Preview effects <a target="_blank" href="http://tympanus.net/Development/HoverEffectIdeas/">here</a>'));
     return $fields;
 }
	/**
	 * Get the pop-up fields for the given record.
	 */
	function getCustomFieldsFor($childData) {
		if(!$childData) {
			user_error("AssetTableField::DetailForm No record found");
			return null;
		}
		
		if($childData->ParentID) {
			$folder = DataObject::get_by_id('File', $childData->ParentID );
		} else {
			$folder = singleton('Folder');
		}
		
		$urlLink = "<div class='field readonly'>";
		$urlLink .= "<label class='left'>"._t('AssetTableField.URL','URL')."</label>";
		$urlLink .= "<span class='readonly'><a href='{$childData->Link()}'>{$childData->RelativeLink()}</a></span>";
		$urlLink .= "</div>";
		
		$detailFormFields = new FieldSet(
			new TabSet("BottomRoot",
				$mainTab = new Tab('Main',
					new TextField("Title", _t('AssetTableField.TITLE','Title')),
					new TextField("Name", _t('AssetTableField.FILENAME','Filename')),
					new LiteralField("AbsoluteURL", $urlLink),
					new ReadonlyField("FileType", _t('AssetTableField.TYPE','Type')),
					new ReadonlyField("Size", _t('AssetTableField.SIZE','Size'), $childData->getSize()),
					new DropdownField("OwnerID", _t('AssetTableField.OWNER','Owner'), Member::mapInCMSGroups()),
					new DateField_Disabled("Created", _t('AssetTableField.CREATED','First uploaded')),
					new DateField_Disabled("LastEdited", _t('AssetTableField.LASTEDIT','Last changed'))
				)
			)
		);
		$mainTab->setTitle(_t('AssetTableField.MAIN', 'Main'));

		if(is_a($childData, 'Image')) {
			$tab = $detailFormFields->findOrMakeTab("BottomRoot.Image", _t('AssetTableField.IMAGE', 'Image'));
			
			$big = $childData->URL;
			$formattedImage = $childData->getFormattedImage('AssetLibraryPreview');
			$thumbnail = $formattedImage ? $formattedImage->URL : '';
			
			// Hmm this required the translated string to be appended to BottomRoot to add this to the Main tab
			$detailFormFields->addFieldToTab('BottomRoot.Main',
				new ReadonlyField("Dimensions", _t('AssetTableField.DIM','Dimensions'))
			);

			$tab->push(
				new LiteralField("ImageFull",
					"<img id='thumbnailImage' src='{$thumbnail}?r=" . rand(1,100000)  . "' alt='{$childData->Name}' />"
				)
			);
		}

		if($childData && $childData->hasMethod('BackLinkTracking')) {
			if(class_exists('Subsite')) Subsite::disable_subsite_filter(true);
			$links = $childData->BackLinkTracking();
			if(class_exists('Subsite')) Subsite::disable_subsite_filter(false);

			if($links && $links->exists()) {
				$backlinks = array();
				foreach($links as $link) {
					$backlinks[] = "<li><a href=\"admin/show/$link->ID\">" . $link->Breadcrumbs(null,true). "</a></li>";
				}
				$backlinks = "<div style=\"clear:left\">". _t('AssetTableField.PAGESLINKING','The following pages link to this file:') ."<ul>" . implode("",$backlinks) . "</ul></div>";
			}
			if(!isset($backlinks)) $backlinks = "<p>". _t('AssetTableField.NOLINKS',"This file hasn't been linked to from any pages.") ."</p>";
			$detailFormFields->addFieldToTab("BottomRoot.Links", new LiteralField("Backlinks", $backlinks));
		}
		
		// the ID field confuses the Controller-logic in finding the right view for ReferencedField
		$detailFormFields->removeByName('ID');
		
		if($childData) $childData->extend('updateCMSFields', $detailFormFields);
		
		return $detailFormFields;
	}
Beispiel #30
0
 /**
  * Returns a FieldSet with which to create the CMS 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.
  *
  * @return FieldSet The fields to be displayed in the CMS.
  */
 function getCMSFields()
 {
     require_once "forms/Form.php";
     Requirements::javascript("cms/javascript/SitetreeAccess.js");
     // Backlink report
     if ($this->hasMethod('BackLinkTracking')) {
         $links = $this->BackLinkTracking();
         if ($links->exists()) {
             foreach ($links as $link) {
                 $backlinks[] = "<li><a class=\"cmsEditlink\" href=\"admin/show/{$link->ID}\">" . $link->Breadcrumbs(null, true) . "</a></li>";
             }
             $backlinks = "<div style=\"clear:left\">\n\t\t\t\t\t" . _t('SiteTree.PAGESLINKING', 'The following pages link to this page:') . "<ul>" . implode("", $backlinks) . "</ul></div>";
         }
     }
     if (!isset($backlinks)) {
         $backlinks = "<p>" . _t('SiteTree.NOBACKLINKS', 'This page hasn\'t been linked to from any pages.') . "</p>";
     }
     // Status / message
     // Create a status message for multiple parents
     if ($this->ID && is_numeric($this->ID)) {
         $linkedPages = DataObject::get("VirtualPage", "CopyContentFromID = {$this->ID}");
     }
     if (isset($linkedPages)) {
         foreach ($linkedPages as $linkedPage) {
             $parentPage = $linkedPage->Parent;
             $parentPageTitle = $parentPage->Title;
             if ($parentPage->ID) {
                 $parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/{$linkedPage->ID}\">{$parentPage->Title}</a>";
             } else {
                 $parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/{$linkedPage->ID}\">" . _t('SiteTree.TOPLEVEL', 'Site Content (Top Level)') . "</a>";
             }
         }
         $lastParent = array_pop($parentPageLinks);
         $parentList = "'{$lastParent}'";
         if (count($parentPageLinks) > 0) {
             $parentList = "'" . implode("', '", $parentPageLinks) . "' and " . $parentList;
         }
         $statusMessage[] = sprintf(_t('SiteTree.APPEARSVIRTUALPAGES', "This content also appears on the virtual pages in the %s sections."), $parentList);
     }
     if ($this->HasBrokenLink || $this->HasBrokenFile) {
         $statusMessage[] = _t('SiteTree.HASBROKENLINKS', "This page has broken links.");
     }
     $message = "STATUS: {$this->Status}<br />";
     if (isset($statusMessage)) {
         $message .= "NOTE: " . implode("<br />", $statusMessage);
     }
     $pagePriorities = array('0.0' => _t('SiteTree.PRIORITYNOTINDEXED', "Not indexed"), '1.0' => '1 - ' . _t('SiteTree.PRIORITYMOSTIMPORTANT', "Most important"), '0.9' => '2', '0.8' => '3', '0.7' => '4', '0.6' => '5', '0.5' => '6', '0.4' => '7', '0.3' => '8', '0.2' => '9', '0.1' => '10 - ' . _t('SiteTree.PRIORITYLEASTIMPORTANT', "Least important"));
     // Lay out the fields
     $fields = new FieldSet(new TabSet("Root", $tabContent = new TabSet('Content', $tabMain = new Tab('Main', new TextField("Title", _t('SiteTree.PAGETITLE', "Page name")), new TextField("MenuTitle", _t('SiteTree.MENUTITLE', "Navigation label")), new HtmlEditorField("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", PR_MEDIUM, 'HTML editor title'))), $tabMeta = new Tab('Meta-data', new FieldGroup(_t('SiteTree.URL', "URL"), new LabelField("http://www.yoursite.com/"), new UniqueRestrictedTextField("URLSegment", "URLSegment", "SiteTree", _t('SiteTree.VALIDATIONURLSEGMENT1', "Another page is using that URL. URL must be unique for each page"), "[^A-Za-z0-9-]+", "-", _t('SiteTree.VALIDATIONURLSEGMENT2', "URLs can only be made up of letters, digits and hyphens."), "", "", "", 50), new LabelField("/")), new HeaderField(_t('SiteTree.METAHEADER', "Search Engine Meta-tags")), new TextField("MetaTitle", _t('SiteTree.METATITLE', "Title")), new TextareaField("MetaDescription", _t('SiteTree.METADESC', "Description")), new TextareaField("MetaKeywords", _t('SiteTree.METAKEYWORDS', "Keywords")), new ToggleCompositeField('AdvancedOptions', _t('SiteTree.METAADVANCEDHEADER', "Advanced Options..."), array(new TextareaField("ExtraMeta", _t('SiteTree.METAEXTRA', "Custom Meta Tags")), new LiteralField("", "<p>" . sprintf(_t('SiteTree.METANOTEPRIORITY', "Manually specify a Google Sitemaps priority for this page (%s)"), '<a href="https://www.google.com/webmasters/tools/docs/en/protocol.html#prioritydef">?</a>') . "</p>"), new DropdownField("Priority", _t('SiteTree.METAPAGEPRIO', "Page Priority"), $pagePriorities)), true))), $tabBehaviour = new Tab('Behaviour', new DropdownField("ClassName", _t('SiteTree.PAGETYPE', "Page type", PR_MEDIUM, 'Classname of a page object'), $this->getClassDropdown()), new CheckboxField("ShowInMenus", _t('SiteTree.SHOWINMENUS', "Show in menus?")), new CheckboxField("ShowInSearch", _t('SiteTree.SHOWINSEARCH', "Show in search?")), new CheckboxField("ProvideComments", _t('SiteTree.ALLOWCOMMENTS', "Allow comments on this page?")), new LiteralField("", "<p>" . _t('SiteTree.NOTEUSEASHOMEPAGE', "Use this page as the 'home page' for the following domains: \n\t\t\t\t\t\t\t(separate multiple domains with commas)") . "</p>"), new TextField("HomepageForDomain", _t('SiteTree.HOMEPAGEFORDOMAIN', "Domain(s)", PR_MEDIUM, 'Listing domains that should be used as homepage'))), $tabToDo = new Tab($this->ToDo ? 'To-do **' : 'To-do', new LiteralField("ToDoHelp", _t('SiteTree.TODOHELP', "<p>You can use this to keep track of work that needs to be done to the content of your site.  To see all your pages with to do information, open the 'Site Reports' window on the left and select 'To Do'</p>")), new TextareaField("ToDo", "")), $tabReports = new TabSet('Reports', $tabBacklinks = new Tab('Backlinks', new LiteralField("Backlinks", $backlinks))), $tabAccess = new Tab('Access', new HeaderField(_t('SiteTree.ACCESSHEADER', "Who can view this page on my site?"), 2), new OptionsetField("Viewers", "", array("Anyone" => _t('SiteTree.ACCESSANYONE', "Anyone"), "LoggedInUsers" => _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users"), "OnlyTheseUsers" => _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)"))), new DropdownField("ViewersGroup", _t('SiteTree.GROUP', "Group"), Group::map()), new HeaderField(_t('SiteTree.EDITHEADER', "Who can edit this inside the CMS?"), 2), new OptionsetField("Editors", "", array("LoggedInUsers" => _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS"), "OnlyTheseUsers" => _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)"))), new DropdownField("EditorsGroup", _t('SiteTree.GROUP'), Group::map()))));
     $tabContent->setTitle(_t('SiteTree.TABCONTENT', "Content"));
     $tabMain->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $tabMeta->setTitle(_t('SiteTree.TABMETA', "Meta-data"));
     $tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behaviour"));
     $tabReports->setTitle(_t('SiteTree.TABREPORTS', "Reports"));
     $tabAccess->setTitle(_t('SiteTree.TABACCESS', "Access"));
     $tabBacklinks->setTitle(_t('SiteTree.TABBACKLINKS', "BackLinks"));
     if (self::$runCMSFieldsExtensions) {
         $this->extend('updateCMSFields', $fields);
     }
     return $fields;
 }