ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilRepositorySelectorInputGUI.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 
24 include_once("./Services/Table/interfaces/interface.ilTableFilterItem.php");
25 include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
26 
39 {
40  protected $options;
41  protected $value;
42  protected $container_types = array("root", "cat", "grp", "fold", "crs");
43 
50  function __construct($a_title = "", $a_postvar = "")
51  {
52  global $lng;
53 
54  parent::__construct($a_title, $a_postvar);
55  $this->setClickableTypes($this->container_types);
56  $this->setHeaderMessage($lng->txt('search_area_info'));
57  $this->setType("rep_select");
58  $this->setSelectText($lng->txt("select"));
59  }
60 
66  function setValue($a_value)
67  {
68  $this->value = $a_value;
69  }
70 
76  function getValue()
77  {
78  return $this->value;
79  }
80 
86  function setValueByArray($a_values)
87  {
88  $this->setValue($a_values[$this->getPostVar()]);
89  }
90 
96  function setSelectText($a_val)
97  {
98  $this->select_text = $a_val;
99  }
100 
106  function getSelectText()
107  {
108  return $this->select_text;
109  }
110 
116  function setHeaderMessage($a_val)
117  {
118  $this->hm = $a_val;
119  }
120 
126  function getHeaderMessage()
127  {
128  return $this->hm;
129  }
130 
136  function setClickableTypes($a_types)
137  {
138  $this->clickable_types = $a_types;
139  }
140 
146  function getClickableTypes()
147  {
148  return $this->clickable_types;
149  }
150 
156  function checkInput()
157  {
158  global $lng;
159 
160  $_POST[$this->getPostVar()] =
162 
163  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
164  {
165  $this->setAlert($lng->txt("msg_input_is_required"));
166 
167  return false;
168  }
169  return true;
170  }
171 
176  {
177  global $tpl, $lng, $ilCtrl, $tree, $ilUser;
178 
179  include_once 'Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php';
180  $ilCtrl->setParameter($this, "postvar", $this->getPostVar());
181 
183 
184  $exp = new ilRepositorySelectorExplorerGUI($this, "showRepositorySelection",
185  $this, "selectRepositoryItem", "root_id");
186  $exp->setTypeWhiteList($this->getVisibleTypes());
187  $exp->setClickableTypes($this->getClickableTypes());
188 
189  if($this->getValue())
190  {
191  $exp->setPathOpen($this->getValue());
192  $exp->setHighlightedNode($this->getHighlightedNode());
193  }
194 
195  if ($exp->handleCommand())
196  {
197  return;
198  }
199  // build html-output
200  $tpl->setContent($exp->getHTML());
201  }
202 
207  {
208  global $ilCtrl, $ilUser;
209 
210  $anchor = $ilUser->prefs["screen_reader_optimization"]
211  ? $this->getFieldId()."_anchor"
212  : "";
213 
214  $this->setValue($_GET["root_id"]);
215  $this->writeToSession();
216 
217  $ilCtrl->returnToParent($this, $anchor);
218  }
219 
223  function reset()
224  {
225  global $ilCtrl, $ilUser;
226 
227  $anchor = $ilUser->prefs["screen_reader_optimization"]
228  ? $this->getFieldId()."_anchor"
229  : "";
230 
231  $this->setValue("");
232  $this->writeToSession();
233 
234  $ilCtrl->returnToParent($this, $anchor);
235  }
236 
240  function render($a_mode = "property_form")
241  {
242  global $lng, $ilCtrl, $ilObjDataCache, $tree;
243 
244  $tpl = new ilTemplate("tpl.prop_rep_select.html", true, true, "Services/Form");
245 
246  $tpl->setVariable("POST_VAR", $this->getPostVar());
247  $tpl->setVariable("ID", $this->getFieldId());
248  $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
249  $tpl->setVariable("TXT_SELECT", $this->getSelectText());
250  $tpl->setVariable("TXT_RESET", $lng->txt("reset"));
251  switch ($a_mode)
252  {
253  case "property_form":
254  $parent_gui = "ilpropertyformgui";
255  break;
256 
257  case "table_filter":
258  $parent_gui = get_class($this->getParent());
259  break;
260  }
261 
262  $ilCtrl->setParameterByClass("ilrepositoryselectorinputgui",
263  "postvar", $this->getPostVar());
264  $tpl->setVariable("HREF_SELECT",
265  $ilCtrl->getLinkTargetByClass(array($parent_gui, "ilformpropertydispatchgui", "ilrepositoryselectorinputgui"),
266  "showRepositorySelection"));
267  $tpl->setVariable("HREF_RESET",
268  $ilCtrl->getLinkTargetByClass(array($parent_gui, "ilformpropertydispatchgui", "ilrepositoryselectorinputgui"),
269  "reset"));
270 
271  if ($this->getValue() > 0 && $this->getValue() != ROOT_FOLDER_ID)
272  {
273  $tpl->setVariable("TXT_ITEM",
274  $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->getValue())));
275  }
276  else
277  {
278  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
279  $title = $nd["title"];
280  if ($title == "ILIAS")
281  {
282  $title = $lng->txt("repository");
283  }
284  if (in_array($nd["type"], $this->getClickableTypes()))
285  {
286  $tpl->setVariable("TXT_ITEM", $title);
287  }
288  }
289  return $tpl->get();
290  }
291 
297  function insert($a_tpl)
298  {
299  $a_tpl->setCurrentBlock("prop_generic");
300  $a_tpl->setVariable("PROP_GENERIC", $this->render());
301  $a_tpl->parseCurrentBlock();
302  }
303 
308  {
309  $html = $this->render("table_filter");
310  return $html;
311  }
312 
318  protected function getHighlightedNode()
319  {
320  global $tree;
321 
322  if(!in_array(ilObject::_lookupType($this->getValue(),true), $this->getVisibleTypes()))
323  {
324  return $tree->getParentId($this->getValue());
325  }
326 
327  return $this->getValue();
328  }
329 
335  protected function getVisibleTypes()
336  {
337  return array_merge((array)$this->container_types, (array)$this->getClickableTypes());
338  }
339 
340 }
getHighlightedNode()
Returns the highlighted object.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
Interface for property form input GUI classes that can be used in table filters.
getVisibleTypes()
returns all visible types like container and clickable types
Explorer for selecting repository items.
render($a_mode="property_form")
Render item.
$_GET["client_id"]
getPostVar()
Get Post Variable.
__construct($a_title="", $a_postvar="")
Constructor.
checkInput()
Check input, strip slashes etc.
setAlert($a_alert)
Set Alert Text.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
setType($a_type)
Set Type.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
setValueByArray($a_values)
Set value by array.
$nd
Definition: error.php:11
This class represents a repository selector in a property form.
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
setClickableTypes($a_types)
Set clickable types.
$ilUser
Definition: imgupload.php:18
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getParent()
Get Parent GUI object.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a property in a property form.
global $lng
Definition: privfeed.php:17
writeToSession()
Write to session.
$_POST["username"]
$html
Definition: example_001.php:87