ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilDragDropFileInputGUI Class Reference

This class represents a file input property where multiple files can be dopped in a property form. More...

+ Inheritance diagram for ilDragDropFileInputGUI:
+ Collaboration diagram for ilDragDropFileInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor.
 setArchiveSuffixes ($a_suffixes)
 Set accepted archive suffixes.
 getArchiveSuffixes ()
 Get accepted archive suffixes.
 setCommandButtonNames ($a_submit_name, $a_cancel_name)
 render ($a_mode="")
 Render html.
 checkInput ()
 Check input, strip slashes etc.
- Public Member Functions inherited from ilFileInputGUI
 setValueByArray ($a_values)
 Set value by array.
 setValue ($a_value)
 Set Value.
 getValue ()
 Get Value.
 setSize ($a_size)
 Set Size.
 getSize ()
 Get Size.
 setFilename ($a_val)
 Set filename value (if filename selection is enabled)
 getFilename ()
 Get Value.
 setSuffixes ($a_suffixes)
 Set Accepted Suffixes.
 getSuffixes ()
 Get Accepted Suffixes.
 setPending ($a_val)
 Set pending filename value.
 getPending ()
 Get pending filename.
 enableFileNameSelection ($a_post_var)
 If enabled, users get the possibility to enter a filename for the uploaded file.
 isFileNameSelectionEnabled ()
 Check if filename selection is enabled.
 getFileNamePostVar ()
 Get file name post var.
 setALlowDeletion ($a_val)
 Set allow deletion.
 getALlowDeletion ()
 Get allow deletion.
 insert (&$a_tpl)
 Insert property html.
 getDeletionFlag ()
 Get deletion flag.
 getToolbarHTML ()
 Get HTML for toolbar.
 setPersonalWorkspaceQuotaCheck ($a_value)
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem.
 getSubItems ()
 Get Subitems.
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively
 checkSubItemsInput ()
 Check SubItems.
 getSubForm ()
 Get sub form html.
 getItemByPostVar ($a_post_var)
 Get item by post var.
- Public Member Functions inherited from ilFormPropertyGUI
executeCommand ()
 Execute command.
 getType ()
 Get Type.
 setTitle ($a_title)
 Set Title.
 getTitle ()
 Get Title.
 setPostVar ($a_postvar)
 Set Post Variable.
 getPostVar ()
 Get Post Variable.
 getFieldId ()
 Get Post Variable.
 setInfo ($a_info)
 Set Information Text.
 getInfo ()
 Get Information Text.
 setAlert ($a_alert)
 Set Alert Text.
 getAlert ()
 Get Alert Text.
 setRequired ($a_required)
 Set Required.
 getRequired ()
 Get Required.
 setDisabled ($a_disabled)
 Set Disabled.
 getDisabled ()
 Get Disabled.
 setParentForm ($a_parentform)
 Set Parent Form.
 getParentForm ()
 Get Parent Form.
 setParent ($a_val)
 Set Parent GUI object.
 getParent ()
 Get Parent GUI object.
 hideSubForm ()
 Sub form hidden on init?
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders)
 getHiddenTitle ()
 Get hidden title.
 serializeData ()
 serialize data
 unserializeData ($a_data)
 unserialize data
 writeToSession ()
 Write to session.
 clearFromSession ()
 Clear session value.
 readFromSession ()
 Read from session.
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties)
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi.
 getMulti ()
 Get Multi.
 setMultiValues (array $a_values)
 Set multi values.
 getMultiValues ()
 Get multi values.
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g.

Protected Member Functions

 getInputAcceptSuffixes ($suffixes)
 buildSuffixList ($suffixes)
 getMaxFileSize ()
- Protected Member Functions inherited from ilFileInputGUI
 outputSuffixes ($a_tpl, $a_block="allowed_suffixes")
 getMaxFileSizeString ()

Static Private Member Functions

static getNextUniqueId ()

Private Attributes

 $uniqueId = 0
 $archive_suffixes = array()
 $submit_button_name = null
 $cancel_button_name = null

Static Private Attributes

static $uniqueInc = 1

Additional Inherited Members

- Protected Attributes inherited from ilFileInputGUI
 $size = 40
 $pending
 $allow_deletion
