ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilBadgeRenderer Class Reference
+ Collaboration diagram for ilBadgeRenderer:

Public Member Functions

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

Static Public Member Functions

static initFromId ($a_id)
 

Protected Member Functions

 getBadgeHash ()
 

Protected Attributes

 $tpl
 
 $ctrl
 
 $lng
 
 $assignment
 
 $badge
 

Static Protected Attributes

static $init
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

37 {
38 global $DIC;
39
40 $this->tpl = $DIC["tpl"];
41 $this->ctrl = $DIC->ctrl();
42 $this->lng = $DIC->language();
43 if ($a_assignment) {
44 $this->assignment = $a_assignment;
45 $this->badge = new ilBadge($this->assignment->getBadgeId());
46 } else {
47 $this->badge = $a_badge;
48 }
49 }
global $DIC
Definition: saml.php:7

References $DIC.

Member Function Documentation

◆ getBadgeHash()

ilBadgeRenderer::getBadgeHash ( )
protected

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

141 {
142 return md5("bdg-" .
143 ($this->assignment
144 ? $this->assignment->getUserId()
145 : "") . "-" .
146 $this->badge->getId());
147 }

Referenced by getHref(), getHTML(), and renderModal().

+ Here is the caller graph for this function:

◆ getHref()

ilBadgeRenderer::getHref ( )

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

111 {
114
115 if (!self::$init) {
116 self::$init = true;
117
118 $url = $ilCtrl->getLinkTargetByClass(
119 "ilBadgeHandlerGUI",
120 "render",
121 "",
122 true,
123 false
124 );
125
126 $tpl->addJavaScript("Services/Badge/js/ilBadgeRenderer.js");
127 $tpl->addOnLoadCode('il.BadgeRenderer.init("' . $url . '");');
128 }
129
130 $hash = $this->getBadgeHash();
131
132 return "#\" data-id=\"badge_" .
133 ($this->assignment
134 ? $this->assignment->getUserId()
135 : "") . "_" .
136 $this->badge->getId() . "_" .
137 $hash;
138 }
global $ilCtrl
Definition: ilias.php:18
$url

References $ctrl, $ilCtrl, $tpl, $url, and getBadgeHash().

+ Here is the call graph for this function:

◆ getHTML()

ilBadgeRenderer::getHTML ( )

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

77 {
80
81 if (!self::$init) {
82 self::$init = true;
83
84 $url = $ilCtrl->getLinkTargetByClass(
85 "ilBadgeHandlerGUI",
86 "render",
87 "",
88 true,
89 false
90 );
91
92 $tpl->addJavaScript("Services/Badge/js/ilBadgeRenderer.js");
93 $tpl->addOnLoadCode('il.BadgeRenderer.init("' . $url . '");');
94 }
95
96 $hash = $this->getBadgeHash();
97
98 $btpl = new ilTemplate("tpl.badge_renderer.html", true, true, "Services/Badge");
99 $btpl->setVariable("BADGE_IMG", $this->badge->getImagePath());
100 $btpl->setVariable("BADGE_TXT", $this->badge->getTitle());
101 $btpl->setVariable("BADGE_ID", "badge_" .
102 ($this->assignment
103 ? $this->assignment->getUserId()
104 : "") . "_" .
105 $this->badge->getId() . "_" .
106 $hash);
107 return $btpl->get();
108 }
special template class to simplify handling of ITX/PEAR

References $ctrl, $ilCtrl, $tpl, $url, and getBadgeHash().

+ Here is the call graph for this function:

◆ initFromId()

static ilBadgeRenderer::initFromId (   $a_id)
static

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

