本文整理汇总了PHP中ilObjFile::getDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjFile::getDirectory方法的具体用法?PHP ilObjFile::getDirectory怎么用?PHP ilObjFile::getDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjFile
的用法示例。
在下文中一共展示了ilObjFile::getDirectory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
function start()
{
$this->__buildHeader();
$attribs = array("obj_id" => "il_" . IL_INST_ID . "_file_" . $this->file->getId(), "version" => $this->file->getVersion(), "size" => $this->file->getFileSize(), "type" => $this->file->getFileType());
$this->xmlStartTag("File", $attribs);
$this->xmlElement("Filename", null, $this->file->getFileName());
$this->xmlElement("Title", null, $this->file->getTitle());
$this->xmlElement("Description", null, $this->file->getDescription());
$this->xmlElement("Rating", null, (int) $this->file->hasRating());
if ($this->attachFileContents) {
$filename = $this->file->getDirectory($this->file->getVersion()) . "/" . $this->file->getFileName();
if (@is_file($filename)) {
if ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_COPY) {
$attribs = array("mode" => "COPY");
copy($filename, $this->target_dir_absolute . "/" . $this->file->getFileName());
$content = $this->target_dir_relative . "/" . $this->file->getFileName();
$this->xmlElement("Content", $attribs, $content);
} elseif ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_REST) {
$attribs = array('mode' => "REST");
include_once './Services/WebServices/Rest/classes/class.ilRestFileStorage.php';
$fs = new ilRestFileStorage();
$tmpname = $fs->storeFileForRest(base64_encode(@file_get_contents($filename)));
$this->xmlElement("Content", $attribs, $tmpname);
} else {
$content = @file_get_contents($filename);
$attribs = array("mode" => "PLAIN");
if ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_ZLIB_ENCODED) {
$attribs["mode"] = "ZLIB";
$content = @gzcompress($content, 9);
} elseif ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_GZIP_ENCODED) {
$attribs["mode"] = "GZIP";
$content = @gzencode($content, 9);
}
$content = base64_encode($content);
$this->xmlElement("Content", $attribs, $content);
}
}
}
include_once "./Services/History/classes/class.ilHistory.php";
$versions = ilHistory::_getEntriesForObject($this->file->getId(), $this->file->getType());
if (count($versions)) {
$this->xmlStartTag("Versions");
foreach ($versions as $version) {
$info_params = $version["info_params"];
list($filename, $history_id) = split(",", $info_params);
$attribs = array("id" => $history_id, "date" => ilUtil::date_mysql2time($version["date"]), "usr_id" => "il_" . IL_INST_ID . "_usr_" . $version["user_id"]);
$this->xmlElement("Version", $attribs);
}
$this->xmlEndTag("Versions");
}
$this->xmlEndTag("File");
$this->__buildFooter();
return true;
}
示例2: setFileContents
/**
* update file according to filename and version, does not update history
* has to be called after (!) file save for new objects, since file storage will be initialised with obj id.
*
*/
public function setFileContents()
{
global $ilLog;
#$ilLog->write(__METHOD__.' '.filesize($this->tmpFilename));
if (filesize($this->tmpFilename) == 0) {
return;
}
$filedir = $this->file->getDirectory($this->file->getVersion());
#$ilLog->write(__METHOD__.' '.$filedir);
if (!is_dir($filedir)) {
$this->file->createDirectory();
ilUtil::makeDir($filedir);
}
$filename = $filedir . "/" . $this->file->getFileName();
if (file_exists($filename)) {
unlink($filename);
}
//echo "-".$this->tmpFilename."-".$filename."-"; exit;
return rename($this->tmpFilename, $filename);
// @file_put_contents($filename, $this->content);
}
示例3: exportHTMLFile
/**
* Export file object
*/
function exportHTMLFile($a_file_id)
{
$file_dir = $this->files_dir . "/file_" . $a_file_id;
ilUtil::makeDir($file_dir);
include_once "./Modules/File/classes/class.ilObjFile.php";
$file_obj = new ilObjFile($a_file_id, false);
$source_file = $file_obj->getDirectory($file_obj->getVersion()) . "/" . $file_obj->getFileName();
if (!is_file($source_file)) {
$source_file = $file_obj->getDirectory() . "/" . $file_obj->getFileName();
}
if (is_file($source_file)) {
copy($source_file, $file_dir . "/" . $file_obj->getFileName());
}
}
示例4: copyFileItems
/**
* copy files of file items
*/
function copyFileItems()
{
$imp_dir = $this->content_object->getImportDirectory();
foreach ($this->file_item_mapping as $origin_id => $file_id) {
if (empty($origin_id)) {
continue;
}
$obj_dir = $origin_id;
$source_dir = $imp_dir . "/" . $this->subdir . "/objects/" . $obj_dir;
include_once "./Modules/File/classes/class.ilObjFile.php";
$file_obj = new ilObjFile($file_id, false);
//$target_dir = ilUtil::getDataDir()."/files/file_".$file_id;
$target_dir = $file_obj->getDirectory();
if (@is_dir($source_dir)) {
// make target directory
ilUtil::makeDir($target_dir);
//@mkdir($target_dir);
//@chmod($target_dir, 0755);
if (@is_dir($target_dir)) {
ilUtil::rCopy($source_dir, $target_dir);
}
}
$test = $file_obj->determineFilesize();
$file_obj->update();
}
}