ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 public function __construct($a_title, $a_postvar, $a_explorer_gui, $a_multi = false)
25 {
26 global $DIC;
27
28 $this->lng = $DIC->language();
29 $lng = $DIC->language();
30
31 $this->multi_nodes = $a_multi;
32 $this->explorer_gui = $a_explorer_gui;
33
34 parent::__construct($a_title, $a_postvar);
35 $this->setType("exp_select");
36 }
37
44 public function getExplHandleCmd()
45 {
46 return "handleExplorerCommand";
47 }
48
52 public function handleExplorerCommand()
53 {
54 $this->explorer_gui->handleCommand();
55 }
56
63 abstract public function getTitleForNodeId($a_id);
64
70 public function setValue($a_value)
71 {
72 if ($this->multi_nodes && !is_array($a_value)) {
73 if ($a_value !== false) {
74 $this->value = array($a_value);
75 } else {
76 $this->value = array();
77 }
78 } else {
79 $this->value = $a_value;
80 }
81 }
82
88 public function getValue()
89 {
90 return $this->value;
91 }
92
98 public function setValueByArray($a_values)
99 {
100 $this->setValue($a_values[$this->getPostVar()]);
101 }
102
108 public function checkInput()
109 {
111
112 // sanitize
113 if ($this->multi_nodes) {
114 if (!is_array($_POST[$this->getPostVar()])) {
115 $_POST[$this->getPostVar()] = array();
116 }
117
118 foreach ($_POST[$this->getPostVar()] as $k => $v) {
119 $_POST[$this->getPostVar()][$k] = ilUtil::stripSlashes($v);
120 }
121 } else {
123 }
124
125 // check required
126 if ($this->getRequired()) {
127 if ((!$this->multi_nodes && trim($_POST[$this->getPostVar()]) == "") ||
128 ($this->multi_nodes && count($_POST[$this->getPostVar()]) == 0)) {
129 $this->setAlert($lng->txt("msg_input_is_required"));
130 return false;
131 }
132 }
133 return true;
134 }
135
136
140 public function render($a_mode = "property_form")
141 {
143
144 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
146 $GLOBALS["tpl"]->addJavascript("./Services/UIComponent/Explorer2/js/Explorer2.js");
147
148 $tpl = new ilTemplate("tpl.prop_expl_select.html", true, true, "Services/UIComponent/Explorer2");
149
150 if ($a_mode != "property_form") {
151 $tpl->touchBlock("tiny_presentation");
152 }
153
154 // set values
155 $val = $this->getValue();
156 if (is_array($val)) {
157 $val_txt = $sep = "";
158 foreach ($val as $v) {
159 $tpl->setCurrentBlock("node_hid");
160 $tpl->setVariable("HID_NAME", $this->getPostVar() . "[]");
161 $tpl->setVariable("HID_VAL", $v);
162 $tpl->parseCurrentBlock();
163 $val_txt.= $sep . $this->getTitleForNodeId($v);
164 $sep = ", ";
165 $this->explorer_gui->setNodeOpen($v);
166 $this->explorer_gui->setNodeSelected($v);
167 }
168 $tpl->setVariable("VAL_TXT", $val_txt);
169 } elseif ($val != "") {
170 $tpl->setCurrentBlock("node_hid");
171 $tpl->setVariable("HID_NAME", $this->getPostVar());
172 $tpl->setVariable("HID_VAL", $val);
173 $tpl->parseCurrentBlock();
174 $tpl->setVariable("VAL_TXT", $this->getTitleForNodeId($val));
175 $this->explorer_gui->setNodeOpen($val);
176 $this->explorer_gui->setNodeSelected($val);
177 }
178
179 $tpl->setVariable("POST_VAR", $this->getPostVar());
180 $tpl->setVariable("ID", $this->getFieldId());
181 // $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
182
183 //added disabled
184 if (!$this->disabled) {
185 $tpl->setCurrentBlock("txt_select");
186 $tpl->setVariable("TXT_SELECT", $lng->txt("select"));
187 $tpl->setVariable("ID_TXT_SELECT", $this->getFieldId());
188 $tpl->parseCurrentBlock();
189
190 $tpl->setCurrentBlock("txt_reset");
191 $tpl->setVariable("TXT_RESET", $lng->txt("reset"));
192 $tpl->setVariable("ID_TXT_RESET", $this->getFieldId());
193 $tpl->parseCurrentBlock();
194 }
195
196 $tpl->setVariable("EXPL", $this->explorer_gui->getHTML());
197
198 $top_tb = new ilToolbarGUI();
199
200 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
201
202 $button = ilLinkButton::getInstance();
203 $button->setCaption("select");
204 $button->addCSSClass("ilExplSelectInputButS");
205 $button->setOmitPreventDoubleSubmission(true);
206 $top_tb->addButtonInstance($button);
207
208 $button = ilLinkButton::getInstance();
209 $button->setCaption("cancel");
210 $button->addCSSClass("ilExplSelectInputButC");
211 $button->setOmitPreventDoubleSubmission(true);
212 $top_tb->addButtonInstance($button);
213
214 // :TODO: we should probably clone the buttons properly
215 $tpl->setVariable("TOP_TB", $top_tb->getHTML());
216 $tpl->setVariable("BOT_TB", $top_tb->getHTML());
217
218 //$tpl->setVariable("HREF_SELECT",
219 // $ilCtrl->getLinkTargetByClass(array($parent_gui, "ilformpropertydispatchgui", "ilrepositoryselectorinputgui"),
220 // "showRepositorySelection"));
221
222 /*if ($this->getValue() > 0 && $this->getValue() != ROOT_FOLDER_ID)
223 {
224 $tpl->setVariable("TXT_ITEM",
225 $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->getValue())));
226 }
227 else
228 {
229 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
230 $title = $nd["title"];
231 if ($title == "ILIAS")
232 {
233 $title = $lng->txt("repository");
234 }
235 if (in_array($nd["type"], $this->getClickableTypes()))
236 {
237 $tpl->setVariable("TXT_ITEM", $title);
238 }
239 }*/
240
241 return $tpl->get();
242 }
243
248 public function insert(&$a_tpl)
249 {
250 $a_tpl->setCurrentBlock("prop_generic");
251 $a_tpl->setVariable("PROP_GENERIC", $this->render());
252 $a_tpl->parseCurrentBlock();
253 }
254
258 public function getTableFilterHTML()
259 {
260 $html = $this->render("table_filter");
261 return $html;
262 }
263}
$tpl
Definition: ilias.php:10
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
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, ilTemplate $a_main_tpl=null)
Init yui panel.
$html
Definition: example_001.php:87
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Interface for property form input GUI classes that can be used in table filters.
global $DIC
Definition: saml.php:7