ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
ilDclSelectionRecordFieldModel Class Reference
+ Inheritance diagram for ilDclSelectionRecordFieldModel:
+ Collaboration diagram for ilDclSelectionRecordFieldModel:

Public Member Functions

 getValue ()
 
 parseExportValue ($value)
 
 getValueFromExcel (ilExcel $excel, int $row, int $col)
 
- 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 ()
 
 serializeData ($value)
 Serialize data before storing to db. More...
 
 deserializeData ($value)
 Deserialize data before applying to field. More...
 
 setValue ($value, bool $omit_parsing=false)
 Set value for record field. More...
 
 setValueFromForm (ilPropertyFormGUI $form)
 
 getFormulaValue ()
 
 parseExportValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 getValueFromExcel (ilExcel $excel, int $row, int $col)
 
 parseValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 getExportValue ()
 
 fillExcelExport (ilExcel $worksheet, int &$row, int &$col)
 
 getPlainText ()
 
 getSortingValue (bool $link=true)
 
 addHiddenItemsToConfirmation (ilConfirmationGUI $confirmation)
 
 parseSortingValue ($value, bool $link=true)
 Returns sortable value for the specific field-types. More...
 
 cloneStructure (ilDclBaseRecordFieldModel $old_record_field)
 
 afterClone ()
 
 getField ()
 
 getId ()
 
 getRecord ()
 
 getRecordRepresentation ()
 
 setRecordRepresentation (ilDclBaseRecordRepresentation $record_representation)
 
 getFieldRepresentation ()
 
 setFieldRepresentation (ilDclBaseFieldRepresentation $field_representation)
 

Protected Member Functions

 getMultipleValuesFromString (string $stringValues)
 Copied from reference field and slightly adjusted. More...
 
 getValueFromString (string $string)
 
- Protected Member Functions inherited from ilDclBaseRecordFieldModel
 doRead ()
 Read object data from database. More...
 
 loadValue ()
 Load the value. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilDclBaseRecordFieldModel
int $id = null
 
ilDclBaseFieldModel $field
 
ilDclBaseRecordModel $record
 
ilDclBaseRecordRepresentation $record_representation = null
 
ilDclBaseFieldRepresentation $field_representation = null
 
 $value
 
ilObjUser $user
 
ilCtrl $ctrl
 
ilDBInterface $db
 
ilLanguage $lng
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 

Detailed Description

Definition at line 21 of file class.ilDclSelectionRecordFieldModel.php.

Member Function Documentation

◆ getMultipleValuesFromString()

ilDclSelectionRecordFieldModel::getMultipleValuesFromString ( string  $stringValues)
protected

Copied from reference field and slightly adjusted.

This method tries to get as many valid values 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 78 of file class.ilDclSelectionRecordFieldModel.php.

References getValueFromString().

Referenced by getValueFromExcel().

78  : array
79  {
80  $delimiter = strpos($stringValues, '; ') ? '; ' : ', ';
81  $slicedStrings = explode($delimiter, $stringValues);
82  $slicedReferences = [];
83  $resolved = 0;
84  for ($i = 0; $i < count($slicedStrings); $i++) {
85  $searchString = implode(array_slice($slicedStrings, $resolved, $i - $resolved + 1));
86  if ($ref = $this->getValueFromString($searchString)) {
87  $slicedReferences[] = $ref;
88  $resolved = $i;
89  continue;
90  }
91 
92  $searchString = $slicedStrings[$i];
93  if ($ref = $this->getValueFromString($searchString)) {
94  $slicedReferences[] = $ref;
95  $resolved = $i;
96  }
97  }
98 
99  return $slicedReferences;
100  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValue()

ilDclSelectionRecordFieldModel::getValue ( )
Returns
array|string

Definition at line 26 of file class.ilDclSelectionRecordFieldModel.php.

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

27  {
28  if ($this->getField()->isMulti() && !is_array($this->value)) {
29  return [$this->value];
30  }
31  if (!$this->getField()->isMulti() && is_array($this->value)) {
32  return array_shift($this->value);
33  }
34 
35  return $this->value;
36  }
+ Here is the call graph for this function:

◆ getValueFromExcel()

ilDclSelectionRecordFieldModel::getValueFromExcel ( ilExcel  $excel,
int  $row,
int  $col 
)

Definition at line 48 of file class.ilDclSelectionRecordFieldModel.php.

References ilDataCollectionImporter\getExcelCharForInteger(), ilDclBaseRecordFieldModel\getField(), getMultipleValuesFromString(), getValueFromString(), and ILIAS\Repository\lng().

49  {
50  $string = parent::getValueFromExcel($excel, $row, $col);
51  $old = $string;
52  if ($this->getField()->isMulti()) {
53  $string = $this->getMultipleValuesFromString($string);
54  $has_value = count($string);
55  } else {
56  $string = $this->getValueFromString($string);
57  $has_value = $string;
58  }
59 
60  if (!$has_value && $old) {
61  $warning = "(" . $row . ", " . ilDataCollectionImporter::getExcelCharForInteger($col + 1) . ") " . $this->lng->txt("dcl_no_such_reference") . " "
62  . $old;
63 
64  return ['warning' => $warning];
65  }
66 
67  return $string;
68  }
getMultipleValuesFromString(string $stringValues)
Copied from reference field and slightly adjusted.
+ Here is the call graph for this function:

◆ getValueFromString()

ilDclSelectionRecordFieldModel::getValueFromString ( string  $string)
protected

Definition at line 102 of file class.ilDclSelectionRecordFieldModel.php.

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

Referenced by getMultipleValuesFromString(), and getValueFromExcel().

102  : ?int
103  {
104  foreach ($this->getField()->getProperty($this->field::PROP_SELECTION_OPTIONS) as $id => $value) {
105  if ($value == $string) {
106  return $id;
107  }
108  }
109 
110  return null;
111  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseExportValue()

ilDclSelectionRecordFieldModel::parseExportValue (   $value)
Parameters
array | string | int$value

Definition at line 41 of file class.ilDclSelectionRecordFieldModel.php.

References ilDclBaseRecordFieldModel\$value, ilDclBaseRecordFieldModel\getField(), ilDclBaseRecordFieldModel\getId(), and ilDclSelectionOption\getValues().

41  : string
42  {
43  $values = ilDclSelectionOption::getValues((int) $this->getField()->getId(), $value);
44 
45  return implode("; ", $values);
46  }
static getValues(int $field_id, $opt_ids)
+ Here is the call graph for this function:

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