Get the custom links array for a role
@param array|string $filter	A list of the roles to include in the result.
If no filter is specified all roles are returned.
@param bool $sort			True if the result list should be sorted
@return array
341298
public function &getCustomRoleRefs( $filter = array(), $sort = true )
	{
		// Make sure the filter is initialized and contains lowercase values
		if ( ! is_array( $filter ) ) $filter = array();
		$filter = array_flip( array_map( 'strtolower', $filter ) );

		$refs = $this->customRoles;

		/**
		 * @var array $result
		 */
		$result = array();

		foreach ( $refs as $refKey => $ref )
		{
			// Apply the filter if one is provided
			if ( count( $filter ) && ! isset( $filter[ strtolower( $refKey ) ] ) ) continue;

			$result[ $refKey ] = $this->customRoles[ $refKey ];

			$linkElement = null;

			// Look for the corresponding link element
			foreach ( $this->roleTypes as $link => $role )
			{
				if ( ! isset( $role[ $refKey ] ) )
				{
					continue;
				}

				$linkElement = $link;
				break;
			}

			if ( is_null( $linkElement ) )
			{
				continue;
			}

			$description = $this->getCustomLinkRoleDescription( $ref, $linkElement, "Custom link role" );
			$result[ $refKey ]['text'] = $description ? $description : "";

			// Remove any prohibited arcs
			if ( isset( $result[ $refKey ]['arcs'] ) && count( $result[ $refKey ]['arcs'] ) )
			{
				$arcs =& $result[ $refKey ]['arcs'];
				foreach ( $arcs as $from => $targets )
				{
					foreach ( $targets as $to => $node )
					{
						if ( $node['use'] == XBRL_Constants::$xlinkUseOptional ) continue;
						unset( $arcs[ $from ][ $to ] );
					}

					if ( count( $arcs[ $from ] ) ) continue;
					unset( $arcs[ $from ] );
				}
			}
		}

		if ( $sort )
		{
			$this->sortRoleRefs( $result );
		}

		return $result;
	}
1166091
public function getServices($filter = null)
	{
		$services = array();

		// Create the request
		$request = new client\Request('/api/mpegts/service/grid');

		if ($filter)
			$request->setFilter($filter);

		// Get the response
		$response = $this->_client->getResponse($request);
		$rawContent = $response->getContent();

		$content = json_decode($rawContent);

		foreach ($content->entries as $entry)
			$services[] = model\Service::fromRawEntry($entry);

		return $services;
	}
1063411
public function listTemplates($filter = null)
    {
        $files = [];

        $name = $filter ? Glob::toRegex($filter, false, false) : '/^[a-zA-Z0-9]\V+\.twig$/';

        /** @var Finder|FileInterface[] $finder */
        $finder = $this->templatesDir->find()
            ->files()
            ->notName('/^_/')
            ->exclude(['node_modules', 'bower_components', '.sass-cache'])
            ->depth('<4')
            ->path($name)
            ->sortByName()
        ;

        foreach ($finder as $file) {
            $name = Str::replaceFirst($file->getFullPath(), $this->templatesDir->getFullPath(), '');
            $files[$name] = $name;
        }

        // Check: Have we defined names for any of the matched templates?
        foreach ((array) $this->themeTemplateSelect as $templateFile) {
            if (!empty($templateFile['name']) && !empty($templateFile['filename']) && in_array($templateFile['filename'], $files)) {
                $files[$templateFile['filename']] = $templateFile['name'];
            }
        }

        return $files;
    }
883981
public function getAll(array $filter)
    {
        $this->select = $this->readSql->select('history');
                    
        $this->joinAuth()->joinAclRole();
        
        $this->filter($filter)->sort($filter); 

        if (array_key_exists('pagination', $filter)) {
            if ($filter['pagination'] == 'off') {  
                return $this->getRows();    
            }
        }

        return $this->getPaginator();
    }
624292
public static function getCustomers($filter = array())
    {
        $filter = Filter::create($filter);
        return self::getCollection('/customers' . $filter->toQuery(), 'Customer');
    }
