ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules 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. More...
 
 setAllowedLinkTypes ($a_val)
 Set allowed link types (BOTH, INT, EXT) More...
 
 getAllowedLinkTypes ()
 Get allowed link types (BOTH, INT, EXT) More...
 
 setInternalLinkDefault ($a_type, $a_obj=0)
 Set internal link default. More...
 
 setInternalLinkFilterTypes (array $a_val)
 Set internal link filter types. More...
 
 executeCommand ()
 Execute current command. More...
 
 setValue ($a_value)
 Set Value. More...
 
 getValue ()
 Get Value. More...
 
 setValueByArray ($a_values)
 Set value by array. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 render ()
 Render item. More...
 
 getContentOutsideFormTag ()
 
 insert (&$a_tpl)
 Insert property html. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
executeCommand ()
 Execute command. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setPostVar ($a_postvar)
 Set Post Variable. More...
 
 getPostVar ()
 Get Post Variable. More...
 
 getFieldId ()
 Get Post Variable. More...
 
 setInfo ($a_info)
 Set Information Text. More...
 
 getInfo ()
 Get Information Text. More...
 
 setAlert ($a_alert)
 Set Alert Text. More...
 
 getAlert ()
 Get Alert Text. More...
 
 setRequired ($a_required)
 Set Required. More...
 
 getRequired ()
 Get Required. More...
 
 setDisabled ($a_disabled)
 Set Disabled. More...
 
 getDisabled ()
 Get Disabled. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm ($a_parentform)
 Set Parent Form. More...
 
 getParentForm ()
 Get Parent Form. More...
 
 setParent ($a_val)
 Set Parent GUI object. More...
 
 getParent ()
 Get Parent GUI object. More...
 
 getSubForm ()
 Get sub form html. More...
 
 hideSubForm ()
 Sub form hidden on init? More...
 
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders) More...
 
 getHiddenTitle ()
 Get hidden title. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
 serializeData ()
 serialize data More...
 
 unserializeData ($a_data)
 unserialize data More...
 
 writeToSession ()
 Write to session. More...
 
 clearFromSession ()
 Clear session value. More...
 
 readFromSession ()
 Read from session. More...
 
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties) More...
 
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi. More...
 
 getMulti ()
 Get Multi. More...
 
 setMultiValues (array $a_values)
 Set multi values. More...
 
 getMultiValues ()
 Get multi values. More...
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 

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. More...
 
 getMultiIconsHTML ()
 Get HTML for multiple value icons. More...
 

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

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

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

References ilFormPropertyGUI\setType().

32  {
33  parent::__construct($a_title, $a_postvar);
34  $this->setType("link");
35  }
setType($a_type)
Set Type.
+ 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
boolean Input ok, true/false

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

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

172  {
173  global $lng;
174 
175  // debugging
176  // return false;
177 
178  if($this->getRequired())
179  {
180  switch($_POST[$this->getPostVar()."_mode"])
181  {
182  case "ext":
183  if(!$_POST[$this->getPostVar()])
184  {
185  $this->setAlert($lng->txt("msg_input_is_required"));
186  return false;
187  }
188  break;
189 
190  case "int":
191  if(!$_POST[$this->getPostVar()."_ajax_type"] ||
192  !$_POST[$this->getPostVar()."_ajax_id"])
193  {
194  $this->setAlert($lng->txt("msg_input_is_required"));
195  return false;
196  }
197  break;
198 
199  default:
200  $this->setAlert($lng->txt("msg_input_is_required"));
201  return false;
202  }
203  }
204 
205  if($_POST[$this->getPostVar()."_mode"] == "int")
206  {
207  $_POST[$this->getPostVar()."_ajax_type"] = ilUtil::stripSlashes($_POST[$this->getPostVar()."_ajax_type"]);
208  $_POST[$this->getPostVar()."_ajax_id"] = ilUtil::stripSlashes($_POST[$this->getPostVar()."_ajax_id"]);
209  $_POST[$this->getPostVar()."_ajax_target"] = ilUtil::stripSlashes($_POST[$this->getPostVar()."_ajax_target"]);
210 
211  // overwriting post-data so getInput() will work
212  $val = $_POST[$this->getPostVar()."_ajax_type"]."|".
213  $_POST[$this->getPostVar()."_ajax_id"];
214  if ($_POST[$this->getPostVar()."_ajax_target"] != "")
215  {
216  $val.= "|".$_POST[$this->getPostVar()."_ajax_target"];
217  }
218 
219  $_POST[$this->getPostVar()] = $val;
220  }
221  else
222  {
223  $_POST[$this->getPostVar()] = ilUtil::stripSlashes($_POST[$this->getPostVar()]);
224  }
225 
226  return true;
227  }
$_POST['username']
Definition: cron.php:12
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ executeCommand()

ilLinkInputGUI::executeCommand ( )

Execute current command.

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

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

83  {
84  global $ilCtrl, $lng;
85 
86  $next_class = $ilCtrl->getNextClass($this);
87  $cmd = $ilCtrl->getCmd();
88 
89  switch($next_class)
90  {
91  case "ilinternallinkgui":
92  $lng->loadLanguageModule("content");
93  require_once("./Modules/LearningModule/classes/class.ilInternalLinkGUI.php");
94  $link_gui = new ilInternalLinkGUI($this->int_link_default_type,
95  $this->int_link_default_obj);
96  foreach ($this->int_link_filter_types as $t)
97  {
98  $link_gui->filterLinkType($t);
99  }
100  $link_gui->setFilterWhiteList(true);
101  $link_gui->setMode("asynch");
102 
103  $ret = $ilCtrl->forwardCommand($link_gui);
104  break;
105 
106  default:
107  var_dump($cmd);
108  //exit();
109  }
110 
111  return $ret;
112  }
$cmd
Definition: sahs_server.php:35
Class ilInternalLinkGUI.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40

◆ getAllowedLinkTypes()

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().

53  {
55  }
+ Here is the caller graph for this function:

◆ getContentOutsideFormTag()

ilLinkInputGUI::getContentOutsideFormTag ( )

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

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

387  {
388  if($this->getAllowedLinkTypes() == self::INT ||
389  $this->getAllowedLinkTypes() == self::BOTH)
390  {
391  // as the ajax-panel uses a form it has to be outside of the parent form!
393  }
394  }
getAllowedLinkTypes()
Get allowed link types (BOTH, INT, EXT)
getInitHTML($a_url, $a_move_to_body=false)
Get initialisation HTML to use interna link editing.
+ Here is the call graph for this function:

◆ getTranslatedValue()

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().

418  {
419  global $lng;
420 
421  $value = explode("|", $a_value);
422 
423  switch($value[0])
424  {
425  case "media":
426  $type = $lng->txt("obj_mob");
427  $name = ilObject::_lookupTitle($value[1]);
428  break;
429 
430  case "page":
431  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
432  $type = $lng->txt("obj_pg");
433  $name = ilLMPageObject::_lookupTitle($value[1]);
434  break;
435 
436  case "term":
437  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
438  $type = $lng->txt("term");
439  $name = ilGlossaryTerm::_lookGlossaryTerm($value[1]);
440  break;
441 
442  default:
443  $type = $lng->txt("obj_".$value[0]);
445  break;
446  }
447 
448  return array("type"=>$type, "name"=>$name);
449  }
static _lookupTitle($a_id)
lookup object title
_lookGlossaryTerm($term_id)
get glossary term
static _lookupTitle($a_obj_id)
Lookup title.
static _lookupObjId($a_id)
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValue()

ilLinkInputGUI::getValue ( )

Get Value.

Returns
string Value

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

Referenced by render().

130  {
131  return $this->value;
132  }
+ Here is the caller graph for this function:

◆ insert()

ilLinkInputGUI::insert ( $a_tpl)

Insert property html.

Returns
int Size

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

References render().

457  {
458  $html = $this->render();
459 
460  $a_tpl->setCurrentBlock("prop_generic");
461  $a_tpl->setVariable("PROP_GENERIC", $html);
462  $a_tpl->parseCurrentBlock();
463  }
render()
Render item.
+ Here is the call graph for this function:

◆ isInternalLink()

static ilLinkInputGUI::isInternalLink (   $a_value)
static

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

Referenced by ilObjLinkResourceGUI\callDirectLink(), and ilObjLinkResourceGUI\callLink().

397  {
398  if(strpos($a_value, "|"))
399  {
400  $parts = explode("|", $a_value);
401  if(sizeof($parts) == 2 || sizeof($parts) == 3)
402  {
403  // numeric id
404  if(is_numeric($parts[1]))
405  {
406  // simple type
407  if(preg_match("/^[a-zA-Z_]+$/", $parts[0], $matches))
408  {
409  return true;
410  }
411  }
412  }
413  }
414  return false;
415  }
+ Here is the caller graph for this function:

◆ render()

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(), and getValue().

Referenced by insert().

233  {
234  global $lng, $ilCtrl;
235 
236  // parse settings
237  $has_int = $has_ext = $has_radio = false;
238  switch($this->getAllowedLinkTypes())
239  {
240  case self::EXT:
241  $has_ext = true;
242  break;
243 
244  case self::INT:
245  $has_int = true;
246  break;
247 
248  case self::BOTH:
249  $has_int = true;
250  $has_ext = true;
251  $has_radio = true;
252  break;
253  }
254 
255  // external
256  if($has_ext)
257  {
258  $title = $has_radio ? $lng->txt("url") : "";
259 
260  // external
261  $ti = new ilTextInputGUI($title, $this->getPostVar());
262  $ti->setMaxLength(200);
263  $ti->setSize(50);
264  }
265 
266  // internal
267  if($has_int)
268  {
269  $ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", $this->getPostVar());
270  $link = array(get_class($this->getParent()), "ilformpropertydispatchgui", get_class($this), "ilinternallinkgui");
271  $link = $ilCtrl->getLinkTargetByClass($link, "", false, true, false);
272  $ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", "");
273 
274  $no_disp_class = (strpos($this->getValue(), "|"))
275  ? ""
276  : " ilNoDisplay";
277 
278  $itpl = new ilTemplate('tpl.prop_link.html',true,true,'Services/Form');
279  $itpl->setVariable("VAL_ID", $this->getPostVar());
280  $itpl->setVariable("URL_EDIT", $link);
281  $itpl->setVariable("TXT_EDIT", $lng->txt("form_get_link"));
282  $itpl->setVariable("CSS_REMOVE", $no_disp_class);
283  $itpl->setVariable("TXT_REMOVE", $lng->txt("remove"));
284 
285  $ne = new ilNonEditableValueGUI($lng->txt("object"), $this->getPostVar()."_val", true);
286 
287  // hidden field for selected value
288  $hidden_type = new ilHiddenInputGUI($this->getPostVar()."_ajax_type");
289  $hidden_id = new ilHiddenInputGUI($this->getPostVar()."_ajax_id");
290  $hidden_target = new ilHiddenInputGUI($this->getPostVar()."_ajax_target");
291  }
292 
293  // mode
294  if ($has_radio)
295  {
296  $ext = new ilRadioOption($lng->txt("form_link_external"), "ext");
297  $ext->addSubItem($ti);
298 
299  $int = new ilRadioOption($lng->txt("form_link_internal"), "int");
300  $int->addSubItem($ne);
301 
302  $mode = new ilRadioGroupInputGUI("", $this->getPostVar()."_mode");
303  $mode->addOption($ext);
304  $mode->addOption($int);
305  }
306  else
307  {
308  $mode = new ilHiddenInputGUI($this->getPostVar()."_mode");
309  if ($has_int)
310  {
311  $mode->setValue("int");
312  }
313  else
314  {
315  $mode->setValue("ext");
316  }
317  }
318 
319  // value
320  $value = $this->getValue();
321  if($value)
322  {
323  // #15647
324  if($has_int && self::isInternalLink($value))
325  {
326  $mode->setValue("int");
327 
328  $value_trans = self::getTranslatedValue($value);
329 
330  $value = explode("|", $value);
331  $hidden_type->setValue($value[0]);
332  $hidden_id->setValue($value[1]);
333  $hidden_target->setValue($value[2]);
334 
335  $itpl->setVariable("VAL_OBJECT_TYPE", $value_trans["type"]);
336  $itpl->setVariable("VAL_OBJECT_NAME", $value_trans["name"]);
337  }
338  else if($has_ext)
339  {
340  $mode->setValue("ext");
341 
342  $ti->setValue($value);
343  }
344  }
345 
346  // #10185 - default for external urls
347  if($has_ext && !$ti->getValue())
348  {
349  $ti->setValue("http://");
350  }
351 
352  $ne->setValue($itpl->get());
353 
354  // to html
355  if ($has_radio)
356  {
357  $html = $mode->render();
358  }
359  else
360  {
361  $html = $mode->getToolbarHTML();
362 
363  if ($has_ext)
364  {
365  $html.= $ti->getToolbarHTML();
366  }
367  else
368  {
369  $html.= $ne->render().
370  '<div class="ilFormInfo">'.$ne->getInfo().'</div>';
371  }
372  }
373 
374  // js for internal link
375  if($has_int)
376  {
377  include_once("./Modules/LearningModule/classes/class.ilInternalLinkGUI.php");
378  $html.= $hidden_type->getToolbarHTML().
379  $hidden_id->getToolbarHTML().
380  $hidden_target->getToolbarHTML();
381  }
382 
383  return $html;
384  }
This class represents an option in a radio group.
getPostVar()
Get Post Variable.
global $ilCtrl
Definition: ilias.php:18
This class represents a hidden form property in a property form.
This class represents a property in a property form.
addSubItem($a_item)
Add Subitem.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
getParent()
Get Parent GUI object.
This class represents a non editable value in a property form.
global $lng
Definition: privfeed.php:40
getAllowedLinkTypes()
Get allowed link types (BOTH, INT, EXT)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAllowedLinkTypes()

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().

43  {
44  $this->allowed_link_types = $a_val;
45  }
+ Here is the caller graph for this function:

◆ setInternalLinkDefault()

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.

64  {
65  $this->int_link_default_type = $a_type;
66  $this->int_link_default_obj = $a_obj;
67  }

◆ setInternalLinkFilterTypes()

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().

75  {
76  $this->int_link_filter_types = $a_val;
77  }
+ Here is the caller graph for this function:

◆ setValue()

ilLinkInputGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

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

Referenced by setValueByArray().

120  {
121  $this->value = $a_value;
122  }
+ Here is the caller graph for this function:

◆ setValueByArray()

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().

140  {
141  switch($a_values[$this->getPostVar()."_mode"])
142  {
143  case "int":
144  if($a_values[$this->getPostVar()."_ajax_type"] &&
145  $a_values[$this->getPostVar()."_ajax_id"])
146  {
147  $val = $a_values[$this->getPostVar()."_ajax_type"]."|".
148  $a_values[$this->getPostVar()."_ajax_id"];
149  if ($a_values[$this->getPostVar()."_ajax_target"] != "")
150  {
151  $val.= "|".$a_values[$this->getPostVar()."_ajax_target"];
152  }
153  $this->setValue($val);
154  }
155  break;
156 
157  default:
158  if($a_values[$this->getPostVar()])
159  {
160  $this->setValue($a_values[$this->getPostVar()]);
161  }
162  break;
163  }
164  }
getPostVar()
Get Post Variable.
setValue($a_value)
Set Value.
+ Here is the call graph for this function:

Field Documentation

◆ $allowed_link_types

ilLinkInputGUI::$allowed_link_types = self::BOTH
protected

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

Referenced by getAllowedLinkTypes().

◆ $int_link_default_obj

ilLinkInputGUI::$int_link_default_obj = 0
protected

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

◆ $int_link_default_type

ilLinkInputGUI::$int_link_default_type = "RepositoryItem"
protected

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

◆ $int_link_filter_types

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

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

◆ BOTH

const ilLinkInputGUI::BOTH = "both"

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

◆ EXT

const ilLinkInputGUI::EXT = "ext"

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

◆ INT

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: