本文整理汇总了PHP中TemporaryFileManager::downloadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP TemporaryFileManager::downloadFile方法的具体用法?PHP TemporaryFileManager::downloadFile怎么用?PHP TemporaryFileManager::downloadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemporaryFileManager
的用法示例。
在下文中一共展示了TemporaryFileManager::downloadFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Display the plugin.
* @param $args array
* @param $request PKPRequest
*/
function display($args, $request)
{
$templateMgr = TemplateManager::getManager($request);
$context = $request->getContext();
parent::display($args, $request);
$templateMgr->assign('plugin', $this);
switch (array_shift($args)) {
case 'index':
case '':
$templateMgr->display($this->getTemplatePath() . 'index.tpl');
break;
case 'uploadImportXML':
$user = $request->getUser();
import('lib.pkp.classes.file.TemporaryFileManager');
$temporaryFileManager = new TemporaryFileManager();
$temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
if ($temporaryFile) {
$json = new JSONMessage(true);
$json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFile->getId()));
} else {
$json = new JSONMessage(false, __('common.uploadFailed'));
}
return $json->getString();
case 'importBounce':
$json = new JSONMessage(true);
$json->setEvent('addTab', array('title' => __('plugins.importexport.users.results'), 'url' => $request->url(null, null, null, array('plugin', $this->getName(), 'import'), array('temporaryFileId' => $request->getUserVar('temporaryFileId')))));
return $json->getString();
case 'import':
$temporaryFileId = $request->getUserVar('temporaryFileId');
$temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
$user = $request->getUser();
$temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
if (!$temporaryFile) {
$json = new JSONMessage(true, __('plugins.importexport.users.uploadFile'));
return $json->getString();
}
$temporaryFilePath = $temporaryFile->getFilePath();
libxml_use_internal_errors(true);
$users = $this->importUsers(file_get_contents($temporaryFilePath), $context, $user);
$validationErrors = array_filter(libxml_get_errors(), create_function('$a', 'return $a->level == LIBXML_ERR_ERROR || $a->level == LIBXML_ERR_FATAL;'));
$templateMgr->assign('validationErrors', $validationErrors);
libxml_clear_errors();
$templateMgr->assign('users', $users);
$json = new JSONMessage(true, $templateMgr->fetch($this->getTemplatePath() . 'results.tpl'));
return $json->getString();
case 'export':
$exportXml = $this->exportUsers((array) $request->getUserVar('selectedUsers'), $request->getContext(), $request->getUser());
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
$exportFileName = $this->getExportFileName($this->getExportPath(), 'users', $context, '.xml');
$fileManager->writeFile($exportFileName, $exportXml);
$fileManager->downloadFile($exportFileName);
$fileManager->deleteFile($exportFileName);
break;
case 'exportAllUsers':
$exportXml = $this->exportAllUsers($request->getContext(), $request->getUser());
import('lib.pkp.classes.file.TemporaryFileManager');
$fileManager = new TemporaryFileManager();
$exportFileName = $this->getExportFileName($this->getExportPath(), 'users', $context, '.xml');
$fileManager->writeFile($exportFileName, $exportXml);
$fileManager->downloadFile($exportFileName);
$fileManager->deleteFile($exportFileName);
break;
default:
$dispatcher = $request->getDispatcher();
$dispatcher->handle404();
}
}