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


PHP GridField::setModelClass方法代码示例

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


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

示例1: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Features');
     $fields->removeByName('ExtraContent');
     $regContent = $fields->dataFieldByName('RegistrationContent');
     $afterContent = $fields->dataFieldByName('AfterRegistrationContent');
     $profileContent = $fields->dataFieldByName('ProfileContent');
     $regContent->addExtraClass('no-pagebreak');
     $afterContent->addExtraClass('no-pagebreak');
     $profileContent->addExtraClass('no-pagebreak');
     $fields->insertAfter(TextareaField::create('ApprovalEmailTemplate', 'Approval Email Template'), 'EmailTemplate');
     $fields->insertAfter(TextField::create('ApprovalEmailSubject', 'Approval Email Subject'), 'EmailTemplate');
     $fields->insertAfter(TextareaField::create('ExpiryReminderEmailTemplate', 'Expiry Reminder Email Template'), 'ApprovalEmailTemplate');
     $fields->insertAfter(TextField::create('ExpiryReminderEmailSubject', 'Expiry Reminder Email Subject'), 'ApprovalEmailTemplate');
     $fields->insertAfter(TextareaField::create('ExpiryEmailTemplate', 'Expiry Email Template'), 'ExpiryReminderEmailTemplate');
     $fields->insertAfter(TextField::create('ExpiryEmailSubject', 'Expiry Email Subject'), 'ExpiryReminderEmailTemplate');
     $fields->addFieldToTab('Root.Members', LiteralField::create('MembersNote', '<p class="message"><strong>Note:</strong> This list has been filtered to include current and pending members only. Use the Members admin area for handling expired memberships and non-member website users.</p>'));
     $members = Member::get()->exclude(array('MembershipStatus' => 'Not applied'))->exclude(array('MembershipStatus' => 'Expired'))->sort(array('ExpiryDate' => 'ASC'));
     $gridField = new GridField('Members', 'NZLARP Members', $members, $config = GridFieldConfig_RecordEditor::create());
     $gridField->setModelClass('Member');
     $columns = $config->getComponentByType('GridFieldDataColumns');
     $columns->setFieldFormatting(array('LastEdited' => function ($value, $item) {
         return $item->LastEditedNice();
     }));
     $columns->setDisplayFields(array('getName' => 'Name', 'Region.Title' => 'Region', 'MembershipStatus' => 'Status', 'ExpiryDate' => 'Expires', 'LastEdited' => 'Last Activity'));
     $fields->addFieldToTab('Root.Members', $gridField);
     $config->getComponentByType('GridFieldPaginator')->setItemsPerPage(200);
     return $fields;
 }
开发者ID:adrexia,项目名称:nzlarps,代码行数:30,代码来源:RegistrationPage.php

