ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilSubEnabledFormPropertyGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2007 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
25
34{
35 protected $sub_items = array();
36
42 public function addSubItem($a_item)
43 {
44 $a_item->setParent($this);
45 $this->sub_items[] = $a_item;
46 }
47
53 public function getSubItems()
54 {
55 return $this->sub_items;
56 }
57
63 public function getSubInputItemsRecursive()
64 {
65 $subInputItems = array();
66
67 foreach ($this->sub_items as $subItem) {
68 if ($subItem->getType() == 'section_header') {
69 continue;
70 }
71
72 $subInputItems[] = $subItem;
73
74 if ($subItem instanceof ilSubEnabledFormPropertyGUI) {
75 $subInputItems = array_merge($subInputItems, $subItem->getSubInputItemsRecursive());
76 }
77 }
78
79 return $subInputItems;
80 }
81
87 final public function checkSubItemsInput()
88 {
89 $ok = true;
90 foreach ($this->getSubItems() as $item) {
91 $item_ok = $item->checkInput();
92 if (!$item_ok) {
93 $ok = false;
94 }
95 }
96 return $ok;
97 }
98
103 final public function getSubForm()
104 {
105 // subitems
106 $pf = null;
107 if (count($this->getSubItems()) > 0) {
108 $pf = new ilPropertyFormGUI();
109 $pf->setMode("subform");
110 $pf->setItems($this->getSubItems());
111 }
112
113 return $pf;
114 }
115
121 public function getItemByPostVar($a_post_var)
122 {
123 if ($this->getPostVar() == $a_post_var) {
124 return $this;
125 }
126
127 foreach ($this->getSubItems() as $item) {
128 if ($item->getType() != "section_header") {
129 $ret = $item->getItemByPostVar($a_post_var);
130 if (is_object($ret)) {
131 return $ret;
132 }
133 }
134 }
135
136 return false;
137 }
138}
An exception for terminatinating execution or to throw for unit testing.
This class represents a property in a property form.
getPostVar()
Get Post Variable.
This class represents a property form user interface.
This class represents a property that may include a sub form.
getItemByPostVar($a_post_var)
Get item by post var.
getSubInputItemsRecursive()
returns a flat array of possibly existing subitems recursively
$ret
Definition: parser.php:6