ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilBookmarkBlockGUI.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 
24 include_once("Services/Block/classes/class.ilBlockGUI.php");
25 
35 {
36  static $block_type = "pdbookm";
37 
41  function ilBookmarkBlockGUI()
42  {
43  global $ilCtrl, $lng, $ilUser;
44 
46 
47  $this->setImage(ilUtil::getImagePath("icon_bm_s.gif"));
48  $this->setTitle($lng->txt("my_bms"));
49  $this->setEnableNumInfo(false);
50  $this->setLimit(99999);
51  $this->setAvailableDetailLevels(3);
52 
53  $this->id = (empty($_GET["bmf_id"]))
54  ? $bmf_id = 1
55  : $_GET["bmf_id"];
56  }
57 
63  static function getBlockType()
64  {
65  return self::$block_type;
66  }
67 
73  static function isRepositoryObject()
74  {
75  return false;
76  }
77 
78 
82  static function getScreenMode()
83  {
84  switch($_GET["cmd"])
85  {
86  default:
87  return IL_SCREEN_SIDE;
88  break;
89  }
90  }
91 
95  function &executeCommand()
96  {
97  global $ilCtrl;
98 
99  $next_class = $ilCtrl->getNextClass();
100  $cmd = $ilCtrl->getCmd("getHTML");
101 
102  return $this->$cmd();
103  }
104 
105  function getHTML()
106  {
107  // workaround to show details row
108  $this->setData(array("dummy"));
109 
110  if ($this->getCurrentDetailLevel() == 0)
111  {
112  return "";
113  }
114  else
115  {
116  return parent::getHTML();
117  }
118  }
119 
123  function fillDataSection()
124  {
125  global $ilUser;
126 
127  include_once("./Services/PersonalDesktop/classes/class.ilBookmarkFolder.php");
129  $this->num_bookmarks = $bm_items["bookmarks"];
130  $this->num_folders = $bm_items["folders"];
131 
132  if ($this->getCurrentDetailLevel() > 1 &&
133  ($this->num_bookmarks > 0 || $this->num_folders > 0))
134  {
135  if ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
136  {
137  $this->setDataSection($this->getPDBookmarkListHTMLTree());
138  }
139  else
140  {
141  $this->setRowTemplate("tpl.bookmark_pd_list.html", "Services/PersonalDesktop");
142  $this->getListRowData();
143  $this->setColSpan(2);
145  }
146  }
147  else
148  {
149  if ($this->num_bookmarks == 0 && $this->num_folders == 0)
150  {
151  $this->setEnableDetailRow(false);
152  }
153  $this->setDataSection($this->getOverview());
154  }
155  }
156 
161  {
162  global $ilCtrl, $ilUser;
163 
164  include_once("./Services/PersonalDesktop/classes/class.ilBookmarkExplorer.php");
165 
166  $showdetails = ($this->getCurrentDetailLevel() > 2);
167  $tpl = new ilTemplate("tpl.bookmark_pd_tree.html", true, true,
168  "Services/PersonalDesktop");
169 
170  $exp = new ilBookmarkExplorer($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"),
171  $_SESSION["AccountId"]);
172  $exp->setAllowedTypes(array('dum','bmf','bm'));
173  $exp->setEnableSmallMode(true);
174  $exp->setTargetGet("bmf_id");
175  $exp->setSessionExpandVariable('mexpand');
176  $ilCtrl->setParameter($this, "bmf_id", $this->id);
177  $exp->setExpandTarget($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"));
178  if ($_GET["mexpand"] == "")
179  {
180  $expanded = $this->id;
181  }
182  else
183  {
184  $expanded = $_GET["mexpand"];
185  }
186  $exp->setExpand($expanded);
187  $exp->setShowDetails($showdetails);
188 
189  // build html-output
190  $exp->setOutput(0);
191  return $exp->getOutput();
192  }
193 
197  function fillFooter()
198  {
199  global $ilCtrl, $lng, $ilUser;
200 
201  $this->setFooterLinks();
202  $this->fillFooterLinks();
203  $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
204  if ($this->tpl->blockExists("block_footer"))
205  {
206  $this->tpl->setCurrentBlock("block_footer");
207  $this->tpl->parseCurrentBlock();
208  }
209  }
210 
214  function setFooterLinks()
215  {
216  global $ilUser, $ilCtrl, $lng;
217 
218  if ($this->num_bookmarks == 0 && $this->num_folders == 0)
219  {
220  return;
221  }
222 
223  // flat
224  if ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
225  {
226  $this->addFooterLink( $lng->txt("list"),
227  $ilCtrl->getLinkTarget($this, "setPdFlatMode"),
228  $ilCtrl->getLinkTarget($this, "setPdFlatMode",
229  "", true),
230  "block_".$this->getBlockType()."_".$this->block_id);
231  }
232  else
233  {
234  $this->addFooterLink($lng->txt("list"));
235  }
236 
237  // as tree
238  if ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
239  {
240  $this->addFooterLink($lng->txt("tree"));
241  }
242  else
243  {
244  $this->addFooterLink($lng->txt("tree"),
245  $ilCtrl->getLinkTarget($this,
246  "setPdTreeMode"),
247  $ilCtrl->getLinkTarget($this,
248  "setPdTreeMode", "", true),
249  "block_".$this->getBlockType()."_".$this->block_id
250  );
251  }
252  }
253 
257  function getListRowData()
258  {
259  global $ilUser, $lng, $ilCtrl;
260 
261  include_once("./Services/PersonalDesktop/classes/class.ilBookmarkFolder.php");
262 
263  $data = array();
264 
265  $bm_items = ilBookmarkFolder::getObjects($_SESSION["ilCurBMFolder"]);
266 
267  if (!ilBookmarkFolder::isRootFolder($_SESSION["ilCurBMFolder"])
268  && !empty($_SESSION["ilCurBMFolder"]))
269  {
270  $ilCtrl->setParameter($this, "curBMFolder",
271  ilBookmarkFolder::_getParentId($_SESSION["ilCurBMFolder"]));
272 
273  $data[] = array(
274  "img" => ilUtil::getImagePath("icon_cat_s.gif"),
275  "alt" => $lng->txt("bmf"),
276  "title" => "..",
277  "link" => $ilCtrl->getLinkTarget($this, "setCurrentBookmarkFolder"));
278 
279  $this->setTitle($this->getTitle().": ".ilBookmarkFolder::_lookupTitle($_SESSION["ilCurBMFolder"]));
280  }
281 
282  foreach ($bm_items as $bm_item)
283  {
284  switch ($bm_item["type"])
285  {
286  case "bmf":
287  $ilCtrl->setParameter($this, "curBMFolder", $bm_item["obj_id"]);
288  $data[] = array(
289  "img" => ilUtil::getImagePath("icon_cat_s.gif"),
290  "alt" => $lng->txt("bmf"),
291  "title" => ilUtil::prepareFormOutput($bm_item["title"]),
292  "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
293  "link" => $ilCtrl->getLinkTarget($this,
294  "setCurrentBookmarkFolder"),
295  "target" => "");
296  break;
297 
298  case "bm":
299  $data[] = array(
300  "img" => ilUtil::getImagePath("spacer.gif"),
301  "alt" => $lng->txt("bm"),
302  "title" => ilUtil::prepareFormOutput($bm_item["title"]),
303  "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
304  "link" => ilUtil::prepareFormOutput($bm_item["target"]),
305  "target" => "_blank");
306  break;
307  }
308  }
309 
310  $this->setData($data);
311  }
312 
316  function fillRow($a_set)
317  {
318  global $ilUser;
319 
320  $this->tpl->setVariable("IMG_BM", $a_set["img"]);
321  $this->tpl->setVariable("IMG_ALT", $a_set["alt"]);
322  $this->tpl->setVariable("BM_TITLE", $a_set["title"]);
323  $this->tpl->setVariable("BM_LINK", $a_set["link"]);
324  $this->tpl->setVariable("BM_TARGET", ilUtil::prepareFormOutput($a_set["target"]));
325 
326  if ($this->getCurrentDetailLevel() > 2)
327  {
328  $this->tpl->setVariable("BM_DESCRIPTION", ilUtil::prepareFormOutput($a_set["desc"]));
329  }
330  else
331  {
332  $this->tpl->setVariable("BM_TOOLTIP", ilUtil::prepareFormOutput($a_set["desc"]));
333  }
334  }
335 
339  function getOverview()
340  {
341  global $ilUser, $lng, $ilCtrl;
342 
343  return '<div class="small">'.$this->num_bookmarks." ".$lng->txt("bm_num_bookmarks").", ".
344  $this->num_folders." ".$lng->txt("bm_num_bookmark_folders")."</div>";
345  }
346 
350  function setPdFlatMode()
351  {
352  global $ilCtrl, $ilUser;
353 
354  $ilUser->writePref("il_pd_bkm_mode", 'flat');
355  if ($ilCtrl->isAsynch())
356  {
357  echo $this->getHTML();
358  exit;
359  }
360  else
361  {
362  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
363  }
364  }
365 
369  function setPdTreeMode()
370  {
371  global $ilCtrl, $ilUser;
372 
373  $ilUser->writePref("il_pd_bkm_mode", 'tree');
374  if ($ilCtrl->isAsynch())
375  {
376  echo $this->getHTML();
377  exit;
378  }
379  else
380  {
381  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
382  }
383  }
384 
389  {
390  global $ilCtrl;
391 
392  $_SESSION["ilCurBMFolder"] = $_GET["curBMFolder"];
393  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
394  }
395 
396 }
397 
398 ?>