public function LinkForm()
 {
     //        echo 'ssss';die();
     $siteTree = new TreeDropdownField('internal', _t('HtmlEditorField.PAGE', "Page"), 'SiteTree', 'ID', 'MenuTitle', true);
     // mimic the SiteTree::getMenuTitle(), which is bypassed when the search is performed
     $siteTree->setSearchFunction(array($this, 'siteTreeSearchCallback'));
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>' . '<strong class="title">%s</strong></span>';
     $form = new Form($this->controller, "{$this->name}/LinkForm", new FieldList($headerWrap = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.LINK', 'Insert Link')))), $contentComposite = new CompositeField(new OptionsetField('LinkType', sprintf($numericLabelTmpl, '1', _t('MarkdownEditorField.LINKTO', 'Link to')), array('internal' => _t('MarkdownEditorField.LINKINTERNAL', 'Page on the site'), 'external' => _t('MarkdownEditorField.LINKEXTERNAL', 'Another website'), 'anchor' => _t('MarkdownEditorField.LINKANCHOR', 'Anchor on this page'), 'email' => _t('MarkdownEditorField.LINKEMAIL', 'Email address')), 'internal'), new LiteralField('Step2', '<div class="step2">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.DETAILS', 'Details')) . '</div>'), $siteTree, new TextField('external', _t('MarkdownEditorField.URL', 'URL'), 'http://'), new EmailField('email', _t('MarkdownEditorField.EMAIL', 'Email address')), new TreeDropdownField('file', _t('MarkdownEditorField.FILE', 'File'), 'File', 'ID', 'Title', true), new TextField('Anchor', _t('MarkdownEditorField.ANCHORVALUE', 'Anchor')), new TextField('LinkText', _t('MarkdownEditorField.LINKTEXT', 'Link text')), new TextField('Description', _t('MarkdownEditorField.LINKDESCR', 'Link title')), new CheckboxField('TargetBlank', _t('MarkdownEditorField.LINKOPENNEWWIN', 'Open link in a new window?')), new HiddenField('Locale', null, $this->controller->Locale))), new FieldList(FormAction::create('insert', _t('HtmlEditorField.BUTTONINSERTLINK', 'Insert link'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
     $headerWrap->addExtraClass('CompositeField composite cms-content-header nolabel ');
     $contentComposite->addExtraClass('ss-insert-link content');
     $form->unsetValidator();
     $form->loadDataFrom($this);
     $form->addExtraClass('markdownfield-form markdowneditorfield-linkform cms-dialog-content');
     $this->extend('updateLinkForm', $form);
     return $form;
 }
コード例 #2
0
 /**
  * @return Form
  */
 public function AddForm()
 {
     $pageTypes = array();
     foreach ($this->PageTypes() as $type) {
         $html = sprintf('<span class="page-icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>', $type->getField('ClassName'), $type->getField('AddAction'), $type->getField('Description'));
         $pageTypes[$type->getField('ClassName')] = DBField::create_field('HTMLText', $html);
     }
     // Ensure generic page type shows on top
     if (isset($pageTypes['Page'])) {
         $pageTitle = $pageTypes['Page'];
         $pageTypes = array_merge(array('Page' => $pageTitle), $pageTypes);
     }
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><span class="title">%s</span></span>';
     $topTitle = _t('CMSPageAddController.ParentMode_top', 'Top level');
     $childTitle = _t('CMSPageAddController.ParentMode_child', 'Under another page');
     $fields = new FieldList(new LiteralField('PageModeHeader', sprintf($numericLabelTmpl, 1, _t('CMSMain.ChoosePageParentMode', 'Choose where to create this page'))), $parentModeField = new SelectionGroup("ParentModeField", array(new SelectionGroup_Item("top", null, $topTitle), new SelectionGroup_Item('child', $parentField = new TreeDropdownField("ParentID", "", 'SiteTree', 'ID', 'TreeTitle'), $childTitle))), $typeField = new OptionsetField("PageType", sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')), $pageTypes, 'Page'), new LiteralField('RestrictedNote', sprintf('<p class="message notice message-restricted">%s</p>', _t('CMSMain.AddPageRestriction', 'Note: Some page types are not allowed for this selection'))));
     $parentField->setSearchFunction(function ($sourceObject, $labelField, $search) {
         return DataObject::get($sourceObject, sprintf("\"MenuTitle\" LIKE '%%%s%%' OR \"Title\" LIKE '%%%s%%'", Convert::raw2sql($search), Convert::raw2sql($search)));
     });
     // TODO Re-enable search once it allows for HTML title display,
     // see http://open.silverstripe.org/ticket/7455
     // $parentField->setShowSearch(true);
     $parentModeField->addExtraClass('parent-mode');
     // CMSMain->currentPageID() automatically sets the homepage,
     // which we need to counteract in the default selection (which should default to root, ID=0)
     if ($parentID = $this->getRequest()->getVar('ParentID')) {
         $parentModeField->setValue('child');
         $parentField->setValue((int) $parentID);
     } else {
         $parentModeField->setValue('top');
     }
     $actions = new FieldList(FormAction::create("doAdd", _t('CMSMain.Create', "Create"))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true), FormAction::create("doCancel", _t('CMSMain.Cancel', "Cancel"))->addExtraClass('ss-ui-action-destructive ss-ui-action-cancel')->setUseButtonTag(true));
     $this->extend('updatePageOptions', $fields);
     $form = CMSForm::create($this, "AddForm", $fields, $actions)->setHTMLID('Form_AddForm');
     $form->setAttribute('data-hints', $this->SiteTreeHints());
     $form->setAttribute('data-childfilter', $this->Link('childfilter'));
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses());
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     return $form;
 }
コード例 #3
0
 /**
  * Return a {@link Form} instance allowing a user to
  * add links in the TinyMCE content editor.
  *  
  * @return Form
  */
 function LinkForm()
 {
     $siteTree = new TreeDropdownField('internal', _t('HtmlEditorField.PAGE', "Page"), 'SiteTree', 'ID', 'MenuTitle', true);
     // mimic the SiteTree::getMenuTitle(), which is bypassed when the search is performed
     $siteTree->setSearchFunction(array($this, 'siteTreeSearchCallback'));
     $form = new Form($this->controller, "{$this->name}/LinkForm", new FieldSet(new LiteralField('Heading', sprintf('<h3>%s</h3>', _t('HtmlEditorField.LINK', 'Link'))), $contentComposite = new CompositeField(new OptionsetField('LinkType', _t('HtmlEditorField.LINKTO', 'Link to'), array('internal' => _t('HtmlEditorField.LINKINTERNAL', 'Page on the site'), 'external' => _t('HtmlEditorField.LINKEXTERNAL', 'Another website'), 'anchor' => _t('HtmlEditorField.LINKANCHOR', 'Anchor on this page'), 'email' => _t('HtmlEditorField.LINKEMAIL', 'Email address'), 'file' => _t('HtmlEditorField.LINKFILE', 'Download a file'))), $siteTree, new TextField('external', _t('HtmlEditorField.URL', 'URL'), 'http://'), new EmailField('email', _t('HtmlEditorField.EMAIL', 'Email address')), new TreeDropdownField('file', _t('HtmlEditorField.FILE', 'File'), 'File', 'Filename', 'Title', true), new TextField('Anchor', _t('HtmlEditorField.ANCHORVALUE', 'Anchor')), new TextField('LinkText', _t('HtmlEditorField.LINKTEXT', 'Link text')), new TextField('Description', _t('HtmlEditorField.LINKDESCR', 'Link description')), new CheckboxField('TargetBlank', _t('HtmlEditorField.LINKOPENNEWWIN', 'Open link in a new window?')), new HiddenField('Locale', null, $this->controller->Locale))), new FieldSet(new FormAction('insert', _t('HtmlEditorField.BUTTONINSERTLINK', 'Insert link')), new FormAction('remove', _t('HtmlEditorField.BUTTONREMOVELINK', 'Remove link'))));
     $contentComposite->addExtraClass('content');
     $form->unsetValidator();
     $form->loadDataFrom($this);
     $this->extend('updateLinkForm', $form);
     return $form;
 }