ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCloudPluginUploadGUI Class Reference

Class ilCloudPluginUploadGUI. More...

+ Inheritance diagram for ilCloudPluginUploadGUI:
+ Collaboration diagram for ilCloudPluginUploadGUI:

Public Member Functions

 executeCommand ()
 execute command
 asyncUploadFile ()
 initUploadForm ()
 cancelAll ()
 uploadFiles ()
 Update properties.
 handleFileUpload ($file_upload)
- Public Member Functions inherited from ilCloudPluginGUI
 __construct ($plugin_service_class)
 getPluginObject ()
 getPluginHookObject ()
 getAdminConfigObject ()
 getService ()
 txt ($var="")

Protected Member Functions

 uploadDirectory ($dir, $parent_id, $file_tree, $keep_structure=true)
 Recursive Method to upload a directory.

Protected Attributes

 $form
- Protected Attributes inherited from ilCloudPluginGUI
 $service = null

Detailed Description

Class ilCloudPluginUploadGUI.

Standard class for uploading files. Can be overwritten if needed.

Author
Timon Amstutz timon.nosp@m..ams.nosp@m.tutz@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
Version
$Id:

Definition at line 17 of file class.ilCloudPluginUploadGUI.php.

Member Function Documentation

ilCloudPluginUploadGUI::asyncUploadFile ( )

Definition at line 40 of file class.ilCloudPluginUploadGUI.php.

References $_POST, $_SESSION, $options, ilJsonUtil\encode(), exit, and initUploadForm().

{
global $ilTabs;
$ilTabs->activateTab("content");
$this->initUploadForm();
echo $this->form->getHTML();
$options = new stdClass();
$options->dropZone = "#ilFileUploadDropZone_1";
$options->fileInput = "#ilFileUploadInput_1";
$options->submitButton = "uploadFiles";
$options->cancelButton = "cancelAll";
$options->dropArea = "#ilFileUploadDropArea_1";
$options->fileList = "#ilFileUploadList_1";
$options->fileSelectButton = "#ilFileUploadFileSelect_1";
echo "<script language='javascript' type='text/javascript'>var fileUpload1 = new ilFileUpload(1, " . ilJsonUtil::encode($options) . ");</script>";
$_SESSION["cld_folder_id"] = $_POST["folder_id"];
}

+ Here is the call graph for this function:

ilCloudPluginUploadGUI::cancelAll ( )

Definition at line 92 of file class.ilCloudPluginUploadGUI.php.

References exit.

{
echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterUpload('cancel');</script>";
}
ilCloudPluginUploadGUI::executeCommand ( )

execute command

Reimplemented from ilCloudPluginGUI.

Definition at line 26 of file class.ilCloudPluginUploadGUI.php.

References $cmd, and $ilCtrl.

{
global $ilCtrl;
$cmd = $ilCtrl->getCmd();
switch ($cmd)
{
default:
$this->$cmd();
break;
}
}
ilCloudPluginUploadGUI::handleFileUpload (   $file_upload)

Definition at line 135 of file class.ilCloudPluginUploadGUI.php.

References $_POST, $_SESSION, ilUtil\delDir(), exit, ilCloudFileTree\getFileTreeFromSession(), ilUtil\ilTempnam(), ilUtil\makeDir(), ilFileUtils\processZipFile(), and uploadDirectory().

Referenced by uploadFiles().

