ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 (string $a_title="", string $a_postvar="")
 
 setAllowedLinkTypes (string $a_val)
 Set allowed link types (LIST, BOTH, INT, EXT) More...
 
 getAllowedLinkTypes ()
 
 setInternalLinkDefault (string $a_type, int $a_obj=0)
 Set internal link default. More...
 
 setInternalLinkFilterTypes (array $a_val)
 Set internal link filter types. More...
 
 setFilterWhiteList (bool $a_val)
 Set filter white list. More...
 
 getFilterWhiteList ()
 
 setExternalLinkMaxLength (int $a_max)
 
 getExternalLinkMaxLength ()
 
 executeCommand ()
 
 setValue (string $a_value)
 Set Value. More...
 
 getValue ()
 Get Value. More...
 
 setValueByArray (array $a_values)
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 getInput ()
 
 render ()
 
 getContentOutsideFormTag ()
 
 insert (ilTemplate $a_tpl)
 
 getIntLinkAttributes ()
 Get value as internal link attributes. More...
 
 setValueByIntLinkAttributes (string $a_type, string $a_target, string $a_target_frame="")
 
 getOnloadCode ()
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct (string $a_title="", string $a_postvar="")
 
 executeCommand ()
 
 getType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setPostVar (string $a_postvar)
 
 getPostVar ()
 
 getFieldId ()
 
 setInfo (string $a_info)
 
 getInfo ()
 
 setAlert (string $a_alert)
 
 getAlert ()
 
 setRequired (bool $a_required)
 
 getRequired ()
 
 setDisabled (bool $a_disabled)
 
 getDisabled ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm (ilPropertyFormGUI $a_parentform)
 
 getParentForm ()
 
 setParent (ilFormPropertyGUI $a_val)
 
 getParent ()
 
 getSubForm ()
 
 hideSubForm ()
 
 setHiddenTitle (string $a_val)
 
 getHiddenTitle ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
 serializeData ()
 
 unserializeData (string $a_data)
 
 setParentTable ($a_val)
 Set parent table. More...
 
 getParentTable ()
 Get parent table. More...
 
 writeToSession ()
 
 clearFromSession ()
 
 readFromSession ()
 
 getHiddenTag (string $a_post_var, string $a_value)
 
 setMulti (bool $a_multi, bool $a_sortable=false, bool $a_addremove=true)
 
 getMulti ()
 
 setMultiValues (array $a_values)
 
 getMultiValues ()
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback (string $a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value for filter. More...
 
 getFormLabelFor ()
 Get label "for" attribute value for form. More...
 
 setRequestParam (string $key, $val)
 This writes the request (aka post) values. More...
 

Static Public Member Functions

static getTypeToAttrType ()
 Get internal types to xml attribute types map. More...
 
static getAttrTypeToType ()
 Get internal types to xml attribute types map (reverse) More...
 
static isInternalLink (string $a_value)
 
static getTranslatedValue (string $a_value)
 
- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters (string $a_text)
 Remove prohibited characters see #19159. More...
 

Data Fields

const EXTERNAL_LINK_MAX_LENGTH = 200
 
const LIST = "list"
 
const BOTH = "both"
 
const INT = "int"
 
const EXT = "ext"
 

Protected Attributes

string $allowed_link_types = self::BOTH
 
string $int_link_default_type = "RepositoryItem"
 
int $int_link_default_obj = 0
 
array $int_link_filter_types = array("RepositoryItem")
 
bool $filter_white_list = true
 
int $external_link_max_length = self::EXTERNAL_LINK_MAX_LENGTH
 
ilObjectDefinition $obj_definition
 
string $requested_postvar
 
string $value = ""
 
- Protected Attributes inherited from ilFormPropertyGUI
array $set_params = []
 
ilTable2GUI $parent_table = null
 
ilFormPropertyGUI $parent_gui = null
 
ilCtrl $ctrl
 
ilLanguage $lng
 
string $type = ""
 
string $title = ""
 
string $postvar = ""
 
string $info = ""
 
string $alert = ""
 
bool $required = false
 
ilPropertyFormGUI $parentform = null
 
string $hidden_title = ""
 
bool $multi = false
 
bool $multi_sortable = false
 
bool $multi_addremove = true
 
array $multi_values = []
 
RequestInterface $request
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
bool $disabled = false
 
ilGlobalTemplateInterface $global_tpl = null
 

Static Protected Attributes

static array $iltypemap
 

Additional Inherited Members

- Protected Member Functions inherited from ilFormPropertyGUI
 symbol ()
 
 setType (string $a_type)
 
 checkParentFormTable ()
 
 getSessionKey ()
 
 getMultiIconsHTML ()
 
 int ($key)
 
 intArray ($key)
 
 str ($key)
 
 raw ($key)
 
 strArray ($key)
 
 arrayArray ($key)
 
 isRequestParamArray (string $key)
 
 getRequestParam (string $key, Refinery\Transformation $t)
 

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

ilLinkInputGUI: ilFormPropertyDispatchGUI ilLinkInputGUI: ilInternalLinkGUI

Deprecated:
12 This component will be removed with ILIAS 12

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilFormPropertyGUI\setType(), and ilFormPropertyGUI\str().

58  {
59  global $DIC;
60 
61  $this->ctrl = $DIC->ctrl();
62  $this->lng = $DIC->language();
63 
64  parent::__construct($a_title, $a_postvar);
65  $this->setType("link");
66 
67  $this->obj_definition = $DIC["objDefinition"];
68 
69  $this->requested_postvar = $this->str("postvar");
70  }
global $DIC
Definition: shib_login.php:26
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilLinkInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
bool Input ok, true/false

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

References ilFormPropertyGUI\$lng, ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFormPropertyGUI\setAlert(), ilFormPropertyGUI\str(), and ilLanguage\txt().

239  : bool
240  {
241  $lng = $this->lng;
242 
243  // debugging
244  // return false;
245 
246  $mode_type = $this->str($this->getPostVar() . "_mode_type");
247  $ajax_type = $this->str($this->getPostVar() . "_ajax_type");
248  $ajax_id = $this->str($this->getPostVar() . "_ajax_id");
249  $mode = $this->str($this->getPostVar() . "_mode");
250  $value = $this->str($this->getPostVar());
251 
252  if ($this->getRequired()) {
253  if ($mode_type == "list") {
254  return true;
255  }
256 
257  switch ($mode) {
258  case "ext":
259  if (!$value) {
260  $this->setAlert($lng->txt("msg_input_is_required"));
261  return false;
262  }
263  break;
264 
265  case "int":
266  if (!$ajax_type || !$ajax_id) {
267  $this->setAlert($lng->txt("msg_input_is_required"));
268  return false;
269  }
270  break;
271 
272  case "no":
273  default:
274  $this->setAlert($lng->txt("msg_input_is_required"));
275  return false;
276  }
277  }
278 
279  return true;
280  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:

◆ executeCommand()

ilLinkInputGUI::executeCommand ( )

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

References ilFormPropertyGUI\$ctrl, ilFormPropertyGUI\$lng, getFilterWhiteList(), and ilLanguage\loadLanguageModule().

160  {
161  $ilCtrl = $this->ctrl;
162  $lng = $this->lng;
163 
164  $next_class = $ilCtrl->getNextClass($this);
165  $cmd = $ilCtrl->getCmd();
166 
167  $ret = "";
168  switch ($next_class) {
169  case "ilinternallinkgui":
170  $lng->loadLanguageModule("content");
171  $link_gui = new ilInternalLinkGUI(
172  $this->int_link_default_type,
173  $this->int_link_default_obj
174  );
175  foreach ($this->int_link_filter_types as $t) {
176  $link_gui->filterLinkType($t);
177  }
178  $link_gui->setFilterWhiteList($this->getFilterWhiteList());
179 
180  $ret = $ilCtrl->forwardCommand($link_gui);
181  break;
182 
183  default:
184  var_dump($cmd);
185  //exit();
186  }
187 
188  return $ret;
189  }
loadLanguageModule(string $a_module)
Load language module.
Internal link selector.
+ Here is the call graph for this function:

◆ getAllowedLinkTypes()

ilLinkInputGUI::getAllowedLinkTypes ( )

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

References $allowed_link_types.

Referenced by getContentOutsideFormTag(), and render().

82  : string
83  {
85  }
+ Here is the caller graph for this function:

◆ getAttrTypeToType()

static ilLinkInputGUI::getAttrTypeToType ( )
static

Get internal types to xml attribute types map (reverse)

Returns
string[]

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

126  : array
127  {
128  return array_flip(self::$iltypemap);
129  }

◆ getContentOutsideFormTag()

ilLinkInputGUI::getContentOutsideFormTag ( )

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

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

498  : string
499  {
500  if ($this->getAllowedLinkTypes() == self::INT ||
501  $this->getAllowedLinkTypes() == self::BOTH ||
502  $this->getAllowedLinkTypes() == self::LIST) {
503  // as the ajax-panel uses a form it has to be outside of the parent form!
505  }
506  return "";
507  }
static getInitHTML(string $a_url)
Get initialisation HTML to use internal link editing.
+ Here is the call graph for this function:

◆ getExternalLinkMaxLength()

ilLinkInputGUI::getExternalLinkMaxLength ( )

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

References $external_link_max_length.

Referenced by render().

154  : int
155  {
157  }
+ Here is the caller graph for this function:

◆ getFilterWhiteList()

ilLinkInputGUI::getFilterWhiteList ( )

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

References $filter_white_list.

Referenced by executeCommand().

141  : bool
142  {
144  }
+ Here is the caller graph for this function:

◆ getInput()

ilLinkInputGUI::getInput ( )

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

References $value, ilFormPropertyGUI\getPostVar(), and ilFormPropertyGUI\str().

Referenced by getIntLinkAttributes().

282  : string
283  {
284  $ajax_type = $this->str($this->getPostVar() . "_ajax_type");
285  $ajax_id = $this->str($this->getPostVar() . "_ajax_id");
286  $ajax_target = $this->str($this->getPostVar() . "_ajax_target");
287  $mode = $this->str($this->getPostVar() . "_mode");
288  $value = $this->str($this->getPostVar());
289 
290  if ($mode == "int") {
291  // overwriting post-data so getInput() will work
292  $val = $ajax_type . "|" . $ajax_id;
293  if ($ajax_target != "") {
294  $val .= "|" . $ajax_target;
295  }
296  return $val;
297  } elseif ($mode == "no") {
298  return "";
299  }
300  return $value;
301  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIntLinkAttributes()

ilLinkInputGUI::getIntLinkAttributes ( )

Get value as internal link attributes.

Returns
array (with keys "Type", "Target" and "TargetFrame")

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

References ilFormPropertyGUI\$type, getInput(), and null.

584  : ?array
585  {
586  $val = explode("|", $this->getInput());
587  $ret = null;
588  $type = "";
589  $target = "";
590  if (self::isInternalLink($this->getInput())) {
591  $target_frame = $val[2] ?? "";
592  $map = self::getTypeToAttrType();
593  if (isset($map[$val[0]])) {
594  $type = $map[$val[0]];
595  $target_type = $val[0];
596  if ($val[0] == "chap") {
597  $target_type = "st";
598  }
599  if ($val[0] == "term") {
600  $target_type = "git";
601  }
602  if ($val[0] == "page") {
603  $target_type = "pg";
604  }
605  $target = "il__" . $target_type . "_" . $val[1];
606  } elseif ($this->obj_definition->isRBACObject($val[0])) {
607  $type = "RepositoryItem";
608  $target = "il__obj_" . $val[1];
609  }
610  if ($type != "") {
611  $ret = array(
612  "Target" => $target,
613  "Type" => $type,
614  "TargetFrame" => $target_frame
615  );
616  }
617  }
618  return $ret;
619  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ getOnloadCode()

ilLinkInputGUI::getOnloadCode ( )

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

References ilInternalLinkGUI\getOnloadCode().

644  : array
645  {
646  return [
648  ];
649  }
static getOnloadCode(string $a_url)
+ Here is the call graph for this function:

◆ getTranslatedValue()

static ilLinkInputGUI::getTranslatedValue ( string  $a_value)
static

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

References $DIC, ilFormPropertyGUI\$lng, ilFormPropertyGUI\$type, ilGlossaryTerm\_lookGlossaryTerm(), ilObject\_lookupObjId(), ilLMObject\_lookupTitle(), ilObject\_lookupTitle(), ilWikiPage\lookupTitle(), and ilLanguage\txt().

Referenced by ilWebResourceEditableLinkTableGUI\fillRow().

526  : array
527  {
528  global $DIC;
529 
530  $lng = $DIC->language();
531 
532  $value = explode("|", $a_value);
533  if ($value === false || $value === []) {
534  return [];
535  }
536  switch ($value[0]) {
537  case "media":
538  $type = $lng->txt("obj_mob");
539  $name = ilObject::_lookupTitle((int) $value[1]);
540  break;
541 
542  case "page":
543  $type = $lng->txt("obj_pg");
544  $name = ilLMPageObject::_lookupTitle((int) $value[1]);
545  break;
546 
547  case "chap":
548  $type = $lng->txt("obj_st");
549  $name = ilStructureObject::_lookupTitle((int) $value[1]);
550  break;
551 
552  case "term":
553  $type = $lng->txt("term");
554  $name = ilGlossaryTerm::_lookGlossaryTerm((int) $value[1]);
555  break;
556 
557  case "wpage":
558  $type = $lng->txt("cont_wiki_page");
559  $name = ilWikiPage::lookupTitle((int) $value[1]);
560  break;
561 
562  default:
563  $type = $lng->txt("obj_" . $value[0]);
565  break;
566  }
567  return array("type" => $type, "name" => $name);
568  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static lookupTitle(int $a_page_id, string $lang="-")
static _lookupObjId(int $ref_id)
static _lookupTitle(int $a_obj_id)
static _lookupTitle(int $obj_id)
static _lookGlossaryTerm(int $term_id)
get glossary term
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTypeToAttrType()

static ilLinkInputGUI::getTypeToAttrType ( )
static

Get internal types to xml attribute types map.

Returns
string[]

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

116  : array
117  {
118  return self::$iltypemap;
119  }

◆ getValue()

ilLinkInputGUI::getValue ( )

Get Value.

Returns
string

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

References $value.

Referenced by render().

204  : string
205  {
206  return $this->value;
207  }
+ Here is the caller graph for this function:

◆ insert()

ilLinkInputGUI::insert ( ilTemplate  $a_tpl)

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

References ilTemplate\parseCurrentBlock(), render(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

570  : void
571  {
572  $html = $this->render();
573 
574  $a_tpl->setCurrentBlock("prop_generic");
575  $a_tpl->setVariable("PROP_GENERIC", $html);
576  $a_tpl->parseCurrentBlock();
577  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:

◆ isInternalLink()

static ilLinkInputGUI::isInternalLink ( string  $a_value)
static

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

References $parts.

Referenced by ilObjLinkResourceGUI\checkLinkInput(), ilObjLinkResourceListGUI\getCommandFrame(), ilWebLinkXmlParser\handlerEndTag(), ilWebLinkDatabaseRepository\isInternalLink(), and ilObjLinkResourceGUI\updateLinks().

509  : bool
510  {
511  if (strpos($a_value, "|")) {
512  $parts = explode("|", $a_value);
513  if (sizeof($parts) == 2 || sizeof($parts) == 3) {
514  // numeric id
515  if (is_numeric($parts[1])) {
516  // simple type
517  if (preg_match("/^[a-zA-Z_]+$/", $parts[0])) {
518  return true;
519  }
520  }
521  }
522  }
523  return false;
524  }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
+ Here is the caller graph for this function:

◆ render()

ilLinkInputGUI::render ( )

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

References ilFormPropertyGUI\$ctrl, ilFormPropertyGUI\$lng, ilFormPropertyGUI\$title, ilRadioOption\addSubItem(), getAllowedLinkTypes(), getExternalLinkMaxLength(), ilFormPropertyGUI\getParentForm(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), getValue(), null, and ilLanguage\txt().

Referenced by insert().

303  : string
304  {
305  $lng = $this->lng;
306  $ilCtrl = $this->ctrl;
307 
308  $ti = null;
309  $ne = null;
310  $hidden_type = null;
311  $hidden_id = null;
312  $hidden_target = null;
313 
314  // parse settings
315  $has_int = $has_ext = $has_radio = $has_list = false;
316  switch ($this->getAllowedLinkTypes()) {
317  case self::EXT:
318  $has_ext = true;
319  break;
320 
321  case self::INT:
322  $has_int = true;
323  break;
324 
325  case self::BOTH:
326  $has_int = true;
327  $has_ext = true;
328  $has_radio = true;
329  break;
330 
331  case self::LIST:
332  $has_int = true;
333  $has_ext = true;
334  $has_radio = true;
335  $has_list = true;
336  break;
337  }
338  if (!$this->getRequired()) {
339  // see #0021274
340  $has_radio = true;
341  }
342 
343  // external
344  if ($has_ext) {
345  $title = $has_radio ? $lng->txt("url") : "";
346 
347  // external
348  $ti = new ilTextInputGUI($title, $this->getPostVar());
349  $ti->setMaxLength($this->getExternalLinkMaxLength());
350  }
351 
352  $itpl = new ilTemplate('tpl.prop_link.html', true, true, 'components/ILIAS/Form');
353 
354  // internal
355  if ($has_int) {
356  $ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", $this->getPostVar());
357  $link = array(get_class($this->getParentForm()), "ilformpropertydispatchgui", get_class($this), "ilinternallinkgui");
358  $link = $ilCtrl->getLinkTargetByClass($link, "", '', true, false);
359  $ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", $this->requested_postvar);
360 
361  $no_disp_class = (strpos($this->getValue(), "|"))
362  ? ""
363  : " ilNoDisplay";
364 
365  $itpl->setVariable("VAL_ID", $this->getPostVar());
366  $itpl->setVariable("URL_EDIT", $link);
367  $itpl->setVariable("TXT_EDIT", $lng->txt("form_get_link"));
368  $itpl->setVariable("CSS_REMOVE", $no_disp_class);
369  $itpl->setVariable("TXT_REMOVE", $lng->txt("remove"));
370 
371  $ne = new ilNonEditableValueGUI($lng->txt("object"), $this->getPostVar() . "_val", true);
372 
373  // hidden field for selected value
374  $hidden_type = new ilHiddenInputGUI($this->getPostVar() . "_ajax_type");
375  $hidden_id = new ilHiddenInputGUI($this->getPostVar() . "_ajax_id");
376  $hidden_target = new ilHiddenInputGUI($this->getPostVar() . "_ajax_target");
377  }
378 
379  // mode
380  if ($has_radio) {
381  // BT 35578: link input might be required (so $has_radio = true), but might only be internal
382  if ($has_ext) {
383  $ext = new ilRadioOption($lng->txt("form_link_external"), "ext");
384  $ext->addSubItem($ti);
385  }
386 
387  if ($has_int) {
388  $int = new ilRadioOption($lng->txt("form_link_internal"), "int");
389  $int->addSubItem($ne);
390  }
391  $mode = new ilRadioGroupInputGUI("", $this->getPostVar() . "_mode");
392  $mode->setParentForm($this->getParentForm());
393  if (!$this->getRequired()) {
394  $no = new ilRadioOption($lng->txt("form_no_link"), "no");
395  $mode->addOption($no);
396  }
397  // BT 35578: link input might be required (so $has_radio = true), but might only be internal
398  if ($has_ext) {
399  $mode->addOption($ext);
400  }
401  if ($has_int) {
402  $mode->addOption($int);
403  }
404  } else {
405  $mode = new ilHiddenInputGUI($this->getPostVar() . "_mode");
406  if ($has_int) {
407  $mode->setValue("int");
408  } else {
409  $mode->setValue("ext");
410  }
411  }
412 
413  // list mode
414  if ($has_list) {
415  $mode_type = new ilRadioGroupInputGUI("", $this->getPostVar() . "_mode_type");
416  $mode_single = new ilRadioOption($lng->txt("webr_link_type_single"), "single");
417  $mode_type->addOption($mode_single);
418  $mode_list = new ilRadioOption($lng->txt("webr_link_type_list"), "list");
419  $mode_type->addOption($mode_list);
420  $mode = new ilRadioGroupInputGUI($lng->txt("webr_link_target"), $this->getPostVar() . "_mode");
421  if (!$this->getRequired()) {
422  $no = new ilRadioOption($lng->txt("form_no_link"), "no");
423  $mode->addOption($no);
424  }
425  $ext = new ilRadioOption($lng->txt("form_link_external"), "ext");
426  $ext->addSubItem($ti);
427  $int = new ilRadioOption($lng->txt("form_link_internal"), "int");
428  $int->addSubItem($ne);
429  $mode->addOption($ext);
430  $mode->addOption($int);
431  $mode_single->addSubItem($mode);
432  }
433 
434  // value
435  $value = $this->getValue();
436  if ($value) {
437  // #15647
438  if ($has_int && self::isInternalLink($value)) {
439  $mode->setValue("int");
440 
441  $value_trans = self::getTranslatedValue($value);
442 
443  $value = explode("|", $value);
444  $hidden_type->setValue($value[0]);
445  $hidden_id->setValue($value[1]);
446  $hidden_target->setValue($value[2] ?? "");
447 
448  $itpl->setVariable("VAL_OBJECT_TYPE", $value_trans["type"]);
449  $itpl->setVariable("VAL_OBJECT_NAME", $value_trans["name"]);
450  if (($value[2] ?? "") != "") {
451  $itpl->setVariable("VAL_TARGET_FRAME", "(" . $value[2] . ")");
452  }
453  } elseif ($has_ext) {
454  $mode->setValue("ext");
455 
456  $ti->setValue($value);
457  }
458  } elseif (!$this->getRequired()) {
459  $mode->setValue("no");
460  }
461 
462  // #10185 - default for external urls
463  if ($has_ext && !$ti->getValue()) {
464  $ti->setValue("https://");
465  }
466 
467  if ($has_int) {
468  $ne->setValue($itpl->get());
469  }
470 
471  // to html
472  if ($has_radio) {
473  $html = $mode->render();
474  } else {
475  $html = $mode->getToolbarHTML();
476 
477  if ($has_ext) {
478  $html .= $ti->getToolbarHTML();
479  } elseif ($has_int) {
480  $html .= $ne->render() .
481  '<div class="help-block">' . $ne->getInfo() . '</div>';
482  }
483  }
484  if ($has_list) {
485  $html = $mode_type->render();
486  }
487 
488  // js for internal link
489  if ($has_int) {
490  $html .= $hidden_type->getToolbarHTML() .
491  $hidden_id->getToolbarHTML() .
492  $hidden_target->getToolbarHTML();
493  }
494 
495  return $html;
496  }
This class represents an option in a radio group.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This class represents a hidden form property in a property form.
This class represents a property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAllowedLinkTypes()

ilLinkInputGUI::setAllowedLinkTypes ( string  $a_val)

Set allowed link types (LIST, BOTH, INT, EXT)

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

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

Referenced by ilObjLinkResourceGUI\addLinkInputToForm(), and ilPageObjectGUI\initOpenedContentForm().

77  : void
78  {
79  $this->allowed_link_types = $a_val;
80  }
+ Here is the caller graph for this function:

◆ setExternalLinkMaxLength()

ilLinkInputGUI::setExternalLinkMaxLength ( int  $a_max)
Parameters
intmax length for external links

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

149  : void
150  {
151  $this->external_link_max_length = $a_max;
152  }

◆ setFilterWhiteList()

ilLinkInputGUI::setFilterWhiteList ( bool  $a_val)

Set filter white list.

Parameters
bool$a_valfilter list is white list

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

136  : void
137  {
138  $this->filter_white_list = $a_val;
139  }

◆ setInternalLinkDefault()

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

Set internal link default.

Parameters
string$a_typelink type
int$a_objobject id

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

96  : void {
97  $this->int_link_default_type = $a_type;
98  $this->int_link_default_obj = $a_obj;
99  }

◆ setInternalLinkFilterTypes()

ilLinkInputGUI::setInternalLinkFilterTypes ( array  $a_val)

Set internal link filter types.

Parameters
array$a_valfilter types

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

106  : void
107  {
108  $this->int_link_filter_types = $a_val;
109  }

◆ setValue()

ilLinkInputGUI::setValue ( string  $a_value)

Set Value.

Parameters
string$a_value

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

Referenced by setValueByArray(), and setValueByIntLinkAttributes().

195  : void
196  {
197  $this->value = $a_value;
198  }
+ Here is the caller graph for this function:

◆ setValueByArray()

ilLinkInputGUI::setValueByArray ( array  $a_values)

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

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

209  : void
210  {
211  switch ($a_values[$this->getPostVar() . "_mode"] ?? null) {
212  case "int":
213  if ($a_values[$this->getPostVar() . "_ajax_type"] &&
214  $a_values[$this->getPostVar() . "_ajax_id"]) {
215  $val = $a_values[$this->getPostVar() . "_ajax_type"] . "|" .
216  $a_values[$this->getPostVar() . "_ajax_id"];
217  if ($a_values[$this->getPostVar() . "_ajax_target"] != "") {
218  $val .= "|" . $a_values[$this->getPostVar() . "_ajax_target"];
219  }
220  $this->setValue($val);
221  }
222  break;
223 
224  case "no":
225  break;
226 
227  default:
228  if ($a_values[$this->getPostVar()]) {
229  $this->setValue($a_values[$this->getPostVar()]);
230  }
231  break;
232  }
233  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setValue(string $a_value)
Set Value.
+ Here is the call graph for this function:

◆ setValueByIntLinkAttributes()

ilLinkInputGUI::setValueByIntLinkAttributes ( string  $a_type,
string  $a_target,
string  $a_target_frame = "" 
)

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

References ilFormPropertyGUI\$type, ilObject\_lookupType(), and setValue().

625  : void {
626  $t = explode("_", $a_target);
627  $target_id = ($t[3] ?? "");
628  $type = "";
629  $map = self::getAttrTypeToType();
630  if ($a_type == "RepositoryItem") {
631  $type = ilObject::_lookupType((int) $target_id, true);
632  } elseif (isset($map[$a_type])) {
633  $type = $map[$a_type];
634  }
635  if ($type != "" && $target_id != "") {
636  $val = $type . "|" . $target_id;
637  if ($a_target_frame != "") {
638  $val .= "|" . $a_target_frame;
639  }
640  $this->setValue($val);
641  }
642  }
setValue(string $a_value)
Set Value.
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

Field Documentation

◆ $allowed_link_types

string ilLinkInputGUI::$allowed_link_types = self::BOTH
protected

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

Referenced by getAllowedLinkTypes().

◆ $external_link_max_length

int ilLinkInputGUI::$external_link_max_length = self::EXTERNAL_LINK_MAX_LENGTH
protected

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

Referenced by getExternalLinkMaxLength().

◆ $filter_white_list

bool ilLinkInputGUI::$filter_white_list = true
protected

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

Referenced by getFilterWhiteList().

◆ $iltypemap

array ilLinkInputGUI::$iltypemap
staticprotected
Initial value:
= array(
"page" => "PageObject",
"chap" => "StructureObject",
"term" => "GlossaryItem",
"wpage" => "WikiPage"
)

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

◆ $int_link_default_obj

int ilLinkInputGUI::$int_link_default_obj = 0
protected

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

◆ $int_link_default_type

string ilLinkInputGUI::$int_link_default_type = "RepositoryItem"
protected

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

◆ $int_link_filter_types

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

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

◆ $obj_definition

ilObjectDefinition ilLinkInputGUI::$obj_definition
protected

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

◆ $requested_postvar

string ilLinkInputGUI::$requested_postvar
protected

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

◆ $value

string ilLinkInputGUI::$value = ""
protected

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

Referenced by getInput(), and getValue().

◆ BOTH

const ilLinkInputGUI::BOTH = "both"

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

Referenced by ilPCSectionGUI\initForm().

◆ EXT

const ilLinkInputGUI::EXT = "ext"

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

Referenced by ilPCSectionGUI\initForm().

◆ EXTERNAL_LINK_MAX_LENGTH

const ilLinkInputGUI::EXTERNAL_LINK_MAX_LENGTH = 200

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

◆ INT

const ilLinkInputGUI::INT = "int"

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

Referenced by ilPageObjectGUI\initOpenedContentForm().

◆ LIST

const ilLinkInputGUI::LIST = "list"

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

Referenced by ilObjLinkResourceGUI\addLinkInputToForm().


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