ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilExplorerSelectInputGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Services/Table/interfaces/interface.ilTableFilterItem.php");
6include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
7
17{
24 function __construct($a_title, $a_postvar, $a_explorer_gui, $a_multi = false)
25 {
26 global $lng;
27
28 $this->multi_nodes = $a_multi;
29 $this->explorer_gui = $a_explorer_gui;
30
31 parent::__construct($a_title, $a_postvar);
32 $this->setType("exp_select");
33 }
34
42 {
43 return "handleExplorerCommand";
44 }
45
50 {
51 $this->explorer_gui->handleCommand();
52 }
53
60 abstract function getTitleForNodeId($a_id);
61
67 function setValue($a_value)
68 {
69 if ($this->multi_nodes && !is_array($a_value))
70 {
71 if ($a_value !== false)
72 {
73 $this->value = array($a_value);
74 }
75 else
76 {
77 $this->value = array();
78 }
79 }
80 else
81 {
82 $this->value = $a_value;
83 }
84 }
85
91 function getValue()
92 {
93 return $this->value;
94 }
95
101 function setValueByArray($a_values)
102 {
103 $this->setValue($a_values[$this->getPostVar()]);
104 }
105
111 function checkInput()
112 {
113 global $lng;
114
115 // sanitize
116 if ($this->multi_nodes)
117 {
118 if (!is_array($_POST[$this->getPostVar()]))
119 {
120 $_POST[$this->getPostVar()] = array();
121 }
122
123 foreach ($_POST[$this->getPostVar()] as $k => $v)
124 {
125 $_POST[$this->getPostVar()][$k] = ilUtil::stripSlashes($v);
126 }
127 }
128 else
129 {
131 }
132
133 // check required
134 if ($this->getRequired())
135 {
136 if ((!$this->multi_nodes && trim($_POST[$this->getPostVar()]) == "") ||
137 ($this->multi_nodes && count($_POST[$this->getPostVar()]) == 0))
138 {
139 $this->setAlert($lng->txt("msg_input_is_required"));
140 return false;
141 }
142 }
143 return true;
144 }
145
146
150 function render($a_mode = "property_form")
151 {
152 global $lng, $ilCtrl, $ilObjDataCache, $tree;
153
154 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
156 $GLOBALS["tpl"]->addJavascript("./Services/UIComponent/Explorer2/js/Explorer2.js");
157
158 $tpl = new ilTemplate("tpl.prop_expl_select.html", true, true, "Services/UIComponent/Explorer2");
159
160
161 // set values
162 $val = $this->getValue();
163 if (is_array($val))
164 {
165 $val_txt = $sep = "";
166 foreach ($val as $v)
167 {
168 $tpl->setCurrentBlock("node_hid");
169 $tpl->setVariable("HID_NAME", $this->getPostVar()."[]");
170 $tpl->setVariable("HID_VAL", $v);
171 $tpl->parseCurrentBlock();
172 $val_txt.= $sep.$this->getTitleForNodeId($v);
173 $sep = ", ";
174 $this->explorer_gui->setNodeOpen($v);
175 $this->explorer_gui->setNodeSelected($v);
176 }
177 $tpl->setVariable("VAL_TXT", $val_txt);
178 }
179 else if ($val != "")
180 {
181 $tpl->setCurrentBlock("node_hid");
182 $tpl->setVariable("HID_NAME", $this->getPostVar());
183 $tpl->setVariable("HID_VAL", $val);
184 $tpl->parseCurrentBlock();
185 $tpl->setVariable("VAL_TXT", $this->getTitleForNodeId($val));
186 $this->explorer_gui->setNodeOpen($val);
187 $this->explorer_gui->setNodeSelected($val);
188 }
189
190 $tpl->setVariable("POST_VAR", $this->getPostVar());
191 $tpl->setVariable("ID", $this->getFieldId());
192// $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
193
194 //added disabled
195 if(!$this->disabled) {
196 $tpl->setCurrentBlock("txt_select");
197 $tpl->setVariable("TXT_SELECT", $lng->txt("select"));
198 $tpl->setVariable("ID_TXT_SELECT", $this->getFieldId());
199 $tpl->parseCurrentBlock();
200
201 $tpl->setCurrentBlock("txt_reset");
202 $tpl->setVariable("TXT_RESET", $lng->txt("reset"));
203 $tpl->setVariable("ID_TXT_RESET", $this->getFieldId());
204 $tpl->parseCurrentBlock();
205 }
206
207 $tpl->setVariable("EXPL", $this->explorer_gui->getHTML());
208
209 $top_tb = new ilToolbarGUI();
210
211 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
212
213 $button = ilLinkButton::getInstance();
214 $button->setCaption("select");
215 $button->addCSSClass("ilExplSelectInputButS");
216 $button->setOmitPreventDoubleSubmission(true);
217 $top_tb->addButtonInstance($button);
218
219 $button = ilLinkButton::getInstance();
220 $button->setCaption("cancel");
221 $button->addCSSClass("ilExplSelectInputButC");
222 $button->setOmitPreventDoubleSubmission(true);
223 $top_tb->addButtonInstance($button);
224
225 // :TODO: we should probably clone the buttons properly
226 $tpl->setVariable("TOP_TB", $top_tb->getHTML());
227 $tpl->setVariable("BOT_TB", $top_tb->getHTML());
228
229 //$tpl->setVariable("HREF_SELECT",
230 // $ilCtrl->getLinkTargetByClass(array($parent_gui, "ilformpropertydispatchgui", "ilrepositoryselectorinputgui"),
231 // "showRepositorySelection"));
232
233 /*if ($this->getValue() > 0 && $this->getValue() != ROOT_FOLDER_ID)
234 {
235 $tpl->setVariable("TXT_ITEM",
236 $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->getValue())));
237 }
238 else
239 {
240 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
241 $title = $nd["title"];
242 if ($title == "ILIAS")
243 {
244 $title = $lng->txt("repository");
245 }
246 if (in_array($nd["type"], $this->getClickableTypes()))
247 {
248 $tpl->setVariable("TXT_ITEM", $title);
249 }
250 }*/
251
252 return $tpl->get();
253 }
254
259 function insert(&$a_tpl)
260 {
261 $a_tpl->setCurrentBlock("prop_generic");
262 $a_tpl->setVariable("PROP_GENERIC", $this->render());
263 $a_tpl->parseCurrentBlock();
264 }
265
270 {
271 $html = $this->render("table_filter");
272 return $html;
273 }
274
275}
global $tpl
Definition: ilias.php:8
Select explorer tree nodes input GUI.
handleExplorerCommand()
Handle explorer command.
getTableFilterHTML()
Get HTML for table filter.
setValueByArray($a_values)
Set value by array.
insert(&$a_tpl)
Insert property html.
getTitleForNodeId($a_id)
Get title for node id (needs to be overwritten, if explorer is not a tree eplorer.
render($a_mode="property_form")
Render item.
getExplHandleCmd()
Get explorer handle command function.
checkInput()
Check input, strip slashes etc.
__construct($a_title, $a_postvar, $a_explorer_gui, $a_multi=false)
Constructor.
This class represents a property in a property form.
setType($a_type)
Set Type.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
getFieldId()
Get Post Variable.
static getInstance()
Factory.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static initPanel($a_resize=false)
Init yui panel.
$_POST['username']
Definition: cron.php:12
$html
Definition: example_001.php:87
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
Interface for property form input GUI classes that can be used in table filters.
global $lng
Definition: privfeed.php:40