- Static Protected Attributes inherited from ilFileInputGUI
static $check_wsp_quota

Detailed Description

This class represents a file input property where multiple files can be dopped in a property form.

Author
Stefan Born stefa.nosp@m.n.bo.nosp@m.rn@ph.nosp@m.zh.c.nosp@m.h
Version
$Id$

Definition at line 13 of file class.ilDragDropFileInputGUI.php.

Constructor & Destructor Documentation

ilDragDropFileInputGUI::__construct (   $a_title = "",
  $a_postvar = "" 
)

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Reimplemented from ilFileInputGUI.

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

References getNextUniqueId().

{
parent::__construct($a_title, $a_postvar);
$this->uniqueId = self::getNextUniqueId();
}

+ Here is the call graph for this function:

Member Function Documentation

ilDragDropFileInputGUI::buildSuffixList (   $suffixes)
protected

Definition at line 191 of file class.ilDragDropFileInputGUI.php.

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

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Reimplemented from ilFileInputGUI.

Definition at line 141 of file class.ilDragDropFileInputGUI.php.

References $_POST, $lng, ilFormPropertyGUI\getPostVar(), and ilFormPropertyGUI\setAlert().

{
global $lng;
// if no information is received, something went wrong
// this is e.g. the case, if the post_max_size has been exceeded
if (!is_array($_FILES[$this->getPostVar()]))
{
$this->setAlert($lng->txt("form_msg_file_size_exceeds"));
return false;
}
// empty file, could be a folder
if ($_FILES[$this->getPostVar()]["size"] < 1)
{
$this->setAlert($lng->txt("error_upload_was_zero_bytes"));
return false;
}
// call base
$inputValid = parent::checkInput();
// set additionally sent input on post array
if ($inputValid)
{
$_POST[$this->getPostVar()]["extract"] = isset($_POST["extract"]) ? (bool)$_POST["extract"] : false;
$_POST[$this->getPostVar()]["title"] = isset($_POST["title"]) ? $_POST["title"] : "";
$_POST[$this->getPostVar()]["description"] = isset($_POST["description"]) ? $_POST["description"] : "";
$_POST[$this->getPostVar()]["keep_structure"] = isset($_POST["keep_structure"]) ? (bool)$_POST["keep_structure"] : true;
}
return $inputValid;
}

+ Here is the call graph for this function:

ilDragDropFileInputGUI::getArchiveSuffixes ( )

Get accepted archive suffixes.

Returns
array Accepted archive suffixes.

Definition at line 54 of file class.ilDragDropFileInputGUI.php.

References $archive_suffixes.

ilDragDropFileInputGUI::getInputAcceptSuffixes (   $suffixes)
protected

Definition at line 175 of file class.ilDragDropFileInputGUI.php.

Referenced by render().

{
$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:

ilDragDropFileInputGUI::getMaxFileSize ( )
protected

Definition at line 207 of file class.ilDragDropFileInputGUI.php.

{
// get the value for the maximal uploadable filesize from the php.ini (if available)
$umf = ini_get("upload_max_filesize");
// get the value for the maximal post data from the php.ini (if available)
$pms = ini_get("post_max_size");
//convert from short-string representation to "real" bytes
$multiplier_a=array("K"=>1024, "M"=>1024*1024, "G"=>1024*1024*1024);
$umf_parts=preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
$pms_parts=preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
if (count($umf_parts) == 2) {
$umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]];
}
if (count($pms_parts) == 2) {
$pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]];
}
// use the smaller one as limit
$max_filesize = min($umf, $pms);
if (!$max_filesize)
$max_filesize=max($umf, $pms);
return $max_filesize;
}
static ilDragDropFileInputGUI::getNextUniqueId ( )
staticprivate

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

Referenced by __construct().

{
return self::$uniqueInc++;
}

+ Here is the caller graph for this function:

ilDragDropFileInputGUI::render (   $a_mode = "")

Render html.

Reimplemented from ilFileInputGUI.

Definition at line 68 of file class.ilDragDropFileInputGUI.php.

References $ilUser, $lng, $tpl, ilObject\_getIcon(), getInputAcceptSuffixes(), ilFileInputGUI\getMaxFileSizeString(), ilDiskQuotaHandler\getStatusLegend(), ilFileInputGUI\getSuffixes(), ilFileUploadGUI\initFileUpload(), iljQueryUtil\initjQuery(), ilDiskQuotaHandler\isUploadPossible(), and ilFileInputGUI\outputSuffixes().

