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

This class represents an image map file property in a property form. More...

+ Inheritance diagram for ilImagemapFileInputGUI:
+ Collaboration diagram for ilImagemapFileInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor.
 setPointsUncheckedFieldEnabled ($pointsUncheckedFieldEnabled)
 getPointsUncheckedFieldEnabled ()
 setAreas ($a_areas)
 getLineColor ()
 setLineColor ($a_color)
 getImagePath ()
 setImagePath ($a_path)
 getImagePathWeb ()
 setImagePathWeb ($a_path_web)
 setAreasByArray ($a_areas)
 getAreas ()
 setValueByArray ($a_values)
 Set value by array.
 setValue ($a_value)
 Set Value.
 checkInput ()
 Check input, strip slashes etc.
 insert (&$a_tpl)
 Insert property html.
- Public Member Functions inherited from ilImageFileInputGUI
 setALlowDeletion ($a_val)
 Set allow deletion.
 getALlowDeletion ()
 Get allow deletion.
 setUseCache ($a_cache)
 Set cache.
 getUseCache ()
 Get cache.
 setImage ($a_image)
 Set Image.
 getImage ()
 Get Image.
 setAlt ($a_alt)
 Set Alternative Text.
 getAlt ()
 Get Alternative Text.
 getDeletionFlag ()
 Get deletion flag.
- Public Member Functions inherited from ilFileInputGUI
 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.
 render ($a_mode="")
 Render html.
 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 Attributes

 $areas = array()
 $image_path = ""
 $image_path_web = ""
 $line_color = ""
 $pointsUncheckedFieldEnabled = false
- Protected Attributes inherited from ilImageFileInputGUI
 $cache
- Protected Attributes inherited from ilFileInputGUI
 $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

Additional Inherited Members

- Protected Member Functions inherited from ilFileInputGUI
 outputSuffixes ($a_tpl, $a_block="allowed_suffixes")
 getMaxFileSizeString ()
- Static Protected Attributes inherited from ilFileInputGUI
static $check_wsp_quota

Detailed Description

This class represents an image map file property in a property form.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
Id:
class.ilImagemapFileInputGUI.php 55178 2014-11-15 10:54:35Z mjansen

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

Constructor & Destructor Documentation

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Reimplemented from ilImageFileInputGUI.

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

References $lng.

{
global $lng;
parent::__construct($a_title, $a_postvar);
}

Member Function Documentation

ilImagemapFileInputGUI::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 137 of file class.ilImagemapFileInputGUI.php.

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

{
global $lng;
if (is_array($_POST[$this->getPostVar()])) $_POST[$this->getPostVar()] = ilUtil::stripSlashesRecursive($_POST[$this->getPostVar()]);
// remove trailing '/'
while (substr($_FILES[$this->getPostVar()]["name"],-1) == '/')
{
$_FILES[$this->getPostVar()]["name"] = substr($_FILES[$this->getPostVar()]["name"],0,-1);
}
$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"];
// 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()))
{
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;
}
}
$max = 0;
if (is_array($_POST[$this->getPostVar()]['coords']['name']))
{
foreach ($_POST[$this->getPostVar()]['coords']['name'] as $idx => $name)
{
if ((!strlen($_POST[$this->getPostVar()]['coords']['points'][$idx])) && ($this->getRequired))
{
$this->setAlert($lng->txt('form_msg_area_missing_points'));
return false;
}
if ((!is_numeric($_POST[$this->getPostVar()]['coords']['points'][$idx])))
{
$this->setAlert($lng->txt('form_msg_numeric_value_required'));
return false;
}
if ($_POST[$this->getPostVar()]['coords']['points'][$idx] > 0) $max = $_POST[$this->getPostVar()]['coords']['points'][$idx];
}
}
if ($max == 0 && (!$filename))
{
$this->setAlert($lng->txt("enter_enough_positive_points"));
return false;
}
return true;
}

+ Here is the call graph for this function:

ilImagemapFileInputGUI::getAreas ( )

Definition at line 111 of file class.ilImagemapFileInputGUI.php.

References $areas.

Referenced by insert().

{
return $this->areas;
}

+ Here is the caller graph for this function:

ilImagemapFileInputGUI::getImagePath ( )

Definition at line 62 of file class.ilImagemapFileInputGUI.php.

References $image_path.

Referenced by insert().

{
}

+ Here is the caller graph for this function:

ilImagemapFileInputGUI::getImagePathWeb ( )

Definition at line 72 of file class.ilImagemapFileInputGUI.php.

References $image_path_web.

Referenced by insert().

{
}

+ Here is the caller graph for this function:

ilImagemapFileInputGUI::getLineColor ( )

