ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Badge\Tile Class Reference
+ Collaboration diagram for ILIAS\Badge\Tile:

Public Member Functions

 __construct (private readonly Container $container, ?BadgeParent $parent=null, ?Modal $modal=null, $sign_file=[ilWACSignedPath::class, 'signFile'], ?Closure $format_date=null,)
 
 inDeck (ilBadge $badge, ilBadgeAssignment $assignment, string $gui)
 
 asTitleWithLeadingImage (ModalContent $content)
 
 asImage (ModalContent $content, int $size=ilBadgeImage::IMAGE_SIZE_M)
 
 asTitle (ModalContent $content)
 
 modalContent (ilBadge $badge)
 
 modalContentWithAssignment (ilBadge $badge, ilBadgeAssignment $assignment)
 
 addAssignment (ModalContent $content, ilBadgeAssignment $assignment)
 

Private Member Functions

 card (ModalContent $content)
 
 modal (Card $card)
 
 image (Component $modal, ilBadge $badge, int $size=ilBadgeImage::IMAGE_SIZE_M)
 
 title (Component $modal, ilBadge $badge)
 
 txt (string $key)
 
 tryFormating (string $valid)
 
 profileButton (ilBadge $badge, ilBadgeAssignment $assignment, string $gui)
 

Private Attributes

readonly Closure $sign_file
 
readonly BadgeParent $parent
 
readonly Modal $modal
 
readonly Closure $format_date
 
readonly ilBadgeImage $badge_image_service
 

Detailed Description

Definition at line 34 of file Tile.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Badge\Tile::__construct ( private readonly Container  $container,
?BadgeParent  $parent = null,
?Modal  $modal = null,
  $sign_file = [ilWACSignedPath::class, 'signFile'],
?Closure  $format_date = null 
)
Parameters
Closure(string)string $sign_file
Closure(int)string $format_date

Definition at line 48 of file Tile.php.

54 {
55 $this->parent = $parent ?? new BadgeParent($this->container);
56 $this->modal = $modal ?? new Modal($this->container);
57 $this->sign_file = Closure::fromCallable($sign_file);
58 if (!$format_date) {
59 class_exists(ilDateTime::class); // Ensure ilDateTime is loaded as IL_CAL_UNIX is defined in ilDateTime.php.
60 $format_date = static fn($date, int $format = IL_CAL_UNIX): string => (
61 ilDatePresentation::formatDate(new ilDateTime($date, $format))
62 );
63 }
64 $this->format_date = $format_date;
65 $this->badge_image_service = new ilBadgeImage($container->resourceStorage(), $container->upload(), $container->ui()->mainTemplate());
66 }
modal(Card $card)
Definition: Tile.php:138
readonly Closure $sign_file
Definition: Tile.php:37
readonly Modal $modal
Definition: Tile.php:39
readonly BadgeParent $parent
Definition: Tile.php:38
readonly Closure $format_date
Definition: Tile.php:41
const IL_CAL_UNIX
Class for date presentation.
@classDescription Date and time handling
$container
@noRector
Definition: wac.php:37

References $container, ILIAS\Badge\Tile\$format_date, ILIAS\Badge\Tile\$parent, ILIAS\Badge\Tile\$sign_file, ilDatePresentation\formatDate(), IL_CAL_UNIX, and ILIAS\Badge\Tile\modal().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAssignment()

ILIAS\Badge\Tile::addAssignment ( ModalContent  $content,
ilBadgeAssignment  $assignment 
)

Definition at line 180 of file Tile.php.

181 {
182 return $content->withAdditionalProperties([
183 $this->txt('badge_issued_on') => ($this->format_date)($assignment->getTimestamp()),
184 ]);
185 }
withAdditionalProperties(array $properties)
txt(string $key)
Definition: Tile.php:187

References ilBadgeAssignment\getTimestamp(), ILIAS\Badge\Tile\txt(), and ILIAS\Badge\ModalContent\withAdditionalProperties().

Referenced by ILIAS\Badge\Tile\modalContentWithAssignment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ asImage()

ILIAS\Badge\Tile::asImage ( ModalContent  $content,
int  $size = ilBadgeImage::IMAGE_SIZE_M 
)
Returns
list<Component>

Definition at line 107 of file Tile.php.

107 : array
108 {
109 $modal = $this->modal($this->card($content));
110 return [
111 $modal,
112 $this->image($modal, $content->badge(), $size),
113 ];
114 }
card(ModalContent $content)
Definition: Tile.php:128
image(Component $modal, ilBadge $badge, int $size=ilBadgeImage::IMAGE_SIZE_M)
Definition: Tile.php:145

References ILIAS\Badge\Tile\$modal, ILIAS\Badge\ModalContent\badge(), ILIAS\Badge\Tile\card(), ILIAS\Badge\Tile\image(), and ILIAS\Badge\Tile\modal().

+ Here is the call graph for this function:

◆ asTitle()

ILIAS\Badge\Tile::asTitle ( ModalContent  $content)
Returns
list<Component>

