ILIAS  Release_4_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.
 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
 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.
 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.
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem.
 getSubItems ()
 Get Subitems.
 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)

Protected Attributes

 $areas = array()
 $image_path = ""
 $image_path_web = ""
 $line_color = ""
- Protected Attributes inherited from ilImageFileInputGUI
 $cache
- Protected Attributes inherited from ilFileInputGUI
 $size = 40
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
 $sub_items = array()
- Protected Attributes inherited from ilFormPropertyGUI
 $type
 $title
 $postvar
 $info
 $alert
 $required = false
 $parentgui
 $parentform

Additional Inherited Members

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

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 22737 2010-01-17 23:23:14Z hschottm

Definition at line 13 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 26 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 107 of file class.ilImagemapFileInputGUI.php.

References $_POST, $error, ilFileInputGUI\$filename, $lng, $name, 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 81 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 48 of file class.ilImagemapFileInputGUI.php.

References $image_path.

Referenced by insert().

{
}

+ Here is the caller graph for this function:

ilImagemapFileInputGUI::getImagePathWeb ( )

Definition at line 58 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 38 of file class.ilImagemapFileInputGUI.php.

References $line_color.

Referenced by insert().

{
}

+ Here is the caller graph for this function:

ilImagemapFileInputGUI::insert ( $a_tpl)

Insert property html.

Reimplemented from ilImageFileInputGUI.

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

References $lng, $preview, $tpl, ilImageFileInputGUI\getAlt(), getAreas(), ilFormPropertyGUI\getFieldId(), ilImageFileInputGUI\getImage(), getImagePath(), ilUtil\getImagePath(), getImagePathWeb(), getLineColor(), ilFileInputGUI\getMaxFileSizeString(), ilFormPropertyGUI\getPostVar(), ilFileInputGUI\getValue(), ilYuiUtil\initDomEvent(), and ilFileInputGUI\outputSuffixes().

{
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()))
{
$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->getAnswertext()))
{
$template->setCurrentBlock('area_name_value');
$template->setVariable('VALUE_NAME', $area->getAnswertext());
$template->parseCurrentBlock();
}
$template->setCurrentBlock('row');
$class = ($counter % 2 == 0) ? "even" : "odd";
if ($counter == 0) $class .= " first";
if ($counter == count($this->getAreas())-1) $class .= " last";
$template->setVariable("ROW_CLASS", $class);
$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", ilUtil::getImagePath('edit_remove.png'));
$template->parseCurrentBlock();
$counter++;
}
$template->setCurrentBlock("areas");
$template->setVariable("TEXT_NAME", $lng->txt("hint"));
$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;
include_once "./Services/YUI/classes/class.ilYuiUtil.php";
$tpl->addJavascript("./Modules/TestQuestionPool/templates/default/imagemap.js");
}

+ Here is the call graph for this function:

ilImagemapFileInputGUI::setAreas (   $a_areas)

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

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

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

References $name.

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)
{
array_push($this->areas, new ASS_AnswerImagemap($name, $a_areas['points'][$idx], $idx, $a_areas['coords'][$idx], $a_areas['shape'][$idx]));
}
}
}

+ Here is the caller graph for this function:

ilImagemapFileInputGUI::setImagePath (   $a_path)

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

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

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

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

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

{
$this->line_color = $a_color;
}
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 97 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 91 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 15 of file class.ilImagemapFileInputGUI.php.

Referenced by getAreas().

ilImagemapFileInputGUI::$image_path = ""
protected

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

Referenced by getImagePath().

ilImagemapFileInputGUI::$image_path_web = ""
protected

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

Referenced by getImagePathWeb().

ilImagemapFileInputGUI::$line_color = ""
protected

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

Referenced by getLineColor().


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