ILIAS  release_7 Revision v7.30-3-g800a261c036
ilDclNReferenceRecordFieldModel Class Reference
+ Inheritance diagram for ilDclNReferenceRecordFieldModel:
+ Collaboration diagram for ilDclNReferenceRecordFieldModel:

Public Member Functions

 getMaxReferenceLength ()
 
 setMaxReferenceLength ($max_reference_length)
 
 doUpdate ()
 Update object in database. More...
 
 getValue ()
 
 getSingleHTML ($options=null)
 @description this funciton is used to in the viewdefinition of a single record. More...
 
 getLinkHTML ($link, $value)
 
 getHTML ()
 
 getValueFromExcel ($excel, $row, $col)
 
 getExportValue ()
 
- Public Member Functions inherited from ilDclReferenceRecordFieldModel
 __construct (ilDclBaseRecordModel $record, ilDclBaseFieldModel $field)
 
 getExportValue ()
 
 getValueFromExcel ($excel, $row, $col)
 
 getReferenceFromValue ($value)
 
 afterClone ()
 
- Public Member Functions inherited from ilDclBaseRecordFieldModel
 __construct (ilDclBaseRecordModel $record, ilDclBaseFieldModel $field)
 
 doCreate ()
 Creates an Id and a database entry. More...
 
 doUpdate ()
 Update object in database. More...
 
 delete ()
 Delete record field in database. More...
 
 getValue ()
 
 getValueForRepresentation ()
 
 serializeData ($value)
 Serialize data before storing to db. More...
 
 deserializeData ($value)
 Deserialize data before applying to field. More...
 
 setValue ($value, $omit_parsing=false)
 Set value for record field. More...
 
 setValueFromForm ($form)
 
 getFormulaValue ()
 
 parseExportValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 getValueFromExcel ($excel, $row, $col)
 
 parseValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 getExportValue ()
 
 fillExcelExport (ilExcel $worksheet, &$row, &$col)
 
 getPlainText ()
 
 getSortingValue ($link=true)
 
 addHiddenItemsToConfirmation (ilConfirmationGUI &$confirmation)
 
 parseSortingValue ($value, $link=true)
 Returns sortable value for the specific field-types. More...
 
 cloneStructure (ilDclBaseRecordFieldModel $old_record_field)
 
 afterClone ()
 
 getField ()
 
 getId ()
 
 getRecord ()
 
 getRecordRepresentation ()
 
 setRecordRepresentation ($record_representation)
 
 getFieldRepresentation ()
 
 setFieldRepresentation ($field_representation)
 

Protected Member Functions

 loadValueSorted ()
 
 loadValue ()
 Load the value. More...
 
 getReferencesFromString ($stringValues)
 This method tries to get as many valid references out of a string separated by commata. More...
 
- Protected Member Functions inherited from ilDclReferenceRecordFieldModel
 getReferencesFromString ($stringValues)
 This method tries to get as many valid references out of a string separated by commata. More...
 
 getCloneRecordId (string $clone_reference)
 
- Protected Member Functions inherited from ilDclBaseRecordFieldModel
 doRead ()
 Read object data from database. More...
 
 loadValue ()
 Load the value. More...
 

Protected Attributes

 $max_reference_length = 20
 
- Protected Attributes inherited from ilDclReferenceRecordFieldModel
 $dcl_obj_id
 
- Protected Attributes inherited from ilDclBaseRecordFieldModel
 $id
 
 $field
 
 $record
 
 $record_representation
 
 $field_representation
 
 $value
 
 $user
 
 $ctrl
 
 $db
 
 $lng
 

Detailed Description

Member Function Documentation

◆ doUpdate()

ilDclNReferenceRecordFieldModel::doUpdate ( )

Update object in database.

Reimplemented from ilDclBaseRecordFieldModel.

Definition at line 35 of file class.ilDclNReferenceRecordFieldModel.php.

