本文整理汇总了PHP中a::sort方法的典型用法代码示例。如果您正苦于以下问题:PHP a::sort方法的具体用法?PHP a::sort怎么用?PHP a::sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类a
的用法示例。
在下文中一共展示了a::sort方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tagcloud
function tagcloud($parent, $options = array())
{
global $site;
// default values
$defaults = array('limit' => false, 'field' => 'tags', 'children' => 'visible', 'baseurl' => $parent->url(), 'param' => 'tag', 'sort' => 'name', 'sortdir' => 'asc');
// merge defaults and options
$options = array_merge($defaults, $options);
switch ($options['children']) {
case 'invisible':
$children = $parent->children()->invisible();
break;
case 'visible':
$children = $parent->children()->visible();
break;
default:
$children = $parent->children();
break;
}
$cloud = array();
foreach ($children as $p) {
$tags = str::split($p->{$options}['field']());
foreach ($tags as $t) {
if (isset($cloud[$t])) {
$cloud[$t]->results++;
} else {
$cloud[$t] = new obj(array('results' => 1, 'name' => $t, 'url' => $options['baseurl'] . '/' . $options['param'] . ':' . $t, 'isActive' => param($options['param']) == $t ? true : false));
}
}
}
$cloud = a::sort($cloud, $options['sort'], $options['sortdir']);
if ($options['limit']) {
$cloud = array_slice($cloud, 0, $options['limit']);
}
return $cloud;
}
示例2: testSort
public function testSort()
{
$users = $this->users;
$users = a::sort($users, 'username', 'asc');
$first = a::first($users);
$last = a::last($users);
$this->assertEquals('mary', $first['username']);
$this->assertEquals('peter', $last['username']);
}
示例3: sortBy
function sortBy($field, $direction = 'asc')
{
$pages = a::sort($this->_, $field . ' ' . $direction);
return new pages($pages);
}
示例4: sortBy
function sortBy($field, $direction = 'asc', $method = SORT_REGULAR)
{
$files = a::sort($this->_, $field, $direction, $method);
return new files($files);
}
示例5: sortBy
function sortBy($field, $direction = 'asc', $method = SORT_REGULAR)
{
if ($field == 'dirname') {
$method = 'natural';
}
$pages = a::sort($this->_, $field, $direction, $method);
return new pages($pages);
}
示例6: html
?>
<main class="main" role="main">
<div class="col-4-6 last">
<article class="text">
<h1><?php
echo html($page->title());
?>
</h1>
<h2>Available Translations</h2>
<dl>
<?php
$langs = a::sort(yaml($page->languages()), 'lang', 'asc');
?>
<?php
foreach ($langs as $lang) {
?>
<dt class="gamma"><a href="https://github.com/getkirby/panel/blob/master/app/languages/<?php
echo $lang['code'];
?>
.php"><?php
echo $lang['lang'];
?>
</a></dt>
<dd><span>Author: </span><?php
echo $lang['author'];
?>
</dd>