当前位置: 首页>>代码示例>>PHP>>正文


PHP JUDownloadHelper::downloadFile方法代码示例

本文整理汇总了PHP中JUDownloadHelper::downloadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDownloadHelper::downloadFile方法的具体用法?PHP JUDownloadHelper::downloadFile怎么用?PHP JUDownloadHelper::downloadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JUDownloadHelper的用法示例。


在下文中一共展示了JUDownloadHelper::downloadFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createDownloadPackage

	public function createDownloadPackage($type, $itemIdArray, $parentId, $version)
	{
		$app = JFactory::getApplication();
		// If set no_counting_download_time, storeId will be used to check if download file in "no counting download" period
		sort($itemIdArray);
		$storeId = md5($type . serialize($itemIdArray) . $version);

		if ($type == 'document')
		{
			$params = JUDownloadHelper::getParams($parentId);
		}
		else
		{
			$params = JUDownloadHelper::getParams(null, $parentId);
		}

		$noCountingDownloadSecond = (int) $params->get('no_counting_download_time', 300);
		if ($noCountingDownloadSecond > 0)
		{
			$storeIdArray = (array) $app->getUserState('com_judownload.download.storeid');
		}
		else
		{
			$storeIdArray = array();
		}

		$user = JFactory::getUser();

		$downloadZippedFileMode      = $params->get('download_zipped_file_mode', 'temp');
		$downloadOneFileNoZippedMode = $params->get('download_one_file_no_zipped_mode', 'temp');

		// Min download speed.
		$minDownloadSpeed = (int) $params->get('min_download_speed', 10);
		$minDownloadSpeed = $minDownloadSpeed > 0 ? $minDownloadSpeed : 10;
		$minDownloadSpeed = $minDownloadSpeed * 1024; //KBps

		// Min live time of download package.
		$adjustFileLiveTime = (int) $params->get('adjust_file_live_time', 60);
		$adjustFileLiveTime = $adjustFileLiveTime >= 0 ? $adjustFileLiveTime : 60;

		// Time download package created.
		$createdTimeDate  = JFactory::getDate()->toSql();
		$createdTimeStamp = strtotime($createdTimeDate);

		// Trigger JU Download after download
		$dispatcher = JDispatcher::getInstance();
		JPluginHelper::importPlugin('judownload');

		// Physical file path to download, to be used in temp folder mode
		$downloadFilePath = '';

		// True if file is zipped by zip class
		$zipFile = false;

		// Get comment for zip package.
		$zipCommentConfig = $params->get('zip_comment', '');

		// Zip comment parsed from $zipCommentConfig case by case
		$zipComment = '';

		if ($type == 'document')
		{
			// Get category id.
			$categoryId      = $parentId;
			$documentIdArray = $itemIdArray;
			// Download multi documents in the same cat
			if (count($documentIdArray) > 1)
			{
				// In this case : user downloading category.
				// Sort array document id.
				sort($documentIdArray);

				// Create zip package.
				$zip     = new Zip();
				$zipFile = true;

				// Parse zip comment
				$zipComment = $this->parseCommentTxt($zipCommentConfig, $categoryId);

				// File id array in all download documents to reference in tmp file table
				$fileIdArrayInTmpZip = array();
				foreach ($documentIdArray AS $documentId)
				{
					$documentObject = JUDownloadHelper::getDocumentById($documentId);
					$documentTitle  = $this->filterFileFolderName($documentObject->title);
					$documentTitle  = trim($documentTitle);
					$fileObjectList = $this->getAllFilesOfDocument($documentId);
					// If document has file, add document title as a folder contains files
					if (count($fileObjectList))
					{
						$zip->addDirectory($documentTitle);
					}

					// File id array in document to log document.download
					$fileIdArray  = array();
					$documentSize = 0;
					foreach ($fileObjectList AS $fileObject)
					{
						$physicalFilePath = $this->getPhysicalFilePath($fileObject->id);

//.........这里部分代码省略.........
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:101,代码来源:download.php

示例2: downloadFile

 public function downloadFile()
 {
     JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $fileId = $app->input->get('fileId', 0);
     $db = JFactory::getDbo();
     $query = 'SELECT `doc_id`, `file_name`, `rename` FROM #__judownload_files WHERE id = ' . $fileId;
     $db->setQuery($query);
     $file = $db->loadObject();
     if ($file) {
         $documentObject = JUDownloadHelper::getDocumentById($file->doc_id);
         $fileDirectory = JUDownloadFrontHelper::getDirectory('file_directory', 'media/com_judownload/files/');
         $version = $app->input->get('version', '');
         if (!$version || $version === $documentObject->version) {
             $filePath = JPATH_SITE . '/' . $fileDirectory . $file->doc_id . '/' . $file->file_name;
         } else {
             $query = "SELECT file_path FROM #__judownload_versions WHERE file_id = " . $fileId . " AND version = " . $db->quote($version);
             $db->setQuery($query);
             $versionFilePath = $db->loadResult();
             if (!$versionFilePath) {
                 return false;
             }
             $filePath = JPATH_SITE . '/' . $fileDirectory . $file->doc_id . '/' . $versionFilePath;
         }
         $filePath = JPath::clean($filePath);
         $downloadResult = JUDownloadHelper::downloadFile($filePath, $file->rename, 'php', '2048', true, true);
         if ($downloadResult !== true) {
             $this->setError($downloadResult);
             return false;
         }
     }
     return true;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:33,代码来源:document.php


注:本文中的JUDownloadHelper::downloadFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。