ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilDclTextRecordRepresentation Class Reference
+ Inheritance diagram for ilDclTextRecordRepresentation:
+ Collaboration diagram for ilDclTextRecordRepresentation:

Public Member Functions

 getHTML (bool $link=true, array $options=[])
 Outputs html of a certain field. More...
 
 fillFormInput (ilPropertyFormGUI $form)
 Fills the form with the value of a record. More...
 
- 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
 
ILIAS COPage Page PageManagerInterface $page_manager
 

Detailed Description

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

Member Function Documentation

◆ fillFormInput()

ilDclTextRecordRepresentation::fillFormInput ( ilPropertyFormGUI  $form)

Fills the form with the value of a record.

Reimplemented from ilDclBaseRecordRepresentation.

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

105 : void
106 {
107 $input_field = $form->getItemByPostVar('field_' . $this->getField()->getId());
108 $raw_input = $this->getFormInput();
109
110 $value = is_array($raw_input) ? $raw_input['link'] : $raw_input;
111 $value = is_string($value) ? $value : "";
112 $field_values = [];
113 if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
114 $field_values["field_" . $this->getRecordField()->getField()->getId() . "_title"] = (isset($raw_input['title'])) ? $raw_input['title'] : '';
115 }
116
117 $field_values["field_" . $this->getRecordField()->getField()->getId()] = $value;
118 $input_field->setValueByArray($field_values);
119 }
getFormInput()
Gets the value from from the record field.
getItemByPostVar(string $a_post_var)

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

+ Here is the call graph for this function:

◆ getHTML()

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

Outputs html of a certain field.

Reimplemented from ilDclBaseRecordRepresentation.

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

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
33 $links = [];
34 if ($field->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
35 $url = $value['link'];
36 $value = $value['title'];
37 if ($url !== "") {
38 $value = $value ?: $this->shortenLink($url);
39 if ($link) {
40 if (substr($url, 0, 3) === 'www') {
41 $url = 'https://' . $url;
42 } elseif (filter_var($url, FILTER_VALIDATE_EMAIL)) {
43 $url = "mailto:" . $url;
44 }
45 $links['dcl_open_url'] = $url;
46 }
47 }
48 }
49 if ($field->hasProperty(ilDclBaseFieldModel::PROP_LINK_DETAIL_PAGE_TEXT) && $link) {
50 if ($this->http->wrapper()->query()->has('tableview_id')) {
51 $tableview_id = $this->http->wrapper()->query()->retrieve('tableview_id', $this->refinery->kindlyTo()->int());
52 } else {
53 $tableview_id = $this->getRecord()->getTable()->getFirstTableViewId($this->user->getId());
54 }
55 if (
57 $this->page_manager->lookupActive($tableview_id, ilDclDetailedViewDefinition::PARENT_TYPE)
58 ) {
59 $this->ctrl->setParameterByClass(ilDclDetailedViewGUI::class, 'record_id', $this->getRecord()->getId());
60 $links['dcl_open_detail_view'] = $this->ctrl->getLinkTargetByClass(ilDclDetailedViewGUI::class, 'renderRecord');
61 $this->ctrl->clearParameterByClass(ilDclDetailedViewGUI::class, 'record_id');
62 }
63 }
64
65 $value = nl2br((string) $value);
66
67 switch (count($links)) {
68 case 0:
69 return $value;
70 case 1:
71 $key = array_keys($links)[0];
72 return $this->renderer->render(
73 $this->factory->link()->standard(
74 $value,
75 reset($links)
76 )->withOpenInNewViewport($key === 'dcl_open_url')
77 );
78 case 2:
79 default:
80 $ui_links = [];
81 foreach ($links as $key => $link) {
82 $ui_links[] = $this->factory->link()->standard(
83 $this->lng->txt($key),
84 $link
85 )->withOpenInNewViewport($key === 'dcl_open_url');
86 }
87 return $this->renderer->render(
88 $this->factory->dropdown()->standard(
89 $ui_links
90 )->withLabel($value)
91 );
92 }
93
94 }
renderer()
factory()
static http()
Fetches the global http state from ILIAS.

References ILIAS\Repository\ctrl(), ilDclDetailedViewDefinition\exists(), factory(), ilDclBaseRecordRepresentation\getField(), ILIAS\Survey\Mode\getId(), ilDclBaseRecordRepresentation\getRecord(), ilDclBaseRecordRepresentation\getRecordField(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ilDclDetailedViewDefinition\PARENT_TYPE, ilDclBaseFieldModel\PROP_LINK_DETAIL_PAGE_TEXT, ilDclBaseFieldModel\PROP_URL, ILIAS\Repository\refinery(), renderer(), shortenLink(), ILIAS\Repository\user(), and ILIAS\GlobalScreen\Scope\Footer\Factory\withOpenInNewViewport().

+ Here is the call graph for this function:

◆ shortenLink()

ilDclTextRecordRepresentation::shortenLink ( string  $value)
protected

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

96 : string
97 {
98 $value = preg_replace('/^(https?:\/\/)?(www\.)?/', '', $value);
99 $half = (int) ((self::LINK_MAX_LENGTH - 4) / 2);
100 $value = preg_replace('/^(.{' . ($half + 1) . '})(.{4,})(.{' . $half . '})$/', '\1...\3', $value);
101
102 return $value;
103 }

References ILIAS\Repository\int().

Referenced by getHTML().

+ 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: