/** * Display the files associated with a journal. * @param $args array * @param $request PKPRequest */ function files($args, $request) { $this->validate(); $this->setupTemplate($request, true); import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $templateMgr = TemplateManager::getManager($request); $this->_parseDirArg($args, $currentDir, $parentDir); $currentPath = $this->_getRealFilesDir($request, $currentDir); if (@is_file($currentPath)) { if ($request->getUserVar('download')) { $fileManager->downloadFile($currentPath); } else { $fileManager->downloadFile($currentPath, $this->_fileMimeType($currentPath), true); } } else { $files = array(); if ($dh = @opendir($currentPath)) { while (($file = readdir($dh)) !== false) { if ($file != '.' && $file != '..') { $filePath = $currentPath . '/' . $file; $isDir = is_dir($filePath); $info = array('name' => $file, 'isDir' => $isDir, 'mimetype' => $isDir ? '' : $this->_fileMimeType($filePath), 'mtime' => filemtime($filePath), 'size' => $isDir ? '' : $fileManager->getNiceFileSize(filesize($filePath))); $files[$file] = $info; } } closedir($dh); } ksort($files); $templateMgr->assign('files', $files); $templateMgr->assign('currentDir', $currentDir); $templateMgr->assign('parentDir', $parentDir); $templateMgr->display('manager/files/index.tpl'); } }
/** * Display the files associated with a journal. */ function files($args) { $this->validate(); $this->setupTemplate(true); import('lib.pkp.classes.file.FileManager'); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('pageHierarchy', array(array(Request::url(null, 'manager'), 'manager.journalManagement'))); FilesHandler::parseDirArg($args, $currentDir, $parentDir); $currentPath = FilesHandler::getRealFilesDir($currentDir); if (@is_file($currentPath)) { $fileMgr = new FileManager(); if (Request::getUserVar('download')) { $fileMgr->downloadFile($currentPath); } else { $fileMgr->viewFile($currentPath, FilesHandler::fileMimeType($currentPath)); } } else { $files = array(); if ($dh = @opendir($currentPath)) { while (($file = readdir($dh)) !== false) { if ($file != '.' && $file != '..') { $filePath = $currentPath . '/' . $file; $isDir = is_dir($filePath); $info = array('name' => $file, 'isDir' => $isDir, 'mimetype' => $isDir ? '' : FilesHandler::fileMimeType($filePath), 'mtime' => filemtime($filePath), 'size' => $isDir ? '' : FileManager::getNiceFileSize(filesize($filePath))); $files[$file] = $info; } } closedir($dh); } ksort($files); $templateMgr->assign_by_ref('files', $files); $templateMgr->assign('currentDir', $currentDir); $templateMgr->assign('parentDir', $parentDir); $templateMgr->assign('helpTopicId', 'journal.managementPages.fileBrowser'); $templateMgr->display('manager/files/index.tpl'); } }
/** * Get nice file size of file. * @return string */ function getNiceFileSize() { return FileManager::getNiceFileSize($this->getData('fileSize')); }
/** * Get nice file size of file. * @return string */ function getNiceFileSize() { $fileManager = new FileManager(); return $fileManager->getNiceFileSize($this->getData('fileSize')); }