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

AMD field type select. More...

+ Inheritance diagram for ilAdvancedMDFieldDefinitionSelectMulti:
+ Collaboration diagram for ilAdvancedMDFieldDefinitionSelectMulti:

Public Member Functions

 getType ()
 
 importCustomDefinitionFormPostValues (ilPropertyFormGUI $a_form)
 
 update ()
 
 getValueForXML (ilADT $element)
 
 importValueFromXML ($a_cdata)
 
 prepareElementForEditor (ilADTFormBridge $a_enum)
 
- Public Member Functions inherited from ilAdvancedMDFieldDefinitionSelect
 getType ()
 
 setOptions (array $a_values=null)
 Set options. More...
 
 getOptions ()
 Get options. More...
 
 getFieldDefinitionForTableGUI ()
 
 addCustomFieldToDefinitionForm (ilPropertyFormGUI $a_form, $a_disabled=false)
 Add input elements to definition form. More...
 
 importCustomDefinitionFormPostValues (ilPropertyFormGUI $a_form)
 Import custom post values from definition form. More...
 
 importDefinitionFormPostValuesNeedsConfirmation ()
 
 prepareCustomDefinitionFormConfirmation (ilPropertyFormGUI $a_form)
 
 update ()
 
 importXMLProperty ($a_key, $a_value)
 
 getValueForXML (ilADT $element)
 
 importValueFromXML ($a_cdata)
 
 prepareElementForEditor (ilADTFormBridge $a_enum)
 
- Public Member Functions inherited from ilAdvancedMDFieldDefinition
 __construct ($a_field_id=null)
 Constructor. More...
 
 getType ()
 Get type. More...
 
 getTypeTitle ()
 Get type title (lang id) More...
 
 getADTDefinition ()
 Get ADT definition instance. More...
 
 getADT ()
 Get ADT instance. More...
 
 getFieldId ()
 Get field_id. More...
 
 setRecordId ($a_id)
 Set record id. More...
 
 getRecordId ()
 Get record id. More...
 
 setImportId ($a_id_string)
 Set import id. More...
 
 getImportId ()
 Get import id. More...
 
 setPosition ($a_pos)
 Set position. More...
 
 getPosition ()
 Get position. More...
 
 setTitle ($a_title)
 Get title. More...
 
 getTitle ()
 Get title. More...
 
 setDescription ($a_desc)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 isSearchSupported ()
 Is search supported at all. More...
 
 isFilterSupported ()
 Is search by filter supported. More...
 
 setSearchable ($a_status)
 Toggle searchable. More...
 
 isSearchable ()
 Is searchable. More...
 
 setRequired ($a_status)
 Toggle required. More...
 
 isRequired ()
 Is required field. More...
 
 getFieldDefinitionForTableGUI ()
 Parse properties for table gui. More...
 
 addToFieldDefinitionForm (ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions)
 Add input elements to definition form. More...
 
 importCustomDefinitionFormPostValues (ilPropertyFormGUI $a_form)
 Import custom post values from definition form. More...
 
 importDefinitionFormPostValues (ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions)
 Import post values from definition form. More...
 
 importDefinitionFormPostValuesNeedsConfirmation ()
 
 prepareCustomDefinitionFormConfirmation (ilPropertyFormGUI $a_form)
 
 prepareDefinitionFormConfirmation (ilPropertyFormGUI $a_form)
 
 generateImportId ($a_field_id)
 Generate unique record id. More...
 
 save ($a_keep_pos=false)
 Create new field entry. More...
 
 update ()
 Update field entry. More...
 
 delete ()
 Delete field entry. More...
 
 toXML (ilXmlWriter $a_writer)
 To Xml. More...
 
 importXMLProperty ($a_key, $a_value)
 Import property from XML. More...
 
 getValueForXML (ilADT $element)
 Parse ADT value for xml (export) More...
 
 importValueFromXML ($a_cdata)
 Import value from xml. More...
 
 importFromECS ($a_ecs_type, $a_value, $a_sub_id)
 Import meta data from ECS. More...
 
 prepareElementForEditor (ilADTFormBridge $a_bridge)
 Prepare editor form elements. More...
 
 getSearchQueryParserValue (ilADTSearchBridge $a_adt_search)
 Get value for search query parser. More...
 
 getSearchValueSerialized (ilADTSearchBridge $a_adt_search)
 Get value for search persistence. More...
 
 setSearchValueSerialized (ilADTSearchBridge $a_adt_search, $a_value)
 Set value from search persistence. More...
 
 searchSubObjects (ilADTSearchBridge $a_adt_search, $a_obj_id, $sub_obj_type)
 
 searchObjects (ilADTSearchBridge $a_adt_search, ilQueryParser $a_parser, array $a_object_types, $a_locate, $a_search_type)
 Search objects. More...
 
 getLuceneSearchString ($a_value)
 Get search string in lucene syntax. More...
 
 prepareElementForSearch (ilADTSearchBridge $a_bridge)
 Prepare search form elements. More...
 
 _clone ($a_new_record_id)
 Clone field definition. More...
 

