当前位置: 首页>>代码示例>>PHP>>正文


PHP Helper::determineIcon方法代码示例

本文整理汇总了PHP中OCA\Files\Helper::determineIcon方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::determineIcon方法的具体用法?PHP Helper::determineIcon怎么用?PHP Helper::determineIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCA\Files\Helper的用法示例。


在下文中一共展示了Helper::determineIcon方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rename

 /**
  * rename a file
  *
  * @param string $dir
  * @param string $oldname
  * @param string $newname
  * @return array
  */
 public function rename($dir, $oldname, $newname)
 {
     $result = array('success' => false, 'data' => NULL);
     // rename to "/Shared" is denied
     if ($dir === '/' and $newname === 'Shared') {
         $result['data'] = array('message' => $this->l10n->t("Invalid folder name. Usage of 'Shared' is reserved."));
         // rename to existing file is denied
     } else {
         if ($this->view->file_exists($dir . '/' . $newname)) {
             $result['data'] = array('message' => $this->l10n->t("The name %s is already used in the folder %s. Please choose a different name.", array($newname, $dir)));
         } else {
             if ($newname !== '.' and !($dir === '/' and $oldname === 'Shared') and $this->view->rename($dir . '/' . $oldname, $dir . '/' . $newname)) {
                 // successful rename
                 $meta = $this->view->getFileInfo($dir . '/' . $newname);
                 if ($meta['mimetype'] === 'httpd/unix-directory') {
                     $meta['type'] = 'dir';
                 } else {
                     $meta['type'] = 'file';
                 }
                 $fileinfo = array('id' => $meta['fileid'], 'mime' => $meta['mimetype'], 'size' => $meta['size'], 'etag' => $meta['etag'], 'directory' => $dir, 'name' => $newname, 'isPreviewAvailable' => \OC::$server->getPreviewManager()->isMimeSupported($meta['mimetype']), 'icon' => \OCA\Files\Helper::determineIcon($meta));
                 $result['success'] = true;
                 $result['data'] = $fileinfo;
             } else {
                 // rename failed
                 $result['data'] = array('message' => $this->l10n->t('%s could not be renamed', array($oldname)));
             }
         }
     }
     return $result;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:38,代码来源:app.php

示例2: testGetFilesByTagMultiple

 public function testGetFilesByTagMultiple()
 {
     $tagName = 'MyTagName';
     $fileInfo1 = new FileInfo('/root.txt', $this->getMockBuilder('\\OC\\Files\\Storage\\Storage')->disableOriginalConstructor()->getMock(), '/var/www/root.txt', ['mtime' => 55, 'mimetype' => 'application/pdf', 'size' => 1234, 'etag' => 'MyEtag'], $this->getMockBuilder('\\OCP\\Files\\Mount\\IMountPoint')->disableOriginalConstructor()->getMock());
     $fileInfo2 = new FileInfo('/root.txt', $this->getMockBuilder('\\OC\\Files\\Storage\\Storage')->disableOriginalConstructor()->getMock(), '/var/www/some/sub.txt', ['mtime' => 999, 'mimetype' => 'application/binary', 'size' => 9876, 'etag' => 'SubEtag'], $this->getMockBuilder('\\OCP\\Files\\Mount\\IMountPoint')->disableOriginalConstructor()->getMock());
     $this->tagService->expects($this->once())->method('getFilesByTag')->with($this->equalTo([$tagName]))->will($this->returnValue([$fileInfo1, $fileInfo2]));
     $expected = new DataResponse(['files' => [['id' => null, 'parentId' => null, 'date' => \OCP\Util::formatDate(55), 'mtime' => 55000, 'icon' => \OCA\Files\Helper::determineIcon($fileInfo1), 'name' => 'root.txt', 'permissions' => null, 'mimetype' => 'application/pdf', 'size' => 1234, 'type' => 'file', 'etag' => 'MyEtag', 'path' => '/', 'tags' => [['MyTagName']]], ['id' => null, 'parentId' => null, 'date' => \OCP\Util::formatDate(999), 'mtime' => 999000, 'icon' => \OCA\Files\Helper::determineIcon($fileInfo2), 'name' => 'root.txt', 'permissions' => null, 'mimetype' => 'application/binary', 'size' => 9876, 'type' => 'file', 'etag' => 'SubEtag', 'path' => '/', 'tags' => [['MyTagName']]]]]);
     $this->assertEquals($expected, $this->apiController->getFilesByTag([$tagName]));
 }
开发者ID:samj1912,项目名称:repo,代码行数:9,代码来源:apicontrollertest.php

示例3: getTrashFiles

 /**
  * Retrieves the contents of a trash bin directory.
  * @param string $dir path to the directory inside the trashbin
  * or empty to retrieve the root of the trashbin
  * @return array of files
  */
 public static function getTrashFiles($dir)
 {
     $result = array();
     $user = \OCP\User::getUser();
     if ($dir && $dir !== '/') {
         $view = new \OC_Filesystemview('/' . $user . '/files_trashbin/files');
         $dirContent = $view->opendir($dir);
         if ($dirContent === false) {
             return null;
         }
         if (is_resource($dirContent)) {
             while (($entryName = readdir($dirContent)) !== false) {
                 if (!\OC\Files\Filesystem::isIgnoredDir($entryName)) {
                     $pos = strpos($dir . '/', '/', 1);
                     $tmp = substr($dir, 0, $pos);
                     $pos = strrpos($tmp, '.d');
                     $timestamp = substr($tmp, $pos + 2);
                     $result[] = array('id' => $entryName, 'timestamp' => $timestamp, 'mime' => $view->getMimeType($dir . '/' . $entryName), 'type' => $view->is_dir($dir . '/' . $entryName) ? 'dir' : 'file', 'location' => $dir);
                 }
             }
             closedir($dirContent);
         }
     } else {
         $query = \OC_DB::prepare('SELECT `id`,`location`,`timestamp`,`type`,`mime` FROM `*PREFIX*files_trash` WHERE `user` = ?');
         $result = $query->execute(array($user))->fetchAll();
     }
     $files = array();
     $id = 0;
     foreach ($result as $r) {
         $i = array();
         $i['id'] = $id++;
         $i['name'] = $r['id'];
         $i['date'] = \OCP\Util::formatDate($r['timestamp']);
         $i['timestamp'] = $r['timestamp'];
         $i['etag'] = $i['timestamp'];
         // dummy etag
         $i['mimetype'] = $r['mime'];
         $i['type'] = $r['type'];
         if ($i['type'] === 'file') {
             $fileinfo = pathinfo($r['id']);
             $i['basename'] = $fileinfo['filename'];
             $i['extension'] = isset($fileinfo['extension']) ? '.' . $fileinfo['extension'] : '';
         }
         $i['directory'] = $r['location'];
         if ($i['directory'] === '/') {
             $i['directory'] = '';
         }
         $i['permissions'] = \OCP\PERMISSION_READ;
         $i['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($r['mime']);
         $i['icon'] = \OCA\Files\Helper::determineIcon($i);
         $files[] = $i;
     }
     usort($files, array('\\OCA\\Files\\Helper', 'fileCmp'));
     return $files;
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:61,代码来源:helper.php

示例4: determineIcon

function determineIcon($file, $sharingRoot, $sharingToken)
{
    // for folders we simply reuse the files logic
    if ($file['type'] == 'dir') {
        return \OCA\Files\Helper::determineIcon($file);
    }
    $relativePath = substr($file['path'], 6);
    $relativePath = substr($relativePath, strlen($sharingRoot));
    if ($file['isPreviewAvailable']) {
        return OCP\publicPreview_icon($relativePath, $sharingToken) . '&c=' . $file['etag'];
    }
    return OCP\mimetype_icon($file['mimetype']);
}
开发者ID:hjimmy,项目名称:owncloud,代码行数:13,代码来源:public.php

示例5: getFiles

 /**
  * Retrieves the contents of the given directory and
  * returns it as a sorted array.
  * @param string $dir path to the directory
  * @return array of files
  */
 public static function getFiles($dir)
 {
     $content = \OC\Files\Filesystem::getDirectoryContent($dir);
     $files = array();
     foreach ($content as $i) {
         $i['date'] = \OCP\Util::formatDate($i['mtime']);
         if ($i['type'] === 'file') {
             $fileinfo = pathinfo($i['name']);
             $i['basename'] = $fileinfo['filename'];
             if (!empty($fileinfo['extension'])) {
                 $i['extension'] = '.' . $fileinfo['extension'];
             } else {
                 $i['extension'] = '';
             }
         }
         $i['directory'] = $dir;
         $i['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($i['mimetype']);
         $i['icon'] = \OCA\Files\Helper::determineIcon($i);
         $files[] = $i;
     }
     usort($files, array('\\OCA\\Files\\Helper', 'fileCmp'));
     return $files;
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:29,代码来源:helper.php

示例6: formatFileInfo

 /**
  * Formats the file info to be returned as JSON to the client.
  *
  * @param \OCP\Files\FileInfo $i
  * @return array formatted file info
  */
 public static function formatFileInfo(FileInfo $i)
 {
     $entry = array();
     $entry['id'] = $i['fileid'];
     $entry['parentId'] = $i['parent'];
     $entry['date'] = \OCP\Util::formatDate($i['mtime']);
     $entry['mtime'] = $i['mtime'] * 1000;
     // only pick out the needed attributes
     $entry['icon'] = \OCA\Files\Helper::determineIcon($i);
     if (\OC::$server->getPreviewManager()->isAvailable($i)) {
         $entry['isPreviewAvailable'] = true;
     }
     $entry['name'] = $i->getName();
     $entry['permissions'] = $i['permissions'];
     $entry['mimetype'] = $i['mimetype'];
     $entry['size'] = $i['size'];
     $entry['type'] = $i['type'];
     $entry['etag'] = $i['etag'];
     if (isset($i['tags'])) {
         $entry['tags'] = $i['tags'];
     }
     if (isset($i['displayname_owner'])) {
         $entry['shareOwner'] = $i['displayname_owner'];
     }
     if (isset($i['is_share_mount_point'])) {
         $entry['isShareMountPoint'] = $i['is_share_mount_point'];
     }
     $mountType = null;
     if ($i->isShared()) {
         $mountType = 'shared';
     } else {
         if ($i->isMounted()) {
             $mountType = 'external';
         }
     }
     if ($mountType !== null) {
         if ($i->getInternalPath() === '') {
             $mountType .= '-root';
         }
         $entry['mountType'] = $mountType;
     }
     if (isset($i['extraData'])) {
         $entry['extraData'] = $i['extraData'];
     }
     return $entry;
 }
开发者ID:riso,项目名称:owncloud-core,代码行数:52,代码来源:helper.php

示例7: formatFileInfo

 /**
  * Formats the file info to be returned as JSON to the client.
  *
  * @param \OCP\Files\FileInfo $i
  * @return array formatted file info
  */
 public static function formatFileInfo(FileInfo $i)
 {
     $entry = array();
     $entry['id'] = $i['fileid'];
     $entry['parentId'] = $i['parent'];
     $entry['date'] = \OCP\Util::formatDate($i['mtime']);
     $entry['mtime'] = $i['mtime'] * 1000;
     // only pick out the needed attributes
     $entry['icon'] = \OCA\Files\Helper::determineIcon($i);
     if (\OC::$server->getPreviewManager()->isAvailable($i)) {
         $entry['isPreviewAvailable'] = true;
     }
     $entry['name'] = $i->getName();
     $entry['permissions'] = $i['permissions'];
     $entry['mimetype'] = $i['mimetype'];
     $entry['size'] = $i['size'];
     $entry['type'] = $i['type'];
     $entry['etag'] = $i['etag'];
     //$entry['mount'] = $i->getStorage()->getId();
     $query = \OC_DB::prepare('SELECT `uid_owner`
                                     FROM
                                     `*PREFIX*share`
                                     WHERE
                                     `item_source` = ?');
     $result = $query->execute(array($entry['id']));
     if (\OCP\DB::isError($result)) {
         \OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage(), \OC_Log::ERROR);
     } else {
         while ($row = $result->fetchRow()) {
             $entry['owner'] = $row['uid_owner'];
         }
     }
     if (isset($i['tags'])) {
         $entry['tags'] = $i['tags'];
     }
     if (isset($i['displayname_owner'])) {
         $entry['shareOwner'] = $i['displayname_owner'];
         $query = \OC_DB::prepare('SELECT `directory_uuid`
                                     FROM
                                     `*PREFIX*ldap_user_mapping`
                                     WHERE
                                     `ldap_dn` LIKE LOWER("cn="?"%")');
         $result = $query->execute(array($entry['shareOwner']));
         if (\OCP\DB::isError($result)) {
             \OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage(), \OC_Log::ERROR);
             if ($entry['shareOwner'] == 'admin') {
                 $entry['storage'] = 'admin';
             }
         } else {
             while ($row = $result->fetchRow()) {
                 $entry['storage'] = $row['directory_uuid'];
             }
             if ($entry['shareOwner'] == 'admin') {
                 $entry['storage'] = 'admin';
             }
         }
     }
     if (isset($i['is_share_mount_point'])) {
         $entry['isShareMountPoint'] = $i['is_share_mount_point'];
     }
     $mountType = null;
     if ($i->isShared()) {
         $mountType = 'shared';
     } else {
         if ($i->isMounted()) {
             $mountType = 'external';
         }
     }
     if ($mountType !== null) {
         if ($i->getInternalPath() === '') {
             $mountType .= '-root';
         }
         $entry['mountType'] = $mountType;
     }
     if (isset($i['extraData'])) {
         $entry['extraData'] = $i['extraData'];
     }
     return $entry;
 }
开发者ID:Ebimedia,项目名称:owncloud,代码行数:85,代码来源:helper.php

示例8: foreach

        $file['mimetype_icon'] = \OCA\Files\Helper::determineIcon($file);
        $files[] = $file;
    }
}
if (is_array($mimetypes) && count($mimetypes)) {
    foreach ($mimetypes as $mimetype) {
        foreach (\OC\Files\Filesystem::getDirectoryContent($dir, $mimetype) as $file) {
            $file['directory'] = $dir;
            $file['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($file['mimetype']);
            $file["date"] = OCP\Util::formatDate($file["mtime"]);
            $file['mimetype_icon'] = \OCA\Files\Helper::determineIcon($file);
            $files[] = $file;
        }
    }
} else {
    foreach (\OC\Files\Filesystem::getDirectoryContent($dir) as $file) {
        $file['directory'] = $dir;
        $file['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($file['mimetype']);
        $file["date"] = OCP\Util::formatDate($file["mtime"]);
        $file['mimetype_icon'] = \OCA\Files\Helper::determineIcon($file);
        $files[] = $file;
    }
}
// Sort by name
usort($files, function ($a, $b) {
    if ($a['name'] === $b['name']) {
        return 0;
    }
    return $a['name'] < $b['name'] ? -1 : 1;
});
OC_JSON::success(array('data' => $files));
开发者ID:omusico,项目名称:isle-web-framework,代码行数:31,代码来源:rawlist.php


注:本文中的OCA\Files\Helper::determineIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。