ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilDclLinkButton.php
Go to the documentation of this file.
1<?php
8{
10
11 protected $attributes;
12
13 protected $useWrapper = false;
14
18 public function isUseWrapper()
19 {
20 return $this->useWrapper;
21 }
22
26 public function setUseWrapper($useWrapper)
27 {
28 $this->useWrapper = $useWrapper;
29 }
30
31 public static function getInstance()
32 {
33 return new self(self::TYPE_DATACOLLECTION_LINK);
34 }
35
36 public function prepareRender()
37 {
38 parent::prepareRender();
39
40 $this->addAttribute('href', ($this->getUrl() ? $this->getUrl() : "#"));
41 $this->addAttribute('target', $this->getTarget());
42 }
43
44 public function render()
45 {
46 $this->prepareRender();
47
48 $output = '';
49 if ($this->useWrapper) {
50 $output .= '<div' . $this->renderAttributesHelper($this->attributes['wrapper']) . '>';
51 }
52
53 $output .= '<a' . $this->renderAttributes($this->attributes['default']) . '>' . $this->renderCaption() . '</a>';
54
55 if ($this->useWrapper) {
56 $output .= '</div>';
57 }
58 return $output;
59 }
60
61 public function addAttribute($key, $value, $wrapper = false)
62 {
63 $this->attributes[$this->getGroupKey($wrapper)][$key] = $value;
64 }
65
66 public function removeAttribute($key, $wrapper = false)
67 {
68 if (isset($this->attributes[$this->getGroupKey($wrapper)][$key])) {
69 unset($this->attributes[$this->getGroupKey($wrapper)][$key]);
70 return true;
71 }
72 return false;
73 }
74
75 public function getAttribute($key, $wrapper = false)
76 {
77 if (isset($this->attributes[$this->getGroupKey($wrapper)][$key])) {
78 return $this->attributes[$this->getGroupKey($wrapper)][$key];
79 }
80 return null;
81 }
82
83 protected function getGroupKey($wrapper)
84 {
85 return ($wrapper)? 'wrapper' : 'default';
86 }
87}
An exception for terminatinating execution or to throw for unit testing.
renderAttributesHelper(array $a_attr)
Render HTML node attributes.
getAttribute($key, $wrapper=false)
static getInstance()
Factory.
removeAttribute($key, $wrapper=false)
prepareRender()
Prepare render.
setUseWrapper($useWrapper)
addAttribute($key, $value, $wrapper=false)
getTarget()
Get target.
renderCaption()
Prepare caption for render.
renderAttributes(array $a_additional_attr=null)
Render current HTML attributes.string
$key
Definition: croninfo.php:18
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output