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

This class represents a file property in a property form. More...

+ Inheritance diagram for ilFileInputGUI:
+ Collaboration diagram for ilFileInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor.
 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.
 checkInput ()
 Check input, strip slashes etc.
 render ($a_mode="")
 Render html.
 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

 outputSuffixes ($a_tpl, $a_block="allowed_suffixes")
 getMaxFileSizeString ()

Protected Attributes

 $size = 40
 $pending
 $allow_deletion
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
 $sub_items = array()
- Protected Attributes inherited from ilFormPropertyGUI
 $type
 $title
 $postvar
 $info
 $alert
 $required = false
 $parentgui
 $parentform
 $hidden_title = ""
 $multi = false
 $multi_sortable = false
 $multi_addremove = true
 $multi_values

Static Protected Attributes

static $check_wsp_quota

Private Attributes

 $filename
 $filename_post

Detailed Description

This class represents a file property in a property form.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 14 of file class.ilFileInputGUI.php.

Constructor & Destructor Documentation

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Reimplemented from ilFormPropertyGUI.

Reimplemented in ilFileWizardInputGUI, ilDragDropFileInputGUI, ilImagemapFileInputGUI, ilFlashFileInputGUI, and ilImageFileInputGUI.

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

References $lng, ilFormPropertyGUI\setHiddenTitle(), and ilFormPropertyGUI\setType().

{
global $lng;
parent::__construct($a_title, $a_postvar);
$this->setType("file");
$this->setHiddenTitle("(".$lng->txt("form_file_input").")");
}

+ Here is the call graph for this function:

Member Function Documentation

ilFileInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Reimplemented from ilFormPropertyGUI.

Reimplemented in ilDragDropFileInputGUI, ilImagemapFileInputGUI, ilFileWizardInputGUI, and ilFlashFileInputGUI.

Definition at line 216 of file class.ilFileInputGUI.php.

References $_POST, $filename, $lng, ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), getSuffixes(), getValue(), ilFormPropertyGUI\setAlert(), ilUtil\stripSlashes(), and ilUtil\virusHandling().

{
global $lng;
$_FILES[$this->getPostVar()]["name"] = ilUtil::stripSlashes($_FILES[$this->getPostVar()]["name"]);
$_FILES[$this->getPostVar()]["name"] = rtrim($_FILES[$this->getPostVar()]["name"], "/");
$filename = $_FILES[$this->getPostVar()]["name"];
$filename_arr = pathinfo($_FILES[$this->getPostVar()]["name"]);
$suffix = $filename_arr["extension"];
$mimetype = $_FILES[$this->getPostVar()]["type"];
$size_bytes = $_FILES[$this->getPostVar()]["size"];
$temp_name = $_FILES[$this->getPostVar()]["tmp_name"];
$error = $_FILES[$this->getPostVar()]["error"];
$_POST[$this->getPostVar()] = $_FILES[$this->getPostVar()];
// 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;
}
// error handling
if ($error > 0)
{
switch ($error)
{
case UPLOAD_ERR_INI_SIZE:
$this->setAlert($lng->txt("form_msg_file_size_exceeds"));
return false;
break;
case UPLOAD_ERR_FORM_SIZE:
$this->setAlert($lng->txt("form_msg_file_size_exceeds"));
return false;
break;
case UPLOAD_ERR_PARTIAL:
$this->setAlert($lng->txt("form_msg_file_partially_uploaded"));
return false;
break;
case UPLOAD_ERR_NO_FILE:
if ($this->getRequired())
{
if (!strlen($this->getValue()))
{
$this->setAlert($lng->txt("form_msg_file_no_upload"));
return false;
}
}
break;
case UPLOAD_ERR_NO_TMP_DIR:
$this->setAlert($lng->txt("form_msg_file_missing_tmp_dir"));
return false;
break;
case UPLOAD_ERR_CANT_WRITE:
$this->setAlert($lng->txt("form_msg_file_cannot_write_to_disk"));
return false;
break;
case UPLOAD_ERR_EXTENSION:
$this->setAlert($lng->txt("form_msg_file_upload_stopped_ext"));
return false;
break;
}
}
// check suffixes
if ($_FILES[$this->getPostVar()]["tmp_name"] != "" &&
is_array($this->getSuffixes()) && count($this->getSuffixes()) > 0)
{
if (!in_array(strtolower($suffix), $this->getSuffixes()))
{
$this->setAlert($lng->txt("form_msg_file_wrong_file_type"));
return false;
}
}
// virus handling
if ($_FILES[$this->getPostVar()]["tmp_name"] != "")
{
$vir = ilUtil::virusHandling($temp_name, $filename);
if ($vir[0] == false)
{
$this->setAlert($lng->txt("form_msg_file_virus_found")."<br />".$vir[1]);
return false;
}
}
return true;
}

+ Here is the call graph for this function:

ilFileInputGUI::enableFileNameSelection (   $a_post_var)

If enabled, users get the possibility to enter a filename for the uploaded file.

public

Parameters
stringpost variable

Definition at line 162 of file class.ilFileInputGUI.php.

{
$this->filename_selection = true;
$this->filename_post = $a_post_var;
}
ilFileInputGUI::getALlowDeletion ( )

Get allow deletion.

Returns
boolean allow deletion

Reimplemented in ilImageFileInputGUI.

Definition at line 206 of file class.ilFileInputGUI.php.

References $allow_deletion.

Referenced by render().

{
}

+ Here is the caller graph for this function:

ilFileInputGUI::getDeletionFlag ( )

Get deletion flag.

Reimplemented in ilFlashFileInputGUI, and ilImageFileInputGUI.

Definition at line 483 of file class.ilFileInputGUI.php.

References $_POST, and ilFormPropertyGUI\getPostVar().

{
if ($_POST[$this->getPostVar()."_delete"])
{
return true;
}
return false;
}

+ Here is the call graph for this function:

ilFileInputGUI::getFilename ( )

Get Value.

Returns
string Value

Definition at line 108 of file class.ilFileInputGUI.php.

References $filename.

Referenced by render().

{
}

+ Here is the caller graph for this function:

ilFileInputGUI::getFileNamePostVar ( )

Get file name post var.

public

Parameters
stringfile name post var

Definition at line 186 of file class.ilFileInputGUI.php.

References $filename_post.

Referenced by render(), and setValueByArray().

{
}

+ Here is the caller graph for this function:

ilFileInputGUI::getMaxFileSizeString ( )
protected

Definition at line 453 of file class.ilFileInputGUI.php.

Referenced by ilImageFileInputGUI\insert(), ilFileWizardInputGUI\insert(), ilImagemapFileInputGUI\insert(), ilFlashFileInputGUI\insert(), ilDragDropFileInputGUI\render(), and render().

{
// 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);
//format for display in mega-bytes
$max_filesize = sprintf("%.1f MB",$max_filesize/1024/1024);
return $max_filesize;
}

+ Here is the caller graph for this function:

ilFileInputGUI::getPending ( )

Get pending filename.

Returns
string Value

Definition at line 150 of file class.ilFileInputGUI.php.

References $pending.

Referenced by ilImageFileInputGUI\insert(), and render().

{
}

+ Here is the caller graph for this function:

ilFileInputGUI::getSize ( )

Get Size.

Returns
int Size

Definition at line 88 of file class.ilFileInputGUI.php.

References $size.

Referenced by render().

{
return $this->size;
}

+ Here is the caller graph for this function:

ilFileInputGUI::getSuffixes ( )

Get Accepted Suffixes.

Returns
array Accepted Suffixes

Definition at line 130 of file class.ilFileInputGUI.php.

Referenced by ilFlashFileInputGUI\checkInput(), ilFileWizardInputGUI\checkInput(), ilImagemapFileInputGUI\checkInput(), checkInput(), outputSuffixes(), and ilDragDropFileInputGUI\render().

{
return $this->suffixes;
}

+ Here is the caller graph for this function:

ilFileInputGUI::getToolbarHTML ( )

Get HTML for toolbar.

Implements ilToolbarItem.

Definition at line 495 of file class.ilFileInputGUI.php.

References render().

{
$html = $this->render("toolbar");
return $html;
}

+ Here is the call graph for this function:

ilFileInputGUI::getValue ( )

Get Value.

Returns
string Value

Reimplemented in ilFlashFileInputGUI.

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

Referenced by ilImagemapFileInputGUI\checkInput(), checkInput(), ilImageFileInputGUI\insert(), ilImagemapFileInputGUI\insert(), and render().

{
return $this->value;
}

+ Here is the caller graph for this function:

