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

This class represents a external and/or internal link in a property form. More...

+ Inheritance diagram for ilLinkInputGUI:
+ Collaboration diagram for ilLinkInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor.
 setAllowedLinkTypes ($a_val)
 Set allowed link types (BOTH, INT, EXT)
 getAllowedLinkTypes ()
 Get allowed link types (BOTH, INT, EXT)
 setInternalLinkDefault ($a_type, $a_obj=0)
 Set internal link default.
 setInternalLinkFilterTypes (array $a_val)
 Set internal link filter types.
 executeCommand ()
 Execute current command.
 setValue ($a_value)
 Set Value.
 getValue ()
 Get Value.
 setValueByArray ($a_values)
 Set value by array.
 checkInput ()
 Check input, strip slashes etc.
 render ()
 Render item.
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g.
 insert (&$a_tpl)
 Insert property html.
- Public Member Functions inherited from ilFormPropertyGUI
 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.
 getSubForm ()
 Get sub form html.
 hideSubForm ()
 Sub form hidden on init?
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders)
 getHiddenTitle ()
 Get hidden title.
 getItemByPostVar ($a_post_var)
 Get item by post var.
 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.

Static Public Member Functions

static isInternalLink ($a_value)
static getTranslatedValue ($a_value)

Data Fields

const BOTH = "both"
const INT = "int"
const EXT = "ext"

Protected Attributes

 $allowed_link_types = self::BOTH
 $int_link_default_type = "RepositoryItem"
 $int_link_default_obj = 0
 $int_link_filter_types = array("RepositoryItem")
- 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 ilFormPropertyGUI
 setType ($a_type)
 Set Type.
 getMultiIconsHTML ()
 Get HTML for multiple value icons.

Detailed Description

This class represents a external and/or internal link in a property form.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

ilLinkInputGUI: ilFormPropertyDispatchGUI ilLinkInputGUI: ilInternalLinkGUI

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

Constructor & Destructor Documentation

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Reimplemented from ilFormPropertyGUI.

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

References ilFormPropertyGUI\setType().

{
parent::__construct($a_title, $a_postvar);
$this->setType("link");
}

+ Here is the call graph for this function:

Member Function Documentation

ilLinkInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Reimplemented from ilFormPropertyGUI.

Definition at line 171 of file class.ilLinkInputGUI.php.

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

{
global $lng;
// debugging
// return false;
if($this->getRequired())
{
switch($_POST[$this->getPostVar()."_mode"])
{
case "ext":
if(!$_POST[$this->getPostVar()])
{
$this->setAlert($lng->txt("msg_input_is_required"));
return false;
}
break;
case "int":
if(!$_POST[$this->getPostVar()."_ajax_type"] ||
!$_POST[$this->getPostVar()."_ajax_id"])
{
$this->setAlert($lng->txt("msg_input_is_required"));
return false;
}
break;
default:
$this->setAlert($lng->txt("msg_input_is_required"));
return false;
}
}
if($_POST[$this->getPostVar()."_mode"] == "int")
{
$_POST[$this->getPostVar()."_ajax_type"] = ilUtil::stripSlashes($_POST[$this->getPostVar()."_ajax_type"]);
$_POST[$this->getPostVar()."_ajax_id"] = ilUtil::stripSlashes($_POST[$this->getPostVar()."_ajax_id"]);
$_POST[$this->getPostVar()."_ajax_target"] = ilUtil::stripSlashes($_POST[$this->getPostVar()."_ajax_target"]);
// overwriting post-data so getInput() will work
$val = $_POST[$this->getPostVar()."_ajax_type"]."|".
$_POST[$this->getPostVar()."_ajax_id"];
if ($_POST[$this->getPostVar()."_ajax_target"] != "")
{
$val.= "|".$_POST[$this->getPostVar()."_ajax_target"];
}
$_POST[$this->getPostVar()] = $val;
}
else
{
}
return true;
}

+ Here is the call graph for this function:

ilLinkInputGUI::executeCommand ( )

Execute current command.

Reimplemented from ilFormPropertyGUI.

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

References $cmd, $ilCtrl, $lng, $ret, and $t.

{
global $ilCtrl, $lng;
$next_class = $ilCtrl->getNextClass($this);
$cmd = $ilCtrl->getCmd();
switch($next_class)
{
case "ilinternallinkgui":
$lng->loadLanguageModule("content");
require_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
$link_gui = new ilInternalLinkGUI($this->int_link_default_type,
$this->int_link_default_obj);
foreach ($this->int_link_filter_types as $t)
{
$link_gui->filterLinkType($t);
}
$link_gui->setFilterWhiteList(true);
$link_gui->setMode("asynch");
$ret = $ilCtrl->forwardCommand($link_gui);
break;
default:
var_dump($cmd);
//exit();
}
return $ret;
}
ilLinkInputGUI::getAllowedLinkTypes ( )

