ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilDataCollectionNReferenceFieldGUI Class Reference

Class ilDataCollectionNReferenceFieldGUI. More...

+ Collaboration diagram for ilDataCollectionNReferenceFieldGUI:

Public Member Functions

 __construct (ilDataCollectionNReferenceField $field)
 
 getSingleHTML ($options=NULL)
 
 getHTML ()
 

Protected Member Functions

 buildTemplate (ilDataCollectionNReferenceField $record_field, $values, $options)
 

Protected Attributes

 $field
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDataCollectionNReferenceFieldGUI::__construct ( ilDataCollectionNReferenceField  $field)

Member Function Documentation

◆ buildTemplate()

ilDataCollectionNReferenceFieldGUI::buildTemplate ( ilDataCollectionNReferenceField  $record_field,
  $values,
  $options 
)
protected
Parameters
$record_field
$values
$options
Returns
ilTemplate

Definition at line 50 of file class.ilDataCollectionNReferenceFieldGUI.php.

50 {
51 $tpl = new ilTemplate("tpl.reference_list.html", true, true, "Modules/DataCollection");
52 $tpl->setCurrentBlock("reference_list");
53 foreach ($values as $value) {
54 $ref_record = ilDataCollectionCache::getRecordCache($value);
55 if (! $ref_record->getTableId() || ! $record_field->getField() || ! $record_field->getField()->getTableId()) {
56 //the referenced record_field does not seem to exist.
57 $record_field->setValue(0);
58 $record_field->doUpdate();
59 } else {
60 $tpl->setCurrentBlock("reference");
61 if (! $options) {
62 $tpl->setVariable("CONTENT", $ref_record->getRecordFieldHTML($record_field->getField()->getFieldRef()));
63 } else {
64 $tpl->setVariable("CONTENT", $record_field->getLinkHTML($options['link']['name'], $value));
65 }
66 $tpl->parseCurrentBlock();
67 }
68 }
69 $tpl->parseCurrentBlock();
70
71 return $tpl;
72 }
global $tpl
Definition: ilias.php:8
static getRecordCache($record_id=0)
setValue($value, $omit_parsing=false)
Set value for record field.
special template class to simplify handling of ITX/PEAR
if(!is_array($argv)) $options

References $options, $tpl, ilDataCollectionNReferenceField\doUpdate(), ilDataCollectionRecordField\getField(), ilDataCollectionNReferenceField\getLinkHTML(), ilDataCollectionCache\getRecordCache(), and ilDataCollectionRecordField\setValue().

Referenced by getSingleHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHTML()

ilDataCollectionNReferenceFieldGUI::getHTML ( )
Returns
array|mixed|string

Definition at line 78 of file class.ilDataCollectionNReferenceFieldGUI.php.

78 {
79 $values = $this->field->getValue();
80 $record_field = $this->field;
81
82 if (!$values OR !count($values)) {
83 return "";
84 }
85
86 $html = "";
87 $cut = false;
88 $tpl = new ilTemplate("tpl.reference_hover.html", true, true, "Modules/DataCollection");
89 $tpl->setCurrentBlock("reference_list");
90 $elements = array();
91 foreach ($values as $value) {
92 $ref_record = ilDataCollectionCache::getRecordCache($value);
93 if (!$ref_record->getTableId() OR !$record_field->getField() OR !$record_field->getField()->getTableId()) {
94 //the referenced record_field does not seem to exist.
95 $record_field->setValue(NULL);
96 $record_field->doUpdate();
97 } else {
98 $elements[] = array('value' => $ref_record->getRecordFieldHTML($this->field->getField()->getFieldRef()),
99 'sort' => $ref_record->getRecordFieldSortingValue($this->field->getField()->getFieldRef()));
100
101 }
102 }
103 //sort fetched elements
104 $is_numeric = false;
105 $ref_field = new ilDataCollectionField($this->field->getField()->getFieldRef());
106 switch ($ref_field->getDatatypeId()) {
109 $is_numeric = true;
110 break;
111 }
112 $elements = ilUtil::sortArray($elements, 'sort', 'asc', $is_numeric);
113
114 //concat
115 foreach($elements as $element) {
116 if ((strlen($html) < $record_field->getMaxReferenceLength())) {
117 $html .= $element['value'] . ", ";
118 } else {
119 $cut = true;
120 }
121 $tpl->setCurrentBlock("reference");
122 $tpl->setVariable("CONTENT", $element['value']);
123 $tpl->parseCurrentBlock();
124 }
125
126 $html = substr($html, 0, - 2);
127 if ($cut) {
128 $html .= "...";
129 }
130 $tpl->setVariable("RECORD_ID", $record_field->getRecord()->getId());
131 $tpl->setVariable("ALL", $html);
132 $tpl->parseCurrentBlock();
133
134 return $tpl->get();
135 }
Class ilDataCollectionField.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$html
Definition: example_001.php:87

References $field, $html, $tpl, ilDataCollectionCache\getRecordCache(), ilDataCollectionDatatype\INPUTFORMAT_DATETIME, ilDataCollectionDatatype\INPUTFORMAT_NUMBER, and ilUtil\sortArray().

+ Here is the call graph for this function:

◆ getSingleHTML()

ilDataCollectionNReferenceFieldGUI::getSingleHTML (   $options = NULL)
Parameters
ilDataCollectionNReferenceField$field
null$options
Returns
string

Definition at line 30 of file class.ilDataCollectionNReferenceFieldGUI.php.

30 {
31 $values = $this->field->getValue();
32
33 if (! $values || ! count($values)) {
34 return "";
35 }
36
37 $tpl = $this->buildTemplate($this->field, $values, $options);
38
39 return $tpl->get();
40 }
buildTemplate(ilDataCollectionNReferenceField $record_field, $values, $options)

References $options, $tpl, and buildTemplate().

+ Here is the call graph for this function:

Field Documentation

◆ $field

ilDataCollectionNReferenceFieldGUI::$field
protected

Definition at line 13 of file class.ilDataCollectionNReferenceFieldGUI.php.

Referenced by __construct(), and getHTML().


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