ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
13 class Card implements C\Card
14 {
15  use ComponentHelper;
17  use Triggerer;
18 
22  protected $title;
23 
27  protected $header_section;
28 
32  protected $content_sections;
33 
37  protected $image;
38 
42  protected $title_action = '';
43 
47  protected $highlight = false;
48 
53  public function __construct($title, \ILIAS\UI\Component\Image\Image $image = null)
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 {
136  $clone->title_action = null;
137  $clone->setTriggeredSignal($action, "click");
138  }
139 
140  return $clone;
141  }
142 
146  public function getTitleAction()
147  {
148  if ($this->title_action !== null) {
149  return $this->title_action;
150  }
151  return $this->getTriggeredSignalsFor("click");
152  }
153 
157  public function withHighlight($status)
158  {
159  $clone = clone $this;
160  $clone->highlight = $status;
161 
162  return $clone;
163  }
164 
168  public function isHighlighted()
169  {
170  return $this->highlight;
171  }
172 
176  public function withOnClick(Signal $signal)
177  {
178  return $this->withTriggeredSignal($signal, 'click');
179  }
183  public function appendOnClick(Signal $signal)
184  {
185  return $this->appendTriggeredSignal($signal, 'click');
186  }
187 }
Class Factory.
Class ChatMainBarProvider .
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
trait ComponentHelper
Provides common functionality for component implementations.
checkStringArg($which, $value)
Throw an InvalidArgumentException if $value is no string.
withImage(\ILIAS\UI\Component\Image\Image $image)
Definition: Card.php:89
getTriggeredSignalsFor($event)
Get signals that are triggered for a certain event.
Definition: Triggerer.php:85
__construct($title, \ILIAS\UI\Component\Image\Image $image=null)
Definition: Card.php:53
appendTriggeredSignal(Component\Signal $signal, $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:31
checkStringOrSignalArg($which, $value)
Throw an InvalidArgumentException if $value is no string or Signal.
checkArgListElements($which, array &$values, $classes)
Check every element of the list if it is an instance of one of the given classes. ...
withTriggeredSignal(Component\Signal $signal, $event)
Add a triggered signal, replacing any other signals registered on the same event. ...
Definition: Triggerer.php:48