Get allowed link types (BOTH, INT, EXT)

Returns
string self::BOTH|self::INT|self::EXT

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

References $allowed_link_types.

Referenced by getContentOutsideFormTag(), and render().

+ Here is the caller graph for this function:

ilLinkInputGUI::getContentOutsideFormTag ( )

Get content that has to reside outside of the parent form tag, e.g.

panels/layers

Returns
string

Reimplemented from ilFormPropertyGUI.

Definition at line 386 of file class.ilLinkInputGUI.php.

References getAllowedLinkTypes(), and ilInternalLinkGUI\getInitHTML().

{
if($this->getAllowedLinkTypes() == self::INT ||
$this->getAllowedLinkTypes() == self::BOTH)
{
// as the ajax-panel uses a form it has to be outside of the parent form!
}
}

+ Here is the call graph for this function:

static ilLinkInputGUI::getTranslatedValue (   $a_value)
static

Definition at line 417 of file class.ilLinkInputGUI.php.

References $lng, ilFormPropertyGUI\$type, ilGlossaryTerm\_lookGlossaryTerm(), ilObject\_lookupObjId(), ilLMObject\_lookupTitle(), and ilObject\_lookupTitle().

Referenced by ilWebResourceEditableLinkTableGUI\fillRow(), and render().

{
global $lng;
$value = explode("|", $a_value);
switch($value[0])
{
case "media":
$type = $lng->txt("obj_mob");
$name = ilObject::_lookupTitle($value[1]);
break;
case "page":
include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
$type = $lng->txt("obj_pg");
$name = ilLMPageObject::_lookupTitle($value[1]);
break;
case "term":
include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
$type = $lng->txt("term");
break;
default:
$type = $lng->txt("obj_".$value[0]);
break;
}
return array("type"=>$type, "name"=>$name);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLinkInputGUI::getValue ( )

Get Value.

Returns
string Value

Definition at line 129 of file class.ilLinkInputGUI.php.

Referenced by render().

{
return $this->value;
}

+ Here is the caller graph for this function:

ilLinkInputGUI::insert ( $a_tpl)

Insert property html.

Returns
int Size

Definition at line 456 of file class.ilLinkInputGUI.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:

static ilLinkInputGUI::isInternalLink (   $a_value)
static

Definition at line 396 of file class.ilLinkInputGUI.php.

Referenced by ilObjLinkResourceGUI\handleSubItemLinks().

{
if(strpos($a_value, "|"))
{
$parts = explode("|", $a_value);
if(sizeof($parts) == 2 || sizeof($parts) == 3)
{
// numeric id
if(is_numeric($parts[1]))
{
// simple type
if(preg_match("/^[a-zA-Z_]+$/", $parts[0], $matches))
{
return true;
}
}
}
}
return false;
}

+ Here is the caller graph for this function:

ilLinkInputGUI::render ( )

Render item.

Definition at line 232 of file class.ilLinkInputGUI.php.

References $ilCtrl, $lng, ilFormPropertyGUI\$title, ilRadioOption\addSubItem(), getAllowedLinkTypes(), ilFormPropertyGUI\getParent(), ilFormPropertyGUI\getPostVar(), getTranslatedValue(), and getValue().

Referenced by insert().

{
global $lng, $ilCtrl;
// parse settings
$has_int = $has_ext = $has_radio = false;
switch($this->getAllowedLinkTypes())
{
case self::EXT:
$has_ext = true;
break;
case self::INT:
$has_int = true;
break;
case self::BOTH:
$has_int = true;
$has_ext = true;
$has_radio = true;
break;
}
// external
if($has_ext)
{
$title = $has_radio ? $lng->txt("url") : "";
// external
$ti = new ilTextInputGUI($title, $this->getPostVar());
$ti->setMaxLength(200);
$ti->setSize(50);
}
// internal
if($has_int)
{
$ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", $this->getPostVar());
$link = array(get_class($this->getParent()), "ilformpropertydispatchgui", get_class($this), "ilinternallinkgui");
$link = $ilCtrl->getLinkTargetByClass($link, "", false, true, false);
$ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", "");
$no_disp_class = (strpos($this->getValue(), "|"))
? ""
: " ilNoDisplay";
$itpl = new ilTemplate('tpl.prop_link.html',true,true,'Services/Form');
$itpl->setVariable("VAL_ID", $this->getPostVar());
$itpl->setVariable("URL_EDIT", $link);
$itpl->setVariable("TXT_EDIT", $lng->txt("form_get_link"));
$itpl->setVariable("CSS_REMOVE", $no_disp_class);
$itpl->setVariable("TXT_REMOVE", $lng->txt("remove"));
$ne = new ilNonEditableValueGUI($lng->txt("object"), $this->getPostVar()."_val", true);
// hidden field for selected value
$hidden_type = new ilHiddenInputGUI($this->getPostVar()."_ajax_type");
$hidden_id = new ilHiddenInputGUI($this->getPostVar()."_ajax_id");
$hidden_target = new ilHiddenInputGUI($this->getPostVar()."_ajax_target");
}
// mode
if ($has_radio)
{
$ext = new ilRadioOption($lng->txt("form_link_external"), "ext");
$ext->addSubItem($ti);
$int = new ilRadioOption($lng->txt("form_link_internal"), "int");
$int->addSubItem($ne);
$mode = new ilRadioGroupInputGUI("", $this->getPostVar()."_mode");
$mode->addOption($ext);
$mode->addOption($int);
}
else
{
$mode = new ilHiddenInputGUI($this->getPostVar()."_mode");
if ($has_int)
{
$mode->setValue("int");
}
else
{
$mode->setValue("ext");
}
}
// value
$value = $this->getValue();
if($value)
{
// #15647
if($has_int && self::isInternalLink($value))
{
$mode->setValue("int");
$value_trans = self::getTranslatedValue($value);
$value = explode("|", $value);
$hidden_type->setValue($value[0]);
$hidden_id->setValue($value[1]);
$hidden_target->setValue($value[2]);
$itpl->setVariable("VAL_OBJECT_TYPE", $value_trans["type"]);
$itpl->setVariable("VAL_OBJECT_NAME", $value_trans["name"]);
}
else if($has_ext)
{
$mode->setValue("ext");
$ti->setValue($value);
}
}
// #10185 - default for external urls
if($has_ext && !$ti->getValue())
{
$ti->setValue("http://");
}
$ne->setValue($itpl->get());
// to html
if ($has_radio)
{
$html = $mode->render();
}
else
{
$html = $mode->getToolbarHTML();
if ($has_ext)
{
$html.= $ti->getToolbarHTML();
}
else
{
$html.= $ne->render().
'<div class="help-block">'.$ne->getInfo().'</div>';
}
}
// js for internal link
if($has_int)
{
include_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
$html.= $hidden_type->getToolbarHTML().
$hidden_id->getToolbarHTML().
$hidden_target->getToolbarHTML();
}
return $html;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLinkInputGUI::setAllowedLinkTypes (   $a_val)

Set allowed link types (BOTH, INT, EXT)

Parameters
string$a_valself::BOTH|self::INT|self::EXT

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

Referenced by ilPageObjectGUI\initOpenedContentForm().

{
$this->allowed_link_types = $a_val;
}

+ Here is the caller graph for this function:

ilLinkInputGUI::setInternalLinkDefault (   $a_type,
  $a_obj = 0 
)

Set internal link default.

Parameters
string$a_typelink type
int$a_objobject id

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

{
$this->int_link_default_type = $a_type;
$this->int_link_default_obj = $a_obj;
}
ilLinkInputGUI::setInternalLinkFilterTypes ( array  $a_val)

Set internal link filter types.

Parameters
array$a_valfilter types

Definition at line 74 of file class.ilLinkInputGUI.php.

Referenced by ilObjLinkResourceGUI\initFormLink().

{
$this->int_link_filter_types = $a_val;
}

+ Here is the caller graph for this function:

ilLinkInputGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

Definition at line 119 of file class.ilLinkInputGUI.php.

Referenced by setValueByArray().

{
$this->value = $a_value;
}

+ Here is the caller graph for this function:

ilLinkInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

Definition at line 139 of file class.ilLinkInputGUI.php.

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

{
switch($a_values[$this->getPostVar()."_mode"])
{
case "int":
if($a_values[$this->getPostVar()."_ajax_type"] &&
$a_values[$this->getPostVar()."_ajax_id"])
{
$val = $a_values[$this->getPostVar()."_ajax_type"]."|".
$a_values[$this->getPostVar()."_ajax_id"];
if ($a_values[$this->getPostVar()."_ajax_target"] != "")
{
$val.= "|".$a_values[$this->getPostVar()."_ajax_target"];
}
$this->setValue($val);
}
break;
default:
if($a_values[$this->getPostVar()])
{
$this->setValue($a_values[$this->getPostVar()]);
}
break;
}
}

+ Here is the call graph for this function:

Field Documentation

ilLinkInputGUI::$allowed_link_types = self::BOTH
protected

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

Referenced by getAllowedLinkTypes().

ilLinkInputGUI::$int_link_default_obj = 0
protected

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

ilLinkInputGUI::$int_link_default_type = "RepositoryItem"
protected

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

ilLinkInputGUI::$int_link_filter_types = array("RepositoryItem")
protected

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

const ilLinkInputGUI::BOTH = "both"

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

const ilLinkInputGUI::EXT = "ext"

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

const ilLinkInputGUI::INT = "int"

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

Referenced by ilPageObjectGUI\initOpenedContentForm().


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