本文整理汇总了PHP中OCP\Util::naturalSortCompare方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::naturalSortCompare方法的具体用法?PHP Util::naturalSortCompare怎么用?PHP Util::naturalSortCompare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Util
的用法示例。
在下文中一共展示了Util::naturalSortCompare方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compareFileNames
/**
* Comparator function to sort files alphabetically and have
* the directories appear first
*
* @param \OCP\Files\FileInfo $a file
* @param \OCP\Files\FileInfo $b file
* @return int -1 if $a must come before $b, 1 otherwise
*/
public static function compareFileNames(FileInfo $a, FileInfo $b)
{
$aType = $a->getType();
$bType = $b->getType();
if ($aType === 'dir' and $bType !== 'dir') {
return -1;
} elseif ($aType !== 'dir' and $bType === 'dir') {
return 1;
} else {
return \OCP\Util::naturalSortCompare($a->getName(), $b->getName());
}
}
示例2: compareContactsFullname
public static function compareContactsFullname($a, $b)
{
return \OCP\Util::naturalSortCompare($a['sortFullname'], $b['sortFullname']);
}
示例3: enhanceMessage
/**
* @param $accountId
* @param $folderId
* @param $id
* @param $m
* @param IAccount $account
* @param $mailBox
* @return mixed
*/
private function enhanceMessage($accountId, $folderId, $id, $m, IAccount $account, $mailBox)
{
$json = $m->getFullMessage($account->getEmail(), $mailBox->getSpecialRole());
$json['senderImage'] = $this->contactsIntegration->getPhoto($m->getFromEmail());
if (isset($json['hasHtmlBody'])) {
$json['htmlBodyUrl'] = $this->buildHtmlBodyUrl($accountId, $folderId, $id);
}
if (isset($json['attachment'])) {
$json['attachment'] = $this->enrichDownloadUrl($accountId, $folderId, $id, $json['attachment']);
}
if (isset($json['attachments'])) {
$json['attachments'] = array_map(function ($a) use($accountId, $folderId, $id) {
return $this->enrichDownloadUrl($accountId, $folderId, $id, $a);
}, $json['attachments']);
// show images first
usort($json['attachments'], function ($a, $b) {
if (isset($a['isImage']) && !isset($b['isImage'])) {
return -1;
} elseif (!isset($a['isImage']) && isset($b['isImage'])) {
return 1;
} else {
Util::naturalSortCompare($a['fileName'], $b['fileName']);
}
});
return $json;
}
return $json;
}