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