Merge pull request #4816 from owncloud/fixing-723-master
Fixing 723 master
This commit is contained in:
commit
c7ca86799b
|
@ -34,6 +34,7 @@ if($doBreadcrumb) {
|
|||
$files = array();
|
||||
foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $i ) {
|
||||
$i["date"] = OCP\Util::formatDate($i["mtime"] );
|
||||
$i['icon'] = \OCA\files\lib\Helper::determineIcon($i);
|
||||
$files[] = $i;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ foreach ($content as $i) {
|
|||
}
|
||||
$i['directory'] = $dir;
|
||||
$i['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($i['mimetype']);
|
||||
$i['icon'] = \OCA\files\lib\Helper::determineIcon($i);
|
||||
$files[] = $i;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,4 +17,33 @@ class Helper
|
|||
'maxHumanFilesize' => $maxHumanFilesize,
|
||||
'usedSpacePercent' => (int)$storageInfo['relative']);
|
||||
}
|
||||
|
||||
public static function determineIcon($file) {
|
||||
if($file['type'] === 'dir') {
|
||||
$dir = $file['directory'];
|
||||
$absPath = \OC\Files\Filesystem::getView()->getAbsolutePath($dir.'/'.$file['name']);
|
||||
$mount = \OC\Files\Filesystem::getMountManager()->find($absPath);
|
||||
if (!is_null($mount)) {
|
||||
$sid = $mount->getStorageId();
|
||||
if (!is_null($sid)) {
|
||||
$sid = explode(':', $sid);
|
||||
if ($sid[0] === 'shared') {
|
||||
return \OC_Helper::mimetypeIcon('dir-shared');
|
||||
}
|
||||
if ($sid[0] !== 'local') {
|
||||
return \OC_Helper::mimetypeIcon('dir-external');
|
||||
}
|
||||
}
|
||||
}
|
||||
return \OC_Helper::mimetypeIcon('dir');
|
||||
}
|
||||
|
||||
if($file['isPreviewAvailable']) {
|
||||
$relativePath = substr($file['path'], 6);
|
||||
return \OC_Helper::previewIcon($relativePath);
|
||||
}
|
||||
return \OC_Helper::mimetypeIcon($file['mimetype']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<input type="hidden" id="disableSharing" data-status="<?php p($_['disableSharing']); ?>">
|
||||
<?php foreach($_['files'] as $file):
|
||||
//strlen('files/') => 6
|
||||
$relativePath = substr($file['path'], 6);
|
||||
// the bigger the file, the darker the shade of grey; megabytes*2
|
||||
$simple_size_color = intval(160-$file['size']/(1024*1024)*2);
|
||||
if($simple_size_color<0) $simple_size_color = 0;
|
||||
|
@ -22,26 +20,7 @@
|
|||
<?php else: ?>
|
||||
<td class="filename svg"
|
||||
<?php endif; ?>
|
||||
<?php if($file['type'] == 'dir'): ?>
|
||||
style="background-image:url(<?php print_unescaped(OCP\mimetype_icon('dir')); ?>)"
|
||||
<?php else: ?>
|
||||
<?php if($_['isPublic']): ?>
|
||||
<?php
|
||||
$relativePath = substr($relativePath, strlen($_['sharingroot']));
|
||||
?>
|
||||
<?php if($file['isPreviewAvailable']): ?>
|
||||
style="background-image:url(<?php print_unescaped(OCP\publicPreview_icon($relativePath, $_['sharingtoken'])); ?>)"
|
||||
<?php else: ?>
|
||||
style="background-image:url(<?php print_unescaped(OCP\mimetype_icon($file['mimetype'])); ?>)"
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<?php if($file['isPreviewAvailable']): ?>
|
||||
style="background-image:url(<?php print_unescaped(OCP\preview_icon($relativePath)); ?>)"
|
||||
<?php else: ?>
|
||||
style="background-image:url(<?php print_unescaped(OCP\mimetype_icon($file['mimetype'])); ?>)"
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
style="background-image:url(<?php print_unescaped($file['icon']); ?>)"
|
||||
>
|
||||
<?php if(!isset($_['readonly']) || !$_['readonly']): ?>
|
||||
<input id="select-<?php p($file['fileid']); ?>" type="checkbox" />
|
||||
|
|
|
@ -19,6 +19,20 @@ function fileCmp($a, $b) {
|
|||
}
|
||||
}
|
||||
|
||||
function determineIcon($file, $sharingRoot, $sharingToken) {
|
||||
// for folders we simply reuse the files logic
|
||||
if($file['type'] == 'dir') {
|
||||
return \OCA\files\lib\Helper::determineIcon($file);
|
||||
}
|
||||
|
||||
$relativePath = substr($file['path'], 6);
|
||||
$relativePath = substr($relativePath, strlen($sharingRoot));
|
||||
if($file['isPreviewAvailable']) {
|
||||
return OCP\publicPreview_icon($relativePath, $sharingToken);
|
||||
}
|
||||
return OCP\mimetype_icon($file['mimetype']);
|
||||
}
|
||||
|
||||
if (isset($_GET['t'])) {
|
||||
$token = $_GET['t'];
|
||||
$linkItem = OCP\Share::getShareByToken($token);
|
||||
|
@ -176,6 +190,7 @@ if (isset($path)) {
|
|||
}
|
||||
$i['directory'] = $getPath;
|
||||
$i['permissions'] = OCP\PERMISSION_READ;
|
||||
$i['icon'] = determineIcon($i, $basePath, $token);
|
||||
$files[] = $i;
|
||||
}
|
||||
usort($files, "fileCmp");
|
||||
|
|
|
@ -65,6 +65,7 @@ foreach ($result as $r) {
|
|||
}
|
||||
$i['permissions'] = OCP\PERMISSION_READ;
|
||||
$i['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($r['mime']);
|
||||
$i['icon'] = \OCA\files\lib\Helper::determineIcon($i);
|
||||
$files[] = $i;
|
||||
}
|
||||
|
||||
|
|
|
@ -232,6 +232,14 @@ class OC_Helper {
|
|||
self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/folder.png';
|
||||
return OC::$WEBROOT . '/core/img/filetypes/folder.png';
|
||||
}
|
||||
if ($mimetype === 'dir-shared') {
|
||||
self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/folder-shared.png';
|
||||
return OC::$WEBROOT . '/core/img/filetypes/folder-shared.png';
|
||||
}
|
||||
if ($mimetype === 'dir-external') {
|
||||
self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/folder-external.png';
|
||||
return OC::$WEBROOT . '/core/img/filetypes/folder-external.png';
|
||||
}
|
||||
|
||||
// Icon exists?
|
||||
if (file_exists(OC::$SERVERROOT . '/core/img/filetypes/' . $icon . '.png')) {
|
||||
|
|
Loading…
Reference in New Issue