ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDclTextRecordRepresentation Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilDclTextRecordRepresentation:
+ Collaboration diagram for ilDclTextRecordRepresentation:

Public Member Functions

 getHTML (bool $link=true, array $options=[])
 
 fillFormInput (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from ilDclBaseRecordRepresentation
 __construct (ilDclBaseRecordFieldModel $record_field)
 
 getFormGUI (ilPropertyFormGUI $formGUI)
 
 parseFormInput ($value)
 function parses stored value to the variable needed to fill into the form for editing. More...
 
 fillFormInput (ilPropertyFormGUI $form)
 Fills the form with the value of a record. More...
 
 getHTML (bool $link=true, array $options=[])
 Outputs html of a certain field. More...
 
 getSingleHTML (?array $options=null, bool $link=true)
 Returns data for single record view. More...
 
 getConfirmationHTML ()
 Returns data for confirmation list When returning false, attribute is ignored in list. More...
 
 fillRow (ilTemplate $tpl)
 Fills row with record data. More...
 
 getRecordField ()
 Get Record Field. More...
 
 getField ()
 Getter shortcut for field. More...
 
 getRecord ()
 Getter shortcut for record. More...
 

Data Fields

const LINK_MAX_LENGTH = 40
 

Protected Member Functions

 shortenLink (string $value)
 
- Protected Member Functions inherited from ilDclBaseRecordRepresentation
 getFormInput ()
 Gets the value from from the record field. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilDclBaseRecordRepresentation
ilDclBaseRecordFieldModel $record_field
 
ilLanguage $lng
 
ilAccess $access
 
ilCtrl $ctrl
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
ILIAS UI Renderer $renderer
 
ilObjUser $user
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

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

Member Function Documentation

◆ fillFormInput()

ilDclTextRecordRepresentation::fillFormInput ( ilPropertyFormGUI  $form)

Definition at line 99 of file class.ilDclTextRecordRepresentation.php.

References ilDclBaseRecordRepresentation\getField(), ilDclBaseRecordRepresentation\getFormInput(), ILIAS\Survey\Mode\getId(), ilPropertyFormGUI\getItemByPostVar(), ilDclBaseRecordRepresentation\getRecordField(), ilDclBaseFieldModel\PROP_TEXTAREA, and ilDclBaseFieldModel\PROP_URL.

99  : void
100  {
101  $input_field = $form->getItemByPostVar('field_' . $this->getField()->getId());
102  $raw_input = $this->getFormInput();
103 
104  $value = is_array($raw_input) ? $raw_input['link'] : $raw_input;
105  $field_values = [];
106  if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
107  $field_values["field_" . $this->getRecordField()->getField()->getId() . "_title"] = (isset($raw_input['title'])) ? $raw_input['title'] : '';
108  }
109 
110  if ($this->getField()->hasProperty(ilDclBaseFieldModel::PROP_TEXTAREA)) {
111  $breaks = ["<br />"];
112  $value = str_ireplace($breaks, "", $value);
113  }
114 
115  $field_values["field_" . $this->getRecordField()->getField()->getId()] = $value;
116  $input_field->setValueByArray($field_values);
117  }
getItemByPostVar(string $a_post_var)
getFormInput()
Gets the value from from the record field.
+ Here is the call graph for this function:

◆ getHTML()

ilDclTextRecordRepresentation::getHTML ( bool  $link = true,
array  $options = [] 
)

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

References $ref_id, ILIAS\Repository\ctrl(), ilDclBaseRecordRepresentation\getField(), ILIAS\Survey\Mode\getId(), ilDclBaseRecordRepresentation\getRecord(), ilDclBaseRecordRepresentation\getRecordField(), ILIAS\FileDelivery\http(), ilDclBaseFieldModel\PROP_LINK_DETAIL_PAGE_TEXT, ilDclBaseFieldModel\PROP_URL, ILIAS\Repository\refinery(), shortenLink(), and ILIAS\Repository\user().

23  : string
24  {
25  $value = $this->getRecordField()->getValue();
26 
27  $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
28  $views = $this->getRecord()->getTable()->getVisibleTableViews($ref_id, true, $this->user->getId());
29 
30  //Property URL
31  $field = $this->getField();
32  if ($field->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
33  if (is_array($value)) {
34  $link = (string) $value['link'];
35  $link_value = $value['title'] ?: $this->shortenLink($link);
36  } else {
37  $link = (string) $value;
38  $link_value = $this->shortenLink($link);
39  }
40 
41  if (substr($link, 0, 3) === 'www') {
42  $link = 'https://' . $link;
43  }
44 
45  if (preg_match(
46  "/^[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i",
47  $link
48  )) {
49  $link = "mailto:" . $link;
50  } elseif (!(preg_match('~(^(news|(ht|f)tp(s?)\://){1}\S+)~i', $link))) {
51  return $link;
52  }
53 
54  $html = "<a rel='noopener' target='_blank' href='" . htmlspecialchars(
55  $link,
56  ENT_QUOTES
57  ) . "'>" . htmlspecialchars($link_value, ENT_QUOTES) . "</a>";
58  } elseif ($field->hasProperty(ilDclBaseFieldModel::PROP_LINK_DETAIL_PAGE_TEXT) && $link && $views !== []) {
59  $view = array_shift($views);
60  if ($this->http->wrapper()->query()->has('tableview_id')) {
61  $tableview_id = $this->http->wrapper()->query()->retrieve('tableview_id', $this->refinery->kindlyTo()->int());
62  foreach ($views as $v) {
63  if ($v->getId() === $tableview_id) {
64  $view = $tableview_id;
65  break;
66  }
67  }
68  }
69 
70  $this->ctrl->clearParametersByClass("ilDclDetailedViewGUI");
71  $this->ctrl->setParameterByClass(
72  'ilDclDetailedViewGUI',
73  'record_id',
74  $this->getRecordField()->getRecord()->getId()
75  );
76 
77  $this->ctrl->setParameterByClass(ilDclDetailedViewGUI::class, 'table_id', $this->getRecord()->getTableId());
78  $this->ctrl->setParameterByClass(ilDclDetailedViewGUI::class, 'tableview_id', $view->getId());
79  $html = '<a href="' . $this->ctrl->getLinkTargetByClass(
80  "ilDclDetailedViewGUI",
81  'renderRecord'
82  ) . '">' . $value . '</a>';
83  } else {
84  $html = (is_array($value) && isset($value['link'])) ? $value['link'] : nl2br((string) $value);
85  }
86 
87  return $html;
88  }
static http()
Fetches the global http state from ILIAS.
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:

◆ shortenLink()

ilDclTextRecordRepresentation::shortenLink ( string  $value)
protected

Definition at line 90 of file class.ilDclTextRecordRepresentation.php.

References ILIAS\Repository\int().

Referenced by getHTML().

90  : string
91  {
92  $value = preg_replace('/^(https?:\/\/)?(www\.)?/', '', $value);
93  $half = (int) ((self::LINK_MAX_LENGTH - 4) / 2);
94  $value = preg_replace('/^(.{' . ($half + 1) . '})(.{4,})(.{' . $half . '})$/', '\1...\3', $value);
95 
96  return $value;
97  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ LINK_MAX_LENGTH

const ilDclTextRecordRepresentation::LINK_MAX_LENGTH = 40

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


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