ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 
 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

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 82 of file class.ilDclSelectionRecordFieldModel.php.

References ilDclBaseRecordFieldModel\getField(), and null.

Referenced by getValueFromExcel().

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

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

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

◆ getValueFromExcel()

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

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

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

53  {
54  $string = (string) parent::getValueFromExcel($excel, $row, $col);
55  $old = $string;
56  if ($this->getField()->isMulti()) {
57  $string = $this->getMultipleValuesFromString($string);
58  $has_value = count($string);
59  } else {
60  $string = $this->getValueFromString($string);
61  $has_value = $string;
62  }
63 
64  if (!$has_value && $old) {
65  $warning = "(" . $row . ", " . ilDataCollectionImporter::getExcelCharForInteger($col + 1) . ") " . $this->lng->txt("dcl_no_such_reference") . " "
66  . $old;
67 
68  return ['warning' => $warning];
69  }
70 
71  return $string;
72  }
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 45 of file class.ilDclSelectionRecordFieldModel.php.

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

45  : string
46  {
47  $values = ilDclSelectionOption::getValues((int) $this->getField()->getId(), $value);
48 
49  return implode("; ", $values);
50  }
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 25 of file class.ilDclSelectionRecordFieldModel.php.

◆ PROP_SELECTION_TYPE

const ilDclSelectionRecordFieldModel::PROP_SELECTION_TYPE = ''

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


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