Ejemplo n.º 1
0
} else {
    $data = array('status' => 'not_found');
    return $data;
}
$urlManager = Driver::getInstance()->getUrlManager();
$currentFolderId = $urlManager->resolveFolderIdFromPath($storage, $path);
/** @var Folder $folder */
$folder = Folder::loadById($currentFolderId);
if (!$folder) {
    $data = array('status' => 'not_found');
    return $data;
}
$securityContext = $storage->getCurrentUserSecurityContext();
$items = array();
$countFolders = $countFiles = 0;
foreach ($folder->getChildren($securityContext) as $item) {
    /** @var File|Folder $item */
    $isFolder = $item instanceof Folder;
    if ($isFolder) {
        $icon = CMobileHelper::mobileDiskGetIconByFilename($item->getName());
        $items[] = array('NAME' => mobileDiskPrepareForJson($item->getName()), 'TABLE_URL' => SITE_DIR . 'mobile/index.php?' . '&mobile_action=' . 'disk_folder_list' . '&path=' . mobileDiskPrepareForJson($path . '/' . $item->getName()) . '&entityId=' . $entityId . '&type=' . $type, 'IMAGE' => CComponentEngine::makePathFromTemplate('/bitrix/components/bitrix/mobile.disk.file.detail/images/folder.png'), 'TABLE_SETTINGS' => array('type' => 'files', 'useTagsInSearch' => 'NO'));
        $countFolders++;
    } else {
        $icon = CMobileHelper::mobileDiskGetIconByFilename($item->getName());
        $items[] = array('ID' => $item->getId(), 'VALUE' => \Bitrix\Disk\Uf\FileUserType::NEW_FILE_PREFIX . $item->getId(), 'NAME' => mobileDiskPrepareForJson($item->getName()), 'URL' => array('URL' => SITE_DIR . "mobile/ajax.php?mobile_action=disk_download_file&action=downloadFile&fileId={$item->getId()}&filename=" . mobileDiskPrepareForJson($item->getName()), 'EXTERNAL' => 'YES'), 'IMAGE' => CComponentEngine::makePathFromTemplate('/bitrix/components/bitrix/mobile.disk.file.detail/images/' . $icon), 'TAGS' => mobileDiskPrepareForJson(\CFile::FormatSize($item->getSize()) . ' ' . $item->getCreateTime()));
        $countFiles++;
    }
}
unset($item);
$data = array("data" => $items, "TABLE_SETTINGS" => array('footer' => mobileDiskPrepareForJson(Loc::getMessage('MD_DISK_TABLE_FOLDERS_FILES', array('#FOLDERS#' => $countFolders, '#FILES#' => $countFiles)))));
return $data;
Ejemplo n.º 2
0
if (empty($_REQUEST['objectId'])) {
    return;
}
/** @var File $file */
$file = File::loadById((int) $_REQUEST['objectId'], array('STORAGE'));
if (!$file) {
    return;
}
$securityContext = $file->getStorage()->getCurrentUserSecurityContext();
if (!$file->canRead($securityContext)) {
    return;
}
if (!empty($_GET['download'])) {
    $fileData = $file->getFile();
    \CFile::viewByUser($fileData, array("force_download" => false, 'attachment_name' => $file->getName()));
}
if (CFile::isImage($file->getName())) {
    $icon = 'img.png';
} else {
    $icons = array('pdf' => 'pdf.png', 'doc' => 'doc.png', 'docx' => 'doc.png', 'ppt' => 'ppt.png', 'pptx' => 'ppt.png', 'rar' => 'rar.png', 'xls' => 'xls.png', 'xlsx' => 'xls.png', 'zip' => 'zip.png');
    $ext = strtolower(getFileExtension($file->getName()));
    $icon = isset($icons[$ext]) ? $icons[$ext] : 'blank.png';
}
$arResult['NAME'] = $file->getName();
$arResult['SIZE'] = $file->getSize();
$arResult['CREATE_TIME'] = $file->getCreateTime();
$arResult['DATE_CREATE'] = $file->getUpdateTime();
$arResult['ICON'] = $this->getPath() . '/images/' . $icon;
$arResult['DESCRIPTION'] = '';
$arResult['URL'] = SITE_DIR . "mobile/disk/{$file->getId()}/download" . '/' . mobileDiskPrepareForJson($file->getName());
$this->IncludeComponentTemplate();