Data Fields

const XML_SEPARATOR = "~|~"
 
- Data Fields inherited from ilAdvancedMDFieldDefinitionSelect
const REMOVE_ACTION_ID = "-iladvmdrm-"
 
- Data Fields inherited from ilAdvancedMDFieldDefinition
const TYPE_SELECT = 1
 
const TYPE_TEXT = 2
 
const TYPE_DATE = 3
 
const TYPE_DATETIME = 4
 
const TYPE_INTEGER = 5
 
const TYPE_FLOAT = 6
 
const TYPE_LOCATION = 7
 
const TYPE_SELECT_MULTI = 8
 
const TYPE_EXTERNAL_LINK = 9
 
const TYPE_INTERNAL_LINK = 10
 

Protected Member Functions

 initADTDefinition ()
 
 findBySingleValue (ilADTEnumSearchBridgeMulti $a_search, $a_value)
 
- Protected Member Functions inherited from ilAdvancedMDFieldDefinitionSelect
 initADTDefinition ()
 
 importFieldDefinition (array $a_def)
 
 getFieldDefinition ()
 
 buildConfirmedObjects (ilPropertyFormGUI $a_form)
 Process custom post values from definition form. More...
 
 addPropertiesToXML (ilXmlWriter $a_writer)
 
- Protected Member Functions inherited from ilAdvancedMDFieldDefinition
 init ()
 Init properties. More...
 
 initADTDefinition ()
 Init adt instance. More...
 
 setADT (ilADT $a_adt)
 Set ADT instance. More...
 
 setFieldId ($a_id)
 Set field_id. More...
 
 importFieldDefinition (array $a_def)
 Import (type-specific) field definition from DB. More...
 
 getFieldDefinition ()
 Get (type-specific) field definition. More...
 
 addCustomFieldToDefinitionForm (ilPropertyFormGUI $a_form, $a_disabled=false)
 Add custom input elements to definition form. More...
 
 getLastPosition ()
 Get last position of record. More...
 
 getDBProperties ()
 Get all definition properties for DB. More...
 
 import (array $a_data)
 Import from DB. More...
 
 read ($a_field_id)
 Read field definition. More...
 
 addPropertiesToXML (ilXmlWriter $a_writer)
 Add (type-specific) properties to xml export. More...
 
 parseSearchObjects (array $a_records, array $a_object_types)
 Add object-data needed for global search to AMD search results. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ilAdvancedMDFieldDefinition
static getInstance ($a_field_id, $a_type=null)
 Get definition instance by type. More...
 
static getInstanceByTypeString ($a_type)
 Get instance by type string (used by import) More...
 
static getInstancesByRecordId ($a_record_id, $a_only_searchable=false)
 Get definitions by record id. More...
 
static getInstancesByObjType ($a_obj_type, $a_active_only=true)
 
static getInstanceByImportId ($a_import_id)
 Get definition instance by import id. More...
 
static getSearchableDefinitionIds ()
 Get searchable definition ids (performance is key) More...
 
static getADTGroupForDefinitions (array $a_defs)
 Init ADTGroup for definitions. More...
 
static getValidTypes ()
 Get all valid types. More...
 
static isValidType ($a_type)
 Is given type valid. More...
 
- Static Protected Member Functions inherited from ilAdvancedMDFieldDefinition
static getTypeString ($a_type)
 Get type string. More...
 
- Protected Attributes inherited from ilAdvancedMDFieldDefinitionSelect
 $options = []
 
 $confirm_objects = []
 
 $confirmed_objects
 
- Protected Attributes inherited from ilAdvancedMDFieldDefinition
 $field_id
 
 $record_id
 
 $import_id
 
 $position
 
 $title
 
 $description
 
 $searchable
 
 $required
 
 $adt_def
 
 $adt
 

Detailed Description

AMD field type select.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Member Function Documentation

◆ findBySingleValue()

ilAdvancedMDFieldDefinitionSelectMulti::findBySingleValue ( ilADTEnumSearchBridgeMulti  $a_search,
  $a_value 
)
protected

Definition at line 78 of file class.ilAdvancedMDFieldDefinitionSelectMulti.php.

References $res, ilADTActiveRecordByType\find(), ilADTSearchBridgeSingle\getADT(), ilAdvancedMDFieldDefinition\getFieldId(), ilADTEnumSearchBridgeMulti\getSQLCondition(), and ilADTActiveRecordByType\SINGLE_COLUMN_NAME.

