本文整理汇总了PHP中ilUtil::getASCIIFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP ilUtil::getASCIIFilename方法的具体用法?PHP ilUtil::getASCIIFilename怎么用?PHP ilUtil::getASCIIFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilUtil
的用法示例。
在下文中一共展示了ilUtil::getASCIIFilename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recurseFolder
/**
* private functions which iterates through all folders and files
* and create an according file structure in a temporary directory. This function works recursive.
*
* @param integer $refid reference it
* @param tmpdictory $tmpdir
* @return returns first created directory
*/
private static function recurseFolder($refid, $title, $tmpdir)
{
global $rbacsystem, $tree, $ilAccess;
$tmpdir = $tmpdir . DIRECTORY_SEPARATOR . ilUtil::getASCIIFilename($title);
ilUtil::makeDir($tmpdir);
$subtree = $tree->getChildsByTypeFilter($refid, array("fold", "file"));
foreach ($subtree as $child) {
if (!$ilAccess->checkAccess("read", "", $child["ref_id"])) {
continue;
}
if (ilObject::_isInTrash($child["ref_id"])) {
continue;
}
if ($child["type"] == "fold") {
ilObjFolder::recurseFolder($child["ref_id"], $child["title"], $tmpdir);
} else {
$newFilename = $tmpdir . DIRECTORY_SEPARATOR . ilUtil::getASCIIFilename($child["title"]);
// copy to temporal directory
$oldFilename = ilObjFile::_lookupAbsolutePath($child["obj_id"]);
if (!copy($oldFilename, $newFilename)) {
throw new ilFileException("Could not copy " . $oldFilename . " to " . $newFilename);
}
touch($newFilename, filectime($oldFilename));
}
}
}
示例2: importBookingsFromDaVinciFile
/**
* Imports rooms and bookings from a given daVinci file
*
* @param type $file daVinci text file from file upload form
* @param boolean $import_rooms true to import rooms
* @param boolean $import_bookings true to import bookings
* @param int $default_cap sets the default room capacity
*/
public function importBookingsFromDaVinciFile($file, $import_rooms, $import_bookings, $default_cap)
{
$this->count_Bookings_without_Room = 0;
$this->count_Rooms_created = 0;
$this->count_Bookings_created = 0;
$file_name = ilUtil::getASCIIFilename($file["name"]);
$file_name_mod = str_replace(" ", "_", $file_name);
$file_path = "templates" . "/" . $file_name_mod;
// construct file path
ilUtil::moveUploadedFile($file["tmp_name"], $file_name_mod, $file_path);
$fileAsString = file_get_contents($file_path);
ilUtil::sendInfo($this->lng->txt("rep_robj_xrs_daVinci_import_message_start"), true);
foreach (preg_split("/((\r?\n)|(\r\n?))/", $fileAsString) as $line) {
$this->checkForKey($line);
}
ilUtil::sendInfo($this->createInfoMessage($import_rooms, $import_bookings), true);
if ($import_rooms === "1") {
foreach ($this->rooms as $room) {
if (!($this->ilRoomSharingDatabase->getRoomWithName($room['name']) !== array())) {
if ($room['cap'] == 0) {
$room['cap'] = (int) $default_cap;
}
//$a_name, $a_type, $a_min_alloc, $a_max_alloc, $a_file_id, $a_building_id
$this->ilRoomSharingDatabase->insertRoom($room['name'], $room['type'], 1, $room['cap'], array(), array());
$this->count_Rooms_created++;
}
}
}
if ($import_bookings === "1") {
foreach ($this->appointments as $booking) {
if ($booking['day'] != 0) {
$usedWeek = clone $this->startingDate;
for ($i = 0; $i < strlen($this->activeWeeks); $i++) {
if ($booking['week'] != NULL) {
if ($booking['week'][$i] === 'X') {
$this->addDaVinciBooking($booking['day'], $booking['start'], $booking['end'], $booking['room'], $booking['prof'], $booking['subject'], $booking['classes'], $usedWeek);
}
} else {
if ($this->activeWeeks[$i] === 'X') {
$this->addDaVinciBooking($booking['day'], $booking['start'], $booking['end'], $booking['room'], $booking['prof'], $booking['subject'], $booking['classes'], $usedWeek);
}
}
$usedWeek->add(new DateInterval('P7D'));
}
}
}
}
$this->displayInfo();
}
示例3: sendMultiFeedbackStructureFile
/**
* Create member status record for a new assignment for all participants
*/
function sendMultiFeedbackStructureFile()
{
global $ilDB;
// send and delete the zip file
$deliverFilename = trim(str_replace(" ", "_", $this->getTitle() . "_" . $this->getId()));
$deliverFilename = ilUtil::getASCIIFilename($deliverFilename);
$deliverFilename = "multi_feedback_" . $deliverFilename;
$exc = new ilObjExercise($this->getExerciseId(), false);
$cdir = getcwd();
// create temporary directoy
$tmpdir = ilUtil::ilTempnam();
ilUtil::makeDir($tmpdir);
$mfdir = $tmpdir . "/" . $deliverFilename;
ilUtil::makeDir($mfdir);
// create subfolders <lastname>_<firstname>_<id> for each participant
include_once "./Modules/Exercise/classes/class.ilExerciseMembers.php";
$exmem = new ilExerciseMembers($exc);
$mems = $exmem->getMembers();
foreach ($mems as $mem) {
$name = ilObjUser::_lookupName($mem);
$subdir = $name["lastname"] . "_" . $name["firstname"] . "_" . $name["login"] . "_" . $name["user_id"];
$subdir = ilUtil::getASCIIFilename($subdir);
ilUtil::makeDir($mfdir . "/" . $subdir);
}
// create the zip file
chdir($tmpdir);
$tmpzipfile = $tmpdir . "/multi_feedback.zip";
ilUtil::zip($tmpdir, $tmpzipfile, true);
chdir($cdir);
ilUtil::deliverFile($tmpzipfile, $deliverFilename . ".zip", "", false, true);
}
示例4: fixFilename
/**
* Fix filename of uploaded file
*
* @param string $a_name upload file name
* @return string fixed file name
*/
static function fixFilename($a_name)
{
$a_name = ilUtil::getASCIIFilename($a_name);
$rchars = array("`", "=", "\$", "{", "}", "'", ";", " ", "(", ")");
$a_name = str_replace($rchars, "_", $a_name);
$a_name = str_replace("__", "_", $a_name);
return $a_name;
}
示例5: updateMediaItem
/**
* update media item from form
*
* @param IlObjectMediaObject $mob
* @param IlMediaItem $mediaItem
* @return string file
*/
private function updateMediaItem($mob, &$mediaItem)
{
$purpose = $mediaItem->getPurpose();
$url_gui = $this->form_gui->getInput("url_" . $purpose);
$file_gui = $this->form_gui->getInput("file_" . $purpose);
if ($url_gui) {
// http
$file = $this->form_gui->getInput("url_" . $purpose);
$title = basename($file);
$location = $this->form_gui->getInput("url_" . $purpose);
$locationType = "Reference";
} elseif ($file_gui["size"] > 0) {
// lokal
// determine and create mob directory, move uploaded file to directory
$mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
if (!is_dir($mob_dir)) {
$mob->createDirectory();
}
$file_name = ilUtil::getASCIIFilename($_FILES['file_' . $purpose]['name']);
$file_name = str_replace(" ", "_", $file_name);
$file = $mob_dir . "/" . $file_name;
$title = $file_name;
$locationType = "LocalFile";
$location = $title;
ilUtil::moveUploadedFile($_FILES['file_' . $purpose]['tmp_name'], $file_name, $file);
ilUtil::renameExecutables($mob_dir);
}
// check if not automatic mimetype detection
if ($_POST["mimetype_" . $purpose] != "") {
$mediaItem->setFormat($_POST["mimetype_" . $purpose]);
} elseif ($mediaItem->getLocation() != "") {
$format = ilObjMediaObject::getMimeType($mediaItem->getLocation());
$mediaItem->setFormat($format);
}
if (isset($file)) {
// get mime type, if not already set!
if (!isset($format)) {
$format = ilObjMediaObject::getMimeType($file);
}
// set real meta and object data
$mediaItem->setFormat($format);
$mediaItem->setLocation($location);
$mediaItem->setLocationType($locationType);
$mediaItem->setHAlign("Left");
$mediaItem->setHeight(self::isAudio($format) ? 0 : 180);
}
if ($purpose == "Standard") {
if (isset($title)) {
$mob->setTitle($title);
}
if (isset($format)) {
$mob->setDescription($format);
}
}
return $file;
}
示例6: uploadRoomsAgreement
/**
* Uploads a new rooms agreement by using the ILIAS MediaObject Service.
* If the old file id is given, the old file will be deleted.
*
* @param array $a_newfile an array containing the input values of the form
* @param string $a_oldFileId to delete trash
*
* @return string uploaded file id
*/
public function uploadRoomsAgreement($a_newfile, $a_oldFileId = "0")
{
if (!empty($a_oldFileId) && $a_oldFileId != "0") {
$agreementFile = new ilObjMediaObject($a_oldFileId);
$agreementFile->delete();
}
$mediaObj = new ilObjMediaObject();
$mediaObj->setTitle("RoomSharingRoomsAgreement");
$mediaObj->setDescription("RoomSharingRoomsAgreement");
$mediaObj->create();
$mob_dir = ilObjMediaObject::_getDirectory($mediaObj->getId());
if (!is_dir($mob_dir)) {
$mediaObj->createDirectory();
}
$file_name = ilUtil::getASCIIFilename($a_newfile["name"]);
$file_name_mod = str_replace(" ", "_", $file_name);
$file = $mob_dir . "/" . $file_name_mod;
ilUtil::moveUploadedFile($a_newfile["tmp_name"], $file_name_mod, $file);
ilUtil::renameExecutables($mob_dir);
$format = ilObjMediaObject::getMimeType($file);
$media_item = new ilMediaItem();
$mediaObj->addMediaItem($media_item);
$media_item->setPurpose("Standard");
$media_item->setFormat($format);
$media_item->setLocation($file_name_mod);
$media_item->setLocationType("LocalFile");
$mediaObj->update();
return $mediaObj->getId();
}
示例7: configureFile
/**
* Configures the file for the updateFloorPlanInfosWithFile and addFloorPlan function.
*
* @param ilObjMediaObject $a_mediaObj
* @param array $a_newfile
*
* @return array with format and filename
*/
private function configureFile($a_mediaObj, $a_newfile = NULL)
{
if ($this->mobjMock) {
return $a_newfile;
}
$mob_dir = ilObjMediaObject::_getDirectory($a_mediaObj->getId());
if (!is_dir($mob_dir)) {
$a_mediaObj->createDirectory();
}
$file_name = ilUtil::getASCIIFilename($a_newfile["name"]);
$file_name_mod = str_replace(" ", "_", $file_name);
$file = $mob_dir . "/" . $file_name_mod;
// construct file path
ilUtil::moveUploadedFile($a_newfile["tmp_name"], $file_name_mod, $file);
ilUtil::renameExecutables($mob_dir);
$format = ilObjMediaObject::getMimeType($file);
return array("format" => $format, "filename" => $file_name_mod);
}
示例8: downloadFolderObject
public function downloadFolderObject()
{
global $ilAccess, $ilErr, $lng;
if (!$ilAccess->checkAccess("read", "", $this->ref_id)) {
$this->ilias->raiseError($this->lng->txt("msg_no_perm_read"), $this->ilias->error_obj->MESSAGE);
}
$filename = $this->object->downloadFolder();
ilUtil::deliverFile($filename, ilUtil::getASCIIFilename($this->object->getTitle() . ".zip"));
}
示例9: deliverPDFfromFO
/**
* Delivers a PDF file from a XSL-FO string
*
* @param string $fo The XSL-FO string
* @access public
*/
public function deliverPDFfromFO($fo, $title = null)
{
global $ilLog;
include_once "./Services/Utilities/classes/class.ilUtil.php";
$fo_file = ilUtil::ilTempnam() . ".fo";
$fp = fopen($fo_file, "w");
fwrite($fp, $fo);
fclose($fp);
include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
try {
$pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($fo);
$filename = strlen($title) ? $title : $this->getTitle();
ilUtil::deliverData($pdf_base64->scalar, ilUtil::getASCIIFilename($filename) . ".pdf", "application/pdf", false, true);
return true;
} catch (XML_RPC2_FaultException $e) {
$ilLog->write(__METHOD__ . ': ' . $e->getMessage());
return false;
} catch (Exception $e) {
$ilLog->write(__METHOD__ . ': ' . $e->getMessage());
return false;
}
/*
include_once "./Services/Transformation/classes/class.ilFO2PDF.php";
$fo2pdf = new ilFO2PDF();
$fo2pdf->setFOString($fo);
$result = $fo2pdf->send();
$filename = (strlen($title)) ? $title : $this->getTitle();
ilUtil::deliverData($result, ilUtil::getASCIIFilename($filename) . ".pdf", "application/pdf", false, true);
*/
}
示例10: deliverFile
/**
* deliver file for download via browser.
* @param $mime Mime of the file
* @param $isInline Set this to true, if the file shall be shown in browser
* @static
*
*/
public static function deliverFile($a_file, $a_filename, $a_mime = '', $isInline = false, $removeAfterDelivery = false, $a_exit_after = true)
{
// should we fail silently?
if (!file_exists($a_file)) {
return false;
}
if ($isInline) {
$disposition = "inline";
// "inline" to view file in browser
} else {
$disposition = "attachment";
// "attachment" to download to hard disk
//$a_mime = "application/octet-stream"; // override mime type to ensure that no browser tries to show the file anyway.
}
// END WebDAV: Show file in browser or provide it as attachment
if (strlen($a_mime)) {
$mime = $a_mime;
} else {
$mime = "application/octet-stream";
// or whatever the mime type is
}
// BEGIN WebDAV: Removed broken HTTPS code.
// END WebDAV: Removed broken HTTPS code.
if ($disposition == "attachment") {
header("Cache-control: private");
} else {
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
}
$ascii_filename = ilUtil::getASCIIFilename($a_filename);
header("Content-Type: {$mime}");
header("Content-Disposition:{$disposition}; filename=\"" . $ascii_filename . "\"");
header("Content-Description: " . $ascii_filename);
// #7271: if notice gets thrown download will fail in IE
$filesize = @filesize($a_file);
if ($filesize) {
header("Content-Length: " . (string) $filesize);
}
include_once './Services/Http/classes/class.ilHTTPS.php';
#if($_SERVER['HTTPS'])
if (ilHTTPS::getInstance()->isDetected()) {
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
}
header("Connection: close");
ilUtil::readFile($a_file);
if ($removeAfterDelivery) {
unlink($a_file);
}
if ($a_exit_after) {
exit;
}
}
示例11: exportAllCodesObject
/**
* Exports all survey codes
*/
public function exportAllCodesObject()
{
$export = $this->object->getSurveyCodesForExport();
ilUtil::deliverData($export, ilUtil::getASCIIFilename($this->object->getTitle() . ".csv"));
}
示例12: copyFile
private static function copyFile($obj_id, $title, $tmpdir)
{
$newFilename = $tmpdir . DIRECTORY_SEPARATOR . ilUtil::getASCIIFilename($title);
// copy to temporary directory
$oldFilename = ilObjFile::_lookupAbsolutePath($obj_id);
if (!copy($oldFilename, $newFilename)) {
throw new ilFileException("Could not copy " . $oldFilename . " to " . $newFilename);
}
touch($newFilename, filectime($oldFilename));
}
示例13: getOfflineFilename
public function getOfflineFilename()
{
return ilUtil::getASCIIFilename($this->getTitle()) . ".pdf";
}
示例14: exportCertificate
/**
* Exports the user results as PDF certificates using
* XSL-FO via XML:RPC calls
*
* @access public
*/
public function exportCertificate()
{
global $ilUser;
include_once "./Services/Utilities/classes/class.ilUtil.php";
include_once "./Services/Certificate/classes/class.ilCertificate.php";
include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
$certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
$archive_dir = $certificate->createArchiveDirectory();
$total_users = array();
$total_users =& $this->object->evalTotalPersonsArray();
if (count($total_users)) {
foreach ($total_users as $active_id => $name) {
$user_id = $this->object->_getUserIdFromActiveId($active_id);
$pdf = $certificate->outCertificate(array("active_id" => $active_id, "userfilter" => $userfilter, "passedonly" => $passedonly), FALSE);
if (strlen($pdf)) {
$certificate->addPDFtoArchiveDirectory($pdf, $archive_dir, $user_id . "_" . str_replace(" ", "_", ilUtil::getASCIIFilename($name)) . ".pdf");
}
}
$zipArchive = $certificate->zipCertificatesInArchiveDirectory($archive_dir, TRUE);
}
}
示例15: downloadAllDeliveredFiles
/**
* Download all submitted files of an assignment (all user)
*
* @param $members array of user names, key is user id
*/
function downloadAllDeliveredFiles($a_eph_id, $a_ass_id, $members)
{
global $lng, $ilObjDataCache, $ilias;
include_once "./Services/Utilities/classes/class.ilUtil.php";
include_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/Ephorus/classes/class.ilFSStorageEphorus.php";
$storage = new ilFSStorageEphorus($a_eph_id, $a_ass_id);
$storage->create();
ksort($members);
//$savepath = $this->getEphorusPath() . "/" . $this->obj_id . "/";
$savepath = $storage->getAbsoluteSubmissionPath();
$cdir = getcwd();
// important check: if the directory does not exist
// ILIAS stays in the current directory (echoing only a warning)
// and the zip command below archives the whole ILIAS directory
// (including the data directory) and sends a mega file to the user :-o
if (!is_dir($savepath)) {
return;
}
// Safe mode fix
// chdir($this->getEphorusPath());
chdir($storage->getTempPath());
$zip = PATH_TO_ZIP;
// check first, if we have enough free disk space to copy all files to temporary directory
$tmpdir = ilUtil::ilTempnam();
ilUtil::makeDir($tmpdir);
chdir($tmpdir);
$dirsize = 0;
foreach ($members as $id => $object) {
$directory = $savepath . DIRECTORY_SEPARATOR . $id;
$dirsize += ilUtil::dirsize($directory);
}
if ($dirsize > disk_free_space($tmpdir)) {
return -1;
}
// copy all member directories to the temporary folder
// switch from id to member name and append the login if the member name is double
// ensure that no illegal filenames will be created
// remove timestamp from filename
$cache = array();
foreach ($members as $id => $user) {
$sourcedir = $savepath . DIRECTORY_SEPARATOR . $id;
if (!is_dir($sourcedir)) {
continue;
}
$userName = ilObjUser::_lookupName($id);
$directory = ilUtil::getASCIIFilename(trim($userName["lastname"]) . "_" . trim($userName["firstname"]));
if (array_key_exists($directory, $cache)) {
// first try is to append the login;
$directory = ilUtil::getASCIIFilename($directory . "_" . trim(ilObjUser::_lookupLogin($id)));
if (array_key_exists($directory, $cache)) {
// second and secure: append the user id as well.
$directory .= "_" . $id;
}
}
$cache[$directory] = $directory;
ilUtil::makeDir($directory);
$sourcefiles = scandir($sourcedir);
foreach ($sourcefiles as $sourcefile) {
if ($sourcefile == "." || $sourcefile == "..") {
continue;
}
$targetfile = trim(basename($sourcefile));
$pos = strpos($targetfile, "_");
if ($pos === false) {
} else {
$targetfile = substr($targetfile, $pos + 1);
}
$targetfile = $directory . DIRECTORY_SEPARATOR . $targetfile;
$sourcefile = $sourcedir . DIRECTORY_SEPARATOR . $sourcefile;
if (!copy($sourcefile, $targetfile)) {
//echo 'Could not copy '.$sourcefile.' to '.$targetfile;
$ilias->raiseError('Could not copy ' . basename($sourcefile) . " to '" . $targetfile . "'.", $ilias->error_obj->MESSAGE);
} else {
// preserve time stamp
touch($targetfile, filectime($sourcefile));
}
}
}
$tmpfile = ilUtil::ilTempnam();
$tmpzipfile = $tmpfile . ".zip";
// Safe mode fix
$zipcmd = $zip . " -r " . ilUtil::escapeShellArg($tmpzipfile) . " .";
exec($zipcmd);
ilUtil::delDir($tmpdir);
$assTitle = ilEphAssignment::lookupTitle($a_ass_id);
chdir($cdir);
ilUtil::deliverFile($tmpzipfile, (strlen($assTitle) == 0 ? strtolower($lng->txt("rep_robj_xeph_ephorus_assignment")) : $assTitle) . ".zip", "", false, true);
}