ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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)
 
 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...
 
 getReferencesFromString ($stringValues)
 This method tries to get as many valid references out of a string separated by commata. More...
 
- 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.

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

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 205 of file class.ilDclNReferenceRecordFieldModel.php.

205 {
206 $values = $this->getValue();
207 $names = array();
208 foreach ($values as $value) {
209 if ($value) {
211 $names[] = $ref_rec->getRecordField($this->getField()->getFieldRef())->getValue();
212 }
213 }
214 $string = "";
215 foreach ($names as $name) {
216 $string .= $name . ", ";
217 }
218 if (!count($names)) {
219 return "";
220 }
221 $string = substr($string, 0, - 2);
222
223 return $string;
224 }
static getRecordCache($record_id=0)

References $names, 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 182 of file class.ilDclNReferenceRecordFieldModel.php.

182 {
183 $ilDataCollectionNReferenceFieldGUI = new ilDclNReferenceFieldGUI($this);
184 return $ilDataCollectionNReferenceFieldGUI->getHTML();
185 }
Class ilDclNReferenceFieldGUI.

◆ getLinkHTML()

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

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

170 {
171 if ($link == "[" . $this->getField()->getTitle() . "]") {
172 $link = NULL;
173 }
174
175 return parent::getLinkHTML($link, $value);
176 }

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 233 of file class.ilDclNReferenceRecordFieldModel.php.

233 {
234 $slicedStrings = explode(", ", $stringValues);
235 $slicedReferences = array();
236 $resolved = 0;
237 for($i = 0; $i < count($slicedStrings); $i++) {
238 //try to find a reference since the last resolved value separated by a comma.
239 // $i = 1; $resolved = 0; $string = "hello, world, gaga" -> try to match "hello, world".
240 $searchString = implode(array_slice($slicedStrings, $resolved, $i - $resolved + 1));
241 if($ref = $this->getReferenceFromValue($searchString)){
242 $slicedReferences[] = $ref;
243 $resolved = $i;
244 continue;
245 }
246
247 //try to find a reference with the current index.
248 // $i = 1; $resolved = 0; $string = "hello, world, gaga" -> try to match "world".
249 $searchString = $slicedStrings[$i];
250 if($ref = $this->getReferenceFromValue($searchString)){
251 $slicedReferences[] = $ref;
252 $resolved = $i;
253 continue;
254 }
255 }
256 return $slicedReferences;
257 }

References 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 157 of file class.ilDclNReferenceRecordFieldModel.php.

157 {
158 $ilDataCollectionNReferenceFieldGUI = new ilDclNReferenceFieldGUI($this);
159 return $ilDataCollectionNReferenceFieldGUI->getSingleHTML($options);
160 }
if(!is_array($argv)) $options

References $options.

◆ getValue()

ilDclNReferenceRecordFieldModel::getValue ( )
Returns
string

Reimplemented from ilDclBaseRecordFieldModel.

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

67 {
68 $this->loadValue();
69
70 return $this->value;
71 }

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 187 of file class.ilDclNReferenceRecordFieldModel.php.

187 {
188 global $DIC;
189 $lng = $DIC['lng'];
190 $stringValue = parent::getValueFromExcel($excel, $row, $col);
191 $this->getReferencesFromString($stringValue);
192 $referenceIds = $this->getReferencesFromString($stringValue);
193 if (!count($referenceIds) && $stringValue) {
194 $warning = "(" . $row . ", " . ilDataCollectionImporter::getExcelCharForInteger($col+1) . ") " . $lng->txt("dcl_no_such_reference") . " "
195 . $stringValue;
196 return array('warning' => $warning);
197 }
198
199 return $referenceIds;
200 }
getReferencesFromString($stringValues)
This method tries to get as many valid references out of a string separated by commata.

References $DIC, ilDclBaseRecordFieldModel\$lng, $row, 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 136 of file class.ilDclNReferenceRecordFieldModel.php.

136 {
137 if ($this->value === NULL) {
138 global $DIC;
139 $ilDB = $DIC['ilDB'];
140 $datatype = $this->getField()->getDatatype();
141 $query = "SELECT * FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = "
142 . $ilDB->quote($this->id, "integer");
143 $set = $ilDB->query($query);
144 $this->value = array();
145 while ($rec = $ilDB->fetchAssoc($set)) {
146 $this->value[] = $rec['value'];
147 }
148 }
149 }

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 74 of file class.ilDclNReferenceRecordFieldModel.php.

74 {
75 if ($this->value === NULL) {
76
77 global $DIC;
78 $ilDB = $DIC['ilDB'];
79 $datatype = $this->getField()->getDatatype();
80 $refField = ilDclCache::getFieldCache($this->getField()->getFieldRef());
81
82 $supported_internal_types = array(
86 );
87
88 $supported_types = array_merge(array(
92 ), $supported_internal_types);
93 $datatypeId = $refField->getDatatypeId();
94 if (in_array($datatypeId, $supported_types)) {
95 if (in_array($datatypeId, $supported_internal_types)) {
96 $query = "SELECT stlocOrig.value AS value, ilias_object.title AS value_ref ";
97 } else {
98 $query = "SELECT stlocOrig.value AS value, stlocRef.value AS value_ref ";
99 }
100 $query .= "FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value AS stlocOrig ";
101
102 $query .= " INNER JOIN il_dcl_record_field AS refField ON stlocOrig.value = refField.record_id AND refField.field_id = "
103 . $ilDB->quote($refField->getId(), "integer");
104 $query .= " INNER JOIN il_dcl_stloc" . $refField->getStorageLocation()
105 . "_value AS stlocRef ON stlocRef.record_field_id = refField.id ";
106 } else {
107 $query = "SELECT stlocOrig.value AS value ";
108 $query .= "FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value AS stlocOrig ";
109 }
110
111 switch ($datatypeId) {
113 $query .= " INNER JOIN object_reference AS ilias_ref ON ilias_ref.ref_id = stlocRef.value ";
114 $query .= " INNER JOIN object_data AS ilias_object ON ilias_object.obj_id = ilias_ref.obj_id ";
115 break;
118 $query .= " INNER JOIN object_data AS ilias_object ON ilias_object.obj_id = stlocRef.value ";
119 break;
120 }
121 $query .= " WHERE stlocOrig.record_field_id = " . $ilDB->quote($this->id, "integer");
122 if (in_array($datatypeId, $supported_types)) {
123 $query .= " ORDER BY value_ref ASC";
124 }
125
126 $set = $ilDB->query($query);
127
128 $this->value = array();
129 while ($rec = $ilDB->fetchAssoc($set)) {
130 $this->value[] = $rec['value'];
131 }
132 }
133 }
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 28 of file class.ilDclNReferenceRecordFieldModel.php.

28 {
29 $this->max_reference_length = $max_reference_length;
30 }

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: