阅读(1275)
赞(9)
修复选择单个文件夹时不显示文件夹大小问题
2023-02-10 12:59:37 更新
文件:core\class\table\table_resources.php
原代码:
if ($contains) {
//文件大小信息
if ($fileinfo['type'] == 'folder') {
$contaions = self::get_contains_by_fid($fileinfo['oid'], true);
$contaions['contain'][1] += 1;
$fileinfo['fsize'] = formatsize($contaions['size']);
$fileinfo['ffsize'] = lang('property_info_size', array('fsize' => formatsize($contaions['size']), 'size' => $contaions['size']));
$fileinfo['contain'] = lang('property_info_contain', array('filenum' => $contaions['contain'][0], 'foldernum' => $contaions['contain'][1]));
} elseif ($fileinfo['ext']) {
$fileinfo['fsize'] = formatsize($fileinfo['size']);
} else {
$fileinfo['fsize'] = formatsize($fileinfo['size']);
}
}
修改后的代码
if ($contains) {
//文件大小信息
if ($fileinfo['type'] == 'folder') {
$contaions = self::get_contains_by_fid($fileinfo['oid'], true);
$contaions['contain'][1] += 1;
$fileinfo['fsize'] = formatsize($contaions['size']);
$fileinfo['ffsize'] = lang('property_info_size', array('fsize' => formatsize($contaions['size']), 'size' => $contaions['size']));
$fileinfo['contain'] = lang('property_info_contain', array('filenum' => $contaions['contain'][0], 'foldernum' => $contaions['contain'][1]));
} elseif ($fileinfo['ext']) {
$fileinfo['fsize'] = formatsize($fileinfo['size']);
} else {
//获取文件基本信息
$fileinfos = DB::fetch_all("select r.*,f.perm_inherit,p.path from %t r left join %t f on r.pfid = f.fid left join %t p on p.fid = r.pfid $wheresql", $param);
$fileinfo = array();
$tmpinfo = array();
$infos = array();
$fileinfo = DB::fetch_first("select r.*,f.perm_inherit,p.path from %t r left join %t f on r.pfid = f.fid left join %t p on r.pfid = p.fid $wheresql", $param);
if (!$fileinfo) {
return array('error' => lang('no_privilege'));
}
//位置信息
$fileinfo['realpath'] = preg_replace('/dzz:(.+?):/', '', $fileinfo['path']);
//统计信息
$fileinfo['opendateline'] = ($filestatis['opendateline']) ? dgmdate($filestatis['opendateline'], 'Y-m-d H:i:s') : dgmdate($fileinfo['dateline'], 'Y-m-d H:i:s');
$fileinfo['editdateline'] = ($filestatis['editdateline']) ? dgmdate($filestatis['editdateline'], 'Y-m-d H:i:s') : dgmdate($fileinfo['dateline'], 'Y-m-d H:i:s');
$fileinfo['fdateline'] = dgmdate($fileinfo['dateline'], 'Y-m-d H:i:s');
//编辑权限信息
$fileinfo['editperm'] = 1;
if ($fileinfo['gid'] > 0) {
$powerarr = perm_binPerm::getPowerArr();
if (!(C::t('organization_admin')->chk_memberperm($fileinfo['gid'])) && !($uid == $fileinfo['uid'] && $fileinfo['perm_inherit'] & $powerarr['edit1']) && !($fileinfo['perm_inherit'] & $powerarr['edit2'])) {
$fileinfo['editperm'] = 0;
}
}
foreach ($fileinfos as $v) {
$infos[$v['rid']] = $v;
$tmpinfo['rids'][] = $v['rid'];
$tmpinfo['names'][] = $v['name'];
$tmpinfo['pfid'][] = $v['pfid'];
$tmpinfo['ext'][] = ($v['ext']) ? $v['ext'] : $v['type'];
$tmpinfo['type'][] = $v['type'];
$tmpinfo['username'][] = $v['username'];
$tnpinfo['hascontain'][$v['rid']] = ($v['type'] == 'folder') ? 1 : 0;
$tmpinfo['realpath'][] = $v['path'];
}
$fileinfo['name'] = getstr(implode(',', array_unique($tmpinfo['names'])), 60);
//判断文件归属
$fileinfo['username'] = (count(array_unique($tmpinfo['username'])) > 1) ? lang('more_member_owner') : $tmpinfo['username'][0];
$fileinfo['type'] = lang('type_folder');
//文件大小和文件个数信息
$tmpinfo['contains'] = array('size' => 0, 'contain' => array(0, 0));
foreach ($tnpinfo['hascontain'] as $k => $v) {
if ($v) {
$tmpinfo['contains']['contain'][1] += 1;
$childcontains = self::get_contains_by_fid($infos[$k]['oid'], true);
$tmpinfo['contains']['contain'][0] += $childcontains['contain'][0];
$tmpinfo['contains']['contain'][1] += $childcontains['contain'][1];
$tmpinfo['contains']['size'] += $childcontains['size'];
} else {
$tmpinfo['contains']['contain'][0] += 1;
$tmpinfo['contains']['size'] += $infos[$k]['size'];
}
}
$fileinfo['fsize'] = formatsize($tmpinfo['contains']['size']);
$fileinfo['ffsize'] = lang('property_info_size', array('fsize' => formatsize($tmpinfo['contains']['size']), 'size' => $tmpinfo['contains']['size']));
$fileinfo['contain'] = lang('property_info_contain', array('filenum' => $tmpinfo['contains']['contain'][0], 'foldernum' => $tmpinfo['contains']['contain'][1]));
$fileinfo['img'] = self::get_icosinfo_by_rid($fileinfo['rid']);
}
}1