36 {
37 global $DIC;
38 $ilDB = $DIC['ilDB'];
39
40 $values = $this->getValue();
41 if (!is_array($values)) {
42 $values = array($values);
43 }
44 $datatype = $this->getField()->getDatatype();
45
46 $query = "DELETE FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = "
47 . $ilDB->quote($this->id, "integer");
48 $ilDB->manipulate($query);
49
50 if (!count($values) || $values[0] == 0) {
51 return;
52 }
53
54 $query = "INSERT INTO il_dcl_stloc" . $datatype->getStorageLocation() . "_value (value, record_field_id, id) VALUES";
55 foreach ($values as $value) {
56 $next_id = $ilDB->nextId("il_dcl_stloc" . $datatype->getStorageLocation() . "_value");
57 $query .= " (" . $ilDB->quote($value, $datatype->getDbType()) . ", " . $ilDB->quote($this->getId(), "integer") . ", "
58 . $ilDB->quote($next_id, "integer") . "),";
59 }
60 $query = substr($query, 0, -1);
61 $ilDB->manipulate($query);
62 }
global $DIC
Definition: goto.php:24
$query
global $ilDB

References $DIC, $ilDB, $query, ilDclBaseRecordFieldModel\$value, ilDclBaseRecordFieldModel\getField(), ilDclBaseRecordFieldModel\getId(), and getValue().

Referenced by ilDclNReferenceFieldGUI\buildTemplate().

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

◆ getExportValue()

ilDclNReferenceRecordFieldModel::getExportValue ( )
Returns
int|string

Reimplemented from ilDclReferenceRecordFieldModel.

Definition at line 219 of file class.ilDclNReferenceRecordFieldModel.php.

220 {
221 $values = $this->getValue();
222 $names = array();
223 foreach ($values as $value) {
224 if ($value) {
226 $names[] = $ref_rec->getRecordField($this->getField()->getFieldRef())->getValue();
227 }
228 }
229 $string = "";
230 foreach ($names as $name) {
231 $string .= $name . ", ";
232 }
233 if (!count($names)) {
234 return "";
235 }
236 $string = substr($string, 0, -2);
237
238 return $string;
239 }
static getRecordCache($record_id=0)
if($format !==null) $name
Definition: metadata.php:230

References $name, ilDclBaseRecordFieldModel\$value, ilDclBaseRecordFieldModel\getField(), ilDclCache\getRecordCache(), and getValue().

+ Here is the call graph for this function:

◆ getHTML()

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

Definition at line 190 of file class.ilDclNReferenceRecordFieldModel.php.

191 {
192 $ilDataCollectionNReferenceFieldGUI = new ilDclNReferenceFieldGUI($this);
193
194 return $ilDataCollectionNReferenceFieldGUI->getHTML();
195 }
Class ilDclNReferenceFieldGUI.

◆ getLinkHTML()

ilDclNReferenceRecordFieldModel::getLinkHTML (   $link,
  $value 
)
Parameters
null$link
$value
Returns
string

Definition at line 177 of file class.ilDclNReferenceRecordFieldModel.php.

178 {
179 if ($link == "[" . $this->getField()->getTitle() . "]") {
180 $link = null;
181 }
182
183 return parent::getLinkHTML($link, $value);
184 }

References ilDclBaseRecordFieldModel\$value, and ilDclBaseRecordFieldModel\getField().

Referenced by ilDclNReferenceFieldGUI\buildTemplate().

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

◆ getMaxReferenceLength()

ilDclNReferenceRecordFieldModel::getMaxReferenceLength ( )

◆ getReferencesFromString()

ilDclNReferenceRecordFieldModel::getReferencesFromString (   $stringValues)
protected

This method tries to get as many valid references out of a string separated by commata.

This is problematic as a string value could contain commata itself. It is optimized to work with an exported list from this DataCollection. And works fine in most cases. Only areference list with the values "hello" and "hello, world" Will mess with it.

Parameters
$stringValuesstring
Returns
int[]

Reimplemented from ilDclReferenceRecordFieldModel.

