當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataObjectSet::merge方法代碼示例

本文整理匯總了PHP中DataObjectSet::merge方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataObjectSet::merge方法的具體用法?PHP DataObjectSet::merge怎麽用?PHP DataObjectSet::merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DataObjectSet的用法示例。


在下文中一共展示了DataObjectSet::merge方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ProductsShowable

 /**
  * Recursively create a set of {@link Product} pages
  * that belong to this ProductGroup as a child, related
  * Product, or through one of this ProductGroup's nested
  * ProductGroup pages.
  * 
  * @param string $extraFilter Additional SQL filters to apply to the Product retrieval
  * @param array $permissions 
  * @return DataObjectSet
  */
 function ProductsShowable($extraFilter = '', $permissions = array("Show All Products"))
 {
     $filter = "`ShowInMenus` = 1";
     if ($extraFilter) {
         $filter .= " AND {$extraFilter}";
     }
     $products = new DataObjectSet();
     $childProducts = DataObject::get('Product', "`ParentID` = {$this->ID} AND {$filter}");
     $relatedProducts = $this->getManyManyComponents('Products', $filter);
     if ($childProducts) {
         $products->merge($childProducts);
     }
     if ($relatedProducts) {
         $products->merge($relatedProducts);
     }
     if (in_array($this->ChildGroupsPermission, $permissions)) {
         if ($childGroups = $this->ChildGroups()) {
             foreach ($childGroups as $childGroup) {
                 $products->merge($childGroup->ProductsShowable($extraFilter, $permissions));
             }
         }
     }
     $products->removeDuplicates();
     return $products;
 }
開發者ID:nicolaas,項目名稱:silverstripe-ecommerce,代碼行數:35,代碼來源:ProductGroup.php