Definition at line 119 of file Tile.php.

119 : array
120 {
121 $modal = $this->modal($this->card($content));
122 return [
123 $modal,
124 $this->title($modal, $content->badge()),
125 ];
126 }
title(Component $modal, ilBadge $badge)
Definition: Tile.php:156

References ILIAS\Badge\Tile\$modal, ILIAS\Badge\ModalContent\badge(), ILIAS\Badge\Tile\card(), ILIAS\Badge\Tile\modal(), and ILIAS\Badge\Tile\title().

+ Here is the call graph for this function:

◆ asTitleWithLeadingImage()

ILIAS\Badge\Tile::asTitleWithLeadingImage ( ModalContent  $content)
Returns
list<Component>

Definition at line 94 of file Tile.php.

94 : array
95 {
96 $modal = $this->modal($this->card($content));
97 return [
98 $modal,
99 $this->image($modal, $content->badge()),
100 $this->title($modal, $content->badge()),
101 ];
102 }

References ILIAS\Badge\Tile\$modal, ILIAS\Badge\ModalContent\badge(), ILIAS\Badge\Tile\card(), ILIAS\Badge\Tile\image(), ILIAS\Badge\Tile\modal(), and ILIAS\Badge\Tile\title().

+ Here is the call graph for this function:

◆ card()

ILIAS\Badge\Tile::card ( ModalContent  $content)
private

Definition at line 128 of file Tile.php.

128 : Component
129 {
130 return $this->container
131 ->ui()
132 ->factory()
133 ->card()
134 ->standard($content->badge()->getTitle())
135 ->withHiddenSections($this->modal->components($content));
136 }

References ILIAS\Badge\ModalContent\badge(), and ILIAS\Badge\Tile\modal().

Referenced by ILIAS\Badge\Tile\asImage(), ILIAS\Badge\Tile\asTitle(), ILIAS\Badge\Tile\asTitleWithLeadingImage(), and ILIAS\Badge\Tile\inDeck().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ image()

ILIAS\Badge\Tile::image ( Component  $modal,
ilBadge  $badge,
int  $size = ilBadgeImage::IMAGE_SIZE_M 
)
private

Definition at line 145 of file Tile.php.

145 : Component
146 {
147 $image_src = $this->badge_image_service->getImageFromBadge($badge, $size);
148 return $this->container
149 ->ui()
150 ->factory()
151 ->image()
152 ->responsive($image_src, $badge->getTitle())
153 ->withAction($modal->getShowSignal());
154 }

References ILIAS\Badge\Tile\$modal, and ilBadge\getTitle().

Referenced by ILIAS\Badge\Tile\asImage(), ILIAS\Badge\Tile\asTitleWithLeadingImage(), and ILIAS\Badge\Tile\inDeck().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ inDeck()

ILIAS\Badge\Tile::inDeck ( ilBadge  $badge,
ilBadgeAssignment  $assignment,
string  $gui 
)
Returns
array{modal: Component, card: Component}

Definition at line 71 of file Tile.php.

71 : array
72 {
73 $parent = $this->parent->asComponent($badge);
74 $badge_sections = $parent ? [$parent] : [];
75 $badge_sections[] = $this->profileButton($badge, $assignment, $gui);
76
77 $content = $this->modalContentWithAssignment($badge, $assignment);
78 $card = $this->card($content);
79 $modal = $this->modal($card);
80 $image = $this->image($modal, $badge);
81 $card = $card->withSections($badge_sections)
82 ->withImage($image)
83 ->withTitleAction($modal->getShowSignal());
84
85 return [
86 'card' => $card,
87 'modal' => $modal,
88 ];
89 }
asComponent(ilBadge $badge)
Definition: BadgeParent.php:55
modalContentWithAssignment(ilBadge $badge, ilBadgeAssignment $assignment)
Definition: Tile.php:175
profileButton(ilBadge $badge, ilBadgeAssignment $assignment, string $gui)
Definition: Tile.php:205

References ILIAS\Badge\Tile\$modal, ILIAS\Badge\Tile\$parent, ILIAS\Badge\BadgeParent\asComponent(), ILIAS\Badge\Tile\card(), ILIAS\Badge\Tile\image(), ILIAS\Badge\Tile\modal(), ILIAS\Badge\Tile\modalContentWithAssignment(), and ILIAS\Badge\Tile\profileButton().

+ Here is the call graph for this function:

◆ modal()

ILIAS\Badge\Tile::modal ( Card  $card)
private

Definition at line 138 of file Tile.php.

138 : Component
139 {
140 return $this->container->ui()->factory()->modal()->lightbox(
141 $this->container->ui()->factory()->modal()->lightboxCardPage($card)
142 );
143 }

Referenced by ILIAS\Badge\Tile\__construct(), ILIAS\Badge\Tile\asImage(), ILIAS\Badge\Tile\asTitle(), ILIAS\Badge\Tile\asTitleWithLeadingImage(), ILIAS\Badge\Tile\card(), and ILIAS\Badge\Tile\inDeck().

