ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilDataCollectionLinkButton.php
Go to the documentation of this file.
1<?php
9
10 protected $attributes;
11
12 protected $useWrapper = false;
13
17 public function isUseWrapper()
18 {
19 return $this->useWrapper;
20 }
21
25 public function setUseWrapper($useWrapper)
26 {
27 $this->useWrapper = $useWrapper;
28 }
29
30 public static function getInstance()
31 {
32 return new self(self::TYPE_DATACOLLECTION_LINK);
33 }
34
35 public function prepareRender() {
36 parent::prepareRender();
37
38 $this->addAttribute('href', ($this->getUrl() ? $this->getUrl() : "#"));
39 $this->addAttribute('target', $this->getTarget());
40 }
41
42 public function render() {
43 $this->prepareRender();
44
45 $output = '';
46 if($this->useWrapper) {
47 $output .= '<div'.$this->renderAttributesHelper($this->attributes['wrapper']).'>';
48 }
49
50 $output .= '<a'.$this->renderAttributes($this->attributes['default']).'>'.$this->renderCaption().'</a>';
51
52 if($this->useWrapper) {
53 $output .= '</div>';
54 }
55 return $output;
56 }
57
58 public function addAttribute($key, $value, $wrapper = false) {
59 $this->attributes[$this->getGroupKey($wrapper)][$key] = $value;
60 }
61
62 public function removeAttribute($key, $wrapper = false) {
63 if(isset($this->attributes[$this->getGroupKey($wrapper)][$key])) {
64 unset($this->attributes[$this->getGroupKey($wrapper)][$key]);
65 return true;
66 }
67 return false;
68 }
69
70 public function getAttribute($key, $wrapper = false) {
71 if(isset($this->attributes[$this->getGroupKey($wrapper)][$key])) {
72 return $this->attributes[$this->getGroupKey($wrapper)][$key];
73 }
74 return null;
75 }
76
77 protected function getGroupKey($wrapper) {
78 return ($wrapper)? 'wrapper' : 'default';
79 }
80}
addAttribute($key, $value, $wrapper=false)
getTarget()
Get target.
renderCaption()
Prepare caption for render.