ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDclSelectionRecordFieldModel Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ 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 ()
 
 getValueForRepresentation ()
 
 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)
 

Data Fields

const PROP_SELECTION_TYPE = ''
 
const PROP_SELECTION_OPTIONS = ''
 

Protected Member Functions

 getMultipleValuesFromString (string $stringValues)
 Copied from reference field and slightly adjusted. More...
 
- 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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 19 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 80 of file class.ilDclSelectionRecordFieldModel.php.

References $i, and ilDclBaseRecordFieldModel\getField().

Referenced by getValueFromExcel().

80  : array
81  {
82  $delimiter = strpos($stringValues, '; ') ? '; ' : ', ';
83  $slicedStrings = explode($delimiter, $stringValues);
84  $slicedReferences = [];
85  $resolved = 0;
86  for ($i = 0; $i < count($slicedStrings); $i++) {
87  //try to find a reference since the last resolved value separated by a comma.
88  // $i = 1; $resolved = 0; $string = "hello, world, gaga" -> try to match "hello, world".
89  $searchString = implode(array_slice($slicedStrings, $resolved, $i - $resolved + 1));
90  if ($ref = $this->getValueFromString($searchString)) {
91  $slicedReferences[] = $ref;
92  $resolved = $i;
93  continue;
94  }
95 
96  //try to find a reference with the current index.
97  // $i = 1; $resolved = 0; $string = "hello, world, gaga" -> try to match "world".
98  $searchString = $slicedStrings[$i];
99  if ($ref = $this->getValueFromString($searchString)) {
100  $slicedReferences[] = $ref;
101  $resolved = $i;
102  }
103  }
104 
105  return $slicedReferences;
106  }
$i
Definition: metadata.php:41
+ 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 28 of file class.ilDclSelectionRecordFieldModel.php.

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

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

◆ getValueFromExcel()

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

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

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

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

◆ parseExportValue()

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

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

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

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

Field Documentation

◆ PROP_SELECTION_OPTIONS

const ilDclSelectionRecordFieldModel::PROP_SELECTION_OPTIONS = ''

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

◆ PROP_SELECTION_TYPE

const ilDclSelectionRecordFieldModel::PROP_SELECTION_TYPE = ''

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


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