Referenced by importCustomDefinitionFormPostValues(), and update().

79  {
80  $res = array();
81 
82  $a_search->getADT()->setSelections(array($a_value));
84 
86  "adv_md_values",
87  "Enum",
88  $this->getFieldId(),
89  $condition
90  );
91  if ($in_use) {
92  foreach ($in_use as $item) {
93  $res[] = array($item["obj_id"], $item["sub_type"], $item["sub_id"], $item["value"]);
94  }
95  }
96 
97  return $res;
98  }
static find($a_table, $a_type, $a_field_id, $a_condition, $a_additional_fields=null)
Find entries.
foreach($_POST as $key=> $value) $res
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getType()

ilAdvancedMDFieldDefinitionSelectMulti::getType ( )

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

23  {
24  return self::TYPE_SELECT_MULTI;
25  }

◆ getValueForXML()

ilAdvancedMDFieldDefinitionSelectMulti::getValueForXML ( ilADT  $element)

Definition at line 192 of file class.ilAdvancedMDFieldDefinitionSelectMulti.php.

193  {
194  return self::XML_SEPARATOR .
195  implode(self::XML_SEPARATOR, $element->getSelections()) .
196  self::XML_SEPARATOR;
197  }

◆ importCustomDefinitionFormPostValues()

ilAdvancedMDFieldDefinitionSelectMulti::importCustomDefinitionFormPostValues ( ilPropertyFormGUI  $a_form)

Definition at line 51 of file class.ilAdvancedMDFieldDefinitionSelectMulti.php.

References ilAdvancedMDFieldDefinitionSelect\buildConfirmedObjects(), findBySingleValue(), ilAdvancedMDFieldDefinition\getADTDefinition(), ilPropertyFormGUI\getInput(), ilADTFactory\getInstance(), ilAdvancedMDFieldDefinitionSelect\getOptions(), ilADTFactory\initActiveRecordByType(), and ilAdvancedMDFieldDefinitionSelect\setOptions().

52  {
53  $old = $this->getOptions();
54  $new = $a_form->getInput("opts");
55 
56  $missing = array_diff($old, $new);
57  if (sizeof($missing)) {
58  $this->confirmed_objects = $this->buildConfirmedObjects($a_form);
59  if (!is_array($this->confirmed_objects)) {
60  $search = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($this->getADTDefinition(), false, false);
62 
63  foreach ($missing as $missing_value) {
64  $in_use = $this->findBySingleValue($search, $missing_value);
65  if (sizeof($in_use)) {
66  foreach ($in_use as $item) {
67  $this->confirm_objects[$missing_value][] = $item;
68  }
69  }
70  }
71  }
72  }
73 
74  $this->old_options = $old;
75  $this->setOptions($new);
76  }
findBySingleValue(ilADTEnumSearchBridgeMulti $a_search, $a_value)
getADTDefinition()
Get ADT definition instance.
static initActiveRecordByType()
Init active record by type.
static getInstance()
Get singleton.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
buildConfirmedObjects(ilPropertyFormGUI $a_form)
Process custom post values from definition form.
+ Here is the call graph for this function:

◆ importValueFromXML()

ilAdvancedMDFieldDefinitionSelectMulti::importValueFromXML (   $a_cdata)

Definition at line 199 of file class.ilAdvancedMDFieldDefinitionSelectMulti.php.

References ilAdvancedMDFieldDefinition\getADT().

200  {
201  $this->getADT()->setSelections(explode(self::XML_SEPARATOR, $a_cdata));
202  }
+ Here is the call graph for this function:

◆ initADTDefinition()

ilAdvancedMDFieldDefinitionSelectMulti::initADTDefinition ( )
protected

Definition at line 32 of file class.ilAdvancedMDFieldDefinitionSelectMulti.php.

References $def, ilAdvancedMDFieldDefinitionSelect\$options, ilADTFactory\getInstance(), and ilAdvancedMDFieldDefinitionSelect\getOptions().

33  {
34  $def = ilADTFactory::getInstance()->getDefinitionInstanceByType("MultiEnum");
35  $def->setNumeric(false);
36 
37  $options = $this->getOptions();
38  $def->setOptions(array_combine($options, $options));
39 
40  // see ilAdvancedMDValues::getActiveRecord()
41  // using ilADTMultiEnumDBBridge::setFakeSingle()
42 
43  return $def;
44  }
static getInstance()
Get singleton.
$def
Definition: croninfo.php:21
+ Here is the call graph for this function:

◆ prepareElementForEditor()