Definition at line 251 of file class.ilDclNReferenceRecordFieldModel.php.

252 {
253 $slicedStrings = explode(", ", $stringValues);
254 $slicedReferences = array();
255 $resolved = 0;
256 for ($i = 0; $i < count($slicedStrings); $i++) {
257 //try to find a reference since the last resolved value separated by a comma.
258 // $i = 1; $resolved = 0; $string = "hello, world, gaga" -> try to match "hello, world".
259 $searchString = implode(array_slice($slicedStrings, $resolved, $i - $resolved + 1));
260 if ($ref = $this->getReferenceFromValue($searchString)) {
261 $slicedReferences[] = $ref;
262 $resolved = $i;
263 continue;
264 }
265
266 //try to find a reference with the current index.
267 // $i = 1; $resolved = 0; $string = "hello, world, gaga" -> try to match "world".
268 $searchString = $slicedStrings[$i];
269 if ($ref = $this->getReferenceFromValue($searchString)) {
270 $slicedReferences[] = $ref;
271 $resolved = $i;
272 continue;
273 }
274 }
275
276 return $slicedReferences;
277 }
$i
Definition: metadata.php:24

References $i, and ilDclReferenceRecordFieldModel\getReferenceFromValue().

Referenced by getValueFromExcel().

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

◆ getSingleHTML()

ilDclNReferenceRecordFieldModel::getSingleHTML (   $options = null)

@description this funciton is used to in the viewdefinition of a single record.

Returns
mixed

Definition at line 163 of file class.ilDclNReferenceRecordFieldModel.php.

164 {
165 $ilDataCollectionNReferenceFieldGUI = new ilDclNReferenceFieldGUI($this);
166
167 return $ilDataCollectionNReferenceFieldGUI->getSingleHTML($options);
168 }

◆ getValue()

ilDclNReferenceRecordFieldModel::getValue ( )
Returns
string

Reimplemented from ilDclBaseRecordFieldModel.

Definition at line 68 of file class.ilDclNReferenceRecordFieldModel.php.

69 {
70 $this->loadValue();
71
72 return $this->value;
73 }

References ilDclBaseRecordFieldModel\$value, and loadValue().

Referenced by doUpdate(), and getExportValue().

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

◆ getValueFromExcel()

ilDclNReferenceRecordFieldModel::getValueFromExcel (   $excel,
  $row,
  $col 
)
Parameters
$excel
$row
$col
Returns
array|string

Reimplemented from ilDclReferenceRecordFieldModel.

Definition at line 198 of file class.ilDclNReferenceRecordFieldModel.php.

199 {
200 global $DIC;
201 $lng = $DIC['lng'];
202 $stringValue = parent::getValueFromExcel($excel, $row, $col);
203 $this->getReferencesFromString($stringValue);
204 $referenceIds = $this->getReferencesFromString($stringValue);
205 if (!count($referenceIds) && $stringValue) {
206 $warning = "(" . $row . ", " . ilDataCollectionImporter::getExcelCharForInteger($col + 1) . ") " . $lng->txt("dcl_no_such_reference") . " "
207 . $stringValue;
208
209 return array('warning' => $warning);
210 }
211
212 return $referenceIds;
213 }
getReferencesFromString($stringValues)
This method tries to get as many valid references out of a string separated by commata.

References $DIC, ilDclBaseRecordFieldModel\$lng, ilDataCollectionImporter\getExcelCharForInteger(), and getReferencesFromString().

+ Here is the call graph for this function:

◆ loadValue()

ilDclNReferenceRecordFieldModel::loadValue ( )
protected

Load the value.

Reimplemented from ilDclBaseRecordFieldModel.

Definition at line 141 of file class.ilDclNReferenceRecordFieldModel.php.

