ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPermanentLinkGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
18 {
22  protected $lng;
23 
27  protected $ctrl;
28 
32  protected $obj_data_cache;
33 
34  protected $align_center = true;
35 
39  public function __construct($a_type, $a_id, $a_append = "", $a_target = "")
40  {
41  global $DIC;
42 
43  $this->lng = $DIC->language();
44  $this->ctrl = $DIC->ctrl();
45  $this->obj_data_cache = $DIC["ilObjDataCache"];
46  $this->setType($a_type);
47  $this->setId($a_id);
48  $this->setAppend($a_append);
49  $this->setIncludePermanentLinkText(true);
50  $this->setTarget($a_target);
51  }
52 
58  public function setIncludePermanentLinkText($a_includepermanentlinktext)
59  {
60  $this->includepermanentlinktext = $a_includepermanentlinktext;
61  }
62 
68  public function getIncludePermanentLinkText()
69  {
70  return $this->includepermanentlinktext;
71  }
72 
78  public function setType($a_type)
79  {
80  $this->type = $a_type;
81  }
82 
88  public function getType()
89  {
90  return $this->type;
91  }
92 
98  public function setId($a_id)
99  {
100  $this->id = $a_id;
101  }
102 
108  public function getId()
109  {
110  return $this->id;
111  }
112 
118  public function setAppend($a_append)
119  {
120  $this->append = $a_append;
121  }
122 
128  public function getAppend()
129  {
130  return $this->append;
131  }
132 
138  public function setTarget($a_target)
139  {
140  $this->target = $a_target;
141  }
142 
148  public function getTarget()
149  {
150  return $this->target;
151  }
152 
158  public function setTitle($a_val)
159  {
160  $this->title = $a_val;
161  }
162 
168  public function getTitle()
169  {
170  return $this->title;
171  }
172 
178  public function setAlignCenter($a_val)
179  {
180  $this->align_center = $a_val;
181  }
182 
188  public function getAlignCenter()
189  {
190  return $this->align_center;
191  }
192 
196  public function getHTML()
197  {
198  $lng = $this->lng;
200  $ilObjDataCache = $this->obj_data_cache;
201 
202  $tpl = new ilTemplate(
203  "tpl.permanent_link.html",
204  true,
205  true,
206  "Services/PermanentLink"
207  );
208 
209  include_once('./Services/Link/classes/class.ilLink.php');
210  $href = ilLink::_getStaticLink(
211  $this->getId(),
212  $this->getType(),
213  true,
214  $this->getAppend()
215  );
216  if ($this->getIncludePermanentLinkText()) {
217  $tpl->setVariable("TXT_PERMA", $lng->txt("perma_link") . ":");
218  }
219 
220  $title = '';
221 
222  // fetch default title for bookmark
223 
224  if ($this->getTitle() != "") {
225  $title = $this->getTitle();
226  } elseif (is_numeric($this->getId())) {
227  $obj_id = $ilObjDataCache->lookupObjId($this->getId());
228  $title = $ilObjDataCache->lookupTitle($obj_id);
229  }
230  #if (!$title)
231  # $bookmark->setTitle("untitled");
232 
233  $tpl->setVariable("TXT_BOOKMARK_DEFAULT", $title);
234 
235  $tpl->setVariable("LINK", $href);
236 
237  if ($this->getAlignCenter()) {
238  $tpl->setVariable("ALIGN", "center");
239  } else {
240  $tpl->setVariable("ALIGN", "left");
241  }
242 
243  if ($this->getTarget() != "") {
244  $tpl->setVariable("TARGET", 'target="' . $this->getTarget() . '"');
245  }
246 
247  $bm_html = self::getBookmarksSelectionList($title, $href);
248  if ($bm_html) {
249  $tpl->setVariable('SELECTION_LIST', $bm_html);
250  }
251 
252  return $tpl->get();
253  }
254 
258  protected static function getBookmarksSelectionList($title, $href)
259  {
260  require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
261 
262  $current_selection_list = new ilAdvancedSelectionListGUI();
263  $random = new \ilRandom();
264  $current_selection_list->setId('socialbm_actions_' . md5(uniqid($random->int(), true)));
265 
266  $html = '';
267 
268  if (!$GLOBALS['DIC']['ilUser']->isAnonymous() && !$GLOBALS['DIC']['ilSetting']->get('disable_bookmarks')) {
269  $GLOBALS['DIC']->ctrl()->setParameterByClass(
270  'ilbookmarkadministrationgui',
271  'bmf_id',
272  1
273  );
274  $GLOBALS['DIC']->ctrl()->setParameterByClass(
275  'ilbookmarkadministrationgui',
276  'return_to',
277  'true'
278  );
279  $GLOBALS['DIC']->ctrl()->setParameterByClass(
280  'ilbookmarkadministrationgui',
281  'bm_title',
282  urlencode($title)
283  );
284  $GLOBALS['DIC']->ctrl()->setParameterByClass(
285  'ilbookmarkadministrationgui',
286  'bm_link',
287  urlencode($href)
288  );
289  $GLOBALS['DIC']->ctrl()->setParameterByClass(
290  'ilbookmarkadministrationgui',
291  'return_to_url',
292  urlencode($_SERVER['REQUEST_URI'])
293  );
294  $link = $GLOBALS['DIC']->ctrl()->getLinkTargetByClass(
295  ['ilPersonalDesktopGUI', 'ilbookmarkadministrationgui'],
296  'newFormBookmark'
297  );
298  $current_selection_list->addItem($GLOBALS['DIC']['lng']->txt("bm_add_to_ilias"), '', $link, '', $GLOBALS['DIC']['lng']->txt('bm_add_to_ilias'), '_top');
299  $html = $current_selection_list->getHTML();
300  }
301 
302  return $html;
303  }
304 }
getIncludePermanentLinkText()
Get Include permanent link text.
static getBookmarksSelectionList($title, $href)
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
Class for permanent links.
setAppend($a_append)
Set Append.
$type
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
if(!array_key_exists('StateId', $_REQUEST)) $id
setTarget($a_target)
Set Target.
setIncludePermanentLinkText($a_includepermanentlinktext)
Set Include permanent link text.
__construct($a_type, $a_id, $a_append="", $a_target="")
Example: type = "wiki", id (ref_id) = "234", append = "_Start_Page".
setAlignCenter($a_val)
Set center alignment.
global $ilCtrl
Definition: ilias.php:18
getHTML()
Get HTML for link.
$a_type
Definition: workflow.php:92
getAlignCenter()
Get center alignment.
special template class to simplify handling of ITX/PEAR
setType($a_type)
Set Type.
User interface class for advanced drop-down selection lists.
$html
Definition: example_001.php:87