ILIAS  release_7 Revision v7.30-3-g800a261c036
ilBadgeRenderer Class Reference

Class ilBadgeRenderer. More...

+ Collaboration diagram for ilBadgeRenderer:

Public Member Functions

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

Protected Attributes

 $lng
 
 $factory
 
 $renderer
 
 $assignment
 
 $badge
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

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

References $DIC.

Member Function Documentation

◆ getHTML()

ilBadgeRenderer::getHTML ( )

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

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

References ilWACSignedPath\signFile().

+ Here is the call graph for this function:

◆ renderModalContent()

ilBadgeRenderer::renderModalContent ( )

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

64 {
66 $lng->loadLanguageModule("badge");
67
68 $modal_content = array();
69
70 $image = $this->factory->image()->responsive($this->badge->getImagePath(), $this->badge->getImage());
71 $modal_content[] = $image;
72
73 $badge_information = [
74 $lng->txt("description") => $this->badge->getDescription(),
75 $lng->txt("badge_criteria") => $this->badge->getCriteria(),
76 ];
77
78 if ($this->assignment) {
79 $badge_information[$lng->txt("badge_issued_on")] = ilDatePresentation::formatDate(
80 new ilDateTime($this->assignment->getTimestamp(), IL_CAL_UNIX)
81 );
82 }
83
84 if ($this->badge->getParentId()) {
85 $parent = $this->badge->getParentMeta();
86 if ($parent["type"] != "bdga") {
87 $parent_icon = $this->factory->symbol()->icon()->custom(
88 ilObject::_getIcon($parent["id"], "big", $parent["type"]),
89 $lng->txt("obj_" . $parent["type"])
90 )->withSize("medium");
91
92 $label = $parent['title'];
93 $ref = current(ilObject::_getAllReferences($parent['id']));
94 if ($ref) {
95 $label = $this->factory->link()->standard($label, ilLink::_getLink($ref, $parent['type']));
96 $label = $this->renderer->render($label);
97 }
98 $badge_information[$lng->txt("object")] = $this->renderer->render($parent_icon) . $label;
99 }
100 }
101
102 if ($this->badge->getValid()) {
103 $badge_information[$lng->txt("badge_valid")] = $this->badge->getValid();
104 }
105
106 $list = $this->factory->listing()->descriptive($badge_information);
107 $modal_content[] = $list;
108
109 return $this->renderer->render($modal_content);
110 }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _getAllReferences($a_id)
get all reference ids of object

References $lng, ilObject\_getAllReferences(), ilObject\_getIcon(), ilLink\_getLink(), ilDatePresentation\formatDate(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

Field Documentation

◆ $assignment

ilBadgeRenderer::$assignment
protected

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

◆ $badge

ilBadgeRenderer::$badge
protected

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

◆ $factory

ilBadgeRenderer::$factory
protected

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

◆ $lng

ilBadgeRenderer::$lng
protected

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

Referenced by renderModalContent().

◆ $renderer

ilBadgeRenderer::$renderer
protected

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


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