{
// create answer object
$response = new stdClass();
$response->fileName = $_POST["title"];
$response->fileSize = intval($file_upload["size"]);
$response->fileType = $file_upload["type"];
$response->fileUnzipped = $file_upload["extract"];
$response->error = null;
if ($file_upload["extract"])
{
$newdir = ilUtil::ilTempnam();
ilUtil::makeDir($newdir);
include_once './Services/Utilities/classes/class.ilFileUtils.php';
try
{
ilFileUtils::processZipFile($newdir, $file_upload["tmp_name"], $file_upload["keep_structure"]);
}
catch (Exception $e)
{
$response->error = $e->getMessage();
ilUtil::delDir($newdir);
}
try
{
$this->uploadDirectory($newdir, $_SESSION["cld_folder_id"], $file_tree, $file_upload["keep_structure"]);
}
catch (Exception $e)
{
$response->error = $e->getMessage();
ilUtil::delDir($newdir);
}
ilUtil::delDir($newdir);
return $response;
}
else
{
$file_tree->uploadFileToService($_SESSION["cld_folder_id"], $file_upload["tmp_name"], $_POST["title"]);
return $response;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCloudPluginUploadGUI::initUploadForm ( )

Definition at line 64 of file class.ilCloudPluginUploadGUI.php.

References $file, $ilCtrl, $lng, and ilUtil\getImagePath().

Referenced by asyncUploadFile(), and uploadFiles().

{
global $ilCtrl, $lng;
include_once("./Services/Form/classes/class.ilDragDropFileInputGUI.php");
include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
$this->form = new ilPropertyFormGUI();
$this->form->setId("upload");
$this->form->setMultipart(true);
$this->form->setHideLabels();
$file = new ilDragDropFileInputGUI($lng->txt("cld_upload_files"), "upload_files");
$file->setRequired(true);
$this->form->addItem($file);
$this->form->addCommandButton("uploadFiles", $lng->txt("upload"));
$this->form->addCommandButton("cancelAll", $lng->txt("cancel"));
$this->form->setTableWidth("100%");
$this->form->setTitle($lng->txt("upload_files_title"));
$this->form->setTitleIcon(ilUtil::getImagePath('icon_file.gif'), $lng->txt('obj_file'));
$this->form->setTitle($lng->txt("upload_files"));
$this->form->setFormAction($ilCtrl->getFormAction($this, "uploadFiles"));
$this->form->setTarget("cld_blank_target");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCloudPluginUploadGUI::uploadDirectory (   $dir,
  $parent_id,
  $file_tree,
  $keep_structure = true 
)
protected

Recursive Method to upload a directory.

Parameters
string$dirpath to directory
int$parent_idid of parent folder
ilCloudFileTree$file_tree
bool$keep_structureif false, only files will be extracted, without folder structure
Exceptions
ilCloudException

Definition at line 195 of file class.ilCloudPluginUploadGUI.php.

References ilFileUtilsException\$BROKEN_FILE, $file, and $lng.

Referenced by handleFileUpload().

{
$dirlist = opendir($dir);
while (false !== ($file = readdir ($dirlist)))
{
if (!is_file($dir . "/" . $file) && !is_dir($dir . "/" . $file))
{
global $lng;
throw new ilCloudException($lng->txt("filenames_not_supported") , ilFileUtilsException::$BROKEN_FILE);
}
if ($file != '.' && $file != '..')
{
$newpath = $dir.'/'.$file;
if (is_dir($newpath))
{
if($keep_structure)
{
$newnode = $file_tree->addFolderToService($parent_id, basename($newpath));
$this->uploadDirectory($newpath, $newnode->getId(), $file_tree);
}
else
{
$this->uploadDirectory($newpath, $parent_id, $file_tree, false);
}
}
else
{
$file_tree->uploadFileToService($parent_id, $newpath, basename($newpath));
}
}
}
closedir($dirlist);
}

+ Here is the caller graph for this function:

ilCloudPluginUploadGUI::uploadFiles ( )

Update properties.

Definition at line 102 of file class.ilCloudPluginUploadGUI.php.

References ilJsonUtil\encode(), exit, handleFileUpload(), initUploadForm(), and ilCloudException\UPLOAD_FAILED.

{
$response = new stdClass();
$response->error = null;
$response->debug = null;
$this->initUploadForm();
if ($this->form->checkInput())
{
try
{
$fileresult = $this->handleFileUpload($this->form->getInput("upload_files"));
if ($fileresult)
{
$response = (object)array_merge((array)$response, (array)$fileresult);
}
} catch (ilException $e)
{
$response->error = $e->getMessage();
}
} else
{
$response->error = $error->getMessage();
}
// send response object (don't use 'application/json' as IE wants to download it!)
header('Vary: Accept');
header('Content-type: text/plain');
echo ilJsonUtil::encode($response);
}

+ Here is the call graph for this function:

Field Documentation

ilCloudPluginUploadGUI::$form
protected

Definition at line 22 of file class.ilCloudPluginUploadGUI.php.


The documentation for this class was generated from the following file: