ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilDclTextRecordRepresentation Class Reference
+ 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
ILIAS UI Factory $factory
 
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

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

Member Function Documentation

◆ fillFormInput()

ilDclTextRecordRepresentation::fillFormInput ( ilPropertyFormGUI  $form)

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

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

89  : void
90  {
91  $input_field = $form->getItemByPostVar('field_' . $this->getField()->getId());
92  $raw_input = $this->getFormInput();
93 
94  $value = is_array($raw_input) ? $raw_input['link'] : $raw_input;
95  $value = is_string($value) ? $value : "";
96  $field_values = [];
97  if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
98  $field_values["field_" . $this->getRecordField()->getField()->getId() . "_title"] = (isset($raw_input['title'])) ? $raw_input['title'] : '';
99  }
100 
101  $field_values["field_" . $this->getRecordField()->getField()->getId()] = $value;
102  $input_field->setValueByArray($field_values);
103  }
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 25 of file class.ilDclTextRecordRepresentation.php.

References ILIAS\LTI\ToolProvider\$key, $ref_id, $url, ILIAS\Repository\ctrl(), ilDclBaseRecordRepresentation\getField(), ILIAS\Survey\Mode\getId(), ilDclBaseRecordRepresentation\getRecord(), ilDclBaseRecordRepresentation\getRecordField(), ILIAS\FileDelivery\http(), ilDclDetailedViewDefinition\isActive(), ILIAS\Repository\lng(), ilDclBaseFieldModel\PROP_LINK_DETAIL_PAGE_TEXT, ilDclBaseFieldModel\PROP_URL, ILIAS\Repository\refinery(), shortenLink(), and ILIAS\Repository\user().

25  : string
26  {
27  $value = $this->getRecordField()->getValue();
28 
29  $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
30 
31  $field = $this->getField();
32  $links = [];
33  if ($field->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
34  $url = $value['link'];
35  $value = $value['title'] ?: $this->shortenLink($url);
36  if ($link) {
37  if (substr($url, 0, 3) === 'www') {
38  $url = 'https://' . $url;
39  } elseif (filter_var($url, FILTER_VALIDATE_EMAIL)) {
40  $url = "mailto:" . $url;
41  }
42  $links['dcl_open_url'] = $url;
43  }
44  }
45  if ($field->hasProperty(ilDclBaseFieldModel::PROP_LINK_DETAIL_PAGE_TEXT) && $link) {
46  if ($this->http->wrapper()->query()->has('tableview_id')) {
47  $tableview_id = $this->http->wrapper()->query()->retrieve('tableview_id', $this->refinery->kindlyTo()->int());
48  } else {
49  $tableview_id = $this->getRecord()->getTable()->getFirstTableViewId($this->user->getId());
50  }
51  if (ilDclDetailedViewDefinition::isActive($tableview_id)) {
52  $this->ctrl->clearParametersByClass("ilDclDetailedViewGUI");
53  $this->ctrl->setParameterByClass(ilDclDetailedViewGUI::class, 'table_id', $this->getRecord()->getTableId());
54  $this->ctrl->setParameterByClass(ilDclDetailedViewGUI::class, 'tableview_id', $tableview_id);
55  $this->ctrl->setParameterByClass(ilDclDetailedViewGUI::class, 'record_id', $this->getRecord()->getId());
56  $links['dcl_open_detail_view'] = $this->ctrl->getLinkTargetByClass(ilDclDetailedViewGUI::class, 'renderRecord');
57  }
58  }
59  $value = nl2br((string) $value);
60 
61  switch (count($links)) {
62  case 0:
63  return $value;
64  case 1:
65  return $this->renderer->render(
66  $this->factory->link()->standard($value, reset($links))->withOpenInNewViewport(true)
67  );
68  case 2:
69  default:
70  $ui_links = [];
71  foreach ($links as $key => $link) {
72  $ui_links[] = $this->factory->link()->standard($this->lng->txt($key), $link)->withOpenInNewViewport(true);
73  }
74  return $this->renderer->render(
75  $this->factory->dropdown()->standard($ui_links)->withLabel($value)
76  );
77  }
78  }
static http()
Fetches the global http state from ILIAS.
$ref_id
Definition: ltiauth.php:67
string $key
Consumer key/client ID value.
Definition: System.php:193
$url
Definition: ltiregstart.php:35
+ Here is the call graph for this function:

◆ shortenLink()

ilDclTextRecordRepresentation::shortenLink ( string  $value)
protected

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

References ILIAS\Repository\int().

Referenced by getHTML().

80  : string
81  {
82  $value = preg_replace('/^(https?:\/\/)?(www\.)?/', '', $value);
83  $half = (int) ((self::LINK_MAX_LENGTH - 4) / 2);
84  $value = preg_replace('/^(.{' . ($half + 1) . '})(.{4,})(.{' . $half . '})$/', '\1...\3', $value);
85 
86  return $value;
87  }
+ 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 23 of file class.ilDclTextRecordRepresentation.php.


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