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


PHP DataObjectSet::toDropdownMap方法代码示例

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


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

示例1: getCMSFields

 function getCMSFields()
 {
     $subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain");
     if (!$subsites) {
         $subsites = new DataObjectSet();
     }
     if (Subsite::hasMainSitePermission(null, array("CMS_ACCESS_CMSMain"))) {
         $subsites->push(new ArrayData(array('Title' => 'Main site', "\"ID\"" => 0)));
     }
     if ($subsites->Count()) {
         $subsiteSelectionField = new DropdownField("CopyContentFromID_SubsiteID", "Subsite", $subsites->toDropdownMap('ID', 'Title'), $this->CopyContentFromID ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID'));
     }
     // Setup the linking to the original page.
     $pageSelectionField = new SubsitesTreeDropdownField("RelatedPageID", _t('VirtualPage.CHOOSE', "Choose a page to link to"), "SiteTree", "ID", "MenuTitle");
     if (isset($_GET['RelatedPageID_SubsiteID'])) {
         $pageSelectionField->setSubsiteID($_GET['RelatedPageID_SubsiteID']);
     }
     $pageSelectionField->setFilterFunction(create_function('$item', 'return $item->ClassName != "VirtualPage";'));
     if ($subsites->Count()) {
         $fields = new FieldSet($subsiteSelectionField, $pageSelectionField);
     } else {
         $fields = new FieldSet($pageSelectionField);
     }
     return $fields;
 }
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:25,代码来源:RelatedPageLink.php

示例2: getCMSFields

 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $subsites = DataObject::get('Subsite');
     if (!$subsites) {
         $subsites = new DataObjectSet();
     }
     $subsites->push(new ArrayData(array('Title' => 'Main site', 'ID' => 0)));
     $subsiteSelectionField = new DropdownField("CopyContentFromID_SubsiteID", "Subsite", $subsites->toDropdownMap('ID', 'Title'), $this->CopyContentFromID ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID'));
     $fields->addFieldToTab('Root.Content.Main', $subsiteSelectionField, 'CopyContentFromID');
     // Setup the linking to the original page.
     $pageSelectionField = new SubsitesTreeDropdownField("CopyContentFromID", _t('VirtualPage.CHOOSE', "Choose a page to link to"), "SiteTree", "ID", "MenuTitle");
     $pageSelectionField->setFilterFunction(create_function('$item', 'return !($item instanceof VirtualPage);'));
     if (Controller::has_curr() && Controller::curr()->getRequest()) {
         $subsiteID = Controller::curr()->getRequest()->getVar('CopyContentFromID_SubsiteID');
         $pageSelectionField->setSubsiteID($subsiteID);
     }
     $fields->replaceField('CopyContentFromID', $pageSelectionField);
     // Create links back to the original object in the CMS
     if ($this->CopyContentFromID) {
         $editLink = "admin/show/{$this->CopyContentFromID}/?SubsiteID=" . $this->CopyContentFrom()->SubsiteID;
         $linkToContent = "\n\t\t\t\t<a class=\"cmsEditlink\" href=\"{$editLink}\">" . _t('VirtualPage.EDITCONTENT', 'Click here to edit the content') . "</a>";
         $fields->removeByName("VirtualPageContentLinkLabel");
         $fields->addFieldToTab("Root.Content.Main", $linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent), 'Title');
         $linkToContentLabelField->setAllowHTML(true);
     }
     $fields->addFieldToTab('Root.Content.Metadata', new TextField('CustomMetaTitle', 'Title (overrides inherited value from the source)'), 'MetaTitle');
     $fields->addFieldToTab('Root.Content.Metadata', new TextareaField('CustomMetaKeywords', 'Keywords (overrides inherited value from the source)'), 'MetaKeywords');
     $fields->addFieldToTab('Root.Content.Metadata', new TextareaField('CustomMetaDescription', 'Description (overrides inherited value from the source)'), 'MetaDescription');
     $fields->addFieldToTab('Root.Content.Metadata', new TextField('CustomExtraMeta', 'Custom Meta Tags (overrides inherited value from the source)'), 'ExtraMeta');
     return $fields;
 }
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:32,代码来源:SubsitesVirtualPage.php


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