142 {
143 if ($this->value === null) {
144 global $DIC;
145 $ilDB = $DIC['ilDB'];
146 $datatype = $this->getField()->getDatatype();
147 $query = "SELECT * FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = "
148 . $ilDB->quote($this->id, "integer");
149 $set = $ilDB->query($query);
150 $this->value = array();
151 while ($rec = $ilDB->fetchAssoc($set)) {
152 $this->value[] = $rec['value'];
153 }
154 }
155 }

References $DIC, $ilDB, $query, and ilDclBaseRecordFieldModel\getField().

Referenced by getValue().

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

◆ loadValueSorted()

ilDclNReferenceRecordFieldModel::loadValueSorted ( )
protected

Definition at line 76 of file class.ilDclNReferenceRecordFieldModel.php.

77 {
78 if ($this->value === null) {
79 global $DIC;
80 $ilDB = $DIC['ilDB'];
81 $datatype = $this->getField()->getDatatype();
82 $refField = ilDclCache::getFieldCache($this->getField()->getFieldRef());
83
84 $supported_internal_types = array(
88 );
89
90 $supported_types = array_merge(
91 array(
95 ),
96 $supported_internal_types
97 );
98 $datatypeId = $refField->getDatatypeId();
99 if (in_array($datatypeId, $supported_types)) {
100 if (in_array($datatypeId, $supported_internal_types)) {
101 $query = "SELECT stlocOrig.value AS value, ilias_object.title AS value_ref ";
102 } else {
103 $query = "SELECT stlocOrig.value AS value, stlocRef.value AS value_ref ";
104 }
105 $query .= "FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value AS stlocOrig ";
106
107 $query .= " INNER JOIN il_dcl_record_field AS refField ON stlocOrig.value = refField.record_id AND refField.field_id = "
108 . $ilDB->quote($refField->getId(), "integer");
109 $query .= " INNER JOIN il_dcl_stloc" . $refField->getStorageLocation()
110 . "_value AS stlocRef ON stlocRef.record_field_id = refField.id ";
111 } else {
112 $query = "SELECT stlocOrig.value AS value ";
113 $query .= "FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value AS stlocOrig ";
114 }
115
116 switch ($datatypeId) {
118 $query .= " INNER JOIN object_reference AS ilias_ref ON ilias_ref.ref_id = stlocRef.value ";
119 $query .= " INNER JOIN object_data AS ilias_object ON ilias_object.obj_id = ilias_ref.obj_id ";
120 break;
123 $query .= " INNER JOIN object_data AS ilias_object ON ilias_object.obj_id = stlocRef.value ";
124 break;
125 }
126 $query .= " WHERE stlocOrig.record_field_id = " . $ilDB->quote($this->id, "integer");
127 if (in_array($datatypeId, $supported_types)) {
128 $query .= " ORDER BY value_ref ASC";
129 }
130
131 $set = $ilDB->query($query);
132
133 $this->value = array();
134 while ($rec = $ilDB->fetchAssoc($set)) {
135 $this->value[] = $rec['value'];
136 }
137 }
138 }
static getFieldCache($field_id=0)

References $DIC, $ilDB, $query, ilDclBaseRecordFieldModel\getField(), ilDclCache\getFieldCache(), ilDclDatatype\INPUTFORMAT_BOOLEAN, ilDclDatatype\INPUTFORMAT_FILE, ilDclDatatype\INPUTFORMAT_ILIAS_REF, ilDclDatatype\INPUTFORMAT_MOB, ilDclDatatype\INPUTFORMAT_NUMBER, and ilDclDatatype\INPUTFORMAT_TEXT.

+ Here is the call graph for this function:

◆ setMaxReferenceLength()

ilDclNReferenceRecordFieldModel::setMaxReferenceLength (   $max_reference_length)
Parameters
int$max_reference_length

Definition at line 29 of file class.ilDclNReferenceRecordFieldModel.php.

30 {
31 $this->max_reference_length = $max_reference_length;
32 }

References $max_reference_length.

Field Documentation

◆ $max_reference_length

ilDclNReferenceRecordFieldModel::$max_reference_length = 20
protected

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