ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSubEnabledFormPropertyGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 protected array $sub_items = array();
30
31 public function addSubItem(ilFormPropertyGUI $a_item): void
32 {
33 $a_item->setParent($this);
34 $this->sub_items[] = $a_item;
35 }
36
37 public function getSubItems(): array
38 {
39 return $this->sub_items;
40 }
41
45 public function getSubInputItemsRecursive(): array
46 {
47 $subInputItems = array();
48
49 foreach ($this->sub_items as $subItem) {
50 if ($subItem->getType() == 'section_header') {
51 continue;
52 }
53
54 $subInputItems[] = $subItem;
55
56 if ($subItem instanceof ilSubEnabledFormPropertyGUI) {
57 $subInputItems = array_merge($subInputItems, $subItem->getSubInputItemsRecursive());
58 }
59 }
60
61 return $subInputItems;
62 }
63
67 final public function checkSubItemsInput(): bool
68 {
69 $ok = true;
70 foreach ($this->getSubItems() as $item) {
71 $item_ok = $item->checkInput();
72 if (!$item_ok) {
73 $ok = false;
74 }
75 }
76 return $ok;
77 }
78
79 final public function getSubForm(): ?ilPropertyFormGUI
80 {
81 // subitems
82 $pf = null;
83 if (count($this->getSubItems()) > 0) {
84 $pf = new ilPropertyFormGUI();
85 $pf->setMode("subform");
86 $pf->setItems($this->getSubItems());
87 }
88
89 return $pf;
90 }
91
92 public function getItemByPostVar(string $a_post_var): ?ilFormPropertyGUI
93 {
94 if ($this->getPostVar() == $a_post_var) {
95 return $this;
96 }
97
98 foreach ($this->getSubItems() as $item) {
99 if ($item->getType() != "section_header") {
100 $ret = $item->getItemByPostVar($a_post_var);
101 if (is_object($ret)) {
102 return $ret;
103 }
104 }
105 }
106
107 return null;
108 }
109}
This class represents a property in a property form.
getItemByPostVar(string $a_post_var)
Get item by post var.
setParent(ilFormPropertyGUI $a_val)
This class represents a property form user interface.
This class represents a property that may include a sub form.
getItemByPostVar(string $a_post_var)
Get item by post var.
getSubInputItemsRecursive()
returns a flat array of possibly existing subitems recursively