本文整理汇总了PHP中FileManager::readFile方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::readFile方法的具体用法?PHP FileManager::readFile怎么用?PHP FileManager::readFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::readFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readFile
/**
* Read a file's contents.
* @param $fileId integer
* @param $revision integer
* @param $output boolean output the file's contents instead of returning a string
* @return boolean
*/
function readFile($fileId, $revision = null, $output = false)
{
$monographFile =& MonographFileManager::_getFile($fileId, $revision);
if (isset($monographFile)) {
return parent::readFile($monographFile->getFilePath(), $output);
} else {
return false;
}
}
示例2: readFile
/**
* Read a file's contents.
* @param $output boolean output the file's contents instead of returning a string
* @return boolean
*/
function readFile($fileId, $userId, $output = false)
{
$temporaryFile =& $this->getFile($fileId, $userId);
if (isset($temporaryFile)) {
$filePath = $this->filesDir . $temporaryFile->getFileName();
return parent::readFile($filePath, $output);
} else {
return false;
}
}
示例3: readFile
/**
* Read a file's contents.
* @param $output boolean output the file's contents instead of returning a string
* @return boolean
*/
function readFile($fileId, $output = false)
{
$minutesFile =& $this->getFile($fileId);
if (isset($minutesFile)) {
$filePath = $this->filesDir . $minutesFile->getType() . '/' . $minutesFile->getFileName();
return parent::readFile($filePath, $output);
} else {
return false;
}
}
示例4:
function &createChildFromFile(&$doc, &$node, $name, $filename)
{
$contents =& FileManager::readFile($filename);
if ($contents === false) {
return null;
}
}
示例5: downloadFile
/**
* Download a file.
* Outputs HTTP headers and file content for download
* @param $filePath string the location of the file to be sent
* @param $mediaType string the MIME type of the file, optional
* @param $inline print file as inline instead of attachment, optional
* @return boolean
*/
function downloadFile($filePath, $mediaType = null, $inline = false, $fileName = null)
{
$result = null;
if (HookRegistry::call('FileManager::downloadFile', array(&$filePath, &$mediaType, &$inline, &$result, &$fileName))) {
return $result;
}
if (is_readable($filePath)) {
if ($mediaType === null) {
// If the media type wasn't specified, try to detect.
$mediaType = String::mime_content_type($filePath);
if (empty($mediaType)) {
$mediaType = 'application/octet-stream';
}
}
if ($fileName === null) {
// If the filename wasn't specified, use the server-side.
$fileName = basename($filePath);
}
Registry::clear();
// Free some memory
header("Content-Type: {$mediaType}");
header('Content-Length: ' . filesize($filePath));
header('Content-Disposition: ' . ($inline ? 'inline' : 'attachment') . "; filename=\"{$fileName}\"");
header('Cache-Control: private');
// Workarounds for IE weirdness
header('Pragma: public');
// Beware of converting to instance call
// https://github.com/pkp/pkp-lib/commit/82f4a36db406ecac3eb88875541a74123e455713#commitcomment-1459396
FileManager::readFile($filePath, true);
return true;
} else {
return false;
}
}
示例6: generateArticleSuppFileDom
/**
* Creates a METS:file for the Supplementary File
* checks if METS:FContent or METS:FLocat should be used
*/
function generateArticleSuppFileDom(&$doc, &$root, &$article, &$suppFile, &$journal)
{
import('classes.file.PublicFileManager');
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
$contentWrapper = Request::getUserVar('contentWrapper');
$mfile =& XMLCustomWriter::createElement($doc, 'METS:file');
$filePath = MetsExportDom::getPublicFilePath($suppFile, '/supp/', $journal);
$chkmd5return = md5_file($filePath);
XMLCustomWriter::setAttribute($mfile, 'ID', 'SF' . $suppFile->getFileId() . '-A' . $suppFile->getArticleId());
XMLCustomWriter::setAttribute($mfile, 'SIZE', $suppFile->getFileSize());
XMLCustomWriter::setAttribute($mfile, 'MIMETYPE', $suppFile->getFileType());
XMLCustomWriter::setAttribute($mfile, 'OWNERID', $suppFile->getFileName());
XMLCustomWriter::setAttribute($mfile, 'CHECKSUM', $chkmd5return);
XMLCustomWriter::setAttribute($mfile, 'CHECKSUMTYPE', 'MD5');
if ($contentWrapper == 'FContent') {
$fileContent =& $fileManager->readFile($filePath);
$fContent =& XMLCustomWriter::createElement($doc, 'METS:FContent');
$fNameNode =& XMLCustomWriter::createChildWithText($doc, $fContent, 'METS:binData', base64_encode($fileContent));
XMLCustomWriter::appendChild($mfile, $fContent);
} else {
$fLocat =& XMLCustomWriter::createElement($doc, 'METS:FLocat');
XMLCustomWriter::setAttribute($fLocat, 'xlink:href', Request::url($journal->getPath(), 'article', 'downloadSuppFile', array($suppFile->getArticleId(), $suppFile->getId())));
XMLCustomWriter::setAttribute($fLocat, 'LOCTYPE', 'URL');
XMLCustomWriter::appendChild($mfile, $fLocat);
}
XMLCustomWriter::appendChild($root, $mfile);
}
示例7: generateArticleSuppFileDom
/**
* Creates a METS:file for the Supplementary File
* checks if METS:FContent or METS:FLocat should be used
*/
function generateArticleSuppFileDom(&$doc, &$root, $article, &$suppFile)
{
import('classes.file.PublicFileManager');
import('classes.file.FileManager');
$contentWrapper = $this->getSetting($this->journalId, 'contentWrapper');
$mfile =& XMLCustomWriter::createElement($doc, 'METS:file');
$filePath = MetsExportDom::getPublicFilePath($suppFile, '/supp/');
$chkmd5return = md5_file($filePath);
XMLCustomWriter::setAttribute($mfile, 'ID', 'SF' . $suppFile->getFileId() . '-A' . $suppFile->getArticleId());
XMLCustomWriter::setAttribute($mfile, 'SIZE', $suppFile->getFileSize());
XMLCustomWriter::setAttribute($mfile, 'MIMETYPE', $suppFile->getFileType());
XMLCustomWriter::setAttribute($mfile, 'OWNERID', $suppFile->getFileName());
XMLCustomWriter::setAttribute($mfile, 'CHECKSUM', $chkmd5return);
XMLCustomWriter::setAttribute($mfile, 'CHECKSUMTYPE', 'MD5');
if ($contentWrapper == 'FContent') {
$fileContent =& FileManager::readFile($filePath);
$fContent =& XMLCustomWriter::createElement($doc, 'METS:FContent');
$fNameNode =& XMLCustomWriter::createChildWithText($doc, $fContent, 'METS:binData', base64_encode($fileContent));
XMLCustomWriter::appendChild($mfile, $fContent);
} else {
$fLocat =& XMLCustomWriter::createElement($doc, 'METS:FLocat');
$fileUrl = MetsExportDom::getPublicSuppFileUrl($suppFile);
XMLCustomWriter::setAttribute($fLocat, 'xlink:href', $fileUrl);
XMLCustomWriter::setAttribute($fLocat, 'LOCTYPE', 'URL');
XMLCustomWriter::appendChild($mfile, $fLocat);
}
XMLCustomWriter::appendChild($root, $mfile);
}
示例8: FileManager
function &createChildFromFile(&$doc, &$node, $name, $filename)
{
$fileManager = new FileManager();
$contents =& $fileManager->readFile($filename);
if ($contents === false) {
$nullVar = null;
return $nullVar;
}
}
示例9: downloadFile
/**
* Download a file.
* Outputs HTTP headers and file content for download
* @param $filePath string the location of the file to be sent
* @param $mediaType string the MIME type of the file, optional
* @param $inline print file as inline instead of attachment, optional
* @return boolean
*/
function downloadFile($filePath, $mediaType = null, $inline = false, $fileName = null)
{
$result = null;
if (HookRegistry::call('FileManager::downloadFile', array(&$filePath, &$mediaType, &$inline, &$result, &$fileName))) {
return $result;
}
$postDownloadHookList = array('FileManager::downloadFileFinished', 'UsageEventPlugin::getUsageEvent');
if (is_readable($filePath)) {
if ($mediaType === null) {
// If the media type wasn't specified, try to detect.
$mediaType = String::mime_content_type($filePath);
if (empty($mediaType)) {
$mediaType = 'application/octet-stream';
}
}
if ($fileName === null) {
// If the filename wasn't specified, use the server-side.
$fileName = basename($filePath);
}
$postDownloadHooks = null;
$hooks = HookRegistry::getHooks();
foreach ($postDownloadHookList as $hookName) {
if (isset($hooks[$hookName])) {
$postDownloadHooks[$hookName] = $hooks[$hookName];
}
}
unset($hooks);
Registry::clear();
// Stream the file to the end user.
header("Content-Type: {$mediaType}");
header('Content-Length: ' . filesize($filePath));
header('Content-Disposition: ' . ($inline ? 'inline' : 'attachment') . "; filename=\"{$fileName}\"");
header('Cache-Control: private');
// Workarounds for IE weirdness
header('Pragma: public');
// Beware of converting to instance call
// https://github.com/pkp/pkp-lib/commit/82f4a36db406ecac3eb88875541a74123e455713#commitcomment-1459396
FileManager::readFile($filePath, true);
if ($postDownloadHooks) {
foreach ($postDownloadHooks as $hookName => $hooks) {
HookRegistry::setHooks($hookName, $hooks);
}
}
$returner = true;
} else {
$returner = false;
}
HookRegistry::call('FileManager::downloadFileFinished', array(&$returner));
return $returner;
}
示例10: readFile
/**
* Read a file's contents.
* @param $output boolean output the file's contents instead of returning a string
* @return boolean
*/
function readFile($fileId, $revision = null, $output = false)
{
$paperFile =& $this->getFile($fileId, $revision);
if (isset($paperFile)) {
$fileType = $paperFile->getFileType();
$filePath = $this->filesDir . $paperFile->getType() . '/' . $paperFile->getFileName();
return parent::readFile($filePath, $output);
} else {
return false;
}
}
示例11: downloadFile
/**
* Download a file.
* Outputs HTTP headers and file content for download
* @param $filePath string the location of the file to be sent
* @param $mediaType string the MIME type of the file, optional
* @param $inline print file as inline instead of attachment, optional
* @return boolean
*/
function downloadFile($filePath, $mediaType = null, $inline = false)
{
$result = null;
if (HookRegistry::call('FileManager::downloadFile', array(&$filePath, &$mediaType, &$inline, &$result))) {
return $result;
}
if (is_readable($filePath)) {
if ($mediaType == null) {
$mediaType = String::mime_content_type($filePath);
if (empty($mediaType)) {
$mediaType = 'application/octet-stream';
}
}
Registry::clear();
// Free some memory
header("Content-Type: {$mediaType}");
header("Content-Length: " . filesize($filePath));
header("Content-Disposition: " . ($inline ? 'inline' : 'attachment') . "; filename=\"" . basename($filePath) . "\"");
header("Cache-Control: private");
// Workarounds for IE weirdness
header("Pragma: public");
import('lib.pkp.classes.file.FileManager');
FileManager::readFile($filePath, true);
return true;
} else {
return false;
}
}
示例12: readFile
/**
* Read a file's contents.
* @param $output boolean output the file's contents instead of returning a string
* @return boolean
*/
function readFile($fileId, $revision = null, $output = false)
{
$articleFile =& $this->getFile($fileId, $revision);
if (isset($articleFile)) {
$filePath = $this->filesDir . $this->fileStageToPath($articleFile->getFileStage()) . '/' . $articleFile->getFileName();
return parent::readFile($filePath, $output);
} else {
return false;
}
}
示例13: downloadFile
/**
* Download a file.
* Outputs HTTP headers and file content for download
* @param $filePath string the location of the file to be sent
* @param $type string the MIME type of the file, optional
* @param $inline print file as inline instead of attachment, optional
* @return boolean
*/
function downloadFile($filePath, $type = null, $inline = false)
{
if (is_readable($filePath)) {
if ($type == null) {
$type = String::mime_content_type($filePath);
if (empty($type)) {
$type = 'application/octet-stream';
}
}
header("Content-Type: {$type}");
header("Content-Length: " . filesize($filePath));
header("Content-Disposition: " . ($inline ? 'inline' : 'attachment') . "; filename=\"" . basename($filePath) . "\"");
header("Cache-Control: private");
// Workarounds for IE weirdness
header("Pragma: public");
import('file.FileManager');
FileManager::readFile($filePath, true);
return true;
} else {
return false;
}
}
示例14: downloadFile
/**
* Download a file.
* Outputs HTTP headers and file content for download
* @param $filePath string the location of the file to be sent
* @param $type string the MIME type of the file, optional
* @param $inline print file as inline instead of attachment, optional
* @return boolean
*/
function downloadFile($filePath, $type = null, $inline = false, $filename = null)
{
if (is_null($filename)) {
$filename = basename($filePath);
}
$u_agent = $_SERVER['HTTP_USER_AGENT'];
if (preg_match('/MSIE/i', $u_agent) && !preg_match('/Opera/i', $u_agent) || strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false) {
$filename = iconv('utf8', 'big5', $filename);
}
//$filename = basename($filePath);
$result = null;
if (HookRegistry::call('FileManager::downloadFile', array(&$filePath, &$type, &$inline, &$result))) {
return $result;
}
if (is_readable($filePath)) {
if ($type == null) {
$type = String::mime_content_type($filePath);
if (empty($type)) {
$type = 'application/octet-stream';
}
}
Registry::clear();
// Free some memory
header("Content-Type: {$type}");
header("Content-Length: " . filesize($filePath));
header("Content-Disposition: " . ($inline ? 'inline' : 'attachment') . "; filename=\"" . $filename . "\"");
header("Cache-Control: private");
// Workarounds for IE weirdness
header("Pragma: public");
import('file.FileManager');
FileManager::readFile($filePath, true);
return true;
} else {
return false;
}
}
示例15: save
function save()
{
global $settings, $rules;
$hasLeaguePref = mysql_fetch_object(mysql_query("SELECT f_lid from league_prefs where f_lid={$this->lid}"));
if ($hasLeaguePref) {
$query = "UPDATE league_prefs SET prime_tid={$this->p_tour}, league_name='" . mysql_real_escape_string($this->league_name) . "', forum_url='" . mysql_real_escape_string($this->forum_url) . "' , welcome='" . mysql_real_escape_string($this->welcome) . "' , rules='" . mysql_real_escape_string($this->rules) . "' WHERE f_lid={$this->lid}";
} else {
$query = "INSERT INTO league_prefs (f_lid, prime_tid, second_tid, league_name, forum_url, welcome, rules) VALUE ({$this->lid}, {$this->p_tour}, {$this->s_tour}, '" . mysql_real_escape_string($this->league_name) . "', '" . mysql_real_escape_string($this->forum_url) . "', '" . mysql_real_escape_string($this->welcome) . "', '" . mysql_real_escape_string($this->rules) . "')";
}
FileManager::writeFile(FileManager::getCssDirectoryName() . "/league_override_{$this->lid}.css", $this->theme_css);
$settingsFileContents = FileManager::readFile(FileManager::getSettingsDirectoryName() . "/settings_{$this->lid}.php");
$settingsFileContents = preg_replace("/settings\\['stylesheet'\\]\\s*=\\s['A-Za-z0-9_]+/", "settings['stylesheet'] = {$this->core_theme_id}", $settingsFileContents);
$settingsFileContents = preg_replace("/settings\\['lang'\\]\\s*=\\s['A-Za-z0-9_\\-]+/", "settings['lang'] = '{$this->language}'", $settingsFileContents);
$settingsFileContents = preg_replace("/rules\\['initial_treasury'\\]\\s*=\\s['A-Za-z0-9_]+/", "rules['initial_treasury'] = {$this->tv}", $settingsFileContents);
$settingsFileContents = preg_replace("/settings\\['core_rules_file'\\]\\s*=\\s[\\.\\/'A-Za-z0-9_]+/", "settings['core_rules_file'] = '{$this->core_rules_file}'", $settingsFileContents);
FileManager::writeFile(FileManager::getSettingsDirectoryName() . "/settings_{$this->lid}.php", $settingsFileContents);
$settings['stylesheet'] = $this->core_theme_id;
$settings['lang'] = $this->language;
$rules['initial_treasury'] = $this->tv;
$settings['core_rules_file'] = $this->core_rules_file;
return mysql_query($query);
}