ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilGlossaryLocatorGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 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 
34 {
35  var $mode;
36  var $temp_var;
37  var $tree;
38  var $obj;
39  var $lng;
40  var $tpl;
41 
42 
44  {
45  global $lng, $tpl, $tree;
46 
47  $this->mode = "edit";
48  $this->temp_var = "LOCATOR";
49  $this->lng =& $lng;
50  $this->tpl =& $tpl;
51  $this->tree =& $tree;
52  }
53 
54  function setTemplateVariable($a_temp_var)
55  {
56  $this->temp_var = $a_temp_var;
57  }
58 
59  function setTerm(&$a_term)
60  {
61  $this->term =& $a_term;
62  }
63 
64  function setGlossary(&$a_glossary)
65  {
66  $this->glossary =& $a_glossary;
67  }
68 
69  function setDefinition(&$a_def)
70  {
71  $this->definition =& $a_def;
72  }
73 
74  function setMode($a_mode)
75  {
76  $this->mode = $a_mode;
77  }
78 
82  function display()
83  {
84  global $lng, $ilCtrl;
85 
86  $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html", "Services/Locator");
87 
88  $path = $this->tree->getPathFull($_GET["ref_id"]);
89 
90  if (is_object($this->term) && ($_GET["def"] > 0 || $this->mode == "presentation"))
91  {
92  $modifier = 0;
93  }
94  else
95  {
96  $modifier = 1;
97  }
98 
99  switch($this->mode)
100  {
101  case "edit":
102  $repository = "./repository.php";
103  break;
104 
105  case "presentation":
106  $script = "ilias.php?baseClass=ilGlossaryPresentationGUI";
107  $repository = "./repository.php";
108  break;
109  }
110 
111  //$this->tpl->touchBlock("locator_separator");
112  //$this->tpl->touchBlock("locator_item");
113 
114  foreach ($path as $key => $row)
115  {
116  //if ($row["child"] == $this->tree->getRootId())
117  //{
118  // continue;
119  //}
120 
121  if (($key < count($path) - $modifier))
122  {
123  $this->tpl->touchBlock("locator_separator");
124  }
125 
126 
127  if ($row["child"] > 0)
128  {
129  $this->tpl->setCurrentBlock("locator_img");
130  $this->tpl->setVariable("IMG_SRC",
131  ilUtil::getImagePath("icon_".$row["type"]."_s.gif"));
132  $this->tpl->setVariable("IMG_ALT",
133  $lng->txt("obj_".$type));
134  $this->tpl->parseCurrentBlock();
135  }
136 
137  $this->tpl->setCurrentBlock("locator_item");
138  $t_frame = "";
139  if ($row["child"] == $this->tree->getRootId())
140  {
141  $title = $this->lng->txt("repository");
142  $link = $repository."?cmd=frameset&ref_id=".$row["child"];
143  $t_frame = ilFrameTargetInfo::_getFrame("MainContent");
144  }
145  else if (($_GET["ref_id"] == $row["child"]))
146  {
147  $title = $this->glossary->getTitle();
148  if ($this->mode == "edit")
149  {
150  $link = $ilCtrl->getLinkTargetByClass("ilobjglossarygui", "listTerms");
151  }
152  else
153  {
154  $link = $script."&amp;ref_id=".$_GET["ref_id"];
155  }
156  }
157  else
158  {
159  $title = $row["title"];
160  $link = $repository."?cmd=frameset&ref_id=".$row["child"];
161  $t_frame = ilFrameTargetInfo::_getFrame("MainContent");
162  }
163  $this->tpl->setVariable("ITEM", $title);
164  $this->tpl->setVariable("LINK_ITEM", $link);
165  if ($t_frame != "")
166  {
167  $this->tpl->setVariable("LINK_TARGET", " target=\"$t_frame\" ");
168  }
169  $this->tpl->parseCurrentBlock();
170  }
171 
172  /*
173  if (is_object($this->definition))
174  {
175  $this->tpl->touchBlock("locator_separator");
176  }*/
177 
178 
179  if (is_object($this->term) && $this->mode != "edit")
180  {
181  $this->tpl->setCurrentBlock("locator_item");
182  $this->tpl->setVariable("ITEM", $this->term->getTerm());
183  //if ($this->mode == "edit")
184  //{
185  // $this->tpl->setVariable("LINK_ITEM",
186  // $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listDefinitions"));
187  //}
188  //else
189  //{
190  $this->tpl->setVariable("LINK_ITEM", $script."&amp;ref_id=".$_GET["ref_id"].
191  "&cmd=listDefinitions&term_id=".$this->term->getId());
192  //}
193  $this->tpl->parseCurrentBlock();
194  }
195 
196  //$this->tpl->touchBlock("locator_separator");
197 
198  if (is_object($this->definition))
199  {
200  $this->tpl->setCurrentBlock("locator_item");
201  $this->tpl->setVariable("ITEM", $this->term->getTerm()." (".
202  $this->lng->txt("cont_definition")." ".
203  $this->definition->getNr().")");
204  if ($this->mode == "edit")
205  {
206  $this->tpl->setVariable("LINK_ITEM",
207  $ilCtrl->getLinkTargetByClass("ilpageobjectgui", "edit"));
208  }
209  else
210  {
211  $this->tpl->setVariable("LINK_ITEM", $script."&amp;ref_id=".$_GET["ref_id"].
212  "&cmd=view&def=".$_GET["def"]);
213  }
214  $this->tpl->parseCurrentBlock();
215  }
216 
217  //$this->tpl->touchBlock("locator_separator");
218 
219  $this->tpl->setCurrentBlock("locator");
220  $this->tpl->setVariable("TXT_LOCATOR", $debug.$this->lng->txt("locator"));
221  $this->tpl->parseCurrentBlock();
222  }
223 
224 }
225 ?>