ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilBookmarkBlockGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("Services/Block/classes/class.ilBlockGUI.php");
6 
17 {
18  public static $block_type = "pdbookm";
19 
23  public function __construct()
24  {
25  global $DIC;
26 
27  $this->ctrl = $DIC->ctrl();
28  $this->lng = $DIC->language();
29  $this->user = $DIC->user();
30  $lng = $DIC->language();
31 
32  parent::__construct();
33 
34  $this->setImage(ilUtil::getImagePath("icon_bm.svg"));
35  $this->setTitle($lng->txt("my_bms"));
36  $this->setEnableNumInfo(false);
37  $this->setLimit(99999);
38  $this->setAvailableDetailLevels(3);
39 
40  $this->id = (empty($_GET["bmf_id"]))
41  ? $bmf_id = 1
42  : $_GET["bmf_id"];
43  }
44 
50  public static function getBlockType()
51  {
52  return self::$block_type;
53  }
54 
60  public static function isRepositoryObject()
61  {
62  return false;
63  }
64 
65 
69  public static function getScreenMode()
70  {
71  switch ($_GET["cmd"]) {
72  default:
73  return IL_SCREEN_SIDE;
74  break;
75  }
76  }
77 
81  public function executeCommand()
82  {
84 
85  $next_class = $ilCtrl->getNextClass();
86  $cmd = $ilCtrl->getCmd("getHTML");
87 
88  return $this->$cmd();
89  }
90 
91  public function getHTML()
92  {
93  // workaround to show details row
94  $this->setData(array("dummy"));
95  if ($this->getCurrentDetailLevel() == 0) {
96  return "";
97  } else {
98  return parent::getHTML();
99  }
100  }
101 
105  public function fillDataSection()
106  {
108 
109  include_once("./Services/Bookmarks/classes/class.ilBookmarkFolder.php");
111  $this->num_bookmarks = $bm_items["bookmarks"];
112  $this->num_folders = $bm_items["folders"];
113 
114  if ($this->getCurrentDetailLevel() > 1 &&
115  ($this->num_bookmarks > 0 || $this->num_folders > 0)) {
116  if ($ilUser->getPref("il_pd_bkm_mode") == 'tree') {
117  $this->setDataSection($this->getPDBookmarkListHTMLTree());
118  } else {
119  $this->setRowTemplate("tpl.bookmark_pd_list.html", "Services/Bookmarks");
120  $this->getListRowData();
121  $this->setColSpan(2);
122  parent::fillDataSection();
123  }
124  } else {
125  if ($this->num_bookmarks == 0 && $this->num_folders == 0) {
126  $this->setEnableDetailRow(false);
127  }
128  $this->setDataSection($this->getOverview());
129  }
130  }
131 
135  public function getPDBookmarkListHTMLTree()
136  {
139 
140  include_once("./Services/Bookmarks/classes/class.ilBookmarkBlockExplorerGUI.php");
141  $exp = new ilBookmarkBlockExplorerGUI($this, "getPDBookmarkListHTMLTree");
142  if (!$exp->handleCommand()) {
143  return "<div id='tree_div'>" . $exp->getHTML() . "</div>";
144  }
145  }
146 
150  public function fillFooter()
151  {
152  $this->setFooterLinks();
153  $this->fillFooterLinks();
154  $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
155  if ($this->tpl->blockExists("block_footer")) {
156  $this->tpl->setCurrentBlock("block_footer");
157  $this->tpl->parseCurrentBlock();
158  }
159  }
160 
164  public function setFooterLinks()
165  {
168  $lng = $this->lng;
169 
170  if ($this->num_bookmarks == 0 && $this->num_folders == 0) {
171  return;
172  }
173 
174  // flat
175  $this->addFooterLink(
176  $lng->txt("list"),
177  $ilCtrl->getLinkTarget($this, "setPdFlatMode"),
178  $ilCtrl->getLinkTarget(
179  $this,
180  "setPdFlatMode",
181  "",
182  true
183  ),
184  "block_" . $this->getBlockType() . "_" . $this->block_id,
185  false,
186  false,
187  ($ilUser->getPref("il_pd_bkm_mode") != 'tree')
188  );
189 
190  // as tree
191  $this->addFooterLink(
192  $lng->txt("tree"),
193  $ilCtrl->getLinkTarget(
194  $this,
195  "setPdTreeMode"
196  ),
197  "",
198  "block_" . $this->getBlockType() . "_" . $this->block_id,
199  false,
200  false,
201  ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
202  );
203  }
204 
208  public function getListRowData()
209  {
211  $lng = $this->lng;
213 
214  include_once("./Services/Bookmarks/classes/class.ilBookmarkFolder.php");
215 
216  $data = array();
217 
218  $sess_cur_bm_folder = "";
219  if (isset($_SESSION["ilCurBMFolder"])) {
220  $sess_cur_bm_folder = $_SESSION["ilCurBMFolder"];
221  }
222 
223  $bm_items = ilBookmarkFolder::getObjects($sess_cur_bm_folder);
224 
225  if (!ilBookmarkFolder::isRootFolder($sess_cur_bm_folder)
226  && !empty($_SESSION["ilCurBMFolder"])) {
227  $ilCtrl->setParameter(
228  $this,
229  "curBMFolder",
230  ilBookmarkFolder::_getParentId($sess_cur_bm_folder)
231  );
232 
233  $data[] = array(
234  "img" => ilUtil::getImagePath("icon_bmf.svg"),
235  "alt" => $lng->txt("bmf"),
236  "title" => "..",
237  "link" => $ilCtrl->getLinkTarget($this, "setCurrentBookmarkFolder"));
238 
239  $this->setTitle($this->getTitle() . ": " . ilBookmarkFolder::_lookupTitle($sess_cur_bm_folder));
240  }
241 
242  foreach ($bm_items as $bm_item) {
243  switch ($bm_item["type"]) {
244  case "bmf":
245  $ilCtrl->setParameter($this, "curBMFolder", $bm_item["obj_id"]);
246  $data[] = array(
247  "img" => ilUtil::getImagePath("icon_bmf.svg"),
248  "alt" => $lng->txt("bmf"),
249  "title" => ilUtil::prepareFormOutput($bm_item["title"]),
250  "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
251  "link" => $ilCtrl->getLinkTarget(
252  $this,
253  "setCurrentBookmarkFolder"
254  ),
255  "target" => "");
256  break;
257 
258  case "bm":
259  $data[] = array(
260  "img" => ilUtil::getImagePath("spacer.png"),
261  "alt" => $lng->txt("bm"),
262  "title" => ilUtil::prepareFormOutput($bm_item["title"]),
263  "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
264  "link" => ilUtil::prepareFormOutput($bm_item["target"]),
265  "rel" => "noopener",
266  "target" => "_blank");
267  break;
268  }
269  }
270 
271  $this->setData($data);
272  }
273 
277  public function fillRow($a_set)
278  {
280 
281  $this->tpl->setVariable("IMG_BM", $a_set["img"]);
282  $this->tpl->setVariable("IMG_ALT", $a_set["alt"]);
283  $this->tpl->setVariable("BM_TITLE", $a_set["title"]);
284  $this->tpl->setVariable("BM_LINK", $a_set["link"]);
285  $this->tpl->setVariable("BM_TARGET", ilUtil::prepareFormOutput($a_set["target"]));
286  if (isset($a_set['rel'])) {
287  $this->tpl->setVariable("BM_REL", $a_set['rel']);
288  }
289 
290  if ($this->getCurrentDetailLevel() > 2) {
291  $this->tpl->setVariable("BM_DESCRIPTION", ilUtil::prepareFormOutput($a_set["desc"]));
292  } else {
293  $this->tpl->setVariable("BM_TOOLTIP", ilUtil::prepareFormOutput($a_set["desc"]));
294  }
295  }
296 
300  public function getOverview()
301  {
303  $lng = $this->lng;
305 
306  return '<div class="small">' . $this->num_bookmarks . " " . $lng->txt("bm_num_bookmarks") . ", " .
307  $this->num_folders . " " . $lng->txt("bm_num_bookmark_folders") . "</div>";
308  }
309 
313  public function setPdFlatMode()
314  {
317 
318  $ilUser->writePref("il_pd_bkm_mode", 'flat');
319  if ($ilCtrl->isAsynch()) {
320  echo $this->getHTML();
321  exit;
322  } else {
323  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
324  }
325  }
326 
330  public function setPdTreeMode()
331  {
334 
335  $ilUser->writePref("il_pd_bkm_mode", 'tree');
336  if ($ilCtrl->isAsynch()) {
337  echo $this->getHTML();
338  exit;
339  } else {
340  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
341  }
342  }
343 
347  public function setCurrentBookmarkFolder()
348  {
350 
351  $_SESSION["ilCurBMFolder"] = $_GET["curBMFolder"];
352  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
353  }
354 }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
fillRow($a_set)
get flat bookmark list for personal desktop
$_SESSION["AccountId"]
BlockGUI class for Bookmarks block.
global $DIC
Definition: saml.php:7
static _getNumberOfObjects()
Get number of folders and bookmarks for current user.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
$_GET["client_id"]
setFooterLinks()
Set footer links.
executeCommand()
execute command
fillFooterLinks($a_top=false, $a_numinfo="")
Fill footer links.
static _lookupTitle($a_bmf_id)
lookup bookmark folder title
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
setCurrentBookmarkFolder()
set current bookmarkfolder on personal desktop
user()
Definition: user.php:4
Bookmark block explorer GUI class.
global $ilCtrl
Definition: ilias.php:18
static getBlockType()
Get block type.
setColSpan($a_colspan)
Set Columns Span.
static isRepositoryObject()
Is block used in repository object?
setImage($a_image)
Set Image.
addFooterLink( $a_text, $a_href="", $a_onclick="", $a_block_id="", $a_top=false, $a_omit_separator=false, $a_checked=false)
Add a footer text/link.
setTitle($a_title)
Set Title.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
setData($a_data)
Set Data.
setAvailableDetailLevels($a_max, $a_min=0)
Set Available Detail Levels.
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
getPDBookmarkListHTMLTree()
get tree bookmark list for personal desktop
setPdFlatMode()
set current desktop view mode to flat
getListRowData()
Get list data (for flat list).
setLimit($a_limit)
Set Limit.
fillDataSection()
Fill data section.
getColSpan()
Get Columns Span.
setPdTreeMode()
set current desktop view mode to tree
This class represents a block method of a block.
static getObjects($a_id)
static
const IL_SCREEN_SIDE
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
static getScreenMode()
Get Screen Mode for current command.
setEnableDetailRow($a_enabledetailrow)
Set EnableDetailRow.
getTitle()
Get Title.
getCurrentDetailLevel()
Get Current Detail Level.