ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
49  function __construct($a_title = "", $a_postvar = "")
50  {
51  global $lng;
52 
53  parent::__construct($a_title, $a_postvar);
54  $this->setClickableTypes(array("root", "cat", "grp", "fold", "crs"));
55  $this->setHeaderMessage($lng->txt('search_area_info'));
56  $this->setType("rep_select");
57  $this->setSelectText($lng->txt("select"));
58  }
59 
65  function setValue($a_value)
66  {
67  $this->value = $a_value;
68  }
69 
75  function getValue()
76  {
77  return $this->value;
78  }
79 
85  function setValueByArray($a_values)
86  {
87  $this->setValue($a_values[$this->getPostVar()]);
88  }
89 
95  function setSelectText($a_val)
96  {
97  $this->select_text = $a_val;
98  }
99 
105  function getSelectText()
106  {
107  return $this->select_text;
108  }
109 
115  function setHeaderMessage($a_val)
116  {
117  $this->hm = $a_val;
118  }
119 
125  function getHeaderMessage()
126  {
127  return $this->hm;
128  }
129 
135  function setClickableTypes($a_types)
136  {
137  $this->clickable_types = $a_types;
138  }
139 
145  function getClickableTypes()
146  {
147  return $this->clickable_types;
148  }
149 
155  function checkInput()
156  {
157  global $lng;
158 
159  $_POST[$this->getPostVar()] =
161 
162  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
163  {
164  $this->setAlert($lng->txt("msg_input_is_required"));
165 
166  return false;
167  }
168  return true;
169  }
170 
175  {
176  global $tpl, $lng, $ilCtrl, $tree, $ilUser;
177 
178  include_once 'Services/Search/classes/class.ilSearchRootSelector.php';
179  $ilCtrl->setParameter($this, "postvar", $this->getPostVar());
180 
182 
183  $exp = new ilSearchRootSelector($ilCtrl->getLinkTarget($this,'showRepositorySelection'));
184  $exp->setExpand($_GET["search_root_expand"] ? $_GET["search_root_expand"] : $tree->readRootId());
185  $exp->setExpandTarget($ilCtrl->getLinkTarget($this,'showRepositorySelection'));
186  $exp->setTargetClass(get_class($this));
187  $exp->setCmd('selectRepositoryItem');
188  $exp->setClickableTypes($this->getClickableTypes());
189 
190  // build html-output
191  $exp->setOutput(0);
192  $tpl->setContent($exp->getOutput());
193  }
194 
199  {
200  global $ilCtrl, $ilUser;
201 
202  $anchor = $ilUser->prefs["screen_reader_optimization"]
203  ? $this->getFieldId()."_anchor"
204  : "";
205 
206  $this->setValue($_GET["root_id"]);
207  $this->writeToSession();
208 
209  $ilCtrl->returnToParent($this, $anchor);
210  }
211 
215  function reset()
216  {
217  global $ilCtrl, $ilUser;
218 
219  $anchor = $ilUser->prefs["screen_reader_optimization"]
220  ? $this->getFieldId()."_anchor"
221  : "";
222 
223  $this->setValue("");
224  $this->writeToSession();
225 
226  $ilCtrl->returnToParent($this, $anchor);
227  }
228 
232  function render($a_mode = "property_form")
233  {
234  global $lng, $ilCtrl, $ilObjDataCache, $tree;
235 
236  $tpl = new ilTemplate("tpl.prop_rep_select.html", true, true, "Services/Form");
237 
238  $tpl->setVariable("POST_VAR", $this->getPostVar());
239  $tpl->setVariable("ID", $this->getFieldId());
240  $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
241  $tpl->setVariable("TXT_SELECT", $this->getSelectText());
242  $tpl->setVariable("TXT_RESET", $lng->txt("reset"));
243  switch ($a_mode)
244  {
245  case "property_form":
246  $parent_gui = "ilpropertyformgui";
247  break;
248 
249  case "table_filter":
250  $parent_gui = get_class($this->getParent());
251  break;
252  }
253 
254  $ilCtrl->setParameterByClass("ilrepositoryselectorinputgui",
255  "postvar", $this->getPostVar());
256  $tpl->setVariable("HREF_SELECT",
257  $ilCtrl->getLinkTargetByClass(array($parent_gui, "ilformpropertydispatchgui", "ilrepositoryselectorinputgui"),
258  "showRepositorySelection"));
259  $tpl->setVariable("HREF_RESET",
260  $ilCtrl->getLinkTargetByClass(array($parent_gui, "ilformpropertydispatchgui", "ilrepositoryselectorinputgui"),
261  "reset"));
262 
263  if ($this->getValue() > 0 && $this->getValue() != ROOT_FOLDER_ID)
264  {
265  $tpl->setVariable("TXT_ITEM",
266  $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->getValue())));
267  }
268  else
269  {
270  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
271  $title = $nd["title"];
272  if ($title == "ILIAS")
273  {
274  $title = $lng->txt("repository");
275  }
276  if (in_array($nd["type"], $this->getClickableTypes()))
277  {
278  $tpl->setVariable("TXT_ITEM", $title);
279  }
280  }
281  return $tpl->get();
282  }
283 
289  function insert(&$a_tpl)
290  {
291  $a_tpl->setCurrentBlock("prop_generic");
292  $a_tpl->setVariable("PROP_GENERIC", $this->render());
293  $a_tpl->parseCurrentBlock();
294  }
295 
300  {
301  $html = $this->render("table_filter");
302  return $html;
303  }
304 
305 }