ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilFileUploadGUI Class Reference
+ Collaboration diagram for ilFileUploadGUI:

Public Member Functions

 __construct ($a_drop_zone_id, $a_ref_id=null, $current_obj=false)
 Creates a new file upload GUI.
 getHTML ()
 Gets the HTML code to enable the file upload.
 enableFormSubmit ($input_field_id, $a_submit_name, $a_cancel_name)
 setMaxFileSize ($a_max)
 Sets the maximum file size in bytes.
 getMaxFileSize ()
 Gets the maximum file size in bytes.
 setArchiveSuffixes ($a_suffixes)
 Set accepted archive suffixes.
 getArchiveSuffixes ()
 Get accepted archive suffixes.
 setSuffixes ($a_suffixes)
 Set accepted suffixes.
 getSuffixes ()
 Get accepted suffixes.
 setInputFieldName ($a_name)
 Sets the name of the input field the files are submitted with.
 getInputFieldName ()
 Gets the name of the input field the files are submitted with.
 setDropAreaId ($a_id)
 getDropAreaId ()
 setFileListId ($a_id)
 getFileListId ()
 setFileSelectButtonId ($a_id)
 getFileSelectButtonId ()

Static Public Member Functions

static initFileUpload ()
 Initializes the file upload and loads the needed javascripts and styles.

Data Fields

const FILE_OBJ_GUI_CLASS = "ilObjFileGUI"

Protected Member Functions

 getSharedHtml ()
 Gets the code that is shared by all upload instances.
 buildSuffixList ($suffixes)

Private Member Functions

 getUploadUrl ()
 makeJqueryId ($a_id)

Private Attributes

 $drop_zone_id = null
 $ref_id = null
 $current_obj = false
 $max_file_size = null
 $suffixes = array()
 $archive_suffixes = array()
 $input_field_name = "upload_files"
 $input_field_id = null
 $use_form = false
 $drop_area_id = null
 $submit_button_name = null
 $cancel_button_name = null
 $file_list_id = null
 $file_select_button_id = null

Static Private Attributes

static $shared_code_loaded = false

Detailed Description

Definition at line 15 of file class.ilFileUploadGUI.php.

Constructor & Destructor Documentation

ilFileUploadGUI::__construct (   $a_drop_zone_id,
  $a_ref_id = null,
  $current_obj = false 
)

Creates a new file upload GUI.

Definition at line 38 of file class.ilFileUploadGUI.php.

References $current_obj, and $ilCtrl.

{
global $ilCtrl;
$this->drop_zone_id = $a_drop_zone_id;
$this->ref_id = $a_ref_id;
$this->current_obj = $current_obj;
}

Member Function Documentation

ilFileUploadGUI::buildSuffixList (   $suffixes)
protected

Definition at line 228 of file class.ilFileUploadGUI.php.

References $suffixes.

Referenced by getHTML().

{
$list = $delim = "";
if (is_array($suffixes) && count($suffixes) > 0)
{
foreach($suffixes as $suffix)
{
$list .= $delim . "\"" . $suffix . "\"";
$delim = ", ";
}
}
return $list;
}

+ Here is the caller graph for this function:

ilFileUploadGUI::enableFormSubmit (   $input_field_id,
  $a_submit_name,
  $a_cancel_name 
)

Definition at line 244 of file class.ilFileUploadGUI.php.

References $input_field_id.

{
$this->use_form = true;
$this->input_field_id = $input_field_id;
$this->submit_button_name = $a_submit_name;
$this->cancel_button_name = $a_cancel_name;
}
ilFileUploadGUI::getArchiveSuffixes ( )

Get accepted archive suffixes.

Returns
array Accepted archive suffixes.

Definition at line 285 of file class.ilFileUploadGUI.php.

References $archive_suffixes.

Referenced by getHTML().

+ Here is the caller graph for this function:

ilFileUploadGUI::getDropAreaId ( )

Definition at line 335 of file class.ilFileUploadGUI.php.

References $drop_area_id.

{
}
ilFileUploadGUI::getFileListId ( )

Definition at line 345 of file class.ilFileUploadGUI.php.

References $file_list_id.

{
}
ilFileUploadGUI::getFileSelectButtonId ( )

Definition at line 355 of file class.ilFileUploadGUI.php.

References $file_select_button_id.

ilFileUploadGUI::getHTML ( )

Gets the HTML code to enable the file upload.

Returns
string The created HTML.

Definition at line 71 of file class.ilFileUploadGUI.php.

References $cancel_button_name, $ilCtrl, $input_field_name, $lng, $options, $ref_id, $submit_button_name, $tpl, ilObject\_lookupObjId(), ilObject\_lookupTitle(), buildSuffixList(), ilJsonUtil\encode(), getArchiveSuffixes(), getMaxFileSize(), getSharedHtml(), getSuffixes(), getUploadUrl(), and makeJqueryId().

