ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDclTextRecordRepresentation Class Reference

Class ilDclTextFieldRepresentation. More...

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

Public Member Functions

 getHTML ($link=true)
 Outputs html of a certain field. More...
 
 fillFormInput ($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 ($form)
 Fills the form with the value of a record. More...
 
 getHTML ($link=true)
 Outputs html of a certain field. More...
 
 getSingleHTML (array $options=null, $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 ($value)
 This method shortens a link. More...
 
- Protected Member Functions inherited from ilDclBaseRecordRepresentation
 getFormInput ()
 Gets the value from from the record field. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilDclBaseRecordRepresentation
 $record_field
 
 $lng
 
 $access
 
 $ctrl
 

Detailed Description

Member Function Documentation

◆ fillFormInput()

ilDclTextRecordRepresentation::fillFormInput (   $form)

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

References $form, array, ilDclBaseRecordRepresentation\getField(), ilDclBaseRecordRepresentation\getFormInput(), ilDclBaseRecordRepresentation\getRecordField(), ilDclBaseFieldModel\PROP_TEXTAREA, and ilDclBaseFieldModel\PROP_URL.

92  {
93  $input_field = $form->getItemByPostVar('field_' . $this->getField()->getId());
94  $raw_input = $this->getFormInput();
95 
96  $value = is_array($raw_input) ? $raw_input['link'] : $raw_input;
97  $field_values = array();
98  if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
99  $field_values["field_" . $this->getRecordField()->getField()->getId() . "_title"] = (isset($raw_input['title']))? $raw_input['title'] : '';
100  }
101 
102  if ($this->getField()->hasProperty(ilDclBaseFieldModel::PROP_TEXTAREA)) {
103  $breaks = array( "<br />" );
104  $value = str_ireplace($breaks, "", $value);
105  }
106 
107  $field_values["field_" . $this->getRecordField()->getField()->getId()] = $value;
108  $input_field->setValueByArray($field_values);
109  }
getFormInput()
Gets the value from from the record field.
if(isset($_POST['submit'])) $form
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getHTML()

ilDclTextRecordRepresentation::getHTML (   $link = true)

Outputs html of a certain field.

Parameters
mixed$value
bool | true$link
Returns
string

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

References $_GET, $html, ilDclBaseRecordRepresentation\getField(), ilDclBaseRecordRepresentation\getRecord(), ilDclBaseRecordRepresentation\getRecordField(), ilDclDetailedViewDefinition\isActive(), ilDclBaseFieldModel\PROP_LINK_DETAIL_PAGE_TEXT, ilDclBaseFieldModel\PROP_URL, and shortenLink().

20  {
21  $value = $this->getRecordField()->getValue();
22 
23  //Property URL
24  $field = $this->getField();
25  if ($field->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
26  if (is_array($value)) {
27  $link = $value['link'];
28  $link_value = $value['title'] ? $value['title'] : $this->shortenLink($link);
29  } else {
30  $link = $value;
31  $link_value = $this->shortenLink($value);
32  }
33 
34  if (substr($link, 0, 3) === 'www') {
35  $link = 'http://' . $link;
36  }
37 
38  if (preg_match("/^[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", $link)) {
39  $link = "mailto:" . $link;
40  } elseif (!(preg_match('~(^(news|(ht|f)tp(s?)\://){1}\S+)~i', $link))) {
41  return $link;
42  }
43 
44  $html = "<a rel='noopener' target='_blank' href='" . htmlspecialchars($link, ENT_QUOTES) . "'>" . htmlspecialchars($link_value, ENT_QUOTES) . "</a>";
45  } elseif ($field->hasProperty(ilDclBaseFieldModel::PROP_LINK_DETAIL_PAGE_TEXT) && $link && ilDclDetailedViewDefinition::isActive($_GET['tableview_id'])) {
46  $this->ctrl->clearParametersByClass("ilDclDetailedViewGUI");
47  $this->ctrl->setParameterByClass('ilDclDetailedViewGUI', 'record_id', $this->getRecordField()->getRecord()->getId());
48  $this->ctrl->setParameterByClass('ilDclDetailedViewGUI', 'tableview_id', $_GET['tableview_id']);
49  $html = '<a href="' . $this->ctrl->getLinkTargetByClass("ilDclDetailedViewGUI", 'renderRecord') . '">' . $value . '</a>';
50  } else {
51  $html = (is_array($value) && isset($value['link']))? $value['link'] : $value;
52  }
53  return $html;
54  }
$_GET["client_id"]
shortenLink($value)
This method shortens a link.
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ shortenLink()

ilDclTextRecordRepresentation::shortenLink (   $value)
protected

This method shortens a link.

The http(s):// and the www part are taken away. The rest will be shortened to sth similar to: "somelink.de/lange...gugus.html".

Parameters
$valueThe link in it's original form.
Returns
string The shortened link

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

Referenced by getHTML().

65  {
66  if (strlen($value) > self::LINK_MAX_LENGTH) {
67  if (substr($value, 0, 7) == "http://") {
68  $value = substr($value, 7);
69  }
70  if (substr($value, 0, 8) == "https://") {
71  $value = substr($value, 8);
72  }
73  if (substr($value, 0, 4) == "www.") {
74  $value = substr($value, 4);
75  }
76  }
77  $link = $value;
78 
79  if (strlen($value) > self::LINK_MAX_LENGTH) {
80  $link = substr($value, 0, (self::LINK_MAX_LENGTH - 3) / 2);
81  $link .= "...";
82  $link .= substr($value, -(self::LINK_MAX_LENGTH - 3) / 2);
83  }
84 
85  return $link;
86  }
+ Here is the caller graph for this function:

Field Documentation

◆ LINK_MAX_LENGTH

const ilDclTextRecordRepresentation::LINK_MAX_LENGTH = 40

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


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