ilFileInputGUI::insert ( $a_tpl)

Insert property html.

Returns
int Size

Reimplemented in ilFlashFileInputGUI, ilImagemapFileInputGUI, ilFileWizardInputGUI, and ilImageFileInputGUI.

Definition at line 424 of file class.ilFileInputGUI.php.

References render().

{
$html = $this->render();
$a_tpl->setCurrentBlock("prop_generic");
$a_tpl->setVariable("PROP_GENERIC", $html);
$a_tpl->parseCurrentBlock();
}

+ Here is the call graph for this function:

ilFileInputGUI::isFileNameSelectionEnabled ( )

Check if filename selection is enabled.

public

Returns
bool enabled/disabled

Definition at line 174 of file class.ilFileInputGUI.php.

Referenced by render().

{
return $this->filename_selection ? true : false;
}

+ Here is the caller graph for this function:

ilFileInputGUI::outputSuffixes (   $a_tpl,
  $a_block = "allowed_suffixes" 
)
protected

Definition at line 434 of file class.ilFileInputGUI.php.

References $lng, and getSuffixes().

Referenced by ilImageFileInputGUI\insert(), ilFileWizardInputGUI\insert(), ilImagemapFileInputGUI\insert(), ilFlashFileInputGUI\insert(), ilDragDropFileInputGUI\render(), and render().

