本文整理汇总了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;
}
示例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();
}
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}