ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilDclSelectionRecordFieldModel Class Reference

Class ilDclSelectionRecordFieldModel. More...

+ Inheritance diagram for ilDclSelectionRecordFieldModel:
+ Collaboration diagram for ilDclSelectionRecordFieldModel:

Public Member Functions

 getValue ()
 
 setValueFromForm ($form)
 
 parseExportValue ($value)
 
 getValueFromExcel ($excel, $row, $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, $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)
 

Data Fields

const PROP_SELECTION_TYPE = ''
 
const PROP_SELECTION_OPTIONS = ''
 

Protected Member Functions

 getMultipleValuesFromString ($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
 $id
 
 $field
 
 $record
 
 $record_representation
 
 $field_representation
 
 $value
 
 $user
 
 $ctrl
 
 $db
 
 $lng
 

Detailed Description

Member Function Documentation

◆ getMultipleValuesFromString()

ilDclSelectionRecordFieldModel::getMultipleValuesFromString (   $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 95 of file class.ilDclSelectionRecordFieldModel.php.

References $delimiter, $i, PHPMailer\PHPMailer\$options, and ilDclBaseRecordFieldModel\getField().

Referenced by getValueFromExcel().

96  {
97  $delimiter = strpos($stringValues, '; ') ? '; ' : ', ';
98  $slicedStrings = explode($delimiter, $stringValues);
99  $slicedReferences = array();
100  $resolved = 0;
101  for ($i = 0; $i < count($slicedStrings); $i++) {
102  //try to find a reference since the last resolved value separated by a comma.
103  // $i = 1; $resolved = 0; $string = "hello, world, gaga" -> try to match "hello, world".
104  $searchString = implode(array_slice($slicedStrings, $resolved, $i - $resolved + 1));
105  if ($ref = $this->getValueFromString($searchString)) {
106  $slicedReferences[] = $ref;
107  $resolved = $i;
108  continue;
109  }
110 
111  //try to find a reference with the current index.
112  // $i = 1; $resolved = 0; $string = "hello, world, gaga" -> try to match "world".
113  $searchString = $slicedStrings[$i];
114  if ($ref = $this->getValueFromString($searchString)) {
115  $slicedReferences[] = $ref;
116  $resolved = $i;
117  continue;
118  }
119  }
120 
121  return $slicedReferences;
122  }
$delimiter
Definition: showstats.php:16
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValue()

ilDclSelectionRecordFieldModel::getValue ( )
Returns
array|mixed|string

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

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

21  {
22  if ($this->getField()->isMulti() && !is_array($this->value)) {
23  return array($this->value);
24  }
25  if (!$this->getField()->isMulti() && is_array($this->value)) {
26  return (count($this->value) == 1) ? array_shift($this->value) : '';
27  }
28 
29  return $this->value;
30  }
+ Here is the call graph for this function:

◆ getValueFromExcel()

ilDclSelectionRecordFieldModel::getValueFromExcel (   $excel,
  $row,
  $col 
)
Parameters
$excel
$row
$col
Returns
array|int|int[]|string

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

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

60  {
61  global $DIC;
62  $lng = $DIC['lng'];
63  $string = parent::getValueFromExcel($excel, $row, $col);
64  $old = $string;
65  if ($this->getField()->isMulti()) {
66  $string = $this->getMultipleValuesFromString($string);
67  $has_value = count($string);
68  } else {
69  $string = $this->getValueFromString($string);
70  $has_value = $string;
71  }
72 
73  if (!$has_value && $old) {
74  $warning = "(" . $row . ", " . ilDataCollectionImporter::getExcelCharForInteger($col + 1) . ") " . $lng->txt("dcl_no_such_reference") . " "
75  . $old;
76 
77  return array('warning' => $warning);
78  }
79 
80  return $string;
81  }
global $DIC
Definition: saml.php:7
getMultipleValuesFromString($stringValues)
Copied from reference field and slightly adjusted.
$warning
Definition: X509warning.php:13
$row
+ Here is the call graph for this function:

◆ parseExportValue()

ilDclSelectionRecordFieldModel::parseExportValue (   $value)

◆ setValueFromForm()

ilDclSelectionRecordFieldModel::setValueFromForm (   $form)

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

References $form.

34  {
35  parent::setValueFromForm($form); // TODO: Change the autogenerated stub
36  }
if(isset($_POST['submit'])) $form

Field Documentation

◆ PROP_SELECTION_OPTIONS

const ilDclSelectionRecordFieldModel::PROP_SELECTION_OPTIONS = ''

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

◆ PROP_SELECTION_TYPE

const ilDclSelectionRecordFieldModel::PROP_SELECTION_TYPE = ''

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


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