52 {
53 $id = explode("_", $_GET["id"]);
54 if (sizeof($id) == 3) {
55 $user_id = $id[0];
56 $badge_id = $id[1];
57 $hash = $id[2];
58
59 if ($user_id) {
60 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
61 $assignment = new ilBadgeAssignment($badge_id, $user_id);
62 if ($assignment->getTimestamp()) {
63 $obj = new self($assignment);
64 }
65 } else {
66 include_once "Services/Badge/classes/class.ilBadge.php";
67 $badge = new ilBadge($badge_id);
68 $obj = new self(null, $badge);
69 }
70 if ($hash == $obj->getBadgeHash()) {
71 return $obj;
72 }
73 }
74 }
$_GET["client_id"]
if(!array_key_exists('StateId', $_REQUEST)) $id

References $_GET, $assignment, $badge, and $id.

Referenced by ilBadgeHandlerGUI\render().

+ Here is the caller graph for this function:

◆ renderModal()

ilBadgeRenderer::renderModal ( )

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

150 {
152
153 include_once "Services/UIComponent/Modal/classes/class.ilModalGUI.php";
154
155 // only needed for modal-js-calls
156 // ilModalGUI::initJS();
157
158 $modal = ilModalGUI::getInstance();
159 $modal->setId("badge_modal_" . $this->getBadgeHash());
160 $modal->setType(ilModalGUI::TYPE_SMALL);
161 $modal->setHeading($this->badge->getTitle());
162
163 $lng->loadLanguageModule("badge");
164
165 $tpl = new ilTemplate("tpl.badge_modal.html", true, true, "Services/Badge");
166
167 $tpl->setVariable("IMG_SRC", $this->badge->getImagePath());
168 $tpl->setVariable("IMG_TXT", $this->badge->getImage());
169
170 $tpl->setVariable("TXT_DESC", $lng->txt("description"));
171 $tpl->setVariable("DESC", nl2br($this->badge->getDescription()));
172
173 $tpl->setVariable("TXT_CRITERIA", $lng->txt("badge_criteria"));
174 $tpl->setVariable("CRITERIA", nl2br($this->badge->getCriteria()));
175
176 if ($this->assignment) {
177 $tpl->setVariable("TXT_TSTAMP", $lng->txt("badge_issued_on"));
178 $tpl->setVariable(
179 "TSTAMP",
180 ilDatePresentation::formatDate(new ilDateTime($this->assignment->getTimestamp(), IL_CAL_UNIX))
181 );
182 }
183
184 if ($this->badge->getParentId()) {
185 $parent = $this->badge->getParentMeta();
186 if ($parent["type"] != "bdga") {
187 $tpl->setVariable("TXT_PARENT", $lng->txt("object"));
188 $tpl->setVariable("PARENT", $parent["title"]);
189 $tpl->setVariable("PARENT_TYPE", $lng->txt("obj_" . $parent["type"]));
190 $tpl->setVariable(
191 "PARENT_ICON",
192 ilObject::_getIcon($parent["id"], "big", $parent["type"])
193 );
194 }
195 }
196
197 if ($this->badge->getValid()) {
198 $tpl->setVariable("TXT_VALID", $lng->txt("badge_valid"));
199 $tpl->setVariable("VALID", $this->badge->getValid());
200 }
201
202 $modal->setBody($tpl->get());
203
204 return $modal->getHTML();
205 }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
static getInstance()
Get instance.
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.

References $lng, $tpl, ilObject\_getIcon(), ilDatePresentation\formatDate(), getBadgeHash(), ilModalGUI\getInstance(), IL_CAL_UNIX, and ilModalGUI\TYPE_SMALL.

+ Here is the call graph for this function:

Field Documentation

◆ $assignment

ilBadgeRenderer::$assignment
protected

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

Referenced by initFromId().

◆ $badge

ilBadgeRenderer::$badge
protected

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

Referenced by initFromId().

◆ $ctrl

ilBadgeRenderer::$ctrl
protected

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

Referenced by getHref(), and getHTML().

◆ $init

ilBadgeRenderer::$init
staticprotected

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

◆ $lng

ilBadgeRenderer::$lng
protected

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

Referenced by renderModal().

◆ $tpl

ilBadgeRenderer::$tpl
protected

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

Referenced by getHref(), getHTML(), and renderModal().


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