ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilDclNReferenceRecordFieldModel Class Reference
+ Inheritance diagram for ilDclNReferenceRecordFieldModel:
+ Collaboration diagram for ilDclNReferenceRecordFieldModel:

Public Member Functions

 getMaxReferenceLength ()
 
 setMaxReferenceLength ($max_reference_length)
 
 doUpdate ()
 
 getValue ()
 
 getSingleHTML ($options=null)
 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 ()
 
 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...
 
- 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 ( )

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

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

Referenced by ilDclNReferenceFieldGUI\buildTemplate().

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: saml.php:7
$values
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExportValue()

ilDclNReferenceRecordFieldModel::getExportValue ( )
Returns
int|string

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

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

220  {
221  $values = $this->getValue();
222  $names = array();
223  foreach ($values as $value) {
224  if ($value) {
225  $ref_rec = ilDclCache::getRecordCache($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  }
$values
static getRecordCache($record_id=0)
+ 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.

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

Referenced by ilDclNReferenceFieldGUI\buildTemplate().

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

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

References $i, and ilDclReferenceRecordFieldModel\getReferenceFromValue().

Referenced by getValueFromExcel().

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: disco.tpl.php:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSingleHTML()

ilDclNReferenceRecordFieldModel::getSingleHTML (   $options = null)

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

Returns
mixed

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

References PHPMailer\PHPMailer\$options.

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

◆ getValue()

ilDclNReferenceRecordFieldModel::getValue ( )
Returns
string

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

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 
)

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

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

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  }
global $DIC
Definition: saml.php:7
$warning
Definition: X509warning.php:13
getReferencesFromString($stringValues)
This method tries to get as many valid references out of a string separated by commata.
$row
+ Here is the call graph for this function:

◆ loadValue()

ilDclNReferenceRecordFieldModel::loadValue ( )
protected

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

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

Referenced by getValue().

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  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ 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.

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.

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  }
global $DIC
Definition: saml.php:7
static getFieldCache($field_id=0)
$query
global $ilDB
+ 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.

References $max_reference_length.

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

Field Documentation

◆ $max_reference_length

ilDclNReferenceRecordFieldModel::$max_reference_length = 20
protected

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