ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\Badge\PublicUserProfileBadgesRenderer Class Reference
+ Collaboration diagram for ILIAS\Badge\PublicUserProfileBadgesRenderer:

Public Member Functions

 __construct (?ilGlobalTemplateInterface $main_tpl=null, ?ilLanguage $lng=null)
 
 render (int $user_id)
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 
ilLanguage $lng
 
IRSS $irss
 

Detailed Description

Definition at line 31 of file class.PublicUserProfileBadgesRenderer.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Badge\PublicUserProfileBadgesRenderer::__construct ( ?ilGlobalTemplateInterface  $main_tpl = null,
?ilLanguage  $lng = null 
)

Definition at line 37 of file class.PublicUserProfileBadgesRenderer.php.

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

40  {
41  global $DIC;
42  $this->main_tpl = $main_tpl ?? $DIC->ui()->mainTemplate();
43  $this->lng = $lng ?? $DIC->language();
44  $this->lng->loadLanguageModule('badge');
45 
46  $this->irss = $DIC->resourceStorage();
47  }
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ render()

ILIAS\Badge\PublicUserProfileBadgesRenderer::render ( int  $user_id)

Definition at line 49 of file class.PublicUserProfileBadgesRenderer.php.

References $renderer, ilBadgeAssignment\getInstancesByUserId(), and ILIAS\Repository\lng().

49  : string
50  {
51  $tpl = new ilTemplate(
52  'tpl.usr_public_profile_badges.html',
53  true,
54  true,
55  'components/ILIAS/Badge'
56  );
57 
58  $this->main_tpl->addJavaScript('assets/js/PublicProfileBadges.js');
59  $this->main_tpl->addOnLoadCode('new BadgeToggle("ilbdgprcont", "ilbdgprfhdm", "ilbdgprfhdl", "ilNoDisplay");');
61  if ($user_badges) {
62  $has_public_badge = false;
63  $cnt = 0;
64 
65  $cut = 20;
66 
67  $badge_by_id = [];
68  $image_rids = [];
69  foreach ($user_badges as $ass) {
70  $badge = new ilBadge($ass->getBadgeId());
71  $image_rids[] = $badge->getImageRid();
72  $badge_by_id[$badge->getId()] = $badge;
73  }
74 
75  $this->irss->preload(array_filter($image_rids));
76 
77  foreach ($user_badges as $ass) {
78  // only active
79  if ($ass->getPosition()) {
80  $cnt++;
81 
82  $renderer = new ilBadgeRenderer($ass, $badge_by_id[$ass->getBadgeId()]);
83 
84  // limit to 20, [MORE] link
85  if ($cnt > $cut) {
86  $tpl->setCurrentBlock('hidden_badge');
87  $tpl->touchBlock('hidden_badge');
88  $tpl->parseCurrentBlock();
89  }
90 
91  $tpl->setCurrentBlock('badge_bl');
92  $tpl->setVariable('BADGE', $renderer->getHTML());
93  $tpl->parseCurrentBlock();
94 
95  $has_public_badge = true;
96  }
97  }
98 
99  if ($cnt > $cut) {
100  $tpl->setVariable('BADGE_HIDDEN_TXT_MORE', $this->lng->txt('badge_profile_more'));
101  $tpl->setVariable('BADGE_HIDDEN_TXT_LESS', $this->lng->txt('badge_profile_less'));
102  }
103 
104  if ($has_public_badge) {
105  $tpl->setVariable('TXT_BADGES', $this->lng->txt('obj_bdga'));
106  }
107  }
108 
109  return $tpl->get();
110  }
$renderer
static getInstancesByUserId(int $a_user_id)
+ Here is the call graph for this function:

Field Documentation

◆ $irss

IRSS ILIAS\Badge\PublicUserProfileBadgesRenderer::$irss
private

Definition at line 35 of file class.PublicUserProfileBadgesRenderer.php.

◆ $lng

ilLanguage ILIAS\Badge\PublicUserProfileBadgesRenderer::$lng
private

Definition at line 34 of file class.PublicUserProfileBadgesRenderer.php.

◆ $main_tpl

ilGlobalTemplateInterface ILIAS\Badge\PublicUserProfileBadgesRenderer::$main_tpl
private

Definition at line 33 of file class.PublicUserProfileBadgesRenderer.php.


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