ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 101 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.

101  : void
102  {
103  $input_field = $form->getItemByPostVar('field_' . $this->getField()->getId());
104  $raw_input = $this->getFormInput();
105 
106  $value = is_array($raw_input) ? $raw_input['link'] : $raw_input;
107  $value = is_string($value) ? $value : "";
108  $field_values = [];
109  if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
110  $field_values["field_" . $this->getRecordField()->getField()->getId() . "_title"] = (isset($raw_input['title'])) ? $raw_input['title'] : '';
111  }
112 
113  if ($this->getField()->hasProperty(ilDclBaseFieldModel::PROP_TEXTAREA)) {
114  $breaks = ["<br />"];
115  $value = str_ireplace($breaks, "", $value);
116  }
117 
118  $field_values["field_" . $this->getRecordField()->getField()->getId()] = $value;
119  $input_field->setValueByArray($field_values);
120  }
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 $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().

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

◆ shortenLink()

ilDclTextRecordRepresentation::shortenLink ( string  $value)
protected

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

References ILIAS\Repository\int().

Referenced by getHTML().

92  : string
93  {
94  $value = preg_replace('/^(https?:\/\/)?(www\.)?/', '', $value);
95  $half = (int) ((self::LINK_MAX_LENGTH - 4) / 2);
96  $value = preg_replace('/^(.{' . ($half + 1) . '})(.{4,})(.{' . $half . '})$/', '\1...\3', $value);
97 
98  return $value;
99  }
+ 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: