本文整理汇总了PHP中ilUtil::makeDir方法的典型用法代码示例。如果您正苦于以下问题:PHP ilUtil::makeDir方法的具体用法?PHP ilUtil::makeDir怎么用?PHP ilUtil::makeDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilUtil
的用法示例。
在下文中一共展示了ilUtil::makeDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initDirectory
/**
* init directory
* overwritten method
* @access public
* @static
* @return string path
*/
function _initDirectory()
{
if (!@file_exists($this->import_path)) {
ilUtil::makeDir($this->import_path);
}
return true;
}
示例2: _createWebspaceDir
/**
* Create webspace directory for the plugin
*
* @param string level ("plugin", "type" or "object")
* @param integer type id or object id
*
* @return string webspace directory
*/
static function _createWebspaceDir($a_level = "plugin", $a_id = 0)
{
switch ($a_level) {
case "plugin":
$plugin_dir = self::_getWebspaceDir('plugin');
if (!is_dir($plugin_dir)) {
ilUtil::makeDir($plugin_dir);
}
return $plugin_dir;
case "type":
$plugin_dir = self::_createWebspaceDir("plugin");
$type_dir = $plugin_dir . "/type_" . $a_id;
if (!is_dir($type_dir)) {
ilUtil::makeDir($type_dir);
}
return $type_dir;
case "object":
$plugin_dir = self::_createWebspaceDir("plugin");
$object_dir = $plugin_dir . "/object_" . $a_id;
if (!is_dir($type_dir)) {
ilUtil::makeDir($object_dir);
}
return $object_dir;
}
}
示例3: buildExportFile
/**
* Build export file
*
* @param
* @return
*/
function buildExportFile()
{
global $ilias;
// create export file
include_once "./Services/Export/classes/class.ilExport.php";
ilExport::_createExportDirectory($this->wiki->getId(), "html", "wiki");
$exp_dir = ilExport::_getExportDirectory($this->wiki->getId(), "html", "wiki");
$this->subdir = $this->wiki->getType() . "_" . $this->wiki->getId();
$this->export_dir = $exp_dir . "/" . $this->subdir;
// initialize temporary target directory
ilUtil::delDir($this->export_dir);
ilUtil::makeDir($this->export_dir);
// system style html exporter
include_once "./Services/Style/classes/class.ilSystemStyleHTMLExport.php";
$this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir);
$this->sys_style_html_export->addImage("icon_wiki.svg");
$this->sys_style_html_export->export();
// init co page html exporter
include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php";
$this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir);
$this->co_page_html_export->setContentStyleId($this->wiki->getStyleSheetId());
$this->co_page_html_export->createDirectories();
$this->co_page_html_export->exportStyles();
$this->co_page_html_export->exportSupportScripts();
// export pages
$this->exportHTMLPages();
// zip everything
if (true) {
// zip it all
$date = time();
$zip_file = ilExport::_getExportDirectory($this->wiki->getId(), "html", "wiki") . "/" . $date . "__" . IL_INST_ID . "__" . $this->wiki->getType() . "_" . $this->wiki->getId() . ".zip";
ilUtil::zip($this->export_dir, $zip_file);
ilUtil::delDir($this->export_dir);
}
}
示例4: createDirectories
/**
* Create directories
*/
function createDirectories()
{
ilUtil::makeDir($this->style_dir);
ilUtil::makeDir($this->style_img_dir);
ilUtil::makeDir($this->img_dir);
ilUtil::makeDir($this->img_browser_dir);
}
示例5: createContainerDirectory
/**
* Create directory for the container.
* It is <webspace_dir>/container_data.
*/
function createContainerDirectory()
{
$webspace_dir = ilUtil::getWebspaceDir();
$cont_dir = $webspace_dir . "/container_data";
if (!is_dir($cont_dir)) {
ilUtil::makeDir($cont_dir);
}
$obj_dir = $cont_dir . "/obj_" . $this->getId();
if (!is_dir($obj_dir)) {
ilUtil::makeDir($obj_dir);
}
}
示例6: getXmlRecord
/**
* Get xml record
*
* @param
* @return
*/
function getXmlRecord($a_entity, $a_version, $a_set)
{
global $ilLog;
if ($a_entity == "usr_profile") {
$tmp_dir = ilUtil::ilTempnam();
ilUtil::makeDir($tmp_dir);
include_once "./Services/User/classes/class.ilObjUser.php";
ilObjUser::copyProfilePicturesToDirectory($a_set["Id"], $tmp_dir);
$this->temp_picture_dirs[$a_set["Id"]] = $tmp_dir;
$a_set["Picture"] = $tmp_dir;
}
return $a_set;
}
示例7: buildExportFile
/**
* Build export file
*
* @param
* @return
*/
function buildExportFile()
{
global $ilias;
// create export file
include_once "./Services/Export/classes/class.ilExport.php";
ilExport::_createExportDirectory($this->object->getId(), "html", "prtf");
$exp_dir = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf");
$this->subdir = $this->object->getType() . "_" . $this->object->getId();
$this->export_dir = $exp_dir . "/" . $this->subdir;
// initialize temporary target directory
ilUtil::delDir($this->export_dir);
ilUtil::makeDir($this->export_dir);
// system style html exporter
include_once "./Services/Style/classes/class.ilSystemStyleHTMLExport.php";
$this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir);
// $this->sys_style_html_export->addImage("icon_prtf_b.png");
$this->sys_style_html_export->export();
// init co page html exporter
include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php";
$this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir);
/* $this->co_page_html_export->setContentStyleId(
$this->object->getStyleSheetId()); */
$this->co_page_html_export->createDirectories();
$this->co_page_html_export->exportStyles();
$this->co_page_html_export->exportSupportScripts();
// banner / profile picture
$prfa_set = new ilSetting("prfa");
if ($prfa_set->get("banner")) {
$banner = $this->object->getImageFullPath();
copy($banner, $this->export_dir . "/" . basename($banner));
}
$ppic = ilObjUser::_getPersonalPicturePath($this->object->getOwner(), "big");
if ($ppic) {
$ppic = array_shift(explode("?", $ppic));
copy($ppic, $this->export_dir . "/" . basename($ppic));
}
// export pages
$this->exportHTMLPages();
// zip everything
if (true) {
// zip it all
$date = time();
$zip_file = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf") . "/" . $date . "__" . IL_INST_ID . "__" . $this->object->getType() . "_" . $this->object->getId() . ".zip";
ilUtil::zip($this->export_dir, $zip_file);
ilUtil::delDir($this->export_dir);
}
return $zip_file;
}
示例8: exportContentCSS
/**
* Export lm content css to a directory
*/
static function exportContentCSS($a_slm_object, $a_target_dir)
{
ilUtil::makeDir($a_target_dir . "/css");
ilUtil::makeDir($a_target_dir . "/css/images");
include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
$active_css = ilObjStyleSheet::getContentStylePath($a_slm_object->getStyleSheetId());
$active_css = split(@'\\?', $active_css, 2);
$css = fread(fopen($active_css[0], 'r'), filesize($active_css[0]));
preg_match_all("/url\\(([^\\)]*)\\)/", $css, $files);
$currdir = getcwd();
chdir(dirname($active_css[0]));
foreach (array_unique($files[1]) as $fileref) {
if (is_file($fileref)) {
copy($fileref, $a_target_dir . "/css/images/" . basename($fileref));
}
$css = str_replace($fileref, "images/" . basename($fileref), $css);
}
chdir($currdir);
fwrite(fopen($a_target_dir . '/css/style.css', 'w'), $css);
}
示例9: __initDirectory
/**
* init directory
* overwritten method
* @access public
* @return string path
*/
function __initDirectory()
{
if (is_writable($this->getPath())) {
ilUtil::makeDir($this->getPath() . '/' . GROUP_PATH);
$this->group_path = $this->getPath() . '/' . GROUP_PATH;
return true;
}
return false;
}
示例10: importUserRoleAssignmentObject
/**
* display form for user import
*/
function importUserRoleAssignmentObject()
{
global $ilUser, $rbacreview, $tpl, $lng, $ilCtrl;
// Blind out tabs for local user import
if ($_GET["baseClass"] == 'ilRepositoryGUI') {
$this->tabs_gui->clearTargets();
}
$this->initUserImportForm();
if ($this->form->checkInput()) {
include_once './Services/AccessControl/classes/class.ilObjRole.php';
include_once './Services/User/classes/class.ilUserImportParser.php';
global $rbacreview, $rbacsystem, $tree, $lng;
$this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_import_roles.html", "Services/User");
$import_dir = $this->getImportDir();
// recreate user import directory
if (@is_dir($import_dir)) {
ilUtil::delDir($import_dir);
}
ilUtil::makeDir($import_dir);
// move uploaded file to user import directory
$file_name = $_FILES["importFile"]["name"];
$parts = pathinfo($file_name);
$full_path = $import_dir . "/" . $file_name;
// check if import file exists
if (!is_file($_FILES["importFile"]["tmp_name"])) {
ilUtil::delDir($import_dir);
$this->ilias->raiseError($this->lng->txt("no_import_file_found"), $this->ilias->error_obj->MESSAGE);
}
ilUtil::moveUploadedFile($_FILES["importFile"]["tmp_name"], $_FILES["importFile"]["name"], $full_path);
// handle zip file
if (strtolower($parts["extension"]) == "zip") {
// unzip file
ilUtil::unzip($full_path);
$xml_file = null;
$file_list = ilUtil::getDir($import_dir);
foreach ($file_list as $a_file) {
if (substr($a_file['entry'], -4) == '.xml') {
$xml_file = $import_dir . "/" . $a_file['entry'];
break;
}
}
if (is_null($xml_file)) {
$subdir = basename($parts["basename"], "." . $parts["extension"]);
$xml_file = $import_dir . "/" . $subdir . "/" . $subdir . ".xml";
}
} else {
$xml_file = $full_path;
}
// check xml file
if (!is_file($xml_file)) {
ilUtil::delDir($import_dir);
$this->ilias->raiseError($this->lng->txt("no_xml_file_found_in_zip") . " " . $subdir . "/" . $subdir . ".xml", $this->ilias->error_obj->MESSAGE);
}
require_once "./Services/User/classes/class.ilUserImportParser.php";
// Verify the data
// ---------------
$importParser = new ilUserImportParser($xml_file, IL_VERIFY);
$importParser->startParsing();
switch ($importParser->getErrorLevel()) {
case IL_IMPORT_SUCCESS:
break;
case IL_IMPORT_WARNING:
$this->tpl->setVariable("IMPORT_LOG", $importParser->getProtocolAsHTML($lng->txt("verification_warning_log")));
break;
case IL_IMPORT_FAILURE:
ilUtil::delDir($import_dir);
$this->ilias->raiseError($lng->txt("verification_failed") . $importParser->getProtocolAsHTML($lng->txt("verification_failure_log")), $this->ilias->error_obj->MESSAGE);
return;
}
// Create the role selection form
// ------------------------------
$this->tpl->setCurrentBlock("role_selection_form");
$this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
$this->tpl->setVariable("TXT_IMPORT_USERS", $this->lng->txt("import_users"));
$this->tpl->setVariable("TXT_IMPORT_FILE", $this->lng->txt("import_file"));
$this->tpl->setVariable("IMPORT_FILE", $file_name);
$this->tpl->setVariable("TXT_USER_ELEMENT_COUNT", $this->lng->txt("num_users"));
$this->tpl->setVariable("USER_ELEMENT_COUNT", $importParser->getUserCount());
$this->tpl->setVariable("TXT_ROLE_ASSIGNMENT", $this->lng->txt("role_assignment"));
$this->tpl->setVariable("BTN_IMPORT", $this->lng->txt("import"));
$this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
$this->tpl->setVariable("XML_FILE_NAME", $xml_file);
// Extract the roles
$importParser = new ilUserImportParser($xml_file, IL_EXTRACT_ROLES);
$importParser->startParsing();
$roles = $importParser->getCollectedRoles();
// get global roles
$all_gl_roles = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
$gl_roles = array();
$roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
foreach ($all_gl_roles as $obj_data) {
// check assignment permission if called from local admin
if ($this->object->getRefId() != USER_FOLDER_ID) {
if (!in_array(SYSTEM_ROLE_ID, $roles_of_user) && !ilObjRole::_getAssignUsersStatus($obj_data['obj_id'])) {
continue;
}
}
//.........这里部分代码省略.........
示例11: 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);
}
}
示例12: createDirectory
/**
* create directory
*/
function createDirectory()
{
global $lng;
// determine directory
$cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
$cur_dir = !empty($cur_subdir) ? $this->main_dir . "/" . $cur_subdir : $this->main_dir;
$new_dir = str_replace(".", "", ilUtil::stripSlashes($_POST["new_dir"]));
$new_dir = str_replace("/", "", $new_dir);
if (!empty($new_dir)) {
ilUtil::makeDir($cur_dir . "/" . $new_dir);
if (is_dir($cur_dir . "/" . $new_dir)) {
ilUtil::sendSuccess($lng->txt("cont_dir_created"), true);
$this->setPerformedCommand("create_dir", array("name" => $new_dir));
}
} else {
ilUtil::sendFailure($lng->txt("cont_enter_a_dir_name"), true);
}
$this->ctrl->saveParameter($this, "cdir");
$this->ctrl->redirect($this, "listFiles");
}
示例13: 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);
}
示例14: create
/**
* create a new client and its subdirectories
* @return boolean true on success
*/
function create()
{
//var_dump($this->getDataDir());exit;
// create base data dir
if (!ilUtil::makeDir($this->getDataDir())) {
$this->error = "could_not_create_base_data_dir :" . $this->getDataDir();
return false;
}
// create sub dirs in base data dir
if (!ilUtil::makeDir($this->getDataDir() . "/mail")) {
$this->error = "could_not_create_mail_data_dir :" . $this->getDataDir() . "/mail";
return false;
}
if (!ilUtil::makeDir($this->getDataDir() . "/lm_data")) {
$this->error = "could_not_create_lm_data_dir :" . $this->getDataDir() . "/lm_data";
return false;
}
if (!ilUtil::makeDir($this->getDataDir() . "/forum")) {
$this->error = "could_not_create_forum_data_dir :" . $this->getDataDir() . "/forum";
return false;
}
if (!ilUtil::makeDir($this->getDataDir() . "/files")) {
$this->error = "could_not_create_files_data_dir :" . $this->getDataDir() . "/files";
return false;
}
// create base webspace dir
if (!ilUtil::makeDir($this->getWebspaceDir())) {
$this->error = "could_not_create_base_webspace_dir :" . $this->getWebspaceDir();
return false;
}
// create sub dirs in base webspace dir
if (!ilUtil::makeDir($this->getWebspaceDir() . "/lm_data")) {
$this->error = "could_not_create_lm_webspace_dir :" . $this->getWebspaceDir() . "/lm_data";
return false;
}
if (!ilUtil::makeDir($this->getWebspaceDir() . "/usr_images")) {
$this->error = "could_not_create_usr_images_webspace_dir :" . $this->getWebspaceDir() . "/usr_images";
return false;
}
if (!ilUtil::makeDir($this->getWebspaceDir() . "/mobs")) {
$this->error = "could_not_create_mobs_webspace_dir :" . $this->getWebspaceDir() . "/mobs";
return false;
}
if (!ilUtil::makeDir($this->getWebspaceDir() . "/css")) {
$this->error = "could_not_create_css_webspace_dir :" . $this->getWebspaceDir() . "/css";
return false;
}
// write client ini
if (!$this->ini->write()) {
$this->error = get_class($this) . ": " . $this->ini->getError();
return false;
}
return true;
}
示例15: 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);
}