00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 include_once("Services/Block/classes/class.ilBlockGUI.php");
00025
00034 class ilBookmarkBlockGUI extends ilBlockGUI
00035 {
00036 static $block_type = "pdbookm";
00037
00041 function ilBookmarkBlockGUI()
00042 {
00043 global $ilCtrl, $lng, $ilUser;
00044
00045 parent::ilBlockGUI();
00046
00047 $this->setImage(ilUtil::getImagePath("icon_bm_s.gif"));
00048 $this->setTitle($lng->txt("my_bms"));
00049 $this->setEnableNumInfo(false);
00050 $this->setLimit(99999);
00051 $this->setAvailableDetailLevels(3);
00052
00053 $this->id = (empty($_GET["bmf_id"]))
00054 ? $bmf_id = 1
00055 : $_GET["bmf_id"];
00056 }
00057
00063 static function getBlockType()
00064 {
00065 return self::$block_type;
00066 }
00067
00073 static function isRepositoryObject()
00074 {
00075 return false;
00076 }
00077
00078
00082 static function getScreenMode()
00083 {
00084 switch($_GET["cmd"])
00085 {
00086 default:
00087 return IL_SCREEN_SIDE;
00088 break;
00089 }
00090 }
00091
00095 function &executeCommand()
00096 {
00097 global $ilCtrl;
00098
00099 $next_class = $ilCtrl->getNextClass();
00100 $cmd = $ilCtrl->getCmd("getHTML");
00101
00102 return $this->$cmd();
00103 }
00104
00105 function getHTML()
00106 {
00107
00108 $this->setData(array("dummy"));
00109
00110 if ($this->getCurrentDetailLevel() == 0)
00111 {
00112 return "";
00113 }
00114 else
00115 {
00116 return parent::getHTML();
00117 }
00118 }
00119
00123 function fillDataSection()
00124 {
00125 global $ilUser;
00126
00127 include_once("./Services/PersonalDesktop/classes/class.ilBookmarkFolder.php");
00128 $bm_items = ilBookmarkFolder::_getNumberOfObjects();
00129 $this->num_bookmarks = $bm_items["bookmarks"];
00130 $this->num_folders = $bm_items["folders"];
00131
00132 if ($this->getCurrentDetailLevel() > 1 &&
00133 ($this->num_bookmarks > 0 || $this->num_folders > 0))
00134 {
00135 if ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
00136 {
00137 $this->setDataSection($this->getPDBookmarkListHTMLTree());
00138 }
00139 else
00140 {
00141 $this->setRowTemplate("tpl.bookmark_pd_list.html", "Services/PersonalDesktop");
00142 $this->getListRowData();
00143 $this->setColSpan(2);
00144 parent::fillDataSection();
00145 }
00146 }
00147 else
00148 {
00149 if ($this->num_bookmarks == 0 && $this->num_folders == 0)
00150 {
00151 $this->setEnableDetailRow(false);
00152 }
00153 $this->setDataSection($this->getOverview());
00154 }
00155 }
00156
00160 function getPDBookmarkListHTMLTree()
00161 {
00162 global $ilCtrl, $ilUser;
00163
00164 include_once("./Services/PersonalDesktop/classes/class.ilBookmarkExplorer.php");
00165
00166 $showdetails = ($this->getCurrentDetailLevel() > 2);
00167 $tpl = new ilTemplate("tpl.bookmark_pd_tree.html", true, true,
00168 "Services/PersonalDesktop");
00169
00170 $exp = new ilBookmarkExplorer($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"),
00171 $_SESSION["AccountId"]);
00172 $exp->setAllowedTypes(array('dum','bmf','bm'));
00173 $exp->setEnableSmallMode(true);
00174 $exp->setTargetGet("bmf_id");
00175 $exp->setSessionExpandVariable('mexpand');
00176 $ilCtrl->setParameter($this, "bmf_id", $this->id);
00177 $exp->setExpandTarget($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"));
00178 if ($_GET["mexpand"] == "")
00179 {
00180 $expanded = $this->id;
00181 }
00182 else
00183 {
00184 $expanded = $_GET["mexpand"];
00185 }
00186 $exp->setExpand($expanded);
00187 $exp->setShowDetails($showdetails);
00188
00189
00190 $exp->setOutput(0);
00191 return $exp->getOutput();
00192 }
00193
00197 function fillFooter()
00198 {
00199 global $ilCtrl, $lng, $ilUser;
00200
00201 $this->setFooterLinks();
00202 $this->fillFooterLinks();
00203 $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
00204 if ($this->tpl->blockExists("block_footer"))
00205 {
00206 $this->tpl->setCurrentBlock("block_footer");
00207 $this->tpl->parseCurrentBlock();
00208 }
00209 }
00210
00214 function setFooterLinks()
00215 {
00216 global $ilUser, $ilCtrl, $lng;
00217
00218 if ($this->num_bookmarks == 0 && $this->num_folders == 0)
00219 {
00220 return;
00221 }
00222
00223
00224 if ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
00225 {
00226 $this->addFooterLink( $lng->txt("flatview"),
00227 $ilCtrl->getLinkTarget($this, "setPdFlatMode"),
00228 $ilCtrl->getLinkTarget($this, "setPdFlatMode",
00229 "", true),
00230 "block_".$this->getBlockType()."_".$this->block_id);
00231 }
00232 else
00233 {
00234 $this->addFooterLink($lng->txt("flatview"));
00235 }
00236
00237
00238 if ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
00239 {
00240 $this->addFooterLink($lng->txt("treeview"));
00241 }
00242 else
00243 {
00244 $this->addFooterLink($lng->txt("treeview"),
00245 $ilCtrl->getLinkTarget($this,
00246 "setPdTreeMode"),
00247 $ilCtrl->getLinkTarget($this,
00248 "setPdTreeMode", "", true),
00249 "block_".$this->getBlockType()."_".$this->block_id
00250 );
00251 }
00252 }
00253
00257 function getListRowData()
00258 {
00259 global $ilUser, $lng, $ilCtrl;
00260
00261 include_once("./Services/PersonalDesktop/classes/class.ilBookmarkFolder.php");
00262
00263 $data = array();
00264
00265 $bm_items = ilBookmarkFolder::getObjects($_SESSION["ilCurBMFolder"]);
00266
00267 if (!ilBookmarkFolder::isRootFolder($_SESSION["ilCurBMFolder"])
00268 && !empty($_SESSION["ilCurBMFolder"]))
00269 {
00270 $ilCtrl->setParameter($this, "curBMFolder",
00271 ilBookmarkFolder::_getParentId($_SESSION["ilCurBMFolder"]));
00272
00273 $data[] = array(
00274 "img" => ilUtil::getImagePath("icon_cat_s.gif"),
00275 "alt" => $lng->txt("bmf"),
00276 "title" => "..",
00277 "link" => $ilCtrl->getLinkTarget($this, "setCurrentBookmarkFolder"));
00278
00279 $this->setTitle($this->getTitle().": ".ilBookmarkFolder::_lookupTitle($_SESSION["ilCurBMFolder"]));
00280 }
00281
00282 foreach ($bm_items as $bm_item)
00283 {
00284 switch ($bm_item["type"])
00285 {
00286 case "bmf":
00287 $ilCtrl->setParameter($this, "curBMFolder", $bm_item["obj_id"]);
00288 $data[] = array(
00289 "img" => ilUtil::getImagePath("icon_cat_s.gif"),
00290 "alt" => $lng->txt("bmf"),
00291 "title" => ilUtil::prepareFormOutput($bm_item["title"]),
00292 "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
00293 "link" => $ilCtrl->getLinkTarget($this,
00294 "setCurrentBookmarkFolder"),
00295 "target" => "");
00296 break;
00297
00298 case "bm":
00299 $data[] = array(
00300 "img" => ilUtil::getImagePath("spacer.gif"),
00301 "alt" => $lng->txt("bm"),
00302 "title" => ilUtil::prepareFormOutput($bm_item["title"]),
00303 "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
00304 "link" => ilUtil::prepareFormOutput($bm_item["target"]),
00305 "target" => "_blank");
00306 break;
00307 }
00308 }
00309
00310 $this->setData($data);
00311 }
00312
00316 function fillRow($a_set)
00317 {
00318 global $ilUser;
00319
00320 $this->tpl->setVariable("IMG_BM", $a_set["img"]);
00321 $this->tpl->setVariable("IMG_ALT", $a_set["alt"]);
00322 $this->tpl->setVariable("BM_TITLE", $a_set["title"]);
00323 $this->tpl->setVariable("BM_LINK", $a_set["link"]);
00324 $this->tpl->setVariable("BM_TARGET", $a_set["target"]);
00325
00326 if ($this->getCurrentDetailLevel() > 2)
00327 {
00328 $this->tpl->setVariable("BM_DESCRIPTION", ilUtil::prepareFormOutput($a_set["desc"]));
00329 }
00330 else
00331 {
00332 $this->tpl->setVariable("BM_TOOLTIP", ilUtil::prepareFormOutput($a_set["desc"]));
00333 }
00334 }
00335
00339 function getOverview()
00340 {
00341 global $ilUser, $lng, $ilCtrl;
00342
00343 return '<div class="small">'.$this->num_bookmarks." ".$lng->txt("bm_num_bookmarks").", ".
00344 $this->num_folders." ".$lng->txt("bm_num_bookmark_folders")."</div>";
00345 }
00346
00350 function setPdFlatMode()
00351 {
00352 global $ilCtrl, $ilUser;
00353
00354 $ilUser->writePref("il_pd_bkm_mode", 'flat');
00355 if ($ilCtrl->isAsynch())
00356 {
00357 echo $this->getHTML();
00358 exit;
00359 }
00360 else
00361 {
00362 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
00363 }
00364 }
00365
00369 function setPdTreeMode()
00370 {
00371 global $ilCtrl, $ilUser;
00372
00373 $ilUser->writePref("il_pd_bkm_mode", 'tree');
00374 if ($ilCtrl->isAsynch())
00375 {
00376 echo $this->getHTML();
00377 exit;
00378 }
00379 else
00380 {
00381 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
00382 }
00383 }
00384
00388 function setCurrentBookmarkFolder()
00389 {
00390 global $ilCtrl;
00391
00392 $_SESSION["ilCurBMFolder"] = $_GET["curBMFolder"];
00393 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
00394 }
00395
00396 }
00397
00398 ?>