+ Here is the caller graph for this function:

◆ modalContent()

ILIAS\Badge\Tile::modalContent ( ilBadge  $badge)

Definition at line 165 of file Tile.php.

166 {
167 $awarded_by = $this->parent->asProperty($badge);
168 return new ModalContent($badge, [
169 $this->txt('criteria') => $badge->getCriteria(),
170 ...($awarded_by !== null ? [$this->txt('awarded_by') => $awarded_by] : []),
171 $this->txt('valid_until') => $this->tryFormating($badge->getValid()),
172 ]);
173 }
tryFormating(string $valid)
Definition: Tile.php:192

References ilBadge\getCriteria(), ilBadge\getValid(), ILIAS\Badge\Tile\tryFormating(), and ILIAS\Badge\Tile\txt().

Referenced by ILIAS\Badge\Tile\modalContentWithAssignment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modalContentWithAssignment()

ILIAS\Badge\Tile::modalContentWithAssignment ( ilBadge  $badge,
ilBadgeAssignment  $assignment 
)

Definition at line 175 of file Tile.php.

176 {
177 return $this->addAssignment($this->modalContent($badge), $assignment);
178 }
addAssignment(ModalContent $content, ilBadgeAssignment $assignment)
Definition: Tile.php:180
modalContent(ilBadge $badge)
Definition: Tile.php:165

References ILIAS\Badge\Tile\addAssignment(), and ILIAS\Badge\Tile\modalContent().

Referenced by ILIAS\Badge\Tile\inDeck().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ profileButton()

ILIAS\Badge\Tile::profileButton ( ilBadge  $badge,
ilBadgeAssignment  $assignment,
string  $gui 
)
private

Definition at line 205 of file Tile.php.

205 : Component
206 {
207 $active = $assignment->getPosition();
208
209 $this->container->ctrl()->setParameterByClass($gui, 'badge_id', $badge->getId());
210
211 $url = $this->container->ctrl()->getLinkTargetByClass(
212 $gui,
213 $active ? 'deactivateInCard' : 'activateInCard'
214 );
215
216 $this->container->ctrl()->setParameterByClass($gui, 'badge_id', '');
217
218 return $this->container->ui()->factory()->button()->standard(
219 $this->txt($active ? 'badge_remove_from_profile' : 'badge_add_to_profile'),
220 $url
221 );
222 }
$url
Definition: shib_logout.php:68

References $url, ilBadge\getId(), ilBadgeAssignment\getPosition(), and ILIAS\Badge\Tile\txt().

Referenced by ILIAS\Badge\Tile\inDeck().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ title()

ILIAS\Badge\Tile::title ( Component  $modal,
ilBadge  $badge 
)
private

Definition at line 156 of file Tile.php.

156 : Component
157 {
158 return $this->container
159 ->ui()
160 ->factory()
161 ->button()
162 ->shy($badge->getTitle(), $modal->getShowSignal());
163 }

References ILIAS\Badge\Tile\$modal, and ilBadge\getTitle().

Referenced by ILIAS\Badge\Tile\asTitle(), and ILIAS\Badge\Tile\asTitleWithLeadingImage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tryFormating()

ILIAS\Badge\Tile::tryFormating ( string  $valid)
private

Definition at line 192 of file Tile.php.

192 : string
193 {
194 if (!$valid) {
195 return $this->txt('endless');
196 }
197
198 try {
199 return ($this->format_date)($valid, IL_CAL_DATE);
200 } catch (ilDateTimeException) {
201 return $valid;
202 }
203 }
const IL_CAL_DATE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$valid

References $valid, IL_CAL_DATE, and ILIAS\Badge\Tile\txt().

Referenced by ILIAS\Badge\Tile\modalContent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ txt()

ILIAS\Badge\Tile::txt ( string  $key)
private

Definition at line 187 of file Tile.php.

187 : string
188 {
189 return $this->container->language()->txt($key);
190 }

Referenced by ILIAS\Badge\Tile\addAssignment(), ILIAS\Badge\Tile\modalContent(), ILIAS\Badge\Tile\profileButton(), and ILIAS\Badge\Tile\tryFormating().

+ Here is the caller graph for this function:

Field Documentation

◆ $badge_image_service

readonly ilBadgeImage ILIAS\Badge\Tile::$badge_image_service
private

Definition at line 42 of file Tile.php.

◆ $format_date

readonly Closure ILIAS\Badge\Tile::$format_date
private

Definition at line 41 of file Tile.php.

Referenced by ILIAS\Badge\Tile\__construct().

◆ $modal

◆ $parent

readonly BadgeParent ILIAS\Badge\Tile::$parent
private

Definition at line 38 of file Tile.php.

Referenced by ILIAS\Badge\Tile\__construct(), and ILIAS\Badge\Tile\inDeck().

◆ $sign_file

readonly Closure ILIAS\Badge\Tile::$sign_file
private

Definition at line 37 of file Tile.php.

Referenced by ILIAS\Badge\Tile\__construct().


The documentation for this class was generated from the following file: