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


PHP ArrayList::removeDuplicates方法代码示例

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


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

示例1: canBeDiscounted

 /**
  * normally returns TRUE, but returns FALSE when it, or its parent is in the list.
  * todo: add products in other product categories
  * @param SiteTree $page
  * @return Boolean
  */
 function canBeDiscounted(SiteTree $page)
 {
     if ($this->owner->PageIDs) {
         $allowedPageIDs = explode(',', $this->owner->PageIDs);
         $checkPages = new ArrayList(array($page));
         $alreadyCheckedPageIDs = array();
         while ($checkPages->Count()) {
             $page = $checkPages->First();
             if (array_search($page->ID, $allowedPageIDs) !== false) {
                 return true;
             }
             $alreadyCheckedPageIDs[] = $page->ID;
             $checkPages->remove($page);
             // Parents list update
             if ($page->hasMethod('AllParentGroups')) {
                 $parents = new ArrayList($page->AllParentGroups()->toArray());
             } else {
                 $parents = new ArrayList();
             }
             $parent = $page->Parent();
             if ($parent && $parent->exists()) {
                 $parents->unshift($parent);
             }
             foreach ($parents as $parent) {
                 if (array_search($parent->ID, $alreadyCheckedPageIDs) === false) {
                     $checkPages->push($parent);
                 }
             }
             $checkPages->removeDuplicates();
         }
         return false;
     }
     return true;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-discount-coupon,代码行数:40,代码来源:DiscountCouponSiteTreeDOD.php

示例2: sequenceGridListItems

 /**
  * Expects parameters 'start' and 'limit' to be set, limits items by filter to page length
  *
  *
  * @param \SS_LIst $items
  * @param          $filters
  * @param array    $parameters
  */
 public function sequenceGridListItems(&$items, $filters, &$parameters = [])
 {
     $out = new \ArrayList();
     $start = $parameters[Constraints::StartIndexGetVar];
     $limit = $parameters[Constraints::PageLengthGetVar];
     if (!is_null($limit)) {
         $added = 0;
         if ($allFilter = Application::get_current_page()->FilterAll()) {
             // first add 'all filter' items
             if ($allTag = $allFilter->Filter) {
                 $index = 0;
                 $added = 0;
                 foreach ($items as $item) {
                     $index++;
                     if ($index < $start) {
                         continue;
                     }
                     if ($allTag == 'all' || $item->GridListFilters()->find('ModelTag', $allTag)) {
                         // we don't add all, we're just getting the count
                         // $out->push($item);
                         $added++;
                     }
                     if ($added >= $limit) {
                         break;
                     }
                 }
             }
         }
         // initial number of 'all filter' items loaded in page
         $parameters['AllLoadCount'] = $added;
         foreach ($filters as $filter) {
             if ($tag = $filter->ModelTag) {
                 $index = 0;
                 $added = 0;
                 foreach ($items as $item) {
                     $index++;
                     if ($index < $start) {
                         continue;
                     }
                     if ($item->hasExtension(HasGridListFilters::class_name())) {
                         if ($item->GridListFilters()->find('ModelTag', $tag)) {
                             $out->push($item);
                             $added++;
                         }
                     }
                     if ($added >= $limit) {
                         break;
                     }
                 }
                 // initial number of items loaded in page (may be less than page length)
                 $filter->LoadCount = $added;
             }
         }
         $out->removeDuplicates();
         $items = $out;
     }
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-modular,代码行数:65,代码来源:PaginateByFilters.php

示例3: getHelpItems

 /**
  * Returns all the {@link InlineHelpTopic}s attached to this page.
  *
  * @return InlineHelpTopic[]
  */
 public function getHelpItems()
 {
     $items = new ArrayList();
     $items->merge(InlineHelpTopic::get()->where('"AttachType" = \'All\''));
     $items->merge(InlineHelpTopic::get()->where(sprintf('"AttachType" = \'Type\' AND "AttachPageType" = \'%s\'', $this->owner->class)));
     $items->merge($this->owner->HelpTopics());
     $stack = $this->owner->parentStack();
     array_shift($stack);
     if ($stack) {
         $items->merge(InlineHelpTopic::get()->where(sprintf('"AttachType" = \'Children\' AND "ParentFilterID" IN(%s)', implode(', ', array_map(create_function('$self', 'return $self->ID;'), $stack)))));
     }
     $items->removeDuplicates();
     return $items;
 }
开发者ID:Neumes,项目名称:silverstripe-inlinehelp,代码行数:19,代码来源:InlineHelpExtension.php

示例4: Discounts

 /**
  * Get all discounts that have been applied to an order.
  *
  * @return ArrayList
  */
 public function Discounts()
 {
     $discounts = Discount::get()->leftJoin("OrderDiscountModifier_Discounts", "\"Discount\".\"ID\" = \"OrderDiscountModifier_Discounts\".\"DiscountID\"")->innerJoin("OrderAttribute", "(\"OrderDiscountModifier_Discounts\".\"OrderDiscountModifierID\" = \"OrderAttribute\".\"ID\")")->filter("OrderAttribute.OrderID", $this->owner->ID);
     $finalDiscounts = new ArrayList();
     foreach ($discounts as $discount) {
         $finalDiscounts->push($discount);
     }
     foreach ($this->owner->Items() as $item) {
         foreach ($item->Discounts() as $discount) {
             $finalDiscounts->push($discount);
         }
     }
     $finalDiscounts->removeDuplicates();
     return $finalDiscounts;
 }
开发者ID:burnbright,项目名称:silverstripe-shop-discount,代码行数:20,代码来源:DiscountedOrderExtension.php

示例5: TalksByMemberID

 function TalksByMemberID($memberID)
 {
     $SpeakerList = new ArrayList();
     // Pull any talks that belong to this Summit and are owned by member
     $talksMemberOwns = $this->Talks("`OwnerID` = " . $memberID . " AND `SummitID` = " . $this->ID);
     $SpeakerList->merge($talksMemberOwns);
     // Now pull any talks that belong to this Summit and the member is listed as a speaker
     $speaker = Speaker::get()->filter('memberID', $memberID)->first();
     if ($speaker) {
         $talksMemberIsASpeaker = $speaker->TalksBySummitID($this->ID);
         // Now merge and de-dupe the lists
         $SpeakerList->merge($talksMemberIsASpeaker);
         $SpeakerList->removeDuplicates('ID');
     }
     return $SpeakerList;
 }
开发者ID:balajijegan,项目名称:openstack-org,代码行数:16,代码来源:Summit.php

示例6: merge_owners

 /**
  * Takes a list of groups and members and return a list of unique member.
  *
  * @param SS_List $groups
  * @param SS_List $members
  *
  * @return ArrayList
  */
 public static function merge_owners(SS_List $groups, SS_List $members)
 {
     $contentReviewOwners = new ArrayList();
     if ($groups->count()) {
         $groupIDs = array();
         foreach ($groups as $group) {
             $familyIDs = $group->collateFamilyIDs();
             if (is_array($familyIDs)) {
                 $groupIDs = array_merge($groupIDs, array_values($familyIDs));
             }
         }
         array_unique($groupIDs);
         if (count($groupIDs)) {
             $groupMembers = DataObject::get("Member")->where("\"Group\".\"ID\" IN (" . implode(",", $groupIDs) . ")")->leftJoin("Group_Members", "\"Member\".\"ID\" = \"Group_Members\".\"MemberID\"")->leftJoin("Group", "\"Group_Members\".\"GroupID\" = \"Group\".\"ID\"");
             $contentReviewOwners->merge($groupMembers);
         }
     }
     $contentReviewOwners->merge($members);
     $contentReviewOwners->removeDuplicates();
     return $contentReviewOwners;
 }
开发者ID:kinglozzer,项目名称:silverstripe-contentreview,代码行数:29,代码来源:SiteTreeContentReview.php

示例7: map_in_groups

 /**
  * Get a member SQLMap of members in specific groups
  * 
  * If no $groups is passed, all members will be returned
  * 
  * @param mixed $groups - takes a SS_List, an array or a single Group.ID
  * @return SQLMap Returns an SQLMap that returns all Member data.
  * @see map()
  */
 public static function map_in_groups($groups = null)
 {
     $groupIDList = array();
     if ($groups instanceof SS_List) {
         foreach ($groups as $group) {
             $groupIDList[] = $group->ID;
         }
     } elseif (is_array($groups)) {
         $groupIDList = $groups;
     } elseif ($groups) {
         $groupIDList[] = $groups;
     }
     // No groups, return all Members
     if (!$groupIDList) {
         return Member::get()->sort(array('Surname' => 'ASC', 'FirstName' => 'ASC'))->map();
     }
     $membersList = new ArrayList();
     // This is a bit ineffective, but follow the ORM style
     foreach (Group::get()->byIDs($groupIDList) as $group) {
         $membersList->merge($group->Members());
     }
     $membersList->removeDuplicates('ID');
     return $membersList->map();
 }
开发者ID:hemant-chakka,项目名称:awss,代码行数:33,代码来源:Member.php

示例8: filters

 /**
  * Returns the filters which should show in-page gathered via provideGridListFilters. These are composed of those specifically set on the GridList first
  * and then those for the current page which may have an alternate strategy to provide them, such as most popular filters from child pages.
  *
  * @return \ArrayList
  */
 protected function filters($mode)
 {
     static $filters;
     if (!$filters) {
         $providers = $this->providers();
         $filters = new \ArrayList();
         foreach ($providers as $provider) {
             // first get filters which have been added specifically to the GridList, e.g. via a HasGridListFilters extendiong on the extended class
             // this will return an array of SS_Lists
             $lists = $provider->extend('provideGridListFilters');
             foreach ($lists as $list) {
                 $filters->merge($list);
             }
             $filters->removeDuplicates();
             $items = $this->items($mode);
             $provider->extend('constrainGridListFilters', $items, $filters);
         }
     }
     return $filters;
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-modular,代码行数:26,代码来源:GridList.php

示例9: 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 SS_List
  */
 public 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 ArrayList();
     foreach (array('Stage', 'Live') as $stage) {
         $joinByStage = $join;
         $table = $class;
         $table .= $stage == 'Live' ? '_Live' : '';
         $stageOrphans = Versioned::get_by_stage($class, $stage, $filter, $sort, null, $limit)->leftJoin($table, "\"{$table}\".\"ParentID\" = \"Parents\".\"ID\"", "Parents");
         $orphans->merge($stageOrphans);
     }
     $orphans->removeDuplicates();
     return $orphans;
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:25,代码来源:RemoveOrphanedPagesTask.php

示例10: FlickrBucketsByDate

    function FlickrBucketsByDate()
    {
        // in 3.1 data list is immutable, hence the chaining
        $sqlbucketidsinorder = 'select distinct FlickrBucketID from (
	  select FlickrBucketID, FlickrPhoto.TakenAt from FlickrBucket
		INNER JOIN FlickrPhoto_FlickrBuckets ON FlickrBucketID = FlickrBucket.ID
		INNER JOIN FlickrPhoto ON FlickrPhoto.ID = FlickrPhoto_FlickrBuckets.FlickrPhotoID
		WHERE (FlickrSetID = ' . $this->ID . ')
		order by FlickrPhoto.TakenAt
	  ) as OrderedBuckets';
        $buckets = FlickrBucket::get()->filter(array('FlickrSetID' => $this->ID))->innerJoin('FlickrPhoto_FlickrBuckets', 'FlickrBucketID = FlickrBucket.ID')->innerJoin('FlickrPhoto', 'FlickrPhotoID = FlickrPhoto.ID')->sort('TakenAt');
        $result = new ArrayList();
        foreach ($buckets->getIterator() as $bucket) {
            $result->push($bucket);
        }
        $result->removeDuplicates();
        return $result;
    }
开发者ID:gordonbanderson,项目名称:flickr-editor,代码行数:18,代码来源:FlickrSet.php

示例11: getOrphanedPages

 /**
  * Gets all orphans from "Stage" and "Live" stages.
  *
  * @param string $class
  * @param array $filter
  * @param string $sort
  * @param string $join
  * @param int|array $limit
  * @return SS_List
  */
 public function getOrphanedPages($class = 'SiteTree', $filter = array(), $sort = null, $join = null, $limit = null)
 {
     // Alter condition
     if (empty($filter)) {
         $where = array();
     } elseif (is_array($filter)) {
         $where = $filter;
     } else {
         $where = array($filter);
     }
     $where[] = array("\"{$class}\".\"ParentID\" != ?" => 0);
     $where[] = '"Parents"."ID" IS NULL';
     $orphans = new ArrayList();
     foreach (array('Stage', 'Live') as $stage) {
         $joinByStage = $join;
         $table = $class;
         $table .= $stage == 'Live' ? '_Live' : '';
         $stageOrphans = Versioned::get_by_stage($class, $stage, $where, $sort, null, $limit)->leftJoin($table, "\"{$table}\".\"ParentID\" = \"Parents\".\"ID\"", "Parents");
         $orphans->merge($stageOrphans);
     }
     $orphans->removeDuplicates();
     return $orphans;
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:33,代码来源:RemoveOrphanedPagesTask.php

示例12: getRecipients

 /**
  * Returns all member recipient objects.
  *
  * @return ArrayList
  */
 public function getRecipients()
 {
     $set = new ArrayList();
     $set->merge($this->RecipientMembers());
     foreach ($this->RecipientGroups() as $group) {
         $set->merge($group->Members());
     }
     $set->removeDuplicates();
     return $set;
 }
开发者ID:silverstripe-australia,项目名称:silverstripe-push,代码行数:15,代码来源:PushNotification.php

示例13: getAssignedMembers

 /**
  * Returns a list of all Members that are assigned to this instance, either directly or via a group.
  *
  * @todo   This could be made more efficient.
  * @return ArrayList
  */
 public function getAssignedMembers()
 {
     $list = new ArrayList();
     $groups = $this->Groups();
     $list->merge($this->Users());
     foreach ($groups as $group) {
         $list->merge($group->Members());
     }
     $list->removeDuplicates();
     return $list;
 }
开发者ID:normann,项目名称:advancedworkflow,代码行数:17,代码来源:WorkflowInstance.php

示例14: all_accessible_sites

 public static function all_accessible_sites($includeMainSite = true, $mainSiteTitle = "Main site", $member = null)
 {
     // Rationalise member arguments
     if (!$member) {
         $member = Member::currentUser();
     }
     if (!$member) {
         return new ArrayList();
     }
     if (!is_object($member)) {
         $member = DataObject::get_by_id('Member', $member);
     }
     $subsites = new ArrayList();
     // Collect subsites for all sections.
     $menu = CMSMenu::get_viewable_menu_items();
     foreach ($menu as $candidate) {
         if ($candidate->controller) {
             $accessibleSites = singleton($candidate->controller)->sectionSites($includeMainSite, $mainSiteTitle, $member);
             // Replace existing keys so no one site appears twice.
             $subsites->merge($accessibleSites);
         }
     }
     $subsites->removeDuplicates();
     return $subsites;
 }
开发者ID:hamaka,项目名称:silverstripe-subsites,代码行数:25,代码来源:Subsite.php

示例15: get_items

 /**
  * Return paginated results in class
  * Only returns items that contain Link()
  * Limited to 1000 results per page
  *
  * @param string
  * @return ArrayList
  */
 public static function get_items($className, $page = 1)
 {
     $items = self::get_filtered_results($className);
     $list = new PaginatedList($items);
     $list->setPageLength(1000);
     $list->setCurrentPage($page);
     $output = new ArrayList();
     /* only push items with a link */
     foreach ($list as $item) {
         $item->ChangeFrequency = self::get_frequency_for_class($className);
         $item->GooglePriority = self::get_priority_for_class($className);
         if ($item->hasMethod('SitemapAbsoluteURL')) {
             $item->SitemapAbsoluteURL = $SitemapAbsoluteURL->SitemapAbsoluteURL();
             $output->push($item);
         } elseif ($item->hasMethod('Link')) {
             $item->SitemapAbsoluteURL = Director::absoluteURL($item->Link());
             $output->push($item);
         }
     }
     /* Make sure we only include one of each link, and no external links (ie: redirector pages */
     $output->removeDuplicates('SitemapAbsoluteURL');
     $external_links = array();
     $base_url = preg_quote(Director::absoluteBaseURL(), '/');
     foreach ($output as $item) {
         if (!preg_match('/^' . $base_url . '/', $item->SitemapAbsoluteURL)) {
             array_push($external_links, $item->SitemapAbsoluteURL);
         }
     }
     if (count($external_links) > 0) {
         $output = $output->exclude('SitemapAbsoluteURL', $external_links);
     }
     return $output;
 }
开发者ID:axllent,项目名称:silverstripe-sitemap,代码行数:41,代码来源:Sitemap.php


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