示例2: testGridFieldModelClass

 /**
  * @covers GridField::getModelClass
  * @covers GridField::setModelClass
  */
 public function testGridFieldModelClass()
 {
     $obj = new GridField('testfield', 'testfield', Member::get());
     $this->assertEquals('Member', $obj->getModelClass(), 'Should return Member');
     $obj->setModelClass('DataModel');
     $this->assertEquals('DataModel', $obj->getModelClass(), 'Should return Member');
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:11,代码来源:GridFieldTest.php

示例3: getCMSFields

 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
     $f->addFieldToTab('Root.Main', new TextField('Name', 'Name'));
     $f->addFieldToTab('Root.Main', $ddl = new DropdownField('ListType', 'ListType', $this->dbObject('ListType')->enumValues()));
     $f->addFieldToTab('Root.Main', $ddl2 = new DropdownField('CategoryID', 'Category', PresentationCategory::get()->filter('SummitID', $_REQUEST['SummitID'])->map('ID', 'Title')));
     $ddl->setEmptyString('-- Select List Type --');
     $ddl2->setEmptyString('-- Select Track  --');
     if ($this->ID > 0) {
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $config->addComponent(new GridFieldPublishSummitEventAction());
         $config->removeComponentsByType('GridFieldDeleteAction');
         $config->removeComponentsByType('GridFieldAddNewButton');
         $config->addComponent($bulk_summit_types = new GridFieldBulkActionAssignSummitTypeSummitEvents());
         $bulk_summit_types->setTitle('Set Summit Types');
         $result = DB::query("SELECT DISTINCT SummitEvent.*, Presentation.*\nFROM SummitEvent\nINNER JOIN Presentation ON Presentation.ID = SummitEvent.ID\nINNER JOIN SummitSelectedPresentation ON SummitSelectedPresentation.PresentationID = Presentation.ID\nINNER JOIN SummitSelectedPresentationList ON SummitSelectedPresentation.SummitSelectedPresentationListID = {$this->ID}\nORDER BY SummitSelectedPresentation.Order ASC\n");
         $presentations = new ArrayList();
         foreach ($result as $row) {
             $presentations->add(new Presentation($row));
         }
         $gridField = new GridField('SummitSelectedPresentations', 'Selected Presentations', $presentations, $config);
         $gridField->setModelClass('Presentation');
         $f->addFieldToTab('Root.Main', $gridField);
     }
     return $f;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:30,代码来源:SummitSelectedPresentationList.php

示例4: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->insertBefore(new DropdownField('MemberID', 'Member', Member::get()->map('ID', "FirstName")), 'AttendingWholeEvent');
     $siteConfig = SiteConfig::current_site_config();
     $current = $siteConfig->getCurrentEventID();
     if ($this->ParentID < 1) {
         $event = Event::get()->byID($current);
     } else {
         $event = Event::get()->byID($this->ParentID);
     }
     $fields->insertAfter(HiddenField::create('ParentID', 'Event', $event->ID), 'ExtraDetail');
     $fields->removeByName('PublicFieldsRaw');
     $fields->removeByName('Sort');
     if ($this->PlayerGames()->Count() > 0) {
         $gridField = new GridField('PlayerGames', 'Games', $this->PlayerGames(), $config = GridFieldConfig_RelationEditor::create());
         $gridField->setModelClass('PlayerGame');
         $config->addComponent(new GridFieldOrderableRows());
         $config->removeComponentsByType('GridFieldPaginator');
         $config->removeComponentsByType('GridFieldPageCount');
         $config->addComponent(new GridFieldDeleteAction(false));
         $config->addComponent($export = new GridFieldExportButton('before'));
         $export->setExportColumns(singleton("PlayerGame")->getExportFields());
         $fields->addFieldToTab('Root.PlayerGames', $gridField);
     }
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:adrexia-gamesevent,代码行数:27,代码来源:Registration.php

示例5: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->insertBefore(TextareaField::create('Intro', 'Intro'), 'Content');
     $fields->insertAfter(ColorPaletteField::create("Colour", "Colour", array('night' => '#333333', 'air' => '#009EE2', 'earth' => ' #79c608', 'passion' => '#b02635', 'people' => '#de347f', 'inspiration' => '#783980')), "Intro");
     $fields->insertBefore($image = UploadField::create('SplashImage', 'Splash Image'), 'Content');
     $image->setFolderName('Uploads/Splash-Images');
     if ($this->ClassName === "Page" || $this->ClassName === "HomePage") {
         $fields->insertAfter(HTMLEditorField::create('ExtraContent'), 'Content');
         $gridField = new GridField('FeatureItems', 'FeatureItems', $this->FeatureItems()->sort(array('Sort' => 'ASC', 'Archived' => 'ASC')), $config = GridFieldConfig_RelationEditor::create());
         $gridField->setModelClass('FeatureItem');
         $fields->addFieldToTab('Root.Features', $gridField);
         $config->addComponent(new GridFieldOrderableRows());
     } else {
         if ($this->ClassName === "CalendarPage") {
             $content = $fields->dataFieldByName('Content');
             $content->addExtraClass('no-pagebreak');
             $events = Event::get()->sort(array('StartDateTime' => 'Desc'))->filterByCallback(function ($record) {
                 return !$record->getIsPastEvent();
             });
             $gridField = new GridField('Event', 'Upcoming Events', $events, $config = GridFieldConfig_RecordEditor::create());
             $gridField->setModelClass('Event');
             $dataColumns = $config->getComponentByType('GridFieldDataColumns');
             $dataColumns->setDisplayFields(array('Title' => 'Title', 'StartDateTime' => 'Date and Time', 'DatesAndTimeframe' => 'Presentation String'));
             $fields->addFieldToTab('Root.UpcomingEvents', $gridField);
         }
     }
     return $fields;
 }
开发者ID:adrexia,项目名称:nzlarps,代码行数:29,代码来源:Page.php

