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

Public Member Functions

 __construct (?ilBadgeAssignment $assignment=null)
 
 constructModal (?Image $badge_image, string $badge_title, array $badge_properties=[])
 
 renderModal (Modal $modal)
 
 renderShyButton (string $label, Modal $modal)
 

Private Member Functions

 translateKeysWithValidDataAttribute (array $properties)
 

Private Attributes

Factory $ui_factory
 
Renderer $ui_renderer
 
ilLanguage $lng
 
ilBadgeAssignment $assignment = null
 

Detailed Description

Definition at line 33 of file ModalBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Badge\ModalBuilder::__construct ( ?ilBadgeAssignment  $assignment = null)

Definition at line 40 of file ModalBuilder.php.

41 {
42 global $DIC;
43
44 $this->ui_factory = $DIC->ui()->factory();
45 $this->ui_renderer = $DIC->ui()->renderer();
46 $this->lng = $DIC->language();
47 $this->lng->loadLanguageModule('badge');
48
49 if ($assignment) {
50 $this->assignment = $assignment;
51 }
52 }
ilBadgeAssignment $assignment
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ constructModal()

ILIAS\Badge\ModalBuilder::constructModal ( ?Image  $badge_image,
string  $badge_title,
array  $badge_properties = [] 
)
Parameters
array<string,string>$badge_properties

Definition at line 57 of file ModalBuilder.php.

61 : Modal {
62 if ($badge_image !== null) {
63 $modal_content[] = $badge_image;
64 }
65
66 if ($this->assignment) {
67 $badge_properties['badge_issued_on'] = ilDatePresentation::formatDate(
68 new ilDateTime($this->assignment->getTimestamp(), IL_CAL_UNIX)
69 );
70 }
71
72 $badge_properties = $this->translateKeysWithValidDataAttribute($badge_properties);
73
74 $modal_content[] = $this->ui_factory->item()
75 ->standard($badge_title)
76 ->withDescription('')
77 ->withProperties($badge_properties);
78
79 $card = $this->ui_factory->card()
80 ->standard($badge_title)
81 ->withHiddenSections($modal_content);
82
83 return $this->ui_factory->modal()->lightbox(
84 $this->ui_factory->modal()->lightboxCardPage($card)
85 );
86 }
translateKeysWithValidDataAttribute(array $properties)
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling

Referenced by ILIAS\Badge\ilBadgeTableGUI\enrichRecord().

+ Here is the caller graph for this function:

◆ renderModal()

ILIAS\Badge\ModalBuilder::renderModal ( Modal  $modal)

Definition at line 88 of file ModalBuilder.php.

88 : string
89 {
90 return $this->ui_renderer->render($modal);
91 }

Referenced by ILIAS\Badge\ilBadgeTableGUI\enrichRecord().

+ Here is the caller graph for this function:

◆ renderShyButton()

ILIAS\Badge\ModalBuilder::renderShyButton ( string  $label,
Modal  $modal 
)

Definition at line 93 of file ModalBuilder.php.

93 : string
94 {
95 return $this->ui_renderer->render($this->ui_factory->button()->shy($label, $modal->getShowSignal()));
96 }

Referenced by ILIAS\Badge\ilBadgeTableGUI\enrichRecord().

+ Here is the caller graph for this function:

◆ translateKeysWithValidDataAttribute()

ILIAS\Badge\ModalBuilder::translateKeysWithValidDataAttribute ( array  $properties)
private
Parameters
array<string,string>$properties
Returns
array<string, string>

Definition at line 102 of file ModalBuilder.php.

102 : array
103 {
104 $translations = [];
105
106 if (\count($properties) > 0) {
107 foreach ($properties as $lang_var => $data) {
108 if ($data !== '') {
109 $translations[$this->lng->txt($lang_var)] = $data;
110 }
111 }
112 }
113 return $translations;
114 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $assignment

ilBadgeAssignment ILIAS\Badge\ModalBuilder::$assignment = null
private

Definition at line 38 of file ModalBuilder.php.

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

◆ $lng

ilLanguage ILIAS\Badge\ModalBuilder::$lng
private

Definition at line 37 of file ModalBuilder.php.

◆ $ui_factory

Factory ILIAS\Badge\ModalBuilder::$ui_factory
private

Definition at line 35 of file ModalBuilder.php.

◆ $ui_renderer

Renderer ILIAS\Badge\ModalBuilder::$ui_renderer
private

Definition at line 36 of file ModalBuilder.php.


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