19 declare(strict_types=1);
43 private int $mode = self::MODE_UNDEFINED;
94 string $a_obj_type =
'',
96 string $a_sub_type =
'',
98 bool $in_repository =
true 102 $this->
user = $DIC->user();
103 $this->
lng = $DIC->language();
104 $this->mode = $a_mode;
105 $this->obj_type = $a_obj_type;
106 $this->obj_id = $a_obj_id;
107 $this->sub_type = $a_sub_type;
108 $this->sub_id = $a_sub_id;
111 if ($a_obj_id && $this->in_repository) {
113 $this->ref_id = end($refs);
117 $this->
http = $DIC->http();
127 $this->adv_id = $a_adv_id;
128 $this->adv_type = $a_adv_type;
129 $this->adv_subtype = $a_adv_subtype;
138 if ($this->adv_type ==
null) {
139 if ($this->in_repository) {
154 $this->ref_id = $a_ref_id;
167 $this->search_values = $a_values;
185 $this->record_filter = $filter;
193 return !(is_array($this->record_filter) && !in_array($record_id, $this->record_filter));
208 switch ($this->mode) {
209 case self::MODE_EDITOR:
212 case self::MODE_SEARCH:
215 case self::MODE_INFO:
218 case self::MODE_APP_PRESENTATION:
221 case self::MODE_REC_SELECTION:
224 case self::MODE_FILTER:
227 case self::MODE_TABLE_HEAD:
230 case self::MODE_TABLE_CELLS:
243 $this->editor_form = array();
245 $record_id = $record_obj->getRecordId();
247 $values =
new ilAdvancedMDValues($record_id, $this->obj_id, $this->sub_type, $this->sub_id);
249 $defs = $values->getDefinitions();
252 if (!
sizeof($defs)) {
264 $adt_group_form->setForm($this->
form);
266 $adt_group_form->setTitle($translations->getTitleForLanguage($this->user->getLanguage()));
267 $adt_group_form->setInfo($translations->getDescriptionForLanguage($this->user->getLanguage()));
269 foreach ($defs as $def) {
270 $element = $adt_group_form->getElement((
string) $def->getFieldId());
271 $element->setTitle($field_translations->getTitleForLanguage(
273 $this->
user->getLanguage()
275 $element->setInfo($field_translations->getDescriptionForLanguage(
277 $this->
user->getLanguage()
281 $def->prepareElementForEditor($element);
283 if ($values->isDisabled((
string) $def->getFieldId())) {
284 $element->setDisabled(
true);
288 $adt_group_form->addToForm();
290 $this->editor_form[$record_id] = array(
"values" => $values,
"form" => $adt_group_form);
300 foreach ($this->editor_form as $item) {
301 $item[
"form"]->importFromPost();
302 if (!$item[
"form"]->validate()) {
316 if (!count($this->editor_form)) {
322 $this->obj_id = $a_obj_id;
325 $this->sub_id = $a_sub_id;
328 foreach ($this->editor_form as $item) {
329 if ($a_obj_id || $a_sub_id) {
331 $item[
"values"]->setActiveRecordPrimary($this->obj_id, $this->sub_type, $this->sub_id);
334 $item[
"values"]->write();
349 $this->
lng->loadLanguageModule(
'search');
351 $this->search_form = array();
356 if (!
sizeof($fields)) {
362 $section->setTitle($record_translations->getTitleForLanguage($this->user->getLanguage()));
363 $section->setInfo($record_translations->getDescriptionForLanguage($this->user->getLanguage()));
364 $this->
form->addItem($section);
366 foreach ($fields as $field) {
370 $field->getADTDefinition(),
374 $field_form->setForm($this->
form);
375 $field_form->setElementId(
"advmd[" . $field->getFieldId() .
"]");
376 $field_form->setTitle($field_translations->getTitleForLanguage(
377 $field->getFieldId(),
378 $this->
user->getLanguage()
381 if (is_array($this->search_form_values) &&
382 isset($this->search_form_values[$field->getFieldId()])) {
383 $field->setSearchValueSerialized($field_form, $this->search_form_values[$field->getFieldId()]);
386 $field->prepareElementForSearch($field_form);
388 $field_form->addToForm();
390 $this->search_form[$field->getFieldId()] = array(
"def" => $field,
"value" => $field_form);
400 if (!is_array($this->search_form)) {
406 foreach ($this->search_form as $field_id => $item) {
407 $item[
"value"]->importFromPost();
408 if (!$item[
"value"]->validate()) {
411 $value = $item[
"def"]->getSearchValueSerialized($item[
"value"]);
412 if ($value !==
null) {
413 $res[$field_id] = $value;
425 $this->search_form_values = $a_values;
439 ) as $record_id => $a_values) {
444 $this->
info->addSection($record_translations->getTitleForLanguage($this->user->getLanguage()));
446 $defs = $a_values->getDefinitions();
447 foreach ($a_values->getADTGroup()->getElements() as $element_id => $element) {
448 if (!$element->isNull()) {
450 $title = $field_translations->getTitleForLanguage($element_id, $this->
user->getLanguage());
455 $presentation_bridge->setSize(
'500px',
'300px');
458 $this->
info->addProperty(
460 $presentation_bridge->getHTML()
475 $definitions = $sub->sortDefinitions($definitions);
477 $positions = array();
478 foreach ($definitions as $position => $value) {
479 $positions[$value->getFieldId()] = $position;
482 $array_elements = array();
488 ) as $record_id => $a_values) {
494 $defs = $a_values->getDefinitions();
495 foreach ($a_values->getADTGroup()->getElements() as $element_id => $element) {
496 if (!$element->isNull()) {
499 if (get_class($element) ==
'ilADTLocation') {
505 $presentation_value = $presentation_bridge->getSortable();
506 } elseif (get_class($element) ==
'ilADTExternalLink' || get_class($element) ==
'ilADTInternalLink') {
508 $presentation_value = $presentation_bridge->getHTML();
510 $presentation_value = strip_tags($presentation_bridge->getHTML());
512 $array_elements[$positions[$element_id]] =
514 "title" => $field_translations->getTitleForLanguage(
516 $this->
user->getLanguage()
518 "value" => $presentation_value
525 return $array_elements;
534 ($this->obj_type !=
'crs' and $this->obj_type !=
'rcrs')
556 $sec_tit = ($a_sec_head ==
"")
557 ? $this->
lng->txt(
"meta_adv_records")
559 $section->setTitle($sec_tit);
560 $this->
form->addItem($section);
565 $cb->setInfo($record_obj->getDescription());
566 $cb->setValue((
string) $record_obj->getRecordId());
567 if (in_array((
string) $record_obj->getRecordId(), $selected)) {
568 $cb->setChecked(
true);
570 $this->
form->addItem($cb);
579 $post_amet_use_rec = [];
580 if ($this->
http->wrapper()->post()->has(
'amet_use_rec')) {
581 $post_amet_use_rec = $this->
http->wrapper()->post()->retrieve(
583 $this->
refinery->kindlyTo()->dictOf(
596 $this->table_gui = $a_val;
610 $this->row_data = $a_val;
636 $this->adt_search = array();
639 $record_id = $record_obj->getRecordId();
644 foreach ($defs as $def) {
646 if (!$def->isFilterSupported()) {
651 $def->getADTDefinition(),
655 $this->adt_search[$def->getFieldId()]->setTableGUI($this->table_gui);
656 $this->adt_search[$def->getFieldId()]->setTitle(
657 $field_translations->getTitleForLanguage($def->getFieldId(), $this->
user->getLanguage())
659 $this->adt_search[$def->getFieldId()]->setElementId(
'md_' . $def->getFieldId());
661 $this->adt_search[$def->getFieldId()]->loadFilter();
662 $this->adt_search[$def->getFieldId()]->addToFilterForm();
672 if (!is_array($this->adt_search)) {
676 foreach ($this->adt_search as $element) {
677 $element->importFromPost();
686 if (!is_array($this->adt_search)) {
691 foreach ($this->adt_search as $def_id => $element) {
692 if (!$element->isNull() ||
693 !$a_only_non_empty) {
694 $res[$def_id] = $element;
706 $record_id = $record_obj->getRecordId();
711 foreach ($defs as $def) {
716 $this->table_gui->addColumn(
717 $field_translations->getTitleForLanguage($def->getFieldId(), $this->
user->getLanguage()),
718 'md_' . $def->getFieldId()
733 $record_id = $record_obj->getRecordId();
736 foreach ($defs as $def) {
742 $res_raw =
$data[
'md_' . $def->getFieldId()] ??
null;
743 $res_presentation =
$data[
'md_' . $def->getFieldId() .
'_presentation'] ??
null;
751 $res = $res_presentation->getHTML();
754 $html .=
"<td class='std'>" .
$res .
"</td>";
static getInstancesForObjectId(int $a_obj_id, ?string $a_obj_type=null, string $a_sub_type="-", int $a_sub_id=0)
importSearchForm()
Load edit form values from post.
setPropertyForm(ilPropertyFormGUI $form)
parseTableCells()
Parse table cells.
const MODE_APP_PRESENTATION
setRecordFilter(?array $filter=null)
Set advanced record filter.
importEditFormPostValues()
Load edit form values from post.
static _getActivatedRecordsByObjectType(string $a_obj_type, string $a_sub_type="", bool $a_only_optional=false)
Get activated records by object type.
static getInstance()
Get singleton instance.
static _getAllReferences(int $id)
get all reference ids for object ID
handleECSDefinitions($a_definition)
handle ecs definitions
getRowData()
Get row data.
__construct(int $a_mode, string $a_obj_type='', int $a_obj_id=0, string $a_sub_type='', int $a_sub_id=0, bool $in_repository=true)
Constructor.
static _getSelectedRecordsByObject(string $a_obj_type, int $a_id, string $a_sub_type="", bool $is_ref_id=true)
parseTableHead()
Parse property for table head.
parseAppointmentPresentationa()
Presentation for calendar agenda list.
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
setSearchFormValues(array $a_values)
checkFilter($record_id)
Check filter.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
info()
description: > Example for rendering a info message box.
static getObjRecSelection(int $a_obj_id, string $a_sub_type="")
Get repository object record selection.
static http()
Fetches the global http state from ILIAS.
setAdvMdRecordObject(int $a_adv_id, string $a_adv_type, string $a_adv_subtype="-")
Set object, that defines the adv md records being used.
static getInstancesByObjType($a_obj_type, $a_active_only=true)
setRefId(int $a_ref_id)
Set ref_id for context.
setRowData(array $a_val)
Set row data.
parseRecordSelection(string $a_sec_head="")
Parse property form in editor mode.
parseFilter()
Parse property for filter (table)
static getInstanceByRecordId(int $record_id)
static saveObjRecSelection(int $a_obj_id, string $a_sub_type="", ?array $a_records=null, bool $a_delete_before=true)
Save repository object record selection.
RefineryFactory $refinery
setSearchValues(array $a_values)
Set values for search form.
getAdvMdRecordObject()
Get adv md record parameters.
form( $class_path, string $cmd, string $submit_caption="")
setInfoObject(ilInfoScreenGUI $info)
get info sections
setTableGUI(ilTable2GUI $a_val)
Set table for self::MODE_TABLE_FILTER.
ADT presentation bridge base class.
getFilterElements(bool $a_only_non_empty=true)
Get SQL conditions for current filter value(s)
parseEditor()
Parse property form in editor mode.
parseSearch()
Parse search.
parseInfoPage()
Presentation for info page.
array $search_form_values
saveSelection()
Save selection per object.
writeEditForm(?int $a_obj_id=null, ?int $a_sub_id=null)
Write edit form values to db.
importFilter()
Import filter (post) values.
static _getInstanceByObjectType(string $a_type)
static getInstanceByRecordId(int $record_id)