ilAdvancedMDFieldDefinitionSelectMulti::prepareElementForEditor ( ilADTFormBridge  $a_enum)

Definition at line 209 of file class.ilAdvancedMDFieldDefinitionSelectMulti.php.

210  {
211  assert($a_enum instanceof ilADTMultiEnumFormBridge);
212 
213  $a_enum->setAutoSort(false);
214  }

◆ update()

ilAdvancedMDFieldDefinitionSelectMulti::update ( )

Definition at line 105 of file class.ilAdvancedMDFieldDefinitionSelectMulti.php.

References $def, ilADTActiveRecordByType\deleteByPrimary(), findBySingleValue(), ilAdvancedMDFieldDefinition\getADTDefinition(), ilAdvancedMDFieldDefinition\getFieldId(), ilADTFactory\getInstance(), ilADTFactory\initActiveRecordByType(), ilPCAMDPageList\migrateField(), ilADTMultiEnumDBBridge\SEPARATOR, League\Flysystem\Adapter\Polyfill\update(), and ilADTActiveRecordByType\writeByPrimary().

106  {
107  if (is_array($this->confirmed_objects) && count($this->confirmed_objects) > 0) {
108  // we need the "old" options for the search
109  $def = $this->getADTDefinition();
110  $def = clone($def);
111  $def->setOptions(array_combine($this->old_options, $this->old_options));
112  $search = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($def, false, false);
114 
115  foreach ($this->confirmed_objects as $old_option => $item_ids) {
116  // get complete old values
117  $old_values = array();
118  foreach ($this->findBySingleValue($search, $old_option) as $item) {
119  $old_values[$item[0] . "_" . $item[1] . "_" . $item[2]] = $item[3];
120  }
121 
122  foreach ($item_ids as $item => $new_option) {
123  $parts = explode("_", $item);
124  $obj_id = $parts[0];
125  $sub_type = $parts[1];
126  $sub_id = $parts[2];
127 
128  // update existing value (with changed option)
129  if (isset($old_values[$item])) {
130  // find changed option in old value
131  $old_value = explode(ilADTMultiEnumDBBridge::SEPARATOR, $old_values[$item]);
132  // remove separators
133  array_shift($old_value);
134  array_pop($old_value);
135 
136  $old_idx = array_keys($old_value, $old_option);
137  if (sizeof($old_idx)) {
138  $old_idx = array_pop($old_idx);
139 
140  // switch option
141  if ($new_option) {
142  $old_value[$old_idx] = $new_option;
143  }
144  // #18885 - remove option
145  else {
146  unset($old_value[$old_idx]);
147  }
148  $new_value = array_unique($old_value);
149 
150  $primary = array(
151  "obj_id" => array("integer", $obj_id),
152  "sub_type" => array("text", $sub_type),
153  "sub_id" => array("integer", $sub_id),
154  "field_id" => array("integer", $this->getFieldId())
155  );
156 
157  // update value
158  if (sizeof($new_value)) {
159  // add separators
160  $new_value = ilADTMultiEnumDBBridge::SEPARATOR .
161  implode(ilADTMultiEnumDBBridge::SEPARATOR, $new_value) .
163 
164  ilADTActiveRecordByType::writeByPrimary("adv_md_values", $primary, "MultiEnum", $new_value);
165  }
166  // remove existing value - nothing left
167  else {
168  ilADTActiveRecordByType::deleteByPrimary("adv_md_values", $primary, "MultiEnum");
169  }
170  }
171  }
172 
173  if ($sub_type == "wpg") {
174  // #15763 - adapt advmd page lists
175  include_once "Modules/Wiki/classes/class.ilPCAMDPageList.php";
176  ilPCAMDPageList::migrateField($obj_id, $this->getFieldId(), $old_option, $new_option, true);
177  }
178  }
179  }
180 
181  $this->confirmed_objects = array();
182  }
183 
184  parent::update();
185  }
findBySingleValue(ilADTEnumSearchBridgeMulti $a_search, $a_value)
getADTDefinition()
Get ADT definition instance.
static initActiveRecordByType()
Init active record by type.
static writeByPrimary($a_table, array $a_primary, $a_type, $a_value)
Write directly.
static getInstance()
Get singleton.
static deleteByPrimary($a_table, array $a_primary, $a_type=null)
Delete values by (partial) primary key.
static migrateField($a_obj_id, $a_field_id, $old_option, $new_option, $a_is_multi=false)
Migrate search/filter values on advmd change.
update($pash, $contents, Config $config)
$def
Definition: croninfo.php:21
+ Here is the call graph for this function:

Field Documentation

◆ XML_SEPARATOR

const ilAdvancedMDFieldDefinitionSelectMulti::XML_SEPARATOR = "~|~"

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