コード例 #1
0
 public function getCMSFields()
 {
     $fields = $this->scaffoldFormFields(array('includeRelations' => $this->ID > 0, 'tabbed' => true, 'ajaxSafe' => true));
     $fields->insertAfter(new ReadonlyField('Type'), 'Title');
     $fields->removeByName('ListID');
     $fields->removeByName('ParentID');
     $fields->removeByName('Sort');
     $fields->removeByName('ExtraClass');
     /** Title
      * By default, the Title is used for reference only
      * Set $enable_title_in_template to true  when using title in template
      */
     if (!$this->enable_title_in_template) {
         $fields->removeByName('HideTitle');
         $title = $fields->fieldByName('Root.Main.Title');
         if ($title) {
             $title->setRightTitle('For reference only. Does not appear in the template.');
         }
     }
     $fields->addFieldToTab('Root.Settings', new TextField('ExtraClass', 'Extra CSS Classes to add'));
     if (!is_a($this, 'ElementList')) {
         $lists = ElementList::get()->filter('ParentID', $this->ParentID);
         if ($lists->exists()) {
             $fields->addFieldToTab('Root.Main', $move = new DropdownField('MoveToListID', 'Move this to another list', $lists->map('ID', 'CMSTitle'), ''));
             $move->setEmptyString('Select a list..');
             $move->setHasEmptyDefault(true);
         }
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
コード例 #2
0
 public function getCMSFields()
 {
     $fields = $this->scaffoldFormFields(array('includeRelations' => $this->ID > 0, 'tabbed' => true, 'ajaxSafe' => true));
     $fields->insertAfter(new ReadonlyField('ClassNameTranslated', _t('BaseElement.TYPE', 'Type'), $this->i18n_singular_name()), 'Title');
     $fields->removeByName('ListID');
     $fields->removeByName('ParentID');
     $fields->removeByName('Sort');
     $fields->removeByName('ExtraClass');
     if (!$this->config()->enable_title_in_template) {
         $fields->removeByName('HideTitle');
         $title = $fields->fieldByName('Root.Main.Title');
         if ($title) {
             $title->setRightTitle('For reference only. Does not appear in the template.');
         }
     }
     $fields->addFieldToTab('Root.Settings', new TextField('ExtraClass', 'Extra CSS Classes to add'));
     if (!is_a($this, 'ElementList')) {
         $lists = ElementList::get()->filter('ParentID', $this->ParentID);
         if ($lists->exists()) {
             $fields->addFieldToTab('Root.Settings', $move = new DropdownField('MoveToListID', 'Move this to another list', $lists->map('ID', 'CMSTitle'), ''));
             $move->setEmptyString('Select a list..');
             $move->setHasEmptyDefault(true);
         }
     }
     if ($virtual = $fields->dataFieldByName('VirtualClones')) {
         if ($this->Parent() && $this->Parent()->exists() && $this->Parent()->getOwnerPage() && $this->Parent()->getOwnerPage()->exists()) {
             $tab = $fields->findOrMakeTab('Root.VirtualClones');
             $tab->setTitle(_t('BaseElement.VIRTUALTABTITLE', 'Linked To'));
             $ownerPage = $this->Parent()->getOwnerPage();
             $tab->push(new LiteralField('DisplaysOnPage', sprintf("<p>The original content block appears on <a href='%s'>%s</a></p>", $ownerPage->hasMethod('CMSEditLink') && $ownerPage->canEdit() ? $ownerPage->CMSEditLink() : $ownerPage->Link(), $ownerPage->MenuTitle)));
             $virtual->setConfig(new GridFieldConfig_Base());
             $virtual->setTitle(_t('BaseElement.OTHERPAGES', 'Other pages'))->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter')->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldDeleteAction')->removeComponentsByType('GridFieldDetailForm')->addComponent(new ElementalGridFieldDeleteAction());
             $virtual->getConfig()->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('getPage.Title' => 'Title', 'getPage.Link' => 'Link'));
         }
     }
     $this->extend('updateCMSFields', $fields);
     if ($this->IsInDB()) {
         if ($this->isEndofLine('BaseElement') && $this->hasExtension('VersionViewerDataObject')) {
             $fields = $this->addVersionViewer($fields, $this);
         }
     }
     return $fields;
 }