1<?php 2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4include_once("./Services/UIComponent/Explorer2/classes/class.ilTreeExplorerGUI.php"); 5 6/** 7 * Bookmark explorer GUI class 8 * 9 * @author Alex Killing <alex.killing@gmx.de> 10 * @version $Id$ 11 * 12 * @ingroup ServicesBookmarks 13 */ 14class ilBookmarkExplorerGUI extends ilTreeExplorerGUI 15{ 16 /** 17 * @var ilObjUser 18 */ 19 protected $user; 20 21 /** 22 * @var ilLanguage 23 */ 24 protected $lng; 25 26 /** 27 * @var ilCtrl 28 */ 29 protected $ctrl; 30 31 /** 32 * Constructor 33 */ 34 public function __construct($a_parent_obj, $a_parent_cmd, $a_user_id = 0) 35 { 36 global $DIC; 37 38 $this->user = $DIC->user(); 39 $this->lng = $DIC->language(); 40 $this->ctrl = $DIC->ctrl(); 41 $ilUser = $DIC->user(); 42 43 if ($a_user_id == 0) { 44 $a_user_id = $ilUser->getId(); 45 } 46 include_once("./Services/Bookmarks/classes/class.ilBookmarkTree.php"); 47 $tree = new ilBookmarkTree($a_user_id); 48 parent::__construct("bm_exp", $a_parent_obj, $a_parent_cmd, $tree); 49 50 $this->setTypeWhiteList(array("bmf", "dum")); 51 52 $this->setSkipRootNode(false); 53 $this->setAjax(false); 54 $this->setOrderField("title"); 55 } 56 57 /** 58 * Get node content 59 * 60 * @param array 61 * @return 62 */ 63 public function getNodeContent($a_node) 64 { 65 $lng = $this->lng; 66 67 if ($a_node["child"] == $this->getNodeId($this->getRootNode())) { 68 return $lng->txt("bookmarks"); 69 } 70 71 return $a_node["title"]; 72 } 73 74 /** 75 * Get node icon 76 * 77 * @param array 78 * @return 79 */ 80 public function getNodeIcon($a_node) 81 { 82 $icon = ilUtil::getImagePath("icon_" . $a_node["type"] . ".svg"); 83 84 return $icon; 85 } 86 87 /** 88 * Get node icon alt attribute 89 * 90 * @param mixed $a_node node object/array 91 * @return string image alt attribute 92 */ 93 public function getNodeIconAlt($a_node) 94 { 95 $lng = $this->lng; 96 97 return $lng->txt("icon") . " " . $lng->txt($a_node["type"]); 98 } 99 100 101 /** 102 * Is node highlighted? 103 * 104 * @param mixed $a_node node object/array 105 * @return boolean node visible true/false 106 */ 107 public function isNodeHighlighted($a_node) 108 { 109 if ($a_node["child"] == $_GET["bmf_id"] || 110 ($_GET["bmf_id"] == "" && $a_node["child"] == $this->getNodeId($this->getRootNode()))) { 111 return true; 112 } 113 return false; 114 } 115 116 /** 117 * Get href for node 118 * 119 * @param mixed $a_node node object/array 120 * @return string href attribute 121 */ 122 public function getNodeHref($a_node) 123 { 124 $ilCtrl = $this->ctrl; 125 126 switch ($a_node["type"]) { 127 // bookmark folder 128 case "bmf": 129 // dummy root 130 case "dum": 131 $ilCtrl->setParameterByClass("ilbookmarkadministrationgui", "bmf_id", $a_node["child"]); 132 133 $ret = $ilCtrl->getLinkTargetByClass("ilbookmarkadministrationgui", ""); 134 if (isset($_GET['bm_link'])) { 135 $this->ctrl->setParameterByClass( 136 "ilbookmarkadministrationgui", 137 'bm_link', 138 urlencode(\ilUtil::stripSlashes($_GET['bm_link'])) 139 ); 140 if (isset($_GET['bm_title'])) { 141 $this->ctrl->setParameterByClass( 142 "ilbookmarkadministrationgui", 143 'bm_title', 144 urlencode(\ilUtil::stripSlashes($_GET['bm_title'])) 145 ); 146 } 147 $ret = $ilCtrl->getLinkTargetByClass("ilbookmarkadministrationgui", "newFormBookmark"); 148 } 149 150 $ilCtrl->setParameterByClass("ilbookmarkadministrationgui", "bmf_id", $_GET["bmf_id"]); 151 return $ret; 152 break; 153 } 154 } 155} 156