ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 function addSubItem($a_item)
43 {
44 $this->sub_items[] = $a_item;
45 }
46
52 function getSubItems()
53 {
54 return $this->sub_items;
55 }
56
62 public function getSubInputItemsRecursive()
63 {
64 $subInputItems = array();
65
66 foreach( $this->sub_items as $subItem )
67 {
68 if( $subItem->getType() == 'section_header' )
69 {
70 continue;
71 }
72
73 $subInputItems[] = $subItem;
74
75 if( $subItem instanceof ilSubEnabledFormPropertyGUI )
76 {
77 $subInputItems = array_merge( $subInputItems, $subItem->getSubInputItemsRecursive() );
78 }
79 }
80
81 return $subInputItems;
82 }
83
89 final function checkSubItemsInput()
90 {
91 $ok = true;
92 foreach($this->getSubItems() as $item)
93 {
94 $item_ok = $item->checkInput();
95 if(!$item_ok)
96 {
97 $ok = false;
98 }
99 }
100 return $ok;
101 }
102
107 final function getSubForm()
108 {
109 // subitems
110 $pf = null;
111 if (count($this->getSubItems()) > 0)
112 {
113 $pf = new ilPropertyFormGUI();
114 $pf->setMode("subform");
115 $pf->setItems($this->getSubItems());
116 }
117
118 return $pf;
119 }
120
126 function getItemByPostVar($a_post_var)
127 {
128 if ($this->getPostVar() == $a_post_var)
129 {
130 return $this;
131 }
132
133 foreach($this->getSubItems() as $item)
134 {
135 if ($item->getType() != "section_header")
136 {
137 $ret = $item->getItemByPostVar($a_post_var);
138 if (is_object($ret))
139 {
140 return $ret;
141 }
142 }
143 }
144
145 return false;
146 }
147
148}
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