ILIAS  release_8 Revision v8.24
ilBadgeRenderer Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilBadgeRenderer:

Public Member Functions

 __construct (ilBadgeAssignment $a_assignment=null, ilBadge $a_badge=null)
 
 getHTML ()
 
 renderModalContent ()
 

Protected Attributes

ilLanguage $lng
 
ILIAS UI Factory $factory
 
ILIAS UI Renderer $renderer
 
ilBadgeAssignment $assignment = null
 
ilBadge $badge = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 22 of file class.ilBadgeRenderer.php.

Constructor & Destructor Documentation

◆ __construct()

ilBadgeRenderer::__construct ( ilBadgeAssignment  $a_assignment = null,
ilBadge  $a_badge = null 
)

Definition at line 30 of file class.ilBadgeRenderer.php.

33 {
34 global $DIC;
35
36 $this->lng = $DIC->language();
37 $this->factory = $DIC->ui()->factory();
38 $this->renderer = $DIC->ui()->renderer();
39 if ($a_assignment) {
40 $this->assignment = $a_assignment;
41 $this->badge = new ilBadge($this->assignment->getBadgeId());
42 } else {
43 $this->badge = $a_badge;
44 }
45 }
global $DIC
Definition: feed.php:28

References $DIC, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ getHTML()

ilBadgeRenderer::getHTML ( )

Definition at line 47 of file class.ilBadgeRenderer.php.

47 : string
48 {
49 $components = array();
50
51 $modal = $this->factory->modal()->roundtrip(
52 $this->badge->getTitle(),
53 $this->factory->legacy($this->renderModalContent())
54 )->withCancelButtonLabel("ok");
55 $components[] = $modal;
56
57 $image_path = ilWACSignedPath::signFile($this->badge->getImagePath());
58 $image = $this->factory->image()->responsive($image_path, $this->badge->getTitle())
59 ->withAction($modal->getShowSignal());
60 $components[] = $image;
61
62 return $this->renderer->render($components);
63 }
static signFile(string $path_to_file)

References ilWACSignedPath\signFile().

+ Here is the call graph for this function:

◆ renderModalContent()

ilBadgeRenderer::renderModalContent ( )

Definition at line 65 of file class.ilBadgeRenderer.php.

65 : string
66 {
68 $lng->loadLanguageModule("badge");
69
70 $modal_content = array();
71
72 $image = $this->factory->image()->responsive(ilWACSignedPath::signFile($this->badge->getImagePath()), $this->badge->getImage());
73 $modal_content[] = $image;
74
75 $badge_information = [
76 $lng->txt("description") => $this->badge->getDescription(),
77 $lng->txt("badge_criteria") => $this->badge->getCriteria(),
78 ];
79
80 if ($this->assignment) {
81 $badge_information[$lng->txt("badge_issued_on")] = ilDatePresentation::formatDate(
82 new ilDateTime($this->assignment->getTimestamp(), IL_CAL_UNIX)
83 );
84 }
85
86 if ($this->badge->getParentId()) {
87 $parent = $this->badge->getParentMeta();
88 if ($parent["type"] !== "bdga") {
89 $parent_icon = $this->factory->symbol()->icon()->custom(
90 ilObject::_getIcon((int) $parent["id"], "big", $parent["type"]),
91 $lng->txt("obj_" . $parent["type"])
92 )->withSize("medium");
93
94 $label = $parent['title'];
95 $ref = current(ilObject::_getAllReferences($parent['id']));
96 if ($ref) {
97 $label = $this->factory->link()->standard($label, ilLink::_getLink($ref, $parent['type']));
98 $label = $this->renderer->render($label);
99 }
100 $badge_information[$lng->txt('object')] = $this->renderer->render($parent_icon) . $label;
101 }
102 }
103
104 if ($this->badge->getValid()) {
105 $badge_information[$lng->txt("badge_valid")] = $this->badge->getValid();
106 }
107
108 $list = $this->factory->listing()->descriptive($badge_information);
109 $modal_content[] = $list;
110
111 return $this->renderer->render($modal_content);
112 }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _getAllReferences(int $id)
get all reference ids for object ID

References $lng, ilObject\_getAllReferences(), ilObject\_getIcon(), ilLink\_getLink(), ilDatePresentation\formatDate(), IL_CAL_UNIX, ilLanguage\loadLanguageModule(), ilWACSignedPath\signFile(), and ilLanguage\txt().

+ Here is the call graph for this function:

Field Documentation

◆ $assignment

ilBadgeAssignment ilBadgeRenderer::$assignment = null
protected

Definition at line 27 of file class.ilBadgeRenderer.php.

◆ $badge

ilBadge ilBadgeRenderer::$badge = null
protected

Definition at line 28 of file class.ilBadgeRenderer.php.

◆ $factory

ILIAS UI Factory ilBadgeRenderer::$factory
protected

Definition at line 25 of file class.ilBadgeRenderer.php.

◆ $lng

ilLanguage ilBadgeRenderer::$lng
protected

Definition at line 24 of file class.ilBadgeRenderer.php.

Referenced by renderModalContent().

◆ $renderer

ILIAS UI Renderer ilBadgeRenderer::$renderer
protected

Definition at line 26 of file class.ilBadgeRenderer.php.


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