Definition at line 52 of file class.ilImagemapFileInputGUI.php.

References $line_color.

Referenced by insert().

{
}

+ Here is the caller graph for this function:

ilImagemapFileInputGUI::getPointsUncheckedFieldEnabled ( )

Definition at line 42 of file class.ilImagemapFileInputGUI.php.

References $pointsUncheckedFieldEnabled.

Referenced by insert(), and setAreasByArray().

+ Here is the caller graph for this function:

ilImagemapFileInputGUI::insert ( $a_tpl)

Insert property html.

Reimplemented from ilImageFileInputGUI.

Definition at line 256 of file class.ilImagemapFileInputGUI.php.

References $lng, $preview, $tpl, ilGlyphGUI\get(), ilImageFileInputGUI\getAlt(), getAreas(), ilFormPropertyGUI\getFieldId(), ilImageFileInputGUI\getImage(), getImagePath(), getImagePathWeb(), getLineColor(), ilFileInputGUI\getMaxFileSizeString(), getPointsUncheckedFieldEnabled(), ilFormPropertyGUI\getPostVar(), ilFileInputGUI\getValue(), ilFileInputGUI\outputSuffixes(), and ilGlyphGUI\REMOVE.

{
global $lng;
$template = new ilTemplate("tpl.prop_imagemap_file.html", true, true, "Modules/TestQuestionPool");
$this->outputSuffixes($template, "allowed_image_suffixes");
if ($this->getImage() != "")
{
if (strlen($this->getValue()))
{
$template->setCurrentBlock("has_value");
$template->setVariable("TEXT_IMAGE_NAME", $this->getValue());
$template->setVariable("POST_VAR_D", $this->getPostVar());
$template->parseCurrentBlock();
}
$template->setCurrentBlock("image");
if (count($this->getAreas()))
{
include_once "./Modules/TestQuestionPool/classes/class.ilImagemapPreview.php";
$preview = new ilImagemapPreview($this->getImagePath().$this->getValue());
foreach ($this->getAreas() as $index => $area)
{
$preview->addArea($index, $area->getArea(), $area->getCoords(), $area->getAnswertext(), "", "", true, $this->getLineColor());
}
$preview->createPreview();
$imagepath = $this->getImagePathWeb() . $preview->getPreviewFilename($this->getImagePath(), $this->getValue()) . "?img=" . time();
$template->setVariable("SRC_IMAGE", $imagepath);
}
else
{
$template->setVariable("SRC_IMAGE", $this->getImage());
}
$template->setVariable("ALT_IMAGE", $this->getAlt());
$template->setVariable("POST_VAR_D", $this->getPostVar());
$template->setVariable("TXT_DELETE_EXISTING",
$lng->txt("delete_existing_file"));
$template->setVariable("TEXT_ADD_RECT", $lng->txt('add_rect'));
$template->setVariable("TEXT_ADD_CIRCLE", $lng->txt('add_circle'));
$template->setVariable("TEXT_ADD_POLY", $lng->txt('add_poly'));
$template->parseCurrentBlock();
}
if(is_array($this->getAreas()) && $this->getAreas())
{
$counter = 0;
foreach ($this->getAreas() as $area)
{
if (strlen($area->getPoints()))
{
$template->setCurrentBlock('area_points_value');
$template->setVariable('VALUE_POINTS', $area->getPoints());
$template->parseCurrentBlock();
}
{
if (strlen($area->getPointsUnchecked()))
{
$template->setCurrentBlock('area_points_unchecked_value');
$template->setVariable('VALUE_POINTS_UNCHECKED', $area->getPointsUnchecked());
$template->parseCurrentBlock();
}
$template->setCurrentBlock('area_points_unchecked_field');
$template->parseCurrentBlock();
}
if (strlen($area->getAnswertext()))
{
$template->setCurrentBlock('area_name_value');
$template->setVariable('VALUE_NAME', $area->getAnswertext());
$template->parseCurrentBlock();
}
$template->setCurrentBlock('row');
$template->setVariable('POST_VAR_R', $this->getPostVar());
$template->setVariable('TEXT_SHAPE', strtoupper($area->getArea()));
$template->setVariable('VALUE_SHAPE', $area->getArea());
$coords = preg_replace("/(\d+,\d+,)/", "\$1 ", $area->getCoords());
$template->setVariable('VALUE_COORDINATES', $area->getCoords());
$template->setVariable('TEXT_COORDINATES', $coords);
$template->setVariable('COUNTER', $counter);
$template->setVariable("REMOVE_BUTTON", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
$template->parseCurrentBlock();
$counter++;
}
$template->setCurrentBlock("areas");
$template->setVariable("TEXT_NAME", $lng->txt("hint"));
{
$template->setVariable("TEXT_POINTS", $lng->txt("points_checked"));
$template->setCurrentBlock('area_points_unchecked_head');
$template->setVariable("TEXT_POINTS_UNCHECKED", $lng->txt("points_unchecked"));
$template->parseCurrentBlock();
}
else
{
$template->setVariable("TEXT_POINTS", $lng->txt("points"));
}
$template->setVariable("TEXT_SHAPE", $lng->txt("shape"));
$template->setVariable("TEXT_COORDINATES", $lng->txt("coordinates"));
$template->setVariable("TEXT_COMMANDS", $lng->txt("actions"));
$template->parseCurrentBlock();
}
$template->setVariable("POST_VAR", $this->getPostVar());
$template->setVariable("ID", $this->getFieldId());
$template->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice")." ".
$a_tpl->setCurrentBlock("prop_generic");
$a_tpl->setVariable("PROP_GENERIC", $template->get());
$a_tpl->parseCurrentBlock();
global $tpl;
$tpl->addJavascript("./Services/Form/js/ServiceFormWizardInput.js");
$tpl->addJavascript("./Modules/TestQuestionPool/templates/default/imagemap.js");
}

+ Here is the call graph for this function:

ilImagemapFileInputGUI::setAreas (   $a_areas)

Definition at line 47 of file class.ilImagemapFileInputGUI.php.

{
$this->areas = $a_areas;
}
ilImagemapFileInputGUI::setAreasByArray (   $a_areas)

Definition at line 82 of file class.ilImagemapFileInputGUI.php.

References getPointsUncheckedFieldEnabled().

Referenced by setValueByArray().

{
if (is_array($a_areas['name']))
{
$this->areas = array();
include_once "./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
foreach ($a_areas['name'] as $idx => $name)
{
if( $this->getPointsUncheckedFieldEnabled() && isset($a_areas['points_unchecked']) )
{
$pointsUnchecked = $a_areas['points_unchecked'][$idx];
}
else
{
$pointsUnchecked = 0.0;
}
array_push($this->areas, new ASS_AnswerImagemap(
$name,
$a_areas['points'][$idx],
$idx,
$a_areas['coords'][$idx], $a_areas['shape'][$idx],
-1,
$pointsUnchecked
));
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilImagemapFileInputGUI::setImagePath (   $a_path)

Definition at line 67 of file class.ilImagemapFileInputGUI.php.

{
$this->image_path = $a_path;
}
ilImagemapFileInputGUI::setImagePathWeb (   $a_path_web)

Definition at line 77 of file class.ilImagemapFileInputGUI.php.

{
$this->image_path_web = $a_path_web;
}
ilImagemapFileInputGUI::setLineColor (   $a_color)

Definition at line 57 of file class.ilImagemapFileInputGUI.php.

{
$this->line_color = $a_color;
}
ilImagemapFileInputGUI::setPointsUncheckedFieldEnabled (   $pointsUncheckedFieldEnabled)

Definition at line 37 of file class.ilImagemapFileInputGUI.php.

References $pointsUncheckedFieldEnabled.

Referenced by assImagemapQuestionGUI\populateQuestionSpecificFormPart().

{
$this->pointsUncheckedFieldEnabled = (bool)$pointsUncheckedFieldEnabled;
}

+ Here is the caller graph for this function:

ilImagemapFileInputGUI::setValue (   $a_value)

Set Value.

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

Parameters
string$a_valueValue

Reimplemented from ilFileInputGUI.

Definition at line 127 of file class.ilImagemapFileInputGUI.php.

Referenced by setValueByArray().

{
parent::setValue($a_value);
}

+ Here is the caller graph for this function:

ilImagemapFileInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

Reimplemented from ilFileInputGUI.

Definition at line 121 of file class.ilImagemapFileInputGUI.php.

References ilFormPropertyGUI\getPostVar(), setAreasByArray(), and setValue().

{
$this->setValue($a_values[$this->getPostVar() . '_name']);
$this->setAreasByArray($a_values[$this->getPostVar()]['coords']);
}

+ Here is the call graph for this function:

Field Documentation

ilImagemapFileInputGUI::$areas = array()
protected

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

Referenced by getAreas().

ilImagemapFileInputGUI::$image_path = ""
protected

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

Referenced by getImagePath().

ilImagemapFileInputGUI::$image_path_web = ""
protected

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

Referenced by getImagePathWeb().

ilImagemapFileInputGUI::$line_color = ""
protected

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

Referenced by getLineColor().

ilImagemapFileInputGUI::$pointsUncheckedFieldEnabled = false
protected

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