ILIAS  release_7 Revision v7.30-3-g800a261c036
Card.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2016 Amstutz Timon <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
4
6
12
13class Card implements C\Card
14{
17 use Triggerer;
18
22 protected $title;
23
27 protected $header_section;
28
33
37 protected $image;
38
42 protected $title_action = '';
43
47 protected $highlight = false;
48
54 {
55 if (!$title instanceof \ILIAS\UI\Component\Button\Shy) {
56 $this->checkStringArg("title", $title);
57 }
58
59 $this->title = $title;
60 $this->image = $image;
61 }
62
66 public function withTitle($title)
67 {
68 if (!$title instanceof \ILIAS\UI\Component\Button\Shy) {
69 $this->checkStringArg("title", $title);
70 }
71
72 $clone = clone $this;
73 $clone->title = $title;
74
75 return $clone;
76 }
77
81 public function getTitle()
82 {
83 return $this->title;
84 }
85
90 {
91 $clone = clone $this;
92 $clone->image = $image;
93 return $clone;
94 }
95
99 public function getImage()
100 {
101 return $this->image;
102 }
103
107 public function withSections(array $sections)
108 {
109 $classes = [\ILIAS\UI\Component\Component::class];
110 $this->checkArgListElements("sections", $sections, $classes);
111
112 $clone = clone $this;
113 $clone->content_sections = $sections;
114 return $clone;
115 }
116
120 public function getSections()
121 {
123 }
124
128 public function withTitleAction($action)
129 {
130 $this->checkStringOrSignalArg("title_action", $action);
131
132 $clone = clone $this;
133 if (is_string($action)) {
134 $clone->title_action = $action;
135 } else {
139 $clone->title_action = null;
140 $clone->setTriggeredSignal($action, "click");
141 }
142
143 return $clone;
144 }
145
149 public function getTitleAction()
150 {
151 if ($this->title_action !== null) {
152 return $this->title_action;
153 }
154 return $this->getTriggeredSignalsFor("click");
155 }
156
160 public function withHighlight($status)
161 {
162 $clone = clone $this;
163 $clone->highlight = $status;
164
165 return $clone;
166 }
167
171 public function isHighlighted()
172 {
173 return $this->highlight;
174 }
175
179 public function withOnClick(Signal $signal)
180 {
181 return $this->withTriggeredSignal($signal, 'click');
182 }
186 public function appendOnClick(Signal $signal)
187 {
188 return $this->appendTriggeredSignal($signal, 'click');
189 }
190}
An exception for terminatinating execution or to throw for unit testing.
withImage(\ILIAS\UI\Component\Image\Image $image)
Definition: Card.php:89
__construct($title, \ILIAS\UI\Component\Image\Image $image=null)
Definition: Card.php:53
A component is the most general form of an entity in the UI.
Definition: Component.php:14
checkStringOrSignalArg($which, $value)
Throw an InvalidArgumentException if $value is no string or Signal.
withTriggeredSignal(Component\Signal $signal, $event)
Add a triggered signal, replacing any other signals registered on the same event.
Definition: Triggerer.php:48
checkStringArg($which, $value)
Throw an InvalidArgumentException if $value is no string.
appendTriggeredSignal(Component\Signal $signal, $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:31
getTriggeredSignalsFor($event)
Get signals that are triggered for a certain event.
Definition: Triggerer.php:85
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
checkArgListElements($which, array &$values, $classes)
Check every element of the list if it is an instance of one of the given classes.
trait ComponentHelper
Provides common functionality for component implementations.
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.