所有列表

@param string $sort 排序
@return array
333162
public function actionAll($sort = '')
    {
        $order = ExtHelpers::getOrder($sort, [
            'group_id',
            'name',
            'is_system',
            'note',
            'status'
        ], [], 'group_id DESC');
        $list = DpAdminGroup::getAll($order);

        return [
            'total' => count($list),
            'list' => $list,
        ];
    }
404505
public function getList($sort = 'name')
    {
        $sites = $this->entityManager->getRepository('Concrete\Core\Entity\Site\Site')
            ->findAll();
        $list = [];
        $factory = new Factory($this->config);
        foreach ($sites as $site) {
            $list[] = $factory->createEntity($site);
        }

        switch ($sort) {
            case 'name':
                $comparer = new Comparer();
                usort($list, function ($siteA, $siteB) use ($comparer) {
                    return $comparer->compare($siteA->getSiteName(), $siteB->getSiteName());
                });
                break;
        }

        return $list;
    }
446142
public static function actionTree($sort = '')
    {
        $order = ExtHelpers::getOrder($sort, [
            'menu_id',
            'parent_id',
            'text',
            'title',
            'url',
            'view_package',
            'expanded',
            'closable',
            'is_folder',
            'is_open_url',
            'is_open_target',
            'is_every_open',
            'is_hide',
            'display_order',
            'note',
            'status',
        ], [], 'display_order ASC,menu_id ASC');
        $tree = DpAdminMenu::getTreeByParentId(null, '', [], $order);

        return [
            'children' => $tree,
        ];
    }
470456
public function kSort($sort = null)
    {
        if ($sort !== null && ! is_int($sort)) {
            throw new \InvalidArgumentException(
                'Invalid sort type. Sort type must ne integer.',
                E_USER_ERROR
            );
        }

        return ksort($this->storedData, $sort);
    }
541003
private function parseSort(array $sort)
    {
        $out = '';
        if (!empty($sort)) {
            $conditions = [];
            foreach ($sort as $field => $direction) {
                $direction = $direction ? 'DESC' : 'ASC';
                $conditions[] = sprintf('%s %s', $field, $direction);
            }
            $out = sprintf(' ORDER BY %s', implode(', ', $conditions));
        }
        return $out;
    }
313617
public function getSort($sortName): ?OrderBy
    {
        [$name, $sorts] = $this->getArrayAndKeyName($sortName, 'sorts');

        return array_first($sorts, function ($sort) use ($name) {
            return $sort->getName() === $name;
        });
    }
541907
public static function sort($sort) {

        if ( is_array($sort) ) return $sort;

        $__sort = array();
        if ( is_string($sort) && $sort != '' ) {
            $oarr = explode(',', $sort);
            foreach ($oarr as $value) {
                $value = preg_replace('/\s+/', ' ', $value);    //去除多余的空格
                $value = explode(' ', $value);
                if ( strtoupper($value[1]) == "DESC" ) {
                    $__sort[$value[0]] = -1;
                } else {
                    $__sort[$value[0]] = 1;
                }
            }
        }
        return $__sort;
    }
521939
public function listForks(string $sort = AbstractApi::SORT_NEWEST): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/forks?:arg',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(),
            http_build_query(['sort' => $sort])));
    }
597699
protected function getNewMigrations( $data = null, $sort = self::SORT_BY_GROUP )
	{
		$migrations = [];
		
		if( is_numeric( $data ) && (int)$data ) {
			$limit = (int)$data;
		}
		// for cases such as migrate
		else if( !empty( $data ) && is_string( $data ) ) {
			return parent::getNewMigrations();
		}
		else {
			$limit = null;
		}
		
		/*
		 * if set $migrationPaths from action
		 */
		if( is_array( $data ) ) {
			$migrationPaths = $data;
		}
		/*
		 * set migrationPath and migrationNamespaces from config
		 */
		else {
			$migrationPaths = array_unique( array_merge( ( $this->migrationPath ?? [] ), ( $this->migrationNamespaces ?? [] ), [ $this->defaultMigrationPath ] ) );
		}
		
		/*
		 * check $migrationPaths and collect subfolders from paths and namespaces
		 */
		foreach( $migrationPaths as $key => $path ) {
			if( $paths = FileHelper::resolvePath( $path, [ 'filter' => '/migration/' ] ) ) {
				
				foreach( $migrationPaths as $key => $searchPath ) {
					if( $searchPath == $path ) {
						/*
						 * change record such as alias to resolved items with or w/o subfolders
						 */
						array_splice( $migrationPaths, $key, 1, $paths );
						break;
					}
				}
				
			}
			/*
			 * if not correct - remove from list
			 */
			else {
				unset( $migrationPaths[ $key ] );
			}
		}
		
		/*
		 * at this moment $this->migrationPath already parsed by BaseMigrateController
		 * and $migrationPaths is resolved result of passed $data
		 * it's need to merge and unique both results
		 */
		if( is_array( $data ) ) {
			$this->migrationPath = array_unique( array_merge( $this->migrationPath, $migrationPaths ) );
		}
		else {
			$this->migrationPath = $migrationPaths;
		}
		
		foreach( $migrationPaths as $path ) {
			
			if( is_dir( $path ) ) {
				$files = FileHelper::findFiles( $path, [ 'only' => [ '*.php' ], 'recursive' => false ] );
			}
			else if( is_file( $path ) ) {
				$files = [ $path ];
			}
			else {
				continue;
			}
			
			if( $files ) {
				
				$migrationsGroup = [];
				
				foreach( $files as $file ) {
					
					if( preg_match( '/(m(\d{6}_?\d{6})\D.*?)\.php$/is', $file, $matches ) && is_file( $file ) ) {
						
						require_once( $file );
						
						$class = $matches[1];
						
						if( $ns = FileHelper::extract_namespace( $file ) ) {
							$class = $ns . '\\' . $class;
						}
						
						$time = str_replace( '_', '', $matches[2] );
						
						// @TODO change 'migrations' to something default
						$suffix = preg_replace( '/.*migrations(.*)\.php/', '$1', $file );
						
						if( !$this->_isApplied( $class ) ) {
							
							$migrationsGroup[ $time . $suffix ] = $class;
							
							if( !isset( $this->_migrationsByGroup[ pathinfo( $file )['dirname'] ][ $class ] ) ) {
								$this->_migrationsByGroup[ pathinfo( $file )['dirname'] ][ $class ] = $file;
								$this->_migrations[ $class ]                                        = $file;
							}
							
						}
					}
				}
				
				// time sort
				ksort( $migrationsGroup );
				$migrations = array_merge( $migrations, $migrationsGroup );
			};
			
		}
		
		$migrations = array_unique( $migrations );
		
		if( $sort == self::SORT_COMMON ) {
			ksort( $migrations );
		}
		
		if( (int)$limit > 0 ) {
			$migrations = array_slice( $migrations, 0, $limit );
		}
		
		return $migrations;
	}