示例6: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Main Content tab
     // Carousel tab
     $carouselItemsGrid = null;
     // Manay to many relations can only be established if we have an id. So put a place holder instead of a grid if this is a new object.
     if ($this->ID == 0) {
         $carouselItemsGrid = TextField::create("CarouselItems", "Carousel Items")->setDisabled(true)->setValue("Page must be saved once before adding Carousel Items.");
     } else {
         $carouselItemsGrid = new GridField('CarouselItems', 'Carousel', $this->CarouselItems()->sort('Archived'), GridFieldConfig_RelationEditor::create());
         $carouselItemsGridUploadComponent = new GridFieldBulkUpload("Image");
         $carouselItemsGridUploadComponent->setUfSetup("setFolderName", $this->ImageFolder("carousel"));
         $carouselItemsGrid->setModelClass('CarouselItem')->getConfig()->addComponent($carouselItemsGridUploadComponent)->addComponent(new GridFieldOrderableRows("SortID"));
     }
     $fields->addFieldToTab('Root.Carousel', $carouselItemsGrid);
     // Links
     $fields->addFieldToTab('Root.Links', new TreeDropdownField('LearnMorePageID', 'Page to link the "Learn More" button to:', 'SiteTree'));
     $fields->addFieldToTab('Root.Links', new TextField('LearnMoreButtonText', 'Text to display on the "Learn More" button:', 'SiteTree'));
     $quickLinksGrid = new GridField('Quicklinks', 'Quicklinks', $this->Quicklinks(), GridFieldConfig_RelationEditor::create());
     $quickLinksGrid->setModelClass('Quicklink');
     $quickLinksFieldGroup = FieldGroup::create($quickLinksGrid)->setTitle('Quick Links');
     $quickLinksFieldGroup->setName("QuicklinkGroup");
     $fields->addFieldToTab('Root.Links', $quickLinksFieldGroup);
     $fields->removeByName('Translations');
     $fields->removeByName('Import');
     $fields->addFieldToTab('Root.Features', ToggleCompositeField::create('FeatureOne', _t('SiteTree.FeatureOne', 'Feature One'), array(new TextField('FeatureOneTitle', 'Title'), new DropdownField('FeatureOneCategory', 'Category', singleton('ExpressHomePage')->dbObject('FeatureOneCategory')->enumValues()), new HTMLEditorField('FeatureOneContent', 'Content'), new TreeDropdownField('FeatureOneLinkID', 'Page to link to', 'SiteTree'), new TextField('FeatureOneButtonText', 'Button text')))->setHeadingLevel(3));
     $fields->addFieldToTab('Root.Features', ToggleCompositeField::create('FeatureTwo', _t('SiteTree.FeatureTwo', 'Feature Two'), array(new TextField('FeatureTwoTitle', 'Title'), new DropdownField('FeatureTwoCategory', 'Category', singleton('ExpressHomePage')->dbObject('FeatureTwoCategory')->enumValues()), new HTMLEditorField('FeatureTwoContent', 'Content'), new TreeDropdownField('FeatureTwoLinkID', 'Page to link to', 'SiteTree'), new TextField('FeatureTwoButtonText', 'Button text')))->setHeadingLevel(3));
     return $fields;
 }
开发者ID:guru-digital,项目名称:gdm-ss-express,代码行数:30,代码来源:ExpressHomePage.php

示例7: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $gridField = new GridField('CarouselItems', 'Carousel', $this->CarouselItems(), GridFieldConfig_RelationEditor::create());
     $gridField->setModelClass('CarouselItem');
     $fields->addFieldToTab('Root.Carousel', $gridField);
     return $fields;
 }
开发者ID:robert-h-curry,项目名称:huttclub,代码行数:8,代码来源:HomePage.php

示例8: testGetClasses

 public function testGetClasses()
 {
     $grid = new GridField('TestGridField');
     $grid->setModelClass('GridFieldAddNewMultiClassTest_A');
     $component = new GridFieldAddNewMultiClass();
     $this->assertEquals(array('GridFieldAddNewMultiClassTest_A' => 'A', 'GridFieldAddNewMultiClassTest_B' => 'B', 'GridFieldAddNewMultiClassTest_C' => 'C'), $component->getClasses($grid), 'Subclasses are populated by default and sorted');
     $component->setClasses(array('GridFieldAddNewMultiClassTest_B' => 'Custom Title', 'GridFieldAddNewMultiClassTest_A'));
     $this->assertEquals(array('GridFieldAddNewMultiClassTest_B' => 'Custom Title', 'GridFieldAddNewMultiClassTest_A' => 'A'), $component->getClasses($grid), 'Sorting and custom titles can be specified');
 }
开发者ID:helpfulrobot,项目名称:ajshort-silverstripe-gridfieldextensions,代码行数:9,代码来源:GridFieldAddNewMultiClassTest.php

示例9: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     $gridfield_config = new GridFieldConfig_RecordViewer();
     $translation = _t('AutoArchiveDestinationExtension.Archivables', 'Archivables');
     $fields->addFieldToTab('Root', new Tab('ArchivablesTab', $translation));
     $fields->addFieldToTab('Root.ArchivablesTab', $gridfield = new GridField('Archivables', $translation, $this->Archivables(true), $gridfield_config));
     $gridfield->setModelClass($this->Archivables()->exists() ? $this->Archivables()->first()->ClassName : AutoArchivableExtension::getExtendedClasses()[0]);
     $gridfield->setDescription(_t('AutoArchiveDestinationExtension.ArchivablesTabDescription', 'This list shows all pages that will be moved under this page when/if they will be archived in the future.'));
 }
