ILIAS  release_8 Revision v8.24
class.ilAdvancedMDFieldDefinition.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21use ILIAS\Refinery\Factory as RefineryFactory;
23
31{
32 public const TYPE_SELECT = 1;
33 public const TYPE_TEXT = 2;
34 public const TYPE_DATE = 3;
35 public const TYPE_DATETIME = 4;
36 public const TYPE_INTEGER = 5;
37 public const TYPE_FLOAT = 6;
38 public const TYPE_LOCATION = 7;
39 public const TYPE_SELECT_MULTI = 8;
40 public const TYPE_ADDRESS = 99;
41 public const TYPE_EXTERNAL_LINK = 9;
42 public const TYPE_INTERNAL_LINK = 10;
43
44 protected ?int $field_id = null;
45 protected int $record_id = 0;
46 protected string $import_id = '';
47 protected int $position = 0;
48 protected string $title = '';
49 protected string $description = '';
50 protected bool $searchable = false;
51 protected bool $required = false;
52 protected ?ilADTDefinition $adt_def = null;
53 protected ?ilADT $adt = null;
54
55 protected string $language = '';
56
57 protected ilDBInterface $db;
58 protected ilLanguage $lng;
59 protected ilLogger $logger;
61 protected RefineryFactory $refinery;
62
63 public function __construct(?int $a_field_id = null, string $language = '')
64 {
65 global $DIC;
66
67 $this->lng = $DIC->language();
68 $this->language = $DIC->language()->getLangKey();
69 $this->refinery = $DIC->refinery();
70 $this->http = $DIC->http();
71
72
73 if ($language) {
74 $this->language = $language;
75 }
77 $this->logger = $DIC->logger()->amet();
78 $this->db = $DIC->database();
79
80 $this->init();
81 $this->read($a_field_id);
82 }
83
84 public static function getInstance(
85 ?int $a_field_id,
86 ?int $a_type = null,
87 string $language = ''
89 global $DIC;
90
91 $db = $DIC->database();
92
93 if (!$a_type) {
94 $set = $db->query("SELECT field_type" .
95 " FROM adv_mdf_definition" .
96 " WHERE field_id = " . $db->quote($a_field_id, "integer"));
97 $a_type = $db->fetchAssoc($set);
98 $a_type = (int) $a_type["field_type"];
99 }
100
101 if (self::isValidType($a_type)) {
102 $class = "ilAdvancedMDFieldDefinition" . self::getTypeString($a_type);
103 return new $class($a_field_id, $language);
104 }
105 throw new ilException("unknown type " . $a_type);
106 }
107
108 public static function exists(int $a_field_id): bool
109 {
110 global $DIC;
111
112 $db = $DIC['ilDB'];
113 $set = $db->query("SELECT field_type" .
114 " FROM adv_mdf_definition" .
115 " WHERE field_id = " . $db->quote($a_field_id, "integer"));
116 if ($db->fetchAssoc($set)) {
117 return true;
118 }
119 return false;
120 }
121
125 public static function getInstanceByTypeString(string $a_type): ?ilAdvancedMDFieldDefinition
126 {
127 // see self::getTypeString()
128 $map = array(
129 self::TYPE_TEXT => "Text",
130 self::TYPE_SELECT => "Select",
131 self::TYPE_DATE => "Date",
132 self::TYPE_DATETIME => "DateTime",
133 self::TYPE_FLOAT => "Float",
134 self::TYPE_LOCATION => "Location",
135 self::TYPE_INTEGER => "Integer",
136 self::TYPE_SELECT_MULTI => "SelectMulti",
137 self::TYPE_EXTERNAL_LINK => 'ExternalLink',
138 self::TYPE_INTERNAL_LINK => 'InternalLink',
139 self::TYPE_ADDRESS => "Address"
140 );
141 $map = array_flip($map);
142 if (array_key_exists($a_type, $map)) {
143 return self::getInstance(null, $map[$a_type]);
144 }
145 return null;
146 }
147
155 public static function getInstancesByRecordId(
156 $a_record_id,
157 $a_only_searchable = false,
158 string $language = ''
159 ): array {
160 global $DIC;
161
162 $ilDB = $DIC['ilDB'];
163
164 $query = "SELECT * FROM adv_mdf_definition" .
165 " WHERE record_id = " . $ilDB->quote($a_record_id, "integer");
166 if ($a_only_searchable) {
167 $query .= " AND searchable = " . $ilDB->quote(1, "integer");
168 }
169 $query .= " ORDER BY position";
170 $set = $ilDB->query($query);
171 $defs = [];
172 while ($row = $ilDB->fetchAssoc($set)) {
173 $field = self::getInstance(null, (int) $row["field_type"], $language);
174 $field->import($row);
175 $defs[(int) $row["field_id"]] = $field;
176 }
177 return $defs;
178 }
179
185 public static function getInstancesByObjType($a_obj_type, $a_active_only = true): array
186 {
187 global $DIC;
188
189 $ilDB = $DIC['ilDB'];
190
191 $query = "SELECT amf.* FROM adv_md_record_objs aro" .
192 " JOIN adv_md_record amr ON aro.record_id = amr.record_id" .
193 " JOIN adv_mdf_definition amf ON aro.record_id = amf.record_id" .
194 " WHERE obj_type = " . $ilDB->quote($a_obj_type, 'text');
195 if ($a_active_only) {
196 $query .= " AND active = " . $ilDB->quote(1, "integer");
197 }
198 $query .= " ORDER BY aro.record_id,position";
199 $res = $ilDB->query($query);
200 $defs = [];
201 while ($row = $ilDB->fetchAssoc($res)) {
202 $field = self::getInstance(null, (int) $row["field_type"]);
203 $field->import($row);
204 $defs[(int) $row["field_id"]] = $field;
205 }
206 return $defs;
207 }
208
209 public static function getInstanceByImportId(string $a_import_id): ?ilAdvancedMDFieldDefinition
210 {
211 global $DIC;
212
213 $ilDB = $DIC['ilDB'];
214
215 $query = "SELECT field_id, field_type FROM adv_mdf_definition" .
216 " WHERE import_id = " . $ilDB->quote($a_import_id, 'text');
217 $set = $ilDB->query($query);
218 if ($ilDB->numRows($set)) {
219 $row = $ilDB->fetchAssoc($set);
220 return self::getInstance((int) $row["field_id"], (int) $row["field_type"]);
221 }
222 return null;
223 }
224
229 public static function getSearchableDefinitionIds()
230 {
231 global $DIC;
232
233 $ilDB = $DIC['ilDB'];
234
235 $field_ids = array();
236
237 $query = "SELECT field_id FROM adv_md_record amr" .
238 " JOIN adv_mdf_definition amfd ON (amr.record_id = amfd.record_id)" .
239 " WHERE active = " . $ilDB->quote(1, "integer") .
240 " AND searchable = " . $ilDB->quote(1, "integer");
241 $set = $ilDB->query($query);
242 while ($row = $ilDB->fetchAssoc($set)) {
243 $field_ids[] = (int) $row["field_id"];
244 }
245 return $field_ids;
246 }
247
254 public static function getADTGroupForDefinitions(array $a_defs): ilADT
255 {
257 $group_def = $factory->getDefinitionInstanceByType("Group");
258 foreach ($a_defs as $def) {
259 $group_def->addElement($def->getFieldId(), $def->getADTDefinition());
260 }
261 $group = $factory->getInstanceByDefinition($group_def);
262
263 // bind adt instances to definition
264 foreach ($group->getElements() as $element_id => $element) {
265 $a_defs[$element_id]->setADT($element);
266 }
267 return $group;
268 }
269
270 protected function init(): void
271 {
272 $this->setRequired(false);
273 $this->setSearchable(false);
274 }
275
280 public static function getValidTypes(): array
281 {
282 return array(
283 self::TYPE_TEXT,
284 self::TYPE_DATE,
285 self::TYPE_DATETIME,
286 self::TYPE_SELECT,
287 self::TYPE_INTEGER,
288 self::TYPE_FLOAT,
289 self::TYPE_LOCATION,
290 self::TYPE_SELECT_MULTI,
291 self::TYPE_EXTERNAL_LINK,
292 self::TYPE_INTERNAL_LINK,
293 self::TYPE_ADDRESS
294 );
295 }
296
297 public static function isValidType(int $a_type): bool
298 {
299 return in_array($a_type, self::getValidTypes());
300 }
301
305 abstract public function getType(): int;
306
310 protected static function getTypeString(int $a_type): string
311 {
312 if (self::isValidType($a_type)) {
313 $map = array(
314 self::TYPE_TEXT => "Text",
315 self::TYPE_SELECT => "Select",
316 self::TYPE_DATE => "Date",
317 self::TYPE_DATETIME => "DateTime",
318 self::TYPE_FLOAT => "Float",
319 self::TYPE_LOCATION => "Location",
320 self::TYPE_INTEGER => "Integer",
321 self::TYPE_SELECT_MULTI => "SelectMulti",
322 self::TYPE_EXTERNAL_LINK => 'ExternalLink',
323 self::TYPE_INTERNAL_LINK => 'InternalLink',
324 self::TYPE_ADDRESS => "Address"
325 );
326 return $map[$a_type];
327 }
328 return '';
329 }
330
334 public function useDefaultLanguageMode(string $language): bool
335 {
336 if (!strlen($language)) {
337 return true;
338 }
339 $record = ilAdvancedMDRecord::_getInstanceByRecordId($this->record_id);
340 return strcmp($record->getDefaultLanguage(), $language) === 0;
341 }
342
346 public function getTypeTitle(): string
347 {
348 return "udf_type_" . strtolower(self::getTypeString($this->getType()));
349 }
350
354 abstract protected function initADTDefinition(): ilADTDefinition;
355
361 {
362 if (!$this->adt_def instanceof ilADTDefinition) {
363 $this->adt_def = $this->initADTDefinition();
364 }
365 return $this->adt_def;
366 }
367
368 public function getADT(): ilADT
369 {
370 if (!$this->adt instanceof ilADT) {
371 $this->adt = ilADTFactory::getInstance()->getInstanceByDefinition($this->getADTDefinition());
372 }
373 return $this->adt;
374 }
375
380 protected function setADT(ilADT $a_adt): void
381 {
382 if (!$this->adt instanceof ilADT) {
383 $this->adt = $a_adt;
384 }
385 }
386
390 protected function setFieldId(int $a_id): void
391 {
392 $this->field_id = $a_id;
393 }
394
398 public function getFieldId(): ?int
399 {
400 return $this->field_id;
401 }
402
406 public function setRecordId(int $a_id): void
407 {
408 $this->record_id = $a_id;
409 }
410
414 public function getRecordId(): int
415 {
416 return $this->record_id;
417 }
418
422 public function setImportId(string $a_id_string): void
423 {
424 if ($a_id_string !== null) {
425 $a_id_string = trim($a_id_string);
426 }
427 $this->import_id = $a_id_string;
428 }
429
433 public function getImportId(): string
434 {
435 return $this->import_id;
436 }
437
441 public function setPosition(int $a_pos): void
442 {
443 $this->position = $a_pos;
444 }
445
449 public function getPosition(): int
450 {
451 return $this->position;
452 }
453
457 public function setTitle(string $a_title): void
458 {
459 if ($a_title !== null) {
460 $a_title = trim($a_title);
461 }
462 $this->title = $a_title;
463 }
464
468 public function getTitle(): string
469 {
470 return $this->title;
471 }
472
476 public function setDescription(string $a_desc): void
477 {
478 if ($a_desc !== null) {
479 $a_desc = trim($a_desc);
480 }
481 $this->description = $a_desc;
482 }
483
487 public function getDescription(): string
488 {
489 return $this->description;
490 }
491
495 public function isSearchSupported(): bool
496 {
497 return true;
498 }
499
503 public function isFilterSupported(): bool
504 {
505 return true;
506 }
507
511 public function setSearchable(bool $a_status): void
512 {
513 // see above
514 if (!$this->isSearchSupported()) {
515 $a_status = false;
516 }
517 $this->searchable = (bool) $a_status;
518 }
519
523 public function isSearchable(): bool
524 {
525 return $this->searchable;
526 }
527
531 public function setRequired(bool $a_status): void
532 {
533 $this->required = $a_status;
534 }
535
539 public function isRequired(): bool
540 {
541 return $this->required;
542 }
543
547 protected function importFieldDefinition(array $a_def): void
548 {
549 }
550
554 protected function getFieldDefinition(): array
555 {
556 return [];
557 }
558
562 public function getFieldDefinitionForTableGUI(string $content_language): array
563 {
564 return [];
565 }
566
571 ilPropertyFormGUI $a_form,
572 bool $a_disabled = false,
573 string $language = ''
574 ): void {
575 }
576
580 public function addToFieldDefinitionForm(
581 ilPropertyFormGUI $a_form,
582 ilAdvancedMDPermissionHelper $a_permissions,
583 string $language = ''
584 ): void {
585 global $DIC;
586 $lng = $DIC['lng'];
587
588 $perm = $a_permissions->hasPermissions(
590 (string) $this->getFieldId(),
591 array(
594 )
595 ,
598 )
599 ,
602 )
603 ,
606 )
607 )
608 );
609
610 // title
612
613 $title = new ilTextInputGUI($lng->txt('title'), 'title');
614 $title->setValue($this->getTitle());
615 $title->setSize(20);
616 $title->setMaxLength(70);
617 $title->setRequired(true);
618 if ($this->getFieldId()) {
619 $translations->modifyTranslationInfoForTitle($this->getFieldId(), $a_form, $title, $language);
620 } else {
621 $title->setValue($this->getTitle());
622 }
623
624 $a_form->addItem($title);
625
627 $title->setDisabled(true);
628 }
629
630 // desc
631 $desc = new ilTextAreaInputGUI($lng->txt('description'), 'description');
632 $desc->setValue($this->getDescription());
633 $desc->setRows(3);
634 $desc->setCols(50);
635 if ($this->getFieldId()) {
636 $translations->modifyTranslationInfoForDescription($this->getFieldId(), $a_form, $desc, $language);
637 } else {
638 $desc->setValue($this->getDescription());
639 }
640
641 $a_form->addItem($desc);
642
644 $desc->setDisabled(true);
645 }
646
647 // searchable
648 $check = new ilCheckboxInputGUI($lng->txt('md_adv_searchable'), 'searchable');
649 $check->setChecked($this->isSearchable());
650 $check->setValue("1");
651 $a_form->addItem($check);
652
654 !$this->isSearchSupported()) {
655 $check->setDisabled(true);
656 }
657
658 /* required
659 $check = new ilCheckboxInputGUI($lng->txt('md_adv_required'), 'required');
660 $check->setChecked($this->isRequired());
661 $check->setValue(1);
662 $a_form->addItem($check);
663 */
664
665 $this->addCustomFieldToDefinitionForm(
666 $a_form,
668 $language
669 );
670 }
671
675 public function importCustomDefinitionFormPostValues(ilPropertyFormGUI $a_form, string $language = ''): void
676 {
677 // type-specific
678 }
679
684 ilPropertyFormGUI $a_form,
685 ilAdvancedMDPermissionHelper $a_permissions,
686 string $active_language
687 ): void {
688 $record = ilAdvancedMDRecord::_getInstanceByRecordId($this->record_id);
689 $is_translation = (($active_language !== '') && ($active_language != $record->getDefaultLanguage()));
690 if (!$a_form->getItemByPostVar("title")->getDisabled() && !$is_translation) {
691 $this->setTitle($a_form->getInput("title"));
692 }
693 if (!$a_form->getItemByPostVar("description")->getDisabled() && !$is_translation) {
694 $this->setDescription($a_form->getInput("description"));
695 }
696 if (!$a_form->getItemByPostVar("searchable")->getDisabled()) {
697 $this->setSearchable((bool) $a_form->getInput("searchable"));
698 }
699
700 if ($a_permissions->hasPermission(
702 (string) $this->getFieldId(),
705 )) {
706 $this->importCustomDefinitionFormPostValues($a_form, $active_language);
707 }
708 }
709
711 {
712 return false;
713 }
714
716 {
717 }
718
720 {
721 $a_form->getItemByPostVar("title")->setDisabled(true);
722 $a_form->getItemByPostVar("description")->setDisabled(true);
723 $a_form->getItemByPostVar("searchable")->setDisabled(true);
724
725 // checkboxes have no hidden on disabled
726 if ($a_form->getInput("searchable")) {
727 $hidden = new ilHiddenInputGUI("searchable");
728 $hidden->setValue("1");
729 $a_form->addItem($hidden);
730 }
731
732 $this->prepareCustomDefinitionFormConfirmation($a_form);
733 }
734
738 protected function getLastPosition(): int
739 {
740 $sql = "SELECT max(position) pos" .
741 " FROM adv_mdf_definition" .
742 " WHERE record_id = " . $this->db->quote($this->getRecordId(), "integer");
743 $set = $this->db->query($sql);
744 if ($this->db->numRows($set)) {
745 $pos = $this->db->fetchAssoc($set);
746 return (int) $pos["pos"];
747 }
748 return 0;
749 }
750
754 public function generateImportId(int $a_field_id): string
755 {
756 return 'il_' . IL_INST_ID . '_adv_md_field_' . $a_field_id;
757 }
758
762 protected function getDBProperties(): array
763 {
764 $fields = array(
765 "field_type" => array("integer", $this->getType()),
766 "record_id" => array("integer", $this->getRecordId()),
767 "import_id" => array("text", $this->getImportId()),
768 "title" => array("text", $this->getTitle()),
769 "description" => array("text", $this->getDescription()),
770 "position" => array("integer", $this->getPosition()),
771 "searchable" => array("integer", $this->isSearchable()),
772 "required" => array("integer", $this->isRequired())
773 );
774
775 $def = $this->getFieldDefinition();
776 if (is_array($def)) {
777 $fields["field_values"] = array("text", serialize($def));
778 }
779 return $fields;
780 }
781
785 protected function import(array $a_data): void
786 {
787 $this->setFieldId((int) $a_data["field_id"]);
788 $this->setRecordId((int) $a_data["record_id"]);
789 $this->setImportId((string) $a_data["import_id"]);
790 $this->setTitle((string) $a_data["title"]);
791 $this->setDescription((string) $a_data["description"]);
792 $this->setPosition((int) $a_data["position"]);
793 $this->setSearchable((bool) $a_data["searchable"]);
794 $this->setRequired((bool) $a_data["required"]);
795 if (isset($a_data['field_values'])) {
796 $field_values = unserialize($a_data['field_values']);
797 if (is_array($field_values)) {
798 $this->importFieldDefinition($field_values);
799 }
800 }
801 }
802
806 protected function read(?int $a_field_id): void
807 {
808 if (!(int) $a_field_id) {
809 return;
810 }
811
812 $sql = "SELECT * FROM adv_mdf_definition" .
813 " WHERE field_id = " . $this->db->quote($a_field_id, "integer");
814 $set = $this->db->query($sql);
815 if ($this->db->numRows($set)) {
816 $row = $this->db->fetchAssoc($set);
817 $this->import($row);
818 }
819 }
820
824 public function save(bool $a_keep_pos = false): void
825 {
826 if ($this->getFieldId()) {
827 $this->update();
828 return;
829 }
830
831 $next_id = $this->db->nextId("adv_mdf_definition");
832
833 // append
834 if (!$a_keep_pos) {
835 $this->setPosition($this->getLastPosition() + 1);
836 }
837
838 // needs unique import id
839 if (!$this->getImportId()) {
840 $this->setImportId($this->generateImportId($next_id));
841 }
842
843 $fields = $this->getDBProperties();
844 $fields["field_id"] = array("integer", $next_id);
845
846 $this->db->insert("adv_mdf_definition", $fields);
847
848 $this->setFieldId($next_id);
849 }
850
854 public function update(): void
855 {
856 if (!$this->getFieldId()) {
857 $this->save();
858 return;
859 }
860
861 $this->db->update(
862 "adv_mdf_definition",
863 $this->getDBProperties(),
864 array("field_id" => array("integer", $this->getFieldId()))
865 );
866 }
867
871 public function delete(): void
872 {
873 if (!$this->getFieldId()) {
874 return;
875 }
876
877 // delete all values
878 ilAdvancedMDValues::_deleteByFieldId($this->getFieldId(), $this->getADT());
879
880 $query = "DELETE FROM adv_mdf_definition" .
881 " WHERE field_id = " . $this->db->quote($this->getFieldId(), "integer");
882 $this->db->manipulate($query);
883 }
884
890 public function toXML(ilXmlWriter $a_writer): void
891 {
892 $a_writer->xmlStartTag('Field', array(
893 'id' => $this->generateImportId($this->getFieldId()),
894 'searchable' => ($this->isSearchable() ? 'Yes' : 'No'),
895 'fieldType' => self::getTypeString($this->getType())
896 ));
897
898 $a_writer->xmlElement('FieldTitle', null, $this->getTitle());
899 $a_writer->xmlElement('FieldDescription', null, $this->getDescription());
900
902 $a_writer->xmlStartTag('FieldTranslations');
903 foreach ($translations->getTranslations($this->getFieldId()) as $translation) {
904 $a_writer->xmlStartTag('FieldTranslation', ['language' => $translation->getLangKey()]);
905 $a_writer->xmlElement(
906 'FieldTranslationTitle',
907 [],
908 $translation->getTitle()
909 );
910 $a_writer->xmlElement(
911 'FieldTranslationDescription',
912 [],
913 $translation->getDescription()
914 );
915 $a_writer->xmlEndTag('FieldTranslation');
916 }
917 $a_writer->xmlEndTag('FieldTranslations');
918 $a_writer->xmlElement('FieldPosition', null, $this->getPosition());
919
920 $this->addPropertiesToXML($a_writer);
921
922 $a_writer->xmlEndTag('Field');
923 }
924
928 protected function addPropertiesToXML(ilXmlWriter $a_writer): void
929 {
930 // type-specific properties
931 }
932
936 public function importXMLProperty(string $a_key, string $a_value): void
937 {
938 }
939
943 abstract public function getValueForXML(ilADT $element): string;
944
949 abstract public function importValueFromXML(string $a_cdata): void;
950
954 public function importFromECS(string $a_ecs_type, $a_value, string $a_sub_id): bool
955 {
956 return false;
957 }
958
962 public function prepareElementForEditor(ilADTFormBridge $a_bridge): void
963 {
964 // type-specific
965 }
966
973 public function getSearchQueryParserValue(ilADTSearchBridge $a_adt_search): string
974 {
975 return '';
976 }
977
978 public function getSearchValueSerialized(ilADTSearchBridge $a_adt_search): string
979 {
980 return $a_adt_search->getSerializedValue();
981 }
982
986 public function setSearchValueSerialized(ilADTSearchBridge $a_adt_search, $a_value): void
987 {
988 $a_adt_search->setSerializedValue($a_value);
989 }
990
994 protected function parseSearchObjects(array $a_records, array $a_object_types): array
995 {
996 $res = [];
997 $obj_ids = [];
998 foreach ($a_records as $record) {
999 if ($record["sub_type"] == "-") {
1000 $obj_ids[] = $record["obj_id"];
1001 }
1002 }
1003
1004 $sql = "SELECT obj_id,type" .
1005 " FROM object_data" .
1006 " WHERE " . $this->db->in("obj_id", $obj_ids, false, "integer") .
1007 " AND " . $this->db->in("type", $a_object_types, false, "text");
1008 $set = $this->db->query($sql);
1009 while ($row = $this->db->fetchAssoc($set)) {
1010 $res[] = $row;
1011 }
1012 return $res;
1013 }
1014
1015 public function searchSubObjects(ilADTSearchBridge $a_adt_search, int $a_obj_id, string $sub_obj_type): array
1016 {
1018
1019 // :TODO:
1020 if ($a_adt_search instanceof ilADTLocationSearchBridgeSingle) {
1021 $element_id = "loc";
1022 }
1023
1024 $condition = $a_adt_search->getSQLCondition($element_id);
1025 if ($condition) {
1027 "adv_md_values",
1028 $this->getADT()->getType(),
1029 $this->getFieldId(),
1030 $condition
1031 );
1032 if (sizeof($objects)) {
1033 $res = array();
1034 foreach ($objects as $item) {
1035 if ($item["obj_id"] == $a_obj_id &&
1036 $item["sub_type"] == $sub_obj_type) {
1037 $res[] = $item["sub_id"];
1038 }
1039 }
1040 return $res;
1041 }
1042 }
1043
1044 return array();
1045 }
1046
1050 public function searchObjects(
1051 ilADTSearchBridge $a_adt_search,
1052 ilQueryParser $a_parser,
1053 array $a_object_types,
1054 string $a_locate,
1055 string $a_search_type
1056 ): array {
1057 // search type only supported/needed for text
1058 $condition = $a_adt_search->getSQLCondition(ilADTActiveRecordByType::SINGLE_COLUMN_NAME);
1059 if ($condition) {
1061 "adv_md_values",
1062 $this->getADT()->getType(),
1063 $this->getFieldId(),
1064 $condition,
1065 $a_locate
1066 );
1067 if (sizeof($objects)) {
1068 return $this->parseSearchObjects($objects, $a_object_types);
1069 }
1070 }
1071 return [];
1072 }
1073
1080 public function getLuceneSearchString($a_value)
1081 {
1082 return $a_value;
1083 }
1084
1088 public function prepareElementForSearch(ilADTSearchBridge $a_bridge): void
1089 {
1090 }
1091
1095 public function _clone(int $a_new_record_id): self
1096 {
1097 $class = get_class($this);
1098 $obj = new $class();
1099 $obj->setRecordId($a_new_record_id);
1100 $obj->setTitle($this->getTitle());
1101 $obj->setDescription($this->getDescription());
1102 $obj->setRequired($this->isRequired());
1103 $obj->setPosition($this->getPosition());
1104 $obj->setSearchable($this->isSearchable());
1105 $obj->importFieldDefinition($this->getFieldDefinition());
1106 $obj->save(true);
1107
1108 return $obj;
1109 }
1110 //
1111 // complex options
1112 //
1113
1114 public function hasComplexOptions(): bool
1115 {
1116 return false;
1117 }
1118
1124 public function getComplexOptionsOverview(object $a_parent_gui, string $parent_cmd): ?string
1125 {
1126 return null;
1127 }
1128}
static return function(ContainerConfigurator $containerConfigurator)
Definition: basic_rector.php:9
$check
Definition: buildRTE.php:81
Builds data types.
Definition: Factory.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static find(string $a_table, string $a_type, int $a_field_id, string $a_condition, ?string $a_additional_fields=null)
Find entries.
ADT definition base class.
ADT form bridge base class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSerializedValue(string $a_value)
Set current value(s) in serialized form (for easy persisting)
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
getSQLCondition(string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
Get SQL condition for current value(s)
ADT base class.
Definition: class.ilADT.php:12
read(?int $a_field_id)
Read field definition.
getLuceneSearchString($a_value)
Get search string in lucene syntax.
getLastPosition()
Get last position of record.
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
addCustomFieldToDefinitionForm(ilPropertyFormGUI $a_form, bool $a_disabled=false, string $language='')
Add custom input elements to definition form.
importValueFromXML(string $a_cdata)
Import value from xml.
addPropertiesToXML(ilXmlWriter $a_writer)
Add (type-specific) properties to xml export.
static getInstanceByImportId(string $a_import_id)
importFieldDefinition(array $a_def)
Import (type-specific) field definition from DB.
getSearchValueSerialized(ilADTSearchBridge $a_adt_search)
setDescription(string $a_desc)
Set description.
useDefaultLanguageMode(string $language)
Check if default language mode has to be used: no language given or language equals default language.
static getInstanceByTypeString(string $a_type)
Get instance by type string (used by import)
importFromECS(string $a_ecs_type, $a_value, string $a_sub_id)
Import meta data from ECS.
getComplexOptionsOverview(object $a_parent_gui, string $parent_cmd)
setImportId(string $a_id_string)
Set import id.
static getADTGroupForDefinitions(array $a_defs)
Init ADTGroup for definitions.
_clone(int $a_new_record_id)
Clone field definition.
initADTDefinition()
Init adt instance.
static getInstancesByObjType($a_obj_type, $a_active_only=true)
isSearchSupported()
Is search supported at all.
parseSearchObjects(array $a_records, array $a_object_types)
Add object-data needed for global search to AMD search results.
getSearchQueryParserValue(ilADTSearchBridge $a_adt_search)
Get value for search query parser.
getFieldDefinitionForTableGUI(string $content_language)
Parse properties for table gui.
getADTDefinition()
Get ADT definition instance.
importCustomDefinitionFormPostValues(ilPropertyFormGUI $a_form, string $language='')
Import custom post values from definition form.
getFieldDefinition()
Get (type-specific) field definition.
getDBProperties()
Get all definition properties for DB.
searchSubObjects(ilADTSearchBridge $a_adt_search, int $a_obj_id, string $sub_obj_type)
static getTypeString(int $a_type)
Get type as string.
setSearchable(bool $a_status)
Toggle searchable.
setSearchValueSerialized(ilADTSearchBridge $a_adt_search, $a_value)
Set value from search persistence.
importXMLProperty(string $a_key, string $a_value)
Import property from XML.
prepareElementForSearch(ilADTSearchBridge $a_bridge)
Prepare search form elements.
static getSearchableDefinitionIds()
Get searchable definition ids (performance is key)
generateImportId(int $a_field_id)
Generate unique record id.
__construct(?int $a_field_id=null, string $language='')
searchObjects(ilADTSearchBridge $a_adt_search, ilQueryParser $a_parser, array $a_object_types, string $a_locate, string $a_search_type)
Search objects.
isFilterSupported()
Is search by filter supported.
save(bool $a_keep_pos=false)
Create new field entry.
prepareElementForEditor(ilADTFormBridge $a_bridge)
Prepare editor form elements.
importDefinitionFormPostValues(ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions, string $active_language)
Import post values from definition form.
prepareDefinitionFormConfirmation(ilPropertyFormGUI $a_form)
prepareCustomDefinitionFormConfirmation(ilPropertyFormGUI $a_form)
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
setRequired(bool $a_status)
Toggle required.
getValueForXML(ilADT $element)
Parse ADT value for xml (export)
Advanced metadata permission helper.
static _getInstanceByRecordId(int $a_record_id)
static _deleteByFieldId(int $a_field_id, ilADT $a_adt)
Delete values by field_id.
This class represents a checkbox property in a property form.
hasPermission(int $a_context_type, string $a_context_id, int $a_action_id, ?int $a_action_sub_id=null)
Check permission.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
Component logger with individual log levels by component id.
This class represents a property form user interface.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
getItemByPostVar(string $a_post_var)
This class represents a text area property in a property form.
This class represents a text property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
const IL_INST_ID
Definition: constants.php:40
global $DIC
Definition: feed.php:28
Interface GlobalHttpState.
Interface ilDBInterface.
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)
$res
Definition: ltiservices.php:69
$factory
Definition: metadata.php:75
static http()
Fetches the global http state from ILIAS.
getRecordId()
Get the system record ID.
Definition: System.php:214
setRecordId(int $id)
Sets the system record ID.
Definition: System.php:223
$query
$lng