ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDclLinkButton.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}
An exception for terminatinating execution or to throw for unit testing.
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.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output