开发者ID:taitava,项目名称:silverstripe-autoarchivable,代码行数:9,代码来源:AutoArchiveDestinationExtension.php

示例10: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->insertAfter(HTMLEditorField::create('ExtraContent'), 'Content');
     $gridField = new GridField('Region', 'Regions', Region::get(), $config = GridFieldConfig_RecordEditor::create());
     $gridField->setModelClass('Region');
     $fields->addFieldToTab('Root.Regions', $gridField);
     return $fields;
 }
开发者ID:adrexia,项目名称:nzlarps,代码行数:9,代码来源:AboutPage.php

示例11: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->insertAfter(new HTMLEditorField('Sidebar', 'Sidebar Content'), 'Content');
     // Slider tab
     $gridField = new GridField('PromotionalBanners', 'Promotional Banners', $this->PromotionalBanners()->sort(array('Sort' => 'ASC', 'Archived' => 'ASC')), $conf = GridFieldConfig_RelationEditor::create());
     $gridField->setModelClass('PromotionalBanner');
     $fields->addFieldToTab('Root.PromotionalBanners', $gridField);
     $conf->addComponent(new GridFieldOrderableRows());
     return $fields;
 }
开发者ID:adrexia,项目名称:whatislarp,代码行数:11,代码来源:Page.php

示例12: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $gridField = new GridField('NewsItems', 'NewsItems', $this->NewsItems()->sort(array('Created' => 'ASC', 'Archived' => 'ASC')), $config = GridFieldConfig_RelationEditor::create());
     $gridField->setModelClass('NewsItem');
     $fields->addFieldtoTab('Root.News', $gridField);
     $config->addComponent(new GridFieldOrderableRows());
     $fields->removeByName('Content');
     $fields->removeByName('ExtraContent');
     $fields->removeByName('Features');
     return $fields;
 }
开发者ID:adrexia,项目名称:nzlarps,代码行数:12,代码来源:NewsPage.php

示例13: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Sidebar');
     $fields->removeByName('PromotionalBanners');
     $fields->insertBefore(UploadField::create('FeatureImage', 'Feature Image'), 'Content');
     // Slider tab
     $gridField = new GridField('SliderItems', 'Slider', $this->SliderItems()->sort(array('Sort' => 'ASC', 'Archived' => 'ASC')), $sliderConf = GridFieldConfig_RelationEditor::create());
     $gridField->setModelClass('SliderItem');
     $fields->addFieldToTab('Root.Slider', $gridField);
     $sliderConf->addComponent(new GridFieldOrderableRows());
     return $fields;
 }
开发者ID:adrexia,项目名称:whatislarp,代码行数:13,代码来源:HomePage.php

示例14: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // NewsGrid
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldAddNewSiteTreeItemButton('toolbar-header-right'), new GridFieldSortableHeader(), new GridFieldFilterHeader(), $dataColumns = new GridFieldDataColumns(), new GridFieldPaginator(20), new GridFieldEditSiteTreeItemButton());
     $dataColumns->setDisplayFields(array('Title' => 'Title', 'URLSegment' => 'URL', 'formattedPublishDate' => 'Publish date', 'getStatus' => 'Status', 'LastEdited' => 'Changed'));
     // include both live and stage versions of pages
     $pages = $this->AllChildrenIncludingDeleted();
     // use gridfield as normal;
     $gridField = new GridField("Subpages", "Manage Blogposts", $pages, $gridFieldConfig);
     $gridField->setModelClass(self::$default_child);
     //$gridField->setModelClass("GridFieldPage"); // prevents "GridField doesn't have a modelClassName" error
     $fields->addFieldToTab("Root.BlogPosts", $gridField);
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:micschk-silverstripe-bloggrid,代码行数:15,代码来源:BlogGridHolder.php

示例15: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $gridEventConfig = GridFieldConfig_RecordEditor::create();
     $gridEventConfig->removeComponentsByType('GridFieldDetailForm');
     $gridEventConfig->addComponent(new CalendarEventPageGridFieldDetailForm());
     //Coming events
     $comingEvents = $this->ComingEvents();
     $GridFieldComing = new GridField('ComingEvents', '', $comingEvents, $gridEventConfig);
     $GridFieldComing->setModelClass('PublicEvent');
     $fields->addFieldToTab('Root.ComingEvents', $GridFieldComing);
     //Past events
     $pastEvents = $this->PastEvents();
     $GridFieldPast = new GridField('PastEvents', '', $pastEvents, $gridEventConfig);
     $GridFieldPast->setModelClass('PublicEvent');
     $fields->addFieldToTab('Root.PastEvents', $GridFieldPast);
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:titledk-silverstripe-calendar,代码行数:18,代码来源:EventPage.php


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