19 declare(strict_types=1);
52 $sign_file = [ilWACSignedPath::class,
'signFile'],
55 $this->parent = $parent ??
new BadgeParent($this->container);
56 $this->
modal = $modal ??
new Modal($this->container);
57 $this->sign_file = Closure::fromCallable($sign_file);
59 class_exists(ilDateTime::class);
60 $format_date =
static fn($date,
int $format =
IL_CAL_UNIX):
string => (
65 $this->badge_image_service =
new ilBadgeImage($container->resourceStorage(), $container->upload(), $container->ui()->mainTemplate());
73 $parent = $this->parent->asComponent($badge);
74 $badge_sections = $parent ? [
$parent] : [];
75 $badge_sections[] = $this->
profileButton($badge, $assignment, $gui);
78 $card = $this->
card($content);
79 $modal = $this->
modal($card);
80 $image = $this->
image($modal, $badge);
81 $card = $card->withSections($badge_sections)
83 ->withTitleAction($modal->getShowSignal());
96 $modal = $this->
modal($this->
card($content));
109 $modal = $this->
modal($this->
card($content));
112 $this->
image($modal, $content->
badge(), $size),
121 $modal = $this->
modal($this->
card($content));
130 return $this->container
134 ->standard($content->
badge()->getTitle())
135 ->withHiddenSections($this->
modal->components($content));
140 return $this->container->ui()->factory()->modal()->lightbox(
141 $this->container->ui()->factory()->modal()->lightboxCardPage($card)
147 $image_src = $this->badge_image_service->getImageFromBadge($badge, $size);
148 return $this->container
152 ->responsive($image_src, $badge->
getTitle())
158 return $this->container
162 ->shy($badge->
getTitle(), $modal->getShowSignal());
167 $awarded_by = $this->parent->asProperty($badge);
170 ...($awarded_by !==
null ? [$this->
txt(
'awarded_by') => $awarded_by] : []),
183 $this->
txt(
'badge_issued_on') => ($this->format_date)($assignment->
getTimestamp()),
187 private function txt(
string $key): string
189 return $this->container->language()->txt($key);
195 return $this->
txt(
'endless');
209 $this->container->ctrl()->setParameterByClass($gui,
'badge_id', $badge->
getId());
211 $url = $this->container->ctrl()->getLinkTargetByClass(
213 $active ?
'deactivateInCard' :
'activateInCard' 216 $this->container->ctrl()->setParameterByClass($gui,
'badge_id',
'');
218 return $this->container->ui()->factory()->button()->standard(
219 $this->
txt($active ?
'badge_remove_from_profile' :
'badge_add_to_profile'),
addAssignment(ModalContent $content, ilBadgeAssignment $assignment)
readonly ilBadgeImage $badge_image_service
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
asTitle(ModalContent $content)
asImage(ModalContent $content, int $size=ilBadgeImage::IMAGE_SIZE_M)
modalContent(ilBadge $badge)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
tryFormating(string $valid)
__construct(private readonly Container $container, ?BadgeParent $parent=null, ?Modal $modal=null, $sign_file=[ilWACSignedPath::class, 'signFile'], ?Closure $format_date=null,)
image(Component $modal, ilBadge $badge, int $size=ilBadgeImage::IMAGE_SIZE_M)
readonly Closure $sign_file
profileButton(ilBadge $badge, ilBadgeAssignment $assignment, string $gui)
readonly Closure $format_date
readonly BadgeParent $parent
modalContentWithAssignment(ilBadge $badge, ilBadgeAssignment $assignment)
asTitleWithLeadingImage(ModalContent $content)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
card(ModalContent $content)
withAdditionalProperties(array $properties)
inDeck(ilBadge $badge, ilBadgeAssignment $assignment, string $gui)
title(Component $modal, ilBadge $badge)