示例2: PublisherMembers

 /**
  * Returns a DataObjectSet of all the members that can publish pages
  * on this site by default
  */
 public function PublisherMembers()
 {
     if ($this->owner->CanPublishType == 'OnlyTheseUsers') {
         $groups = $this->owner->PublisherGroups();
         $members = new DataObjectSet();
         if ($groups) {
             foreach ($groups as $group) {
                 $members->merge($group->Members());
             }
         }
         // Default to ADMINs, if something goes wrong
         if (!$members->Count()) {
             $group = Permission::get_groups_by_permission('ADMIN')->first();
             $members = $group->Members();
         }
         return $members;
     } else {
         if ($this->owner->CanPublishType == 'LoggedInUsers') {
             // We don't want to return every user in the CMS....
             return Permission::get_members_by_permission('CMS_ACCESS_CMSMain');
         } else {
             $group = Permission::get_groups_by_permission('ADMIN')->first();
             return $group->Members();
         }
     }
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-cmsworkflow,代碼行數:30,代碼來源:SiteConfigTwoStepWorkflow.php

示例3: PublisherMembers

 /**
  * Returns a DataObjectSet of all the members that can publish this page
  */
 public function PublisherMembers()
 {
     if ($this->owner->CanPublishType == 'OnlyTheseUsers') {
         $groups = $this->owner->PublisherGroups();
         $members = new DataObjectSet();
         if ($groups) {
             foreach ($groups as $group) {
                 $members->merge($group->Members());
             }
         }
         // Default to ADMINs, if something goes wrong
         if (!$members->Count()) {
             $group = Permission::get_groups_by_permission('ADMIN')->first();
             $members = $group->Members();
         }
         return $members;
     } elseif ($this->owner->CanPublishType == 'Inherit') {
         if ($this->owner->Parent()->Exists()) {
             return $this->owner->Parent()->PublisherMembers();
         } else {
             return SiteConfig::current_site_config()->PublisherMembers();
         }
     } elseif ($this->owner->CanPublishType == 'LoggedInUsers') {
         return Permission::get_members_by_permission('CMS_ACCESS_CMSMain');
     } else {
         $group = Permission::get_groups_by_permission('ADMIN')->first();
         return $group->Members();
     }
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-cmsworkflow,代碼行數:32,代碼來源:SiteTreeCMSTwoStepWorkflow.php

示例4: AllGroupPermissions

 /**
  * Collate permissions for this and all parent folders.
  * 
  * @return DataObjectSet
  */
 function AllGroupPermissions()
 {
     $groupSet = new DataObjectSet();
     $groups = $this->owner->GroupPermissions();
     foreach ($groups as $group) {
         $groupSet->push($group);
     }
     if ($this->owner->ParentID) {
         $groupSet->merge($this->owner->InheritedGroupPermissions());
     }
     $groupSet->removeDuplicates();
     return $groupSet;
 }
開發者ID:hamishcampbell,項目名稱:silverstripe-securefiles,代碼行數:18,代碼來源:SecureFileGroupPermissionDecorator.php

示例5: AllMemberPermissions

 /**
  * Collate permissions for this and all parent folders.
  * 
  * @return DataObjectSet
  */
 function AllMemberPermissions()
 {
     $memberSet = new DataObjectSet();
     $members = $this->owner->MemberPermissions();
     foreach ($members as $member) {
         $memberSet->push($member);
     }
     if ($this->owner->ParentID) {
         $memberSet->merge($this->owner->InheritedMemberPermissions());
     }
     $memberSet->removeDuplicates();
     return $memberSet;
 }
開發者ID:hamishcampbell,項目名稱:silverstripe-securefiles,代碼行數:18,代碼來源:SecureFileMemberPermissionDecorator.php

示例6: getNewsHolders

 /**
  * Collect NewsHolders recursively.
  * 
  * @param int $parentID
  * 
  * @return DataObjectSet
  */
 protected function getNewsHolders($parentID)
 {
     $parentID = (int) $parentID;
     $collected = new DataObjectSet();
     $children = DataObject::get('NewsHolder', "\"ParentID\" = {$parentID}", "\"Sort\" DESC");
     if ($children) {
         foreach ($children as $child) {
             $collected->push($child);
             $grandChildren = $this->getNewsHolders($child->ID);
             $collected->merge($grandChildren);
         }
     }
     return $collected;
 }
開發者ID:redema,項目名稱:silverstripe-news,代碼行數:21,代碼來源:NewsHolder.php

示例7: processAll

 protected function processAll($filepath, $preview = false)
 {
     $this->extend('updateColumnMap', $this->columnMap);
     // we have to check for the existence of this in case the stockcontrol module hasn't been loaded
     // and the CSV still contains a Stock column
     self::$hasStockImpl = Object::has_extension('Product', 'ProductStockDecorator');
     $results = parent::processAll($filepath, $preview);
     //After results have been processed, publish all created & updated products
     $objects = new DataObjectSet();
     $objects->merge($results->Created());
     $objects->merge($results->Updated());
     foreach ($objects as $object) {
         if (!$object->ParentID) {
             //set parent page
             if (is_numeric(self::$parentpageid) && DataObject::get_by_id('ProductGroup', self::$parentpageid)) {
                 //cached option
                 $object->ParentID = self::$parentpageid;
             } elseif ($parentpage = DataObject::get_one('ProductGroup', "\"Title\" = 'Products'", '"Created" DESC')) {
                 //page called 'Products'
                 $object->ParentID = self::$parentpageid = $parentpage->ID;
             } elseif ($parentpage = DataObject::get_one('ProductGroup', "\"ParentID\" = 0", '"Created" DESC')) {
                 //root page
                 $object->ParentID = self::$parentpageid = $parentpage->ID;
             } elseif ($parentpage = DataObject::get_one('ProductGroup', "", '"Created" DESC')) {
                 //any product page
                 $object->ParentID = self::$parentpageid = $parentpage->ID;
             } else {
                 $object->ParentID = self::$parentpageid = 0;
             }
         }
         $object->extend('updateImport');
         //could be used for setting other attributes, such as stock level
         $object->writeToStage('Stage');
         $object->publish('Stage', 'Live');
     }
     return $results;
 }
開發者ID:riddler7,項目名稱:silverstripe-ecommerce,代碼行數:37,代碼來源:ProductBulkLoader.php

示例8: blogOwners

 /**
  * Get members who have BLOGMANAGEMENT and ADMIN permission
  */
 function blogOwners($sort = 'Name', $direction = "ASC")
 {
     $adminMembers = Permission::get_members_by_permission('ADMIN');
     $blogOwners = Permission::get_members_by_permission('BLOGMANAGEMENT');
     if (!$adminMembers) {
         $adminMembers = new DataObjectSet();
     }
     if (!$blogOwners) {
         $blogOwners = new DataObjectSet();
     }
     $blogOwners->merge($adminMembers);
     $blogOwners->sort($sort, $direction);
     $this->extend('extendBlogOwners', $blogOwners);
     return $blogOwners;
 }
開發者ID:nicmart,項目名稱:comperio-site,代碼行數:18,代碼來源:BlogHolder.php

示例9: getCMSFields

 /**
  * Caution: Only call on instances, not through a singleton.
  *
  * @return FieldSet
  */
 public function getCMSFields()
 {
     $fields = new FieldSet(new TabSet("Root", new Tab(_t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", $this->fieldLabel('Title')), $memberList = new MemberTableField($this, "Members", $this, null, false)), $permissionsTab = new Tab(_t('SecurityAdmin.PERMISSIONS', 'Permissions'), new PermissionCheckboxSetField('Permissions', false, 'Permission', 'GroupID', $this)), new Tab(_t('Security.IPADDRESSES', 'IP Addresses'), new LiteralField("", _t('SecurityAdmin.IPADDRESSESHELP', "<p>You can restrict this group to a particular \n\t\t\t\t\t\tIP address range (one range per line). <br />Ranges can be in any of the following forms: <br />\n\t\t\t\t\t\t203.96.152.12<br />\n\t\t\t\t\t\t203.96.152/24<br />\n\t\t\t\t\t\t203.96/16<br />\n\t\t\t\t\t\t203/8<br /><br />If you enter one or more IP address ranges in this box, then members will only get\n\t\t\t\t\t\tthe rights of being in this group if they log on from one of the valid IP addresses.  It won't prevent\n\t\t\t\t\t\tpeople from logging in.  This is because the same user might have to log in to access parts of the\n\t\t\t\t\t\tsystem without IP address restrictions.")), new TextareaField("IPRestrictions", "IP Ranges", 10))));
     // Only add a dropdown for HTML editor configurations if more than one is available.
     // Otherwise Member->getHtmlEditorConfigForCMS() will default to the 'cms' configuration.
     $editorConfigMap = HtmlEditorConfig::get_available_configs_map();
     if (count($editorConfigMap) > 1) {
         $fields->addFieldToTab('Root.Permissions', new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', $editorConfigMap), 'Permissions');
     }
     if (!Permission::check('EDIT_PERMISSIONS')) {
         $fields->removeFieldFromTab('Root', 'Permissions');
         $fields->removeFieldFromTab('Root', 'IP Addresses');
     }
     // Only show the "Roles" tab if permissions are granted to edit them,
     // and at least one role exists
     if (Permission::check('APPLY_ROLES') && DataObject::get('PermissionRole')) {
         $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.ROLES', 'Roles'));
         $fields->addFieldToTab('Root.Roles', new LiteralField("", "<p>" . _t('SecurityAdmin.ROLESDESCRIPTION', "This section allows you to add roles to this group. Roles are logical groupings of permissions, which can be editied in the Roles tab") . "</p>"));
         // Add roles (and disable all checkboxes for inherited roles)
         $allRoles = Permission::check('ADMIN') ? DataObject::get('PermissionRole') : DataObject::get('PermissionRole', 'OnlyAdminCanApply = 0');
         $groupRoles = $this->Roles();
         $inheritedRoles = new DataObjectSet();
         $ancestors = $this->getAncestors();
         foreach ($ancestors as $ancestor) {
             $ancestorRoles = $ancestor->Roles();
             if ($ancestorRoles) {
                 $inheritedRoles->merge($ancestorRoles);
             }
         }
         $fields->findOrMakeTab('Root.Roles', 'Root.' . _t('SecurityAdmin.ROLES', 'Roles'));
         $fields->addFieldToTab('Root.Roles', $rolesField = new CheckboxSetField('Roles', 'Roles', $allRoles));
         $rolesField->setDefaultItems($inheritedRoles->column('ID'));
         $rolesField->setDisabledItems($inheritedRoles->column('ID'));
     }
     $memberList->setController($this);
     $memberList->setPermissions(array('edit', 'delete', 'export', 'add', 'inlineadd'));
     $memberList->setParentClass('Group');
     $memberList->setPopupCaption(_t('SecurityAdmin.VIEWUSER', 'View User'));
     $memberList->setRelationAutoSetting(false);
     $fields->push($idField = new HiddenField("ID"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
開發者ID:Raiser,項目名稱:Praktikum,代碼行數:48,代碼來源:Group.php

示例10: refresh

 /**
  * Refreshes the file list. If passed an array of IDs in the request, 
  * it augments the list with those files.
  *
  * @param SS_HTTPRequest
  * @return SSViewer
  */
 public function refresh(SS_HTTPRequest $r)
 {
     if ($r->requestVar('ids')) {
         $ids = array_unique($r->requestVar('ids'));
         $files = new DataObjectSet();
         $implodestring = implode(',', $ids);
         $implodestring = preg_replace("/^[,]/", "", $implodestring);
         if ($set = DataObject::get("File", "`ID` IN ({$implodestring})")) {
             foreach ($set as $file) {
                 $this->processFile($file);
                 $files->push($file);
             }
             $files->merge($this->Files());
             $files->removeDuplicates();
         } else {
             die("File {$id} doesn't exist");
         }
     } else {
         $files = $this->Files();
     }
     return $this->customise(array('Files' => $files))->renderWith($this->AttachedFilesTemplate);
 }
開發者ID:heyday,項目名稱:KickAssets,代碼行數:29,代碼來源:MultipleFileAttachmentField.php

示例11: DependentPages

 /**
  * Returns the pages that depend on this page.
  * This includes virtual pages, pages that link to it, etc.
  * 
  * @param $includeVirtuals Set to false to exlcude virtual pages.
  */
 function DependentPages($includeVirtuals = true)
 {
     if (is_callable('Subsite::disable_subsite_filter')) {
         Subsite::disable_subsite_filter(true);
     }
     // Content links
     $items = $this->BackLinkTracking();
     if (!$items) {
         $items = new DataObjectSet();
     } else {
         foreach ($items as $item) {
             $item->DependentLinkType = 'Content link';
         }
     }
     // Virtual pages
     if ($includeVirtuals) {
         $virtuals = $this->VirtualPages();
         if ($virtuals) {
             foreach ($virtuals as $item) {
                 $item->DependentLinkType = 'Virtual page';
             }
             $items->merge($virtuals);
         }
     }
     // Redirector pages
     $redirectors = DataObject::get("RedirectorPage", "\"RedirectorPage\".\"RedirectionType\" = 'Internal' AND \"LinkToID\" = {$this->ID}");
     if ($redirectors) {
         foreach ($redirectors as $item) {
             $item->DependentLinkType = 'Redirector page';
         }
         $items->merge($redirectors);
     }
     if (is_callable('Subsite::disable_subsite_filter')) {
         Subsite::disable_subsite_filter(false);
     }
     return $items;
 }
開發者ID:eLBirador,項目名稱:AllAboutCity,代碼行數:43,代碼來源:SiteTree.php

示例12: getLatestYoutubeVideos

 function getLatestYoutubeVideos($num)
 {
     $username = 'LoveyourCoast';
     $youtube = new YoutubeService();
     $videos1 = $youtube->getVideosUploadedByUser($username, $num, 1, 'published');
     $videos2 = $youtube->getFavoriteVideosByUser($username, $num, 1, 'published');
     $videos = new DataObjectSet();
     $videos->merge($videos1);
     $videos->merge($videos2);
     return $videos;
 }
開發者ID:SustainableCoastlines,項目名稱:loveyourwater,代碼行數:11,代碼來源:Page.php

示例13: get_by_publisher

 public static function get_by_publisher($class, $publisher, $status = null)
 {
     // To ensure 2.3 and 2.4 compatibility
     $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
     if ($status) {
         $statusStr = "'" . implode("','", $status) . "'";
     }
     $classes = (array) ClassInfo::subclassesFor($class);
     $classesSQL = implode("','", $classes);
     // build filter
     $filter = "{$bt}WorkflowRequest{$bt}.{$bt}ClassName{$bt} IN ('{$classesSQL}') ";
     if ($status) {
         $filter .= "AND {$bt}WorkflowRequest{$bt}.{$bt}Status{$bt} IN (" . $statusStr . ")";
     }
     $onDraft = Versioned::get_by_stage("SiteTree", "Stage", $filter, "{$bt}SiteTree{$bt}.{$bt}LastEdited{$bt} DESC", "LEFT JOIN {$bt}WorkflowRequest{$bt} ON {$bt}WorkflowRequest{$bt}.{$bt}PageID{$bt} = {$bt}SiteTree{$bt}.{$bt}ID{$bt} ");
     $onLive = Versioned::get_by_stage("SiteTree", "Live", $filter, "{$bt}SiteTree_Live{$bt}.{$bt}LastEdited{$bt} DESC", "LEFT JOIN {$bt}WorkflowRequest{$bt} ON {$bt}WorkflowRequest{$bt}.{$bt}PageID{$bt} = {$bt}SiteTree_Live{$bt}.{$bt}ID{$bt} ");
     $return = new DataObjectSet();
     $return->merge($onDraft);
     $return->merge($onLive);
     $return->removeDuplicates();
     $canPublish = SiteTree::batch_permission_check($return->column('ID'), $publisher->ID, 'CanPublishType', 'SiteTree_PublisherGroups', 'canPublish');
     foreach ($return as $page) {
         if (!isset($canPublish[$page->ID]) || !$canPublish[$page->ID]) {
             $return->remove($page);
         }
     }
     return $return;
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-cmsworkflow,代碼行數:28,代碼來源:WorkflowThreeStepRequest.php

示例14: Actions

	public function Actions()
	{
	   $actions = new DataObjectSet();
	   foreach($this->parent->permissions as $perm) {
	     $action = false;
	     switch($perm) {
	       case "edit":
	       case "view":
	         $actions->push(new DataObjectManagerAction(
	           $this->ViewOrEdit_i18n(),
	           $this->EditLink(),
	           "popup",
	           "dataobject_manager/images/page_white_{$this->ViewOrEdit()}.png",
	           "editlink"	,
	           $this->parent->PopupWidth()           
	         ));
	       break;
	       	       	       
	       case "delete":
	         $actions->push(new DataObjectManagerAction(
	           _t('DataObjectManager.DELETE','Delete'),
	           $this->DeleteLink(),
	           "delete",
	           "dataobject_manager/images/trash.gif",
	           null,
	           $this->parent->getSetting('confirmDelete') ? "confirm" : null
	         ));
	       break;
	       
	       case "duplicate":
	         $actions->push(new DataObjectManagerAction(
	           _t('DataObjectManager.DUPLICATE','Duplicate'),
	           $this->DuplicateLink(),
	           "popup",
	           "dataobject_manager/images/page_copy.png",
	           null,
	           400
	         ));
	       break;
	     }
	   }
	   if($custom = $this->CustomActions()) {
	     if($custom instanceof DataObjectSet)
	       $actions->merge($custom);
	     else
	       $actions->push($custom);
	   }
	   return $actions;
	}
開發者ID:notioncollective,項目名稱:stationid,代碼行數:49,代碼來源:DataObjectManager.php

示例15: getOrphanedPages

 /**
  * Gets all orphans from "Stage" and "Live" stages.
  * 
  * @param string $class
  * @param string $filter
  * @param string $sort
  * @param string $join
  * @param int|array $limit
  * @return DataObjectSet
  */
 function getOrphanedPages($class = 'SiteTree', $filter = '', $sort = null, $join = null, $limit = null)
 {
     $filter .= $filter ? ' AND ' : '';
     $filter .= sprintf("\"%s\".\"ParentID\" != 0 AND \"Parents\".\"ID\" IS NULL", $class);
     $orphans = new DataObjectSet();
     foreach (array('Stage', 'Live') as $stage) {
         $joinByStage = $join;
         $table = $class;
         $table .= $stage == 'Live' ? '_Live' : '';
         $joinByStage .= sprintf("LEFT JOIN \"%s\" AS \"Parents\" ON \"%s\".\"ParentID\" = \"Parents\".\"ID\"", $table, $table);
         $stageOrphans = Versioned::get_by_stage($class, $stage, $filter, $sort, $joinByStage, $limit);
         $orphans->merge($stageOrphans);
     }
     $orphans->removeDuplicates();
     return $orphans;
 }
開發者ID:hamishcampbell,項目名稱:silverstripe-sapphire,代碼行數:26,代碼來源:RemoveOrphanedPagesTask.php


注:本文中的DataObjectSet::merge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。