本文整理汇总了PHP中ilUtil::deliverFile方法的典型用法代码示例。如果您正苦于以下问题:PHP ilUtil::deliverFile方法的具体用法?PHP ilUtil::deliverFile怎么用?PHP ilUtil::deliverFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilUtil
的用法示例。
在下文中一共展示了ilUtil::deliverFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deliver
public function deliver()
{
$file = $this->object->getFilePath();
if ($file) {
ilUtil::deliverFile($file, $this->object->getTitle() . ".pdf");
}
}
示例2: ilSCORMOfflineMode
$lng->loadLanguageModule("sop");
$this->lng =& $lng;
$this->ctrl =& $ilCtrl;
$this->ctrl->saveParameter($this, "ref_id");
$this->offlineMode = new ilSCORMOfflineMode();
$this->online_icon = 'icon_slm_b.png';
$this->offline_icon = 'icon_slm_b_offline.png';
$this->icon = $this->online_icon;
}
function executeCommand()
{
global $tpl, $ilCtrl;
$this->lmId = ilObject::_lookupObjectId($_GET["ref_id"]);
$this->clientIdSop = $this->offlineMode->getClientIdSop();
$cmd = $ilCtrl->getCmd();
$this->setOfflineModeTabs($cmd);
switch ($cmd) {
case 'offlineMode_il2sopContent':
ilUtil::deliverFile(ilUtil::getDataDir() . "/lm_data/lm_" . $this->lmId . ".zip", "lm_" . $this->lmId . ".zip");
break;
case 'offlineMode_il2sop':
$this->offlineMode->il2sop();
break;
case 'offlineMode_il2sopStop':
$this->offlineMode->setOfflineMode("online");
$this->view($this->offlineMode->getOfflineMode(), "msg_export_failure");
break;
case 'offlineMode_il2sopOk':
$this->offlineMode->setOfflineMode("offline");
$this->view($this->offlineMode->getOfflineMode(), "msg_export_ok");
break;
case 'offlineMode_sop2il':
$this->offlineMode->sop2il();
break;
case 'offlineMode_sop2ilStop':
$this->offlineMode->setOfflineMode("offline");
$this->view($this->offlineMode->getOfflineMode(), "msg_push_tracking_failure");
break;
case 'offlineMode_sop2ilOk':
$this->offlineMode->setOfflineMode("online");
$this->view($this->offlineMode->getOfflineMode(), "msg_push_tracking_ok");
示例3: downloadFileObject
/**
* Download assignment file
*/
function downloadFileObject()
{
global $rbacsystem;
$file = $_POST["file"] ? $_POST["file"] : $_GET["file"];
// check read permission
$this->checkPermission("read");
if (!isset($file)) {
ilUtil::sendFailure($this->lng->txt("exc_select_one_file"), true);
$this->ctrl->redirect($this, "view");
}
// check, whether file belongs to assignment
include_once "./Modules/Exercise/classes/class.ilExAssignment.php";
$files = ilExAssignment::getFiles($this->object->getId(), (int) $_GET["ass_id"]);
$file_exist = false;
foreach ($files as $lfile) {
if ($lfile["name"] == urldecode($file)) {
$file_exist = true;
break;
}
}
if (!$file_exist) {
echo "FILE DOES NOT EXIST";
exit;
}
// check whether assignment as already started
$ass = new ilExAssignment((int) $_GET["ass_id"]);
$not_started_yet = false;
if ($ass->getStartTime() > 0 && time() - $ass->getStartTime() <= 0) {
$not_started_yet = true;
}
// deliver file
if (!$not_started_yet) {
include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php";
$storage = new ilFSStorageExercise($this->object->getId(), (int) $_GET["ass_id"]);
$p = $storage->getAssignmentFilePath(urldecode($file));
ilUtil::deliverFile($p, urldecode($file));
}
return true;
}
示例4: downloadTemplate
/**
* Download template file
*/
public function downloadTemplate()
{
if (is_file($this->type->getCertificateTemplatesPath(true))) {
$filename = srCertificateTemplateTypeFactory::getById($this->type->getTemplateTypeId())->getTemplateFilename();
ilUtil::deliverFile($this->type->getCertificateTemplatesPath(true), $filename);
}
$this->editTemplate();
}
示例5: exportToExcel
//.........这里部分代码省略.........
if (strcmp($fieldname, "matriculation") == 0) {
$resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('matriculation')), $format_title);
}
}
}
$resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('test')), $format_title);
foreach ($titles as $title) {
$resultsheet->write($row, $col++, ilExcelUtils::_convert_text($title), $format_title);
}
$row++;
foreach ($data->getParticipants() as $active_id => $userdata) {
$username = !is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName()) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID {$active_id}";
if (array_key_exists($username, $usernames)) {
$usernames[$username]++;
$username .= " ({$i})";
} else {
$usernames[$username] = 1;
}
$col = 0;
$resultsheet->write($row, $col++, $username);
$resultsheet->write($row, $col++, $userdata->getLogin());
if (count($additionalFields)) {
$userfields = ilObjUser::_lookupFields($userdata->getUserID());
foreach ($additionalFields as $fieldname) {
if (strcmp($fieldname, "matriculation") == 0) {
if (strlen($userfields[$fieldname])) {
$resultsheet->write($row, $col++, ilExcelUtils::_convert_text($userfields[$fieldname]));
} else {
$col++;
}
}
}
}
$resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->test_obj->getTitle()));
$pass = $userdata->getScoredPass();
if (is_object($userdata) && is_array($userdata->getQuestions($pass))) {
foreach ($userdata->getQuestions($pass) as $question) {
$objQuestion =& $this->test_obj->_instanciateQuestion($question["aid"]);
if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(), 'assSingleChoice') == 0) {
$solution = $objQuestion->getSolutionValues($active_id, $pass);
$pos = $positions[$question["aid"]];
$selectedanswer = chr(65 + $solution[0]["value1"]);
$resultsheet->write($row, $col + $pos, ilExcelUtils::_convert_text($selectedanswer));
}
}
}
$row++;
}
}
} else {
// test participant result export
$usernames = array();
$participantcount = count($data->getParticipants());
$allusersheet = false;
$pages = 0;
$i = 0;
foreach ($data->getParticipants() as $active_id => $userdata) {
$i++;
$username = !is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName()) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID {$active_id}";
if (array_key_exists($username, $usernames)) {
$usernames[$username]++;
$username .= " ({$i})";
} else {
$usernames[$username] = 1;
}
if ($participantcount > 250) {
if (!$allusersheet || $pages - 1 < floor($row / 64000)) {
$resultsheet =& $workbook->addWorksheet($this->lng->txt("eval_all_users") . ($pages > 0 ? " (" . ($pages + 1) . ")" : ""));
$allusersheet = true;
$row = 0;
$pages++;
}
} else {
$resultsheet =& $workbook->addWorksheet($username);
}
if (method_exists($resultsheet, "writeString")) {
$pass = $userdata->getScoredPass();
$row = $allusersheet ? $row : 0;
$resultsheet->writeString($row, 0, ilExcelUtils::_convert_text(sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $userdata->getName())), $format_bold);
$row += 2;
if (is_object($userdata) && is_array($userdata->getQuestions($pass))) {
foreach ($userdata->getQuestions($pass) as $question) {
require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$question = assQuestion::_instanciateQuestion($question["id"]);
if (is_object($question)) {
$row = $question->setExportDetailsXLS($resultsheet, $row, $active_id, $pass, $format_title, $format_bold);
}
}
}
}
}
}
$workbook->close();
if ($deliver) {
ilUtil::deliverFile($excelfile, $testname, "application/vnd.ms-excel", false, true);
exit;
} else {
return $excelfile;
}
}
示例6: export
/**
* Build and deliver export file
*/
function export()
{
$zip = $this->buildExportFile();
ilUtil::deliverFile($zip, $this->object->getTitle() . ".zip", '', false, true);
}
示例7: downloadFolder
public function downloadFolder()
{
global $lng, $rbacsystem, $ilAccess;
include_once "./Services/Utilities/classes/class.ilUtil.php";
include_once 'Modules/File/classes/class.ilObjFile.php';
include_once 'Modules/File/classes/class.ilFileException.php';
if (!$ilAccess->checkAccess("read", "", $this->getRefId())) {
$this->ilErr->raiseError(get_class($this) . "::downloadFolder(): missing read permission!", $this->ilErr->WARNING);
}
if (ilObject::_isInTrash($this->getRefId())) {
$this->ilErr->raiseError(get_class($this) . "::downloadFolder(): object is trashed!", $this->ilErr->WARNING);
}
$zip = PATH_TO_ZIP;
$tmpdir = ilUtil::ilTempnam();
ilUtil::makeDir($tmpdir);
$basename = ilUtil::getAsciiFilename($this->getTitle());
$deliverFilename = $basename . ".zip";
$zipbasedir = $tmpdir . DIRECTORY_SEPARATOR . $basename;
$tmpzipfile = $tmpdir . DIRECTORY_SEPARATOR . $deliverFilename;
try {
ilObjFolder::recurseFolder($this->getRefId(), $this->getTitle(), $tmpdir);
ilUtil::zip($zipbasedir, $tmpzipfile);
rename($tmpzipfile, $zipfile = ilUtil::ilTempnam());
ilUtil::delDir($tmpdir);
ilUtil::deliverFile($zipfile, $deliverFilename, '', false, true);
} catch (ilFileException $e) {
ilUtil::sendInfo($e->getMessage(), true);
}
}
示例8: exportUserSpecificResults
//.........这里部分代码省略.........
array_push($csvfile, $csvrow);
}
// #11179
$surveyname = $this->object->getTitle() . " " . $this->lng->txt("svy_eval_user") . " " . date("Y-m-d");
$surveyname = preg_replace("/\\s/", "_", trim($surveyname));
$surveyname = ilUtil::getASCIIFilename($surveyname);
switch ($export_format) {
case self::TYPE_XLS:
include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
$excelfile = ilUtil::ilTempnam();
$adapter = new ilExcelWriterAdapter($excelfile, FALSE);
$workbook = $adapter->getWorkbook();
$workbook->setVersion(8);
// Use Excel97/2000 Format
// Creating a worksheet
$format_bold =& $workbook->addFormat();
$format_bold->setBold();
$format_percent =& $workbook->addFormat();
$format_percent->setNumFormat("0.00%");
$format_datetime =& $workbook->addFormat();
$format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
$format_title =& $workbook->addFormat();
$format_title->setBold();
$format_title->setColor('black');
$format_title->setPattern(1);
$format_title->setFgColor('silver');
$format_title_plain =& $workbook->addFormat();
$format_title_plain->setColor('black');
$format_title_plain->setPattern(1);
$format_title_plain->setFgColor('silver');
// Creating a worksheet
$pages = floor(count($csvfile[0]) / 250) + 1;
$worksheets = array();
for ($i = 0; $i < $pages; $i++) {
$worksheets[$i] =& $workbook->addWorksheet();
}
$row = 0;
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
$contentstartrow = 0;
foreach ($csvfile as $csvrow) {
$col = 0;
if ($row == 0) {
$worksheet = 0;
$mainworksheet =& $worksheets[$worksheet];
foreach ($csvrow as $text) {
if (is_array($text)) {
$textcount = 0;
foreach ($text as $string) {
$mainworksheet->writeString($row + $textcount, $col, ilExcelUtils::_convert_text($string, $_POST["export_format"]), $format_title);
$textcount++;
$contentstartrow = max($contentstartrow, $textcount);
}
$col++;
} else {
$mainworksheet->writeString($row, $col++, ilExcelUtils::_convert_text($text, $_POST["export_format"]), $format_title);
}
if ($col % 251 == 0) {
$worksheet++;
$col = 1;
$mainworksheet =& $worksheets[$worksheet];
$mainworksheet->writeString($row, 0, ilExcelUtils::_convert_text($csvrow[0], $_POST["export_format"]), $format_title);
}
}
$row = $contentstartrow;
} else {
$worksheet = 0;
$mainworksheet =& $worksheets[$worksheet];
foreach ($csvrow as $text) {
if (is_numeric($text)) {
$mainworksheet->writeNumber($row, $col++, $text);
} else {
$mainworksheet->writeString($row, $col++, ilExcelUtils::_convert_text($text, $_POST["export_format"]));
}
if ($col % 251 == 0) {
$worksheet++;
$col = 1;
$mainworksheet =& $worksheets[$worksheet];
$mainworksheet->writeString($row, 0, ilExcelUtils::_convert_text($csvrow[0], $_POST["export_format"]));
}
}
}
$row++;
}
$workbook->close();
ilUtil::deliverFile($excelfile, "{$surveyname}.xls", "application/vnd.ms-excel");
exit;
break;
case self::TYPE_SPSS:
$csv = "";
$separator = ";";
foreach ($csvfile as $idx => $csvrow) {
$csvrow =& str_replace("\n", " ", $this->object->processCSVRow($csvrow, TRUE, $separator));
$csv .= join($csvrow, $separator) . "\n";
}
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::deliverData($csv, "{$surveyname}.csv");
exit;
break;
}
}
示例9: downloadFile
/**
* delete object file
*/
function downloadFile()
{
if (!isset($_POST["file"])) {
$this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
}
if (count($_POST["file"]) > 1) {
$this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"), $this->ilias->error_obj->MESSAGE);
}
$cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
$cur_dir = !empty($cur_subdir) ? $this->main_dir . "/" . $cur_subdir : $this->main_dir;
$file = $cur_dir . "/" . $_POST["file"][0];
// validate against files of current directory
$valid = false;
foreach (ilUtil::getDir($cur_dir) as $entry) {
if ($entry["type"] == "file" && $cur_dir . "/" . $entry["entry"] == $file) {
$valid = true;
break;
}
}
if (@is_file($file) && !@is_dir($file) && $valid) {
ilUtil::deliverFile($file, $_POST["file"][0]);
exit;
} else {
$this->ctrl->saveParameter($this, "cdir");
$this->ctrl->redirect($this, "listFiles");
}
}
示例10: deliverPostFile
public function deliverPostFile()
{
global $ilUser;
$id = (int) $_GET["object_id"];
if (!$id) {
return;
}
include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
$book_id = ilBookingReservation::getObjectReservationForUser($id, $ilUser->getId());
$obj = new ilBookingReservation($book_id);
if ($obj->getUserId() != $ilUser->getId()) {
return;
}
include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
$obj = new ilBookingObject($id);
$file = $obj->getPostFileFullPath();
if ($file) {
ilUtil::deliverFile($file, $obj->getPostFile());
}
}
示例11: deliverMobFile
/**
* Deliver mob file
*
* @param
* @return
*/
function deliverMobFile($a_purpose = "Standard", $a_increase_download_cnt = false)
{
$mob = $this->getMobId();
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mob = new ilObjMediaObject($mob);
$mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
// check purpose
if (!$mob->hasPurposeItem($a_purpose)) {
return false;
}
$m_item = $mob->getMediaItem($a_purpose);
if ($m_item->getLocationType() != "Reference") {
$file = $mob_dir . "/" . $m_item->getLocation();
if (file_exists($file) && is_file($file)) {
if ($a_increase_download_cnt) {
$this->increaseDownloadCounter();
}
ilUtil::deliverFile($file, $m_item->getLocation());
} else {
ilUtil::sendFailure("File not found!", true);
return false;
}
} else {
if ($a_increase_download_cnt) {
$this->increaseDownloadCounter();
}
ilUtil::redirect($m_item->getLocation());
}
}
示例12: downloadItemObject
/**
* Delete news items.
*/
function downloadItemObject()
{
global $ilCtrl;
$this->checkPermission("read");
$mc_item = new ilNewsItem($_GET["item_id"]);
$mob = $mc_item->getMobId();
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mob = new ilObjMediaObject($mob);
$mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
$purpose = $_GET["purpose"];
$m_item = $mob->getMediaItem($purpose);
if ($m_item->getLocationType() != "Reference") {
$file = $mob_dir . "/" . $m_item->getLocation();
if (file_exists($file) && is_file($file)) {
ilUtil::deliverFile($file, $m_item->getLocation());
} else {
ilUtil::sendFailure("File not found!", true);
$ilCtrl->redirect($this, "listItems");
}
} else {
ilUtil::redirect($m_item->getLocation());
}
exit;
}
示例13: sendAndCreateSimpleExportFile
public function sendAndCreateSimpleExportFile()
{
$orgu_id = ilObjOrgUnit::getRootOrgId();
$orgu_ref_id = ilObjOrgUnit::getRootOrgRefId();
ilExport::_createExportDirectory($orgu_id, "xml", "orgu");
$export_dir = ilExport::_getExportDirectory($orgu_id, "xml", "orgu");
$ts = time();
// Workaround for test assessment
$sub_dir = $ts . '__' . IL_INST_ID . '__' . "orgu" . '_' . $orgu_id . "";
$new_file = $sub_dir . '.zip';
$export_run_dir = $export_dir . "/" . $sub_dir;
ilUtil::makeDirParents($export_run_dir);
$writer = $this->simpleExport($orgu_ref_id);
$writer->xmlDumpFile($export_run_dir . "/manifest.xml", false);
// zip the file
ilUtil::zip($export_run_dir, $export_dir . "/" . $new_file);
ilUtil::delDir($export_run_dir);
// Store info about export
include_once './Services/Export/classes/class.ilExportFileInfo.php';
$exp = new ilExportFileInfo($orgu_id);
$exp->setVersion(ILIAS_VERSION_NUMERIC);
$exp->setCreationDate(new ilDateTime($ts, IL_CAL_UNIX));
$exp->setExportType('xml');
$exp->setFilename($new_file);
$exp->create();
ilUtil::deliverFile($export_dir . "/" . $new_file, $new_file);
return array("success" => true, "file" => $new_file, "directory" => $export_dir);
}
示例14: downloadExportFile
function downloadExportFile()
{
if (!isset($_POST["file"])) {
$this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
}
if (count($_POST["file"]) > 1) {
$this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"), $this->ilias->error_obj->MESSAGE);
}
$export = new ilSCORM2004Export($this->object);
$export_dir = $export->getExportDirectoryForType($_POST['type'][$_POST['file'][0]]);
ilUtil::deliverFile($export_dir . "/" . $_POST['file'][0], $_POST['file'][0]);
}
示例15: download
/**
* Download file
*/
function download()
{
global $ilCtrl, $lng;
if (!isset($_POST["file"])) {
ilUtil::sendFailure($lng->txt("no_checkbox"), true);
$ilCtrl->redirect($this, "listExportFiles");
}
if (count($_POST["file"]) > 1) {
ilUtil::sendFailure($lng->txt("exp_select_max_one_item"), true);
$ilCtrl->redirect($this, "listExportFiles");
}
$file = explode(":", $_POST["file"][0]);
include_once "./Services/Export/classes/class.ilExport.php";
$export_dir = ilExport::_getExportDirectory($this->obj->getId(), str_replace("..", "", $file[0]), $this->obj->getType());
ilUtil::deliverFile($export_dir . "/" . $file[1], $file[1]);
}