Ejemplo n.º 1
0
 /**
  * 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());
     }
 }
Ejemplo n.º 2
0
 public static function compareContactsFullname($a, $b)
 {
     return \OCP\Util::naturalSortCompare($a['sortFullname'], $b['sortFullname']);
 }
Ejemplo n.º 3
0
 /**
  * @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;
 }