{
global $lng, $tpl, $ilUser;
$quota_exceeded = $quota_legend = false;
if(self::$check_wsp_quota)
{
include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
{
$lng->loadLanguageModule("file");
return $lng->txt("personal_workspace_quota_exceeded_warning");
}
else
{
}
}
// make sure jQuery is loaded
// add file upload scripts
include_once("./Services/FileUpload/classes/class.ilFileUploadGUI.php");
// load template
$this->tpl = new ilTemplate("tpl.prop_dndfiles.html", true, true, "Services/Form");
// general variables
$this->tpl->setVariable("UPLOAD_ID", $this->uniqueId);
// input
$this->tpl->setVariable("FILE_SELECT_ICON", ilObject::_getIcon("", "", "fold"));
$this->tpl->setVariable("TXT_SHOW_ALL_DETAILS", $lng->txt('show_all_details'));
$this->tpl->setVariable("TXT_HIDE_ALL_DETAILS", $lng->txt('hide_all_details'));
$this->tpl->setVariable("TXT_SELECTED_FILES", $lng->txt('selected_files'));
$this->tpl->setVariable("TXT_DRAG_FILES_HERE", $lng->txt('drag_files_here'));
$this->tpl->setVariable("TXT_NUM_OF_SELECTED_FILES", $lng->txt('num_of_selected_files'));
$this->tpl->setVariable("TXT_SELECT_FILES_FROM_COMPUTER", $lng->txt('select_files_from_computer'));
$this->tpl->setVariable("TXT_OR", $lng->txt('logic_or'));
$this->tpl->setVariable("INPUT_ACCEPT_SUFFIXES", $this->getInputAcceptSuffixes($this->getSuffixes()));
// info
$this->tpl->setCurrentBlock("max_size");
$this->tpl->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice")." ".$this->getMaxFileSizeString());
$this->tpl->parseCurrentBlock();
if($quota_legend)
{
$this->tpl->setVariable("TXT_MAX_SIZE", $quota_legend);
$this->tpl->parseCurrentBlock();
}
$this->outputSuffixes($this->tpl);
// create file upload object
$upload = new ilFileUploadGUI("ilFileUploadDropZone_" . $this->uniqueId, $this->uniqueId, false);
$upload->enableFormSubmit("ilFileUploadInput_" . $this->uniqueId, $this->submit_button_name, $this->cancel_button_name);
$upload->setDropAreaId("ilFileUploadDropArea_" . $this->uniqueId);
$upload->setFileListId("ilFileUploadList_" . $this->uniqueId);
$upload->setFileSelectButtonId("ilFileUploadFileSelect_" . $this->uniqueId);
$this->tpl->setVariable("FILE_UPLOAD", $upload->getHTML());
return $this->tpl->get();
}

+ Here is the call graph for this function:

ilDragDropFileInputGUI::setArchiveSuffixes (   $a_suffixes)

Set accepted archive suffixes.

Parameters
array$a_suffixesAccepted archive suffixes.

Definition at line 44 of file class.ilDragDropFileInputGUI.php.

Referenced by ilObjFileGUI\initMultiUploadForm().

{
$this->archive_suffixes = $a_suffixes;
}

+ Here is the caller graph for this function:

ilDragDropFileInputGUI::setCommandButtonNames (   $a_submit_name,
  $a_cancel_name 
)

Definition at line 59 of file class.ilDragDropFileInputGUI.php.

{
$this->submit_button_name = $a_submit_name;
$this->cancel_button_name = $a_cancel_name;
}

Field Documentation

ilDragDropFileInputGUI::$archive_suffixes = array()
private

Definition at line 16 of file class.ilDragDropFileInputGUI.php.

Referenced by getArchiveSuffixes().

ilDragDropFileInputGUI::$cancel_button_name = null
private

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

ilDragDropFileInputGUI::$submit_button_name = null
private

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

ilDragDropFileInputGUI::$uniqueId = 0
private

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

ilDragDropFileInputGUI::$uniqueInc = 1
staticprivate

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


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