395316
public function getOrphanedPages($class = SiteTree::class, $filter = array(), $sort = null, $join = null, $limit = null)
    {
        // Alter condition
        $table = DataObject::getSchema()->tableName($class);
        if (empty($filter)) {
            $where = array();
        } elseif (is_array($filter)) {
            $where = $filter;
        } else {
            $where = array($filter);
        }
        $where[] = array("\"{$table}\".\"ParentID\" != ?" => 0);
        $where[] = '"Parents"."ID" IS NULL';

        $orphans = new ArrayList();
        foreach (array(Versioned::DRAFT, Versioned::LIVE) as $stage) {
            $table .= ($stage == Versioned::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;
    }
1242927
public function clientList(array $filter = array())
  {
    $clients = array();

    foreach($this->getParent()->clientList() as $client)
    {
      if($client["cid"] == $this->getId())
      {
        $clients[$client->getId()] = $client;
      }
    }

    return $this->filterList($clients, $filter);
  }
357340
public function clientList(array $filter = array())
  {
    if($this->clientList === null)
    {
      $clients = $this->request("clientlist -uid -away -badges -voice -info -times -groups -icon -country -ip")->toAssocArray("clid");

      $this->clientList = array();

      foreach($clients as $clid => $client)
      {
        if($this->getParent()->getExcludeQueryClients() && $client["client_type"]) continue;

        $this->clientList[$clid] = new Client($this, $client);
      }

      uasort($this->clientList, array(__CLASS__, "sortClientList"));

      $this->resetNodeList();
    }

    return $this->filterList($this->clientList, $filter);
  }
885536
protected function selfToArray(Array $filter = array())
    {
        $filter = array_flip($filter);
        $hasFilter = count($filter) > 0;
        $values = array();
        foreach ($this as $key => $value) {
            if (!$hasFilter || isset($filter[$key])) {
                $values[$key] = $this->$key;
            }
        }
        return $values;
    }
716724
public function getRecords($filter = '', $order = ['.id'], $page = 1, $count = null, $dataDimensions = null)
    {
        if ($dataDimensions == null) {
            $dataDimensions = $this->getCurrentDataDimensions();
        }

        if (!is_array($order))
        {
            $order = [$order];
        }

        if ($this->readConnection instanceof FilteringConnection) {
            $records = $this->readConnection->getRecords($this->getCurrentContentTypeName(), $dataDimensions, $filter,
                $page, $count, $order);
        } else {

            $records = $this->getAllRecords($dataDimensions);

            if ($filter != '') {
                $records = RecordsFilter::filterRecords($records, $filter);
            }

            $records = RecordsSorter::orderRecords($records, $order);

            if ($count != null) {
                $records = RecordsPager::sliceRecords($records, $page, $count);
            }
        }

        foreach ($records as $record) {
            $record->setRepository($this);
        }

        return $records;
    }
1109326
public function filter($filter)
    {
        if (is_array($filter) != true) {
            $filter = [$filter];
        }

        foreach ($filter as $item) {
            $this->filters[] = str_replace('./', $this->outpath . '/', $item);
        }

        return $this;
    }
871916
protected function getAnswerModel(array $filter, array $data, $sort)
    {
        $exportModelSource = $this->loader->getExportModelSource('AnswerExportModelSource');
        $model = $exportModelSource->getModel($filter, $data);
        $noExportColumns = $model->getColNames('noExport');
        foreach($noExportColumns as $colName) {
            $model->remove($colName, 'label');
        }
        $model->applyParameters($filter, true);

        $model->addSort($sort);

        return $model;
    }
394408
public function globalFeed($filter = array(), $orderBy = 'ID DESC', $since = null, $number = 10, $markViewed = true) {
		$number = (int) $number;
		
		if (!count($filter)) {
			$filter = array('ParentID' => 0);
		}
		$filter['Deleted'] = 0;

		$items = MicroPost::get()->filter($filter)->sort($orderBy);
		
		if ($since) {
			$since = (int) $since;
			$items = $items->filter('ID:GreaterThan', $since);
		}

		if ($markViewed) {
			$this->recordUserAction();
		}
		$items = $this->updatePostList($items);
		return $items->limit($number)->restrict();
	}
400840
public function fetch(array $filter, array $sorting = [])
    {
        $this->filter = $filter;
        $this->sorting = $sorting;
        $this->prefetch = true;
        $this->items = null;

        return $this;
    }
748081
protected function listFolderItems($folder, $filter, $sortBy)
    {
        $filter = $filter !== self::FILTER_EVERYTHING ? $filter : null;

        return MediaLibrary::instance()->listFolderContents($folder, $sortBy, $filter);
    }
24197
public function listFiles( $filter = NULL ) : array
    {
        $path = $this->path;

        if ( !file_exists($path) )    return NULL;

        if ( !is_readable($path) )    return NULL;

        if ( is_file($path) )    return NULL;

        $files = array();

        $dh = opendir($path);
        while( ($file_name = readdir($dh)) !== FALSE ){
            if ( $file_name === '.' || $file_name === '..' ){
                continue;
            }
            $file = new File( $file_name, $this );
            if ( $filter ){
                if ( $filter instanceof FileFilterInterface ){
                    if ( $filter->accept($file) ){
                        $files[] = $file;
                    }
                }
                else if ( is_callable($filter) ){
                    if ( $filter($file) ){
                        $files[] = $file;
                    }
                }
            }
            else{
                $files[] = $file;
            }
        }
        return $files;
    }
635942
public function &getPresentationRoleRefs( $filter = array(), $sort = true )
	{
		// Make sure the filter is initialized and contains lowercase values
		if ( ! is_array( $filter ) ) $filter = array();
		$filter = array_flip( array_map( 'strtolower', $filter ) );

		/**
		 * @var array $refs
		 */
		$refs = $this->context->presentationRoleRefs;
		/**
		 * @var array $result
		 */
		$result = array();

		foreach ( $refs as $refKey => $ref )
		{
			// Apply the filter if one is provided
			if ( count( $filter ) && ! isset( $filter[ strtolower( $refKey ) ] ) ) continue;

			// The presentation hierarchy may be implemented in another taxonomy
			if ( isset( $ref['hierarchy'] ) )
			{
				$result[ $refKey ]  = $ref;
			}
			else
			{
				$result[ $refKey ] = $this->context->presentationRoleRefs[ $refKey ];
			}

			$result[ $refKey ]['text'] = $this->getPresentationLinkRoleDescription( $ref );
		}

		if ( $sort )
		{
			$this->sortRoleRefs( $result );
		}

		return $result;
	}