{
global $lng, $ilCtrl, $tpl;
// get values
// build options
$options = new stdClass();
$options->dropZone = $this->makeJqueryId($this->drop_zone_id);
// set url
$url = $this->getUploadUrl();
if ($url === false)
return "";
if ($url != null)
$options->url = $this->getUploadUrl();
// get title and replace quotes with HTML entities
if ($this->ref_id != null && !$this->use_form)
{
$title = str_replace("\"", """, $title);
$title = str_replace("'", "'", $title);
$options->listTitle = $title;
}
// input field (use id if specified)
if ($this->input_field_id != null)
$options->fileInput = $this->makeJqueryId($this->input_field_id);
else if ($this->input_field_name != null)
// buttons
if ($this->submit_button_name != null)
if ($this->cancel_button_name != null)
// drop area
if ($this->drop_area_id != null)
$options->dropArea = $this->makeJqueryId($this->drop_area_id);
// file list
if ($this->file_list_id != null)
$options->fileList = $this->makeJqueryId($this->file_list_id);
// file list
if ($this->file_select_button_id != null)
$options->fileSelectButton = $this->makeJqueryId($this->file_select_button_id);
// max size
$max_size = $this->getMaxFileSize();
if ($max_size != null)
$options->maxFileSize = $max_size;
// allowed extensions
$allowed_suffixes = $this->buildSuffixList($this->getSuffixes());
if ($allowed_suffixes != "")
$options->allowedExtensions = "[" . $allowed_suffixes . "]";
// supported archive extensions
$supported_archives = $this->buildSuffixList($this->getArchiveSuffixes());
if ($supported_archives != "")
$options->supportedArchives = "[" . $supported_archives . "]";
// inject load script
include_once("./Services/JSON/classes/class.ilJsonUtil.php");
$onLoadCode = "";
if ($this->use_form)
$onLoadCode = "var fileUpload$id = new ilFileUpload($id, " . ilJsonUtil::encode($options) . ");";
else
$onLoadCode = "il.FileUpload.add(\"$id\", " . ilJsonUtil::encode($options) . ", " . ($this->current_obj ? "true" : "false") . ");";
$tpl->addOnLoadCode($onLoadCode);
// return shared code
return $this->getSharedHtml();
}

+ Here is the call graph for this function:

ilFileUploadGUI::getInputFieldName ( )

Gets the name of the input field the files are submitted with.

Returns
string The name of the input field.

Definition at line 325 of file class.ilFileUploadGUI.php.

References $input_field_name.

ilFileUploadGUI::getMaxFileSize ( )

Gets the maximum file size in bytes.

Definition at line 265 of file class.ilFileUploadGUI.php.

References $max_file_size.

Referenced by getHTML().

{
}

+ Here is the caller graph for this function:

ilFileUploadGUI::getSharedHtml ( )
protected

Gets the code that is shared by all upload instances.

Returns
string The shared code by all upload instances.

Definition at line 158 of file class.ilFileUploadGUI.php.

References $lng, ilFileUploadSettings\getConcurrentUploads(), ilUtil\getImagePath(), ilFileUploadUtil\getMaxFileSize(), and initFileUpload().

Referenced by getHTML().

{
global $lng;
// already loaded?
if (self::$shared_code_loaded)
return "";
// make sure required scripts are loaded
// load script template
$tpl_shared = new ilTemplate("tpl.fileupload_shared.html", true, true, "Services/FileUpload");
// initialize localized texts
$lng->loadLanguageModule("form");
$tpl_shared->setCurrentBlock("fileupload_texts");
$tpl_shared->setVariable("ERROR_MSG_FILE_TOO_LARGE", $lng->txt("form_msg_file_size_exceeds"));
$tpl_shared->setVariable("ERROR_MSG_WRONG_FILE_TYPE", $lng->txt("form_msg_file_wrong_file_type"));
$tpl_shared->setVariable("ERROR_MSG_EMPTY_FILE_OR_FOLDER", $lng->txt("error_empty_file_or_folder"));
$tpl_shared->setVariable("ERROR_MSG_UPLOAD_ZERO_BYTES", $lng->txt("error_upload_was_zero_bytes"));
$tpl_shared->setVariable("QUESTION_CANCEL_ALL", $lng->txt("cancel_file_upload"));
$tpl_shared->setVariable("ERROR_MSG_EXTRACT_FAILED", $lng->txt("error_extraction_failed"));
$tpl_shared->setVariable("PROGRESS_UPLOADING", $lng->txt("uploading"));
$tpl_shared->setVariable("PROGRESS_EXTRACTING", $lng->txt("extracting"));
$tpl_shared->setVariable("DROP_FILES_HERE", $lng->txt("drop_files_on_repo_obj_info"));
$tpl_shared->parseCurrentBlock();
// initialize default values
$tpl_shared->setCurrentBlock("fileupload_defaults");
$tpl_shared->setVariable("CONCURRENT_UPLOADS", ilFileUploadSettings::getConcurrentUploads());
$tpl_shared->setVariable("MAX_FILE_SIZE", ilFileUploadUtil::getMaxFileSize());
$tpl_shared->setVariable("ALLOWED_SUFFIXES", "");
$tpl_shared->setVariable("SUPPORTED_ARCHIVES", "\"zip\"");
$tpl_shared->parseCurrentBlock();
// load panel template
$tpl_panel = new ilTemplate("tpl.fileupload_panel_template.html", true, true, "Services/FileUpload");
$tpl_panel->setVariable("TXT_HEADER", $lng->txt("upload_files_title"));
$tpl_panel->setVariable("TXT_SHOW_ALL_DETAILS", $lng->txt('show_all_details'));
$tpl_panel->setVariable("TXT_HIDE_ALL_DETAILS", $lng->txt('hide_all_details'));
$tpl_shared->setCurrentBlock("fileupload_panel_tmpl");
$tpl_shared->setVariable("PANEL_TEMPLATE_HTML", $tpl_panel->get());
$tpl_shared->parseCurrentBlock();
// load row template
$tpl_row = new ilTemplate("tpl.fileupload_row_template.html", true, true, "Services/FileUpload");
$tpl_row->setVariable("IMG_ALERT", ilUtil::getImagePath("icon_alert_s.gif"));
$tpl_row->setVariable("ALT_ALERT", $lng->txt("alert"));
$tpl_row->setVariable("TXT_CANCEL", $lng->txt("cancel"));
$tpl_row->setVariable("TXT_REMOVE", $lng->txt("remove"));
$tpl_row->setVariable("TXT_TITLE", $lng->txt("title"));
$tpl_row->setVariable("TXT_DESCRIPTION", $lng->txt("description"));
$tpl_row->setVariable("TXT_EXTRACT", $lng->txt("unzip"));
$tpl_row->setVariable("TXT_KEEP_STRUCTURE", $lng->txt("take_over_structure"));
$tpl_row->setVariable("TXT_KEEP_STRUCTURE_INFO", $lng->txt("take_over_structure_info"));
$tpl_row->setVariable("TXT_PENDING", $lng->txt("upload_pending"));
$tpl_shared->setCurrentBlock("fileupload_row_tmpl");
$tpl_shared->setVariable("ROW_TEMPLATE_HTML", $tpl_row->get());
$tpl_shared->parseCurrentBlock();
// shared code now loaded
self::$shared_code_loaded = true;
// create HTML
return $tpl_shared->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilFileUploadGUI::getSuffixes ( )

Get accepted suffixes.

Returns
array Accepted suffixes.

Definition at line 305 of file class.ilFileUploadGUI.php.

References $suffixes.

Referenced by getHTML().

{
}

+ Here is the caller graph for this function:

ilFileUploadGUI::getUploadUrl ( )
private

Definition at line 360 of file class.ilFileUploadGUI.php.

References $ilCtrl, and ilFileUploadUtil\isUploadSupported().

Referenced by getHTML().

{
global $ilCtrl;
// return null when the form is used
if ($this->use_form)
return null;
// check if supported
return false;
// build upload URL
include_once("Modules/File/classes/class.ilObjFileGUI.php");
$ilCtrl->setParameterByClass(self::FILE_OBJ_GUI_CLASS, "ref_id", $this->ref_id);
$ilCtrl->setParameterByClass(self::FILE_OBJ_GUI_CLASS, "new_type", "file");
return $ilCtrl->getFormActionByClass(self::FILE_OBJ_GUI_CLASS, "uploadFiles", "", true, false);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilFileUploadGUI::initFileUpload ( )
static

Initializes the file upload and loads the needed javascripts and styles.

Definition at line 50 of file class.ilFileUploadGUI.php.

References $tpl, and ilUtil\getStyleSheetLocation().

Referenced by ilObjectGUI\enableDragDropFileUpload(), ilCloudPluginItemCreationListGUI\getGroupedListItemsHTML(), getSharedHtml(), ilObjectListGUI\insertFileUpload(), and ilDragDropFileInputGUI\render().

{
global $tpl;
// needed scripts
$tpl->addJavaScript("./Services/FileUpload/js/tmpl.js");
$tpl->addJavaScript("./Services/FileUpload/js/jquery.ui.widget.js");
$tpl->addJavaScript("./Services/FileUpload/js/jquery.iframe-transport.js");
$tpl->addJavaScript("./Services/FileUpload/js/jquery.fileupload.js");
$tpl->addJavaScript("./Services/FileUpload/js/jquery.ba-dotimeout.min.js");
$tpl->addJavaScript("./Services/FileUpload/js/ilFileUpload.js");
// needed styles
$tpl->addCss(ilUtil::getStyleSheetLocation("filesystem", "fileupload.css", "Services/FileUpload"));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilFileUploadGUI::makeJqueryId (   $a_id)
private

Definition at line 380 of file class.ilFileUploadGUI.php.

Referenced by getHTML().

{
if ($a_id != null && count($a_id) > 0)
{
if ($a_id[0] != "#")
return "#" . $a_id;
}
return $a_id;
}

+ Here is the caller graph for this function:

ilFileUploadGUI::setArchiveSuffixes (   $a_suffixes)

Set accepted archive suffixes.

Parameters
array$a_suffixesAccepted archive suffixes.

Definition at line 275 of file class.ilFileUploadGUI.php.

{
$this->archive_suffixes = $a_suffixes;
}
ilFileUploadGUI::setDropAreaId (   $a_id)

Definition at line 330 of file class.ilFileUploadGUI.php.

{
$this->drop_area_id = $a_id;
}
ilFileUploadGUI::setFileListId (   $a_id)

Definition at line 340 of file class.ilFileUploadGUI.php.

{
$this->file_list_id = $a_id;
}
ilFileUploadGUI::setFileSelectButtonId (   $a_id)

Definition at line 350 of file class.ilFileUploadGUI.php.

{
$this->file_select_button_id = $a_id;
}
ilFileUploadGUI::setInputFieldName (   $a_name)

Sets the name of the input field the files are submitted with.

Parameters
string$a_nameThe name of the input field.

Definition at line 315 of file class.ilFileUploadGUI.php.

{
$this->input_field_name = $a_name;
}
ilFileUploadGUI::setMaxFileSize (   $a_max)

Sets the maximum file size in bytes.

Parameters
int$a_max_sizeThe maximum file size in bytes.

Definition at line 257 of file class.ilFileUploadGUI.php.

{
$this->max_file_size = $a_max;
}
ilFileUploadGUI::setSuffixes (   $a_suffixes)

Set accepted suffixes.

Parameters
array$a_suffixesAccepted suffixes.

Definition at line 295 of file class.ilFileUploadGUI.php.

{
$this->suffixes = $a_suffixes;
}

Field Documentation

ilFileUploadGUI::$archive_suffixes = array()
private

Definition at line 25 of file class.ilFileUploadGUI.php.

Referenced by getArchiveSuffixes().

ilFileUploadGUI::$cancel_button_name = null
private

Definition at line 31 of file class.ilFileUploadGUI.php.

Referenced by getHTML().

ilFileUploadGUI::$current_obj = false
private

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

Referenced by __construct().

ilFileUploadGUI::$drop_area_id = null
private

Definition at line 29 of file class.ilFileUploadGUI.php.

Referenced by getDropAreaId().

ilFileUploadGUI::$drop_zone_id = null
private

Definition at line 20 of file class.ilFileUploadGUI.php.

ilFileUploadGUI::$file_list_id = null
private

Definition at line 32 of file class.ilFileUploadGUI.php.

Referenced by getFileListId().

ilFileUploadGUI::$file_select_button_id = null
private

Definition at line 33 of file class.ilFileUploadGUI.php.

Referenced by getFileSelectButtonId().

ilFileUploadGUI::$input_field_id = null
private

Definition at line 27 of file class.ilFileUploadGUI.php.

Referenced by enableFormSubmit().

ilFileUploadGUI::$input_field_name = "upload_files"
private

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

Referenced by getHTML(), and getInputFieldName().

ilFileUploadGUI::$max_file_size = null
private

Definition at line 23 of file class.ilFileUploadGUI.php.

Referenced by getMaxFileSize().

ilFileUploadGUI::$ref_id = null
private

Definition at line 21 of file class.ilFileUploadGUI.php.

Referenced by getHTML().

ilFileUploadGUI::$shared_code_loaded = false
staticprivate

Definition at line 18 of file class.ilFileUploadGUI.php.

ilFileUploadGUI::$submit_button_name = null
private

Definition at line 30 of file class.ilFileUploadGUI.php.

Referenced by getHTML().

ilFileUploadGUI::$suffixes = array()
private

Definition at line 24 of file class.ilFileUploadGUI.php.

Referenced by buildSuffixList(), and getSuffixes().

ilFileUploadGUI::$use_form = false
private

Definition at line 28 of file class.ilFileUploadGUI.php.

const ilFileUploadGUI::FILE_OBJ_GUI_CLASS = "ilObjFileGUI"

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


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