ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 37 of file class.ilDclNReferenceRecordFieldModel.php.

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

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

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

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

◆ getLinkHTML()

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

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

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

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

244 {
245 $slicedStrings = explode(", ", $stringValues);
246 $slicedReferences = array();
247 $resolved = 0;
248 for ($i = 0; $i < count($slicedStrings); $i++) {
249 //try to find a reference since the last resolved value separated by a comma.
250 // $i = 1; $resolved = 0; $string = "hello, world, gaga" -> try to match "hello, world".
251 $searchString = implode(array_slice($slicedStrings, $resolved, $i - $resolved + 1));
252 if ($ref = $this->getReferenceFromValue($searchString)) {
253 $slicedReferences[] = $ref;
254 $resolved = $i;
255 continue;
256 }
257
258 //try to find a reference with the current index.
259 // $i = 1; $resolved = 0; $string = "hello, world, gaga" -> try to match "world".
260 $searchString = $slicedStrings[$i];
261 if ($ref = $this->getReferenceFromValue($searchString)) {
262 $slicedReferences[] = $ref;
263 $resolved = $i;
264 continue;
265 }
266 }
267 return $slicedReferences;
268 }
$i
Definition: disco.tpl.php:19

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

163 {
164 $ilDataCollectionNReferenceFieldGUI = new ilDclNReferenceFieldGUI($this);
165 return $ilDataCollectionNReferenceFieldGUI->getSingleHTML($options);
166 }
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20

References $options.

◆ getValue()

ilDclNReferenceRecordFieldModel::getValue ( )
Returns
string

Reimplemented from ilDclBaseRecordFieldModel.

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

71 {
72 $this->loadValue();
73
74 return $this->value;
75 }

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

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

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

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

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

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