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


PHP TreeDropdownField::setSearchFunction方法代码示例

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


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

示例1: LinkForm

 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;
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-markdown,代码行数:16,代码来源:MarkdownEditorField.php

示例2: AddForm

 /**
  * @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;
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:44,代码来源:CMSPageAddController.php

示例3: LinkForm

 /**
  * 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;
 }
开发者ID:hamishcampbell,项目名称:silverstripe-sapphire,代码行数:18,代码来源:HtmlEditorField.php


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