4 require_once
"Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php";
29 return self::TYPE_SELECT;
40 $def->setNumeric(
false);
60 if ($a_values !== null) {
61 foreach ($a_values as $idx => $value) {
62 $a_values[$idx] = trim($value);
63 if (!$a_values[$idx]) {
64 unset($a_values[$idx]);
67 $a_values = array_unique($a_values);
70 $this->options = $a_values;
104 return array(
$lng->txt(
"meta_advmd_select_options") => implode(
",", $this->
getOptions()));
121 $field->setMulti(
true,
true);
122 $field->setMaxLength(255);
128 $field->setValue(array_shift(
$options));
132 $field->setDisabled(
true);
144 $recipes = $a_form->
getInput(
"conf_det");
145 if (is_array($recipes[$this->
getFieldId()])) {
147 $sum = $a_form->
getInput(
"conf_det_act");
153 foreach ($recipes as $old_option => $recipe) {
154 $sum_act = $sum[$old_option];
155 $sgl_act = $sgl[$old_option];
157 if ($recipe ==
"sum") {
163 foreach (array_keys($sgl_act) as $obj_idx) {
164 if ($sum_act == self::REMOVE_ACTION_ID) {
167 $res[$old_option][$obj_idx] = $sum_act;
171 foreach ($sgl_act as $sgl_index => $sgl_item) {
174 } elseif ($sgl_item == self::REMOVE_ACTION_ID) {
175 $sgl_act[$sgl_index] =
"";
179 $res[$old_option] = $sgl_act;
197 $missing = array_diff($old, $new);
198 if (
sizeof($missing)) {
200 if (!is_array($this->confirmed_objects)) {
203 "field_id" => array(
"integer", $this->
getFieldId()),
208 $this->confirm_objects = [];
209 foreach ($in_use as $item) {
221 return is_array($this->confirm_objects) && count($this->confirm_objects) > 0;
229 $objDefinition = $DIC[
'objDefinition'];
232 if (is_array($this->confirm_objects) && count($this->confirm_objects) > 0) {
233 $new_options = $a_form->
getInput(
"opts");
236 $sec->setTitle(
$lng->txt(
"md_adv_confirm_definition_select_section"));
239 foreach ($this->confirm_objects as $old_option => $items) {
240 $details =
new ilRadioGroupInputGUI(
$lng->txt(
"md_adv_confirm_definition_select_option") .
': "' . $old_option .
'"',
"conf_det[" . $this->
getFieldId() .
"][" . $old_option .
"]");
242 $details->setValue(
"sum");
250 $sum =
new ilRadioOption(
$lng->txt(
"md_adv_confirm_definition_select_option_all"),
"sum");
251 $details->addOption($sum);
254 $lng->txt(
"md_adv_confirm_definition_select_option_all_action"),
255 "conf_det_act[" . $this->
getFieldId() .
"][" . $old_option .
"]" 259 "" =>
$lng->txt(
"please_select"),
260 self::REMOVE_ACTION_ID =>
$lng->txt(
"md_adv_confirm_definition_select_option_remove")
262 foreach ($new_options as $new_option) {
263 $options[$new_option] =
$lng->txt(
"md_adv_confirm_definition_select_option_overwrite") .
': "' . $new_option .
'"';
266 $sum->addSubItem($sel);
273 $sel->setAlert(
$lng->txt(
"msg_input_is_required"));
277 $single =
new ilRadioOption(
$lng->txt(
"md_adv_confirm_definition_select_option_single"),
"sgl");
278 $details->addOption($single);
279 foreach ($items as $item) {
281 $sub_type = $item[1];
284 $item_id = $obj_id .
"_" . $sub_type .
"_" . $sub_id;
291 $class =
"ilObj" . $objDefinition->getClassName(
$type);
292 $class_path = $objDefinition->getLocation(
$type);
293 include_once $class_path .
"/class." . $class .
".php";
294 $ints = class_implements($class);
295 if (isset($ints[
"ilAdvancedMetaDataSubItems"])) {
296 $sub_title = $class::getAdvMDSubItemTitle($obj_id, $sub_type, $sub_id);
298 $title .=
' (' . $sub_title .
')';
304 $type_title .
' ' .
$title,
305 "conf[" . $this->
getFieldId() .
"][" . $old_option .
"][" . $item_id .
"]" 307 $sel->setRequired(
true);
309 "" =>
$lng->txt(
"please_select"),
310 self::REMOVE_ACTION_ID =>
$lng->txt(
"md_adv_confirm_definition_select_option_remove")
312 foreach ($new_options as $new_option) {
313 $options[$new_option] =
$lng->txt(
"md_adv_confirm_definition_select_option_overwrite") .
': "' . $new_option .
'"';
322 $sel->setAlert(
$lng->txt(
"msg_input_is_required"));
327 $single->addSubItem($sel);
342 if (is_array($this->confirmed_objects) && count($this->confirmed_objects) > 0) {
344 foreach ($this->confirmed_objects as $old_option => $item_ids) {
345 foreach ($item_ids as $item => $new_option) {
346 $item = explode(
"_", $item);
348 $sub_type = $item[1];
354 "obj_id" => array(
"integer", $obj_id),
355 "sub_type" => array(
"text", $sub_type),
356 "sub_id" => array(
"integer", $sub_id),
357 "field_id" => array(
"integer", $this->
getFieldId())
363 "obj_id" => array(
"integer", $obj_id),
364 "sub_type" => array(
"text", $sub_type),
365 "sub_id" => array(
"integer", $sub_id),
366 "field_id" => array(
"integer", $this->
getFieldId())
371 if ($sub_type ==
"wpg") {
373 include_once
"Modules/Wiki/classes/class.ilPCAMDPageList.php";
389 $a_writer->
xmlElement(
'FieldValue', null, $value);
395 $this->options[] = $a_value;
405 return $element->getSelection();
410 $this->
getADT()->setSelection($a_cdata);
422 $a_enum->setAutoSort(
false);
This class represents an option in a radio group.
prepareCustomDefinitionFormConfirmation(ilPropertyFormGUI $a_form)
static initActiveRecordByType()
Init active record by type.
AMD field abstract base class.
getFieldDefinitionForTableGUI()
getADT()
Get ADT instance.
importXMLProperty($a_key, $a_value)
importValueFromXML($a_cdata)
addPropertiesToXML(ilXmlWriter $a_writer)
static _lookupTitle($a_id)
lookup object title
static writeByPrimary($a_table, array $a_primary, $a_type, $a_value)
Write directly.
static getInstance()
Get singleton.
importFieldDefinition(array $a_def)
addCustomFieldToDefinitionForm(ilPropertyFormGUI $a_form, $a_disabled=false)
Add input elements to definition form.
foreach($_POST as $key=> $value) $res
static deleteByPrimary($a_table, array $a_primary, $a_type=null)
Delete values by (partial) primary key.
importCustomDefinitionFormPostValues(ilPropertyFormGUI $a_form)
Import custom post values from definition form.
setOptions(array $a_values=null)
Set options.
static migrateField($a_obj_id, $a_field_id, $old_option, $new_option, $a_is_multi=false)
Migrate search/filter values on advmd change.
static readByPrimary($a_table, array $a_primary, $a_type=null)
Read directly.
This class represents a text property in a property form.
importDefinitionFormPostValuesNeedsConfirmation()
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
prepareElementForEditor(ilADTFormBridge $a_enum)
update($pash, $contents, Config $config)
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
getFieldId()
Get field_id.
getValueForXML(ilADT $element)
buildConfirmedObjects(ilPropertyFormGUI $a_form)
Process custom post values from definition form.