1192698
public function sortByValue($sort = SORT_NUMERIC)
    {
        return $this
            ->groupBy(function (Card $card) {
                return $card->value();
            })
            ->map(function (CardCollection $valueGroup) {
                return $valueGroup->sortBySuitValue();
            })
            ->flatten()
            ->sortBy(function (Card $card) {
                return $card->value();
            }, $sort)
            ->values();
    }
1014189
public function andSort(Sort $sort = null) : Sort
    {
        if ($sort === null) {
            return $this;
        }
        $orders = $this->orders;
        foreach ($sort as $order) {
            $orders[] = $order;
        }
        return new Sort($orders);
    }
27081
public function sort($sorts)
    {
        usort($this->rows, 
            function ($a, $b) use ($sorts) {
                $cmp = 0;
                foreach ($sorts as $sort => $direction) {
                    if (is_string($direction)) {
                        $cmp = is_numeric($a[$sort]) && is_numeric($b[$sort]) ? 
                            $a[$sort] - $b[$sort] : strcmp($a[$sort], $b[$sort]);
                        $cmp = $direction === 'asc' ? $cmp : - $cmp;
                    } else if (is_callable($direction)) {
                        $cmp = $direction($a[$sort], $b[$sort]);
                    }
                    if ($cmp !== 0) {
                        break;
                    }
                }
                return $cmp;
            }
        );
        return $this;
    }
963776
public function getItems($order = null)
    {
        if (null === $order) {
            return $this->items;
        }

        return $this->sort($this->items, $order);
    }
1120025
public static function actionMenu($sort = '')
    {
        $group_id = \Yii::$app->request->get('group_id');

        $order = ExtHelpers::getOrder($sort, [
            'menu_id',
            'parent_id',
            'text',
            'title',
            'url',
            'view_package',
            'expanded',
            'closable',
            'is_open_url',
            'is_open_target',
            'is_every_open',
            'is_hide',
            'display_order',
            'note',
            'status',
        ], [], 'menu_id DESC');
        $tree = DpAdminMenu::getGroupMenuTreeByParentId($group_id, null, $order);

        return [
            'children' => $tree,
        ];
    }
739243
public function getOrdered($collection, $sort = null)
    {
        if (!$sort) {
            return $collection;
        }

        $unordered = [];
        foreach ($collection as $content) {
            $unordered[$content->getId()] = $content;
        }

        $ordered = [];
        foreach ($sort as $id) {
            if (isset($unordered[$id])) {
                $ordered[] = $unordered[$id];
            }
        }

        return $ordered;
    }
1197916
protected function checkOrder($order='') {
         if(is_string($order) && !empty($order)) {
            $orders = explode(',',$order);
            $_order = array();
            foreach ($orders as $order){
                $array = explode(' ',trim($order));
                $field   =   $array[0];
                $sort   =   isset($array[1])?$array[1]:'ASC';
                // 解析成视图字段
                foreach ($this->viewFields as $name=>$val){
                    $k = isset($val['_as'])?$val['_as']:$name;
                    $val  =  $this->_checkFields($name,$val);
                    if(false !== $_field = array_search($field,$val,true)) {
                        // 存在视图字段
                        $field     =  is_numeric($_field)?$k.'.'.$field:$k.'.'.$_field;
                        break;
                    }
                }
                $_order[] = $field.' '.$sort;
            }
            $order = implode(',',$_order);
         }
        return $order;
    }
811566
public function GetAll(& $pagination = null, $sorting = null)
    {
        $usersList = $this->GetList('users_all', $pagination, null, null, null, $sorting);

        $users = array();
        if (is_array($usersList)) {
            foreach ($usersList as $user) {
                array_push($users, $this->GetUserResponse($user));
            }
        }
        return $users;
    }