ILIAS  Release_4_2_x_branch Revision 61807
 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 
168  $exp = new ilBookmarkExplorer($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"),
169  $_SESSION["AccountId"]);
170  $exp->setAllowedTypes(array('dum','bmf','bm'));
171  $exp->setEnableSmallMode(true);
172  $exp->setTargetGet("bmf_id");
173  $exp->setSessionExpandVariable('mexpand');
174  $ilCtrl->setParameter($this, "bmf_id", $this->id);
175  $exp->setExpandTarget($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"));
176  if ($_GET["mexpand"] == "")
177  {
178  $expanded = $this->id;
179  }
180  else
181  {
182  $expanded = $_GET["mexpand"];
183  }
184  $exp->setExpand($expanded);
185  $exp->setShowDetails($showdetails);
186 
187  // build html-output
188  $exp->setOutput(0);
189  return $exp->getOutput();
190  }
191 
195  function fillFooter()
196  {
197  global $ilCtrl, $lng, $ilUser;
198 
199  $this->setFooterLinks();
200  $this->fillFooterLinks();
201  $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
202  if ($this->tpl->blockExists("block_footer"))
203  {
204  $this->tpl->setCurrentBlock("block_footer");
205  $this->tpl->parseCurrentBlock();
206  }
207  }
208 
212  function setFooterLinks()
213  {
214  global $ilUser, $ilCtrl, $lng;
215 
216  if ($this->num_bookmarks == 0 && $this->num_folders == 0)
217  {
218  return;
219  }
220 
221  // flat
222  if ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
223  {
224  $this->addFooterLink( $lng->txt("list"),
225  $ilCtrl->getLinkTarget($this, "setPdFlatMode"),
226  $ilCtrl->getLinkTarget($this, "setPdFlatMode",
227  "", true),
228  "block_".$this->getBlockType()."_".$this->block_id);
229  }
230  else
231  {
232  $this->addFooterLink($lng->txt("list"));
233  }
234 
235  // as tree
236  if ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
237  {
238  $this->addFooterLink($lng->txt("tree"));
239  }
240  else
241  {
242  $this->addFooterLink($lng->txt("tree"),
243  $ilCtrl->getLinkTarget($this,
244  "setPdTreeMode"),
245  $ilCtrl->getLinkTarget($this,
246  "setPdTreeMode", "", true),
247  "block_".$this->getBlockType()."_".$this->block_id
248  );
249  }
250  }
251 
255  function getListRowData()
256  {
257  global $ilUser, $lng, $ilCtrl;
258 
259  include_once("./Services/PersonalDesktop/classes/class.ilBookmarkFolder.php");
260 
261  $data = array();
262 
263  $sess_cur_bm_folder = "";
264  if (isset($_SESSION["ilCurBMFolder"]))
265  {
266  $sess_cur_bm_folder = $_SESSION["ilCurBMFolder"];
267  }
268 
269  $bm_items = ilBookmarkFolder::getObjects($sess_cur_bm_folder);
270 
271  if (!ilBookmarkFolder::isRootFolder($sess_cur_bm_folder)
272  && !empty($_SESSION["ilCurBMFolder"]))
273  {
274  $ilCtrl->setParameter($this, "curBMFolder",
275  ilBookmarkFolder::_getParentId($sess_cur_bm_folder));
276 
277  $data[] = array(
278  "img" => ilUtil::getImagePath("icon_cat_s.gif"),
279  "alt" => $lng->txt("bmf"),
280  "title" => "..",
281  "link" => $ilCtrl->getLinkTarget($this, "setCurrentBookmarkFolder"));
282 
283  $this->setTitle($this->getTitle().": ".ilBookmarkFolder::_lookupTitle($sess_cur_bm_folder));
284  }
285 
286  foreach ($bm_items as $bm_item)
287  {
288  switch ($bm_item["type"])
289  {
290  case "bmf":
291  $ilCtrl->setParameter($this, "curBMFolder", $bm_item["obj_id"]);
292  $data[] = array(
293  "img" => ilUtil::getImagePath("icon_cat_s.gif"),
294  "alt" => $lng->txt("bmf"),
295  "title" => ilUtil::prepareFormOutput($bm_item["title"]),
296  "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
297  "link" => $ilCtrl->getLinkTarget($this,
298  "setCurrentBookmarkFolder"),
299  "target" => "");
300  break;
301 
302  case "bm":
303  $data[] = array(
304  "img" => ilUtil::getImagePath("spacer.gif"),
305  "alt" => $lng->txt("bm"),
306  "title" => ilUtil::prepareFormOutput($bm_item["title"]),
307  "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
308  "link" => ilUtil::prepareFormOutput($bm_item["target"]),
309  "target" => "_blank");
310  break;
311  }
312  }
313 
314  $this->setData($data);
315  }
316 
320  function fillRow($a_set)
321  {
322  global $ilUser;
323 
324  $this->tpl->setVariable("IMG_BM", $a_set["img"]);
325  $this->tpl->setVariable("IMG_ALT", $a_set["alt"]);
326  $this->tpl->setVariable("BM_TITLE", $a_set["title"]);
327  $this->tpl->setVariable("BM_LINK", $a_set["link"]);
328  $this->tpl->setVariable("BM_TARGET", ilUtil::prepareFormOutput($a_set["target"]));
329 
330  if ($this->getCurrentDetailLevel() > 2)
331  {
332  $this->tpl->setVariable("BM_DESCRIPTION", ilUtil::prepareFormOutput($a_set["desc"]));
333  }
334  else
335  {
336  $this->tpl->setVariable("BM_TOOLTIP", ilUtil::prepareFormOutput($a_set["desc"]));
337  }
338  }
339 
343  function getOverview()
344  {
345  global $ilUser, $lng, $ilCtrl;
346 
347  return '<div class="small">'.$this->num_bookmarks." ".$lng->txt("bm_num_bookmarks").", ".
348  $this->num_folders." ".$lng->txt("bm_num_bookmark_folders")."</div>";
349  }
350 
354  function setPdFlatMode()
355  {
356  global $ilCtrl, $ilUser;
357 
358  $ilUser->writePref("il_pd_bkm_mode", 'flat');
359  if ($ilCtrl->isAsynch())
360  {
361  echo $this->getHTML();
362  exit;
363  }
364  else
365  {
366  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
367  }
368  }
369 
373  function setPdTreeMode()
374  {
375  global $ilCtrl, $ilUser;
376 
377  $ilUser->writePref("il_pd_bkm_mode", 'tree');
378  if ($ilCtrl->isAsynch())
379  {
380  echo $this->getHTML();
381  exit;
382  }
383  else
384  {
385  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
386  }
387  }
388 
393  {
394  global $ilCtrl;
395 
396  $_SESSION["ilCurBMFolder"] = $_GET["curBMFolder"];
397  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
398  }
399 
400 }
401 
402 ?>