{
global $lng;
if (is_array($this->getSuffixes()) && count($this->getSuffixes()) > 0)
{
$suff_str = $delim = "";
foreach($this->getSuffixes() as $suffix)
{
$suff_str.= $delim.".".$suffix;
$delim = ", ";
}
$a_tpl->setCurrentBlock($a_block);
$a_tpl->setVariable("TXT_ALLOWED_SUFFIXES",
$lng->txt("file_allowed_suffixes")." ".$suff_str);
$a_tpl->parseCurrentBlock();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilFileInputGUI::render (   $a_mode = "")

Render html.

Reimplemented in ilDragDropFileInputGUI.

Definition at line 317 of file class.ilFileInputGUI.php.

References $lng, $pending, getALlowDeletion(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getFieldId(), getFilename(), getFileNamePostVar(), getMaxFileSizeString(), getPending(), ilFormPropertyGUI\getPostVar(), getSize(), ilDiskQuotaHandler\getStatusLegend(), getValue(), isFileNameSelectionEnabled(), ilDiskQuotaHandler\isUploadPossible(), and outputSuffixes().

Referenced by getToolbarHTML(), and insert().

{
global $lng;
$quota_exceeded = $quota_legend = false;
if(self::$check_wsp_quota)
{
include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
{
$lng->loadLanguageModule("file");
$quota_exceeded = $lng->txt("personal_workspace_quota_exceeded_warning");
}
else
{
}
}
$f_tpl = new ilTemplate("tpl.prop_file.html", true, true, "Services/Form");
// show filename selection if enabled
{
$f_tpl->setCurrentBlock('filename');
$f_tpl->setVariable('POST_FILENAME',$this->getFileNamePostVar());
$f_tpl->setVariable('VAL_FILENAME',$this->getFilename());
$f_tpl->setVariable('FILENAME_ID',$this->getFieldId());
$f_tpl->setVAriable('TXT_FILENAME_HINT',$lng->txt('if_no_title_then_filename'));
$f_tpl->parseCurrentBlock();
}
else
{
if (trim($this->getValue() != ""))
{
if (!$this->getDisabled() && $this->getALlowDeletion())
{
$f_tpl->setCurrentBlock("delete_bl");
$f_tpl->setVariable("POST_VAR_D", $this->getPostVar());
$f_tpl->setVariable("TXT_DELETE_EXISTING",
$lng->txt("delete_existing_file"));
$f_tpl->parseCurrentBlock();
}
$f_tpl->setCurrentBlock('prop_file_propval');
$f_tpl->setVariable('FILE_VAL', $this->getValue());
$f_tpl->parseCurrentBlock();
}
}
if ($a_mode != "toolbar")
{
if(!$quota_exceeded)
{
$this->outputSuffixes($f_tpl);
$f_tpl->setCurrentBlock("max_size");
$f_tpl->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice")." ".
$f_tpl->parseCurrentBlock();
if($quota_legend)
{
$f_tpl->setVariable("TXT_MAX_SIZE", $quota_legend);
$f_tpl->parseCurrentBlock();
}
}
else
{
$f_tpl->setCurrentBlock("max_size");
$f_tpl->setVariable("TXT_MAX_SIZE", $quota_exceeded);
$f_tpl->parseCurrentBlock();
}
}
else if($quota_exceeded)
{
return $quota_exceeded;
}
$pending = $this->getPending();
{
$f_tpl->setCurrentBlock("pending");
$f_tpl->setVariable("TXT_PENDING", $lng->txt("file_upload_pending").
": ".$pending);
$f_tpl->parseCurrentBlock();
}
if ($this->getDisabled() || $quota_exceeded)
{
$f_tpl->setVariable("DISABLED",
" disabled=\"disabled\"");
}
$f_tpl->setVariable("POST_VAR", $this->getPostVar());
$f_tpl->setVariable("ID", $this->getFieldId());
$f_tpl->setVariable("SIZE", $this->getSize());
return $f_tpl->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilFileInputGUI::setALlowDeletion (   $a_val)

Set allow deletion.

Parameters
boolean$a_valallow deletion

Reimplemented in ilImageFileInputGUI.

Definition at line 196 of file class.ilFileInputGUI.php.

Referenced by ilBookingObjectGUI\initForm(), and ilCalendarCategoryGUI\initImportForm().

{
$this->allow_deletion = $a_val;
}

+ Here is the caller graph for this function:

ilFileInputGUI::setFilename (   $a_val)

Set filename value (if filename selection is enabled)

Parameters
string$a_val

Definition at line 98 of file class.ilFileInputGUI.php.

Referenced by setValueByArray().

{
$this->filename = $a_val;
}

+ Here is the caller graph for this function:

ilFileInputGUI::setPending (   $a_val)

Set pending filename value.

Parameters
string$a_val

Definition at line 140 of file class.ilFileInputGUI.php.

{
$this->pending = $a_val;
}
ilFileInputGUI::setPersonalWorkspaceQuotaCheck (   $a_value)

Definition at line 501 of file class.ilFileInputGUI.php.

References ilDiskQuotaActivationChecker\_isPersonalWorkspaceActive().

Referenced by ilObjFileGUI\executeCommand(), ilObjPortfolioGUI\executeCommand(), ilObjBlogGUI\executeCommand(), ilObjBlogGUI\initEditCustomForm(), and ilObjPortfolioBaseGUI\initEditCustomForm().

{
if((bool)$a_value)
{
include_once "Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
{
self::$check_wsp_quota = true;
return;
}
}
self::$check_wsp_quota = false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilFileInputGUI::setSize (   $a_size)

Set Size.

Parameters
int$a_sizeSize

Definition at line 78 of file class.ilFileInputGUI.php.

Referenced by ilFileSystemGUI\listFiles().

{
$this->size = $a_size;
}

+ Here is the caller graph for this function:

ilFileInputGUI::setValue (   $a_value)

Set Value.

(used for displaying file title of existing file below input field)

Parameters
string$a_valueValue

Reimplemented in ilImagemapFileInputGUI, and ilFlashFileInputGUI.

Definition at line 58 of file class.ilFileInputGUI.php.

Referenced by ilObjUserFolderGUI\initNewAccountMailForm(), and setValueByArray().

{
$this->value = $a_value;
}

+ Here is the caller graph for this function:

ilFileInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

Reimplemented in ilImagemapFileInputGUI, and ilFlashFileInputGUI.

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

References getFileNamePostVar(), ilFormPropertyGUI\getPostVar(), setFilename(), and setValue().

{
if (!is_array($a_values[$this->getPostVar()]))
{
$this->setValue($a_values[$this->getPostVar()]);
}
$this->setFilename($a_values[$this->getFileNamePostVar()]);
}

+ Here is the call graph for this function:

Field Documentation

ilFileInputGUI::$allow_deletion
protected
ilFileInputGUI::$check_wsp_quota
staticprotected

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

ilFileInputGUI::$filename_post
private

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

Referenced by getFileNamePostVar().

ilFileInputGUI::$pending
protected

Definition at line 19 of file class.ilFileInputGUI.php.

Referenced by getPending(), ilImageFileInputGUI\insert(), and render().

ilFileInputGUI::$size = 40
protected

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

Referenced by getSize().


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