User interface for like feature.
More...
User interface for like feature.
- Author
- Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
- Version
- $Id$
Definition at line 13 of file class.ilLikeGUI.php.
◆ __construct()
ilLikeGUI constructor.
- Parameters
-
Definition at line 70 of file class.ilLikeGUI.php.
71 {
73
74 $this->main_tpl = ($main_tpl == null)
75 ?
$DIC->ui()->mainTemplate()
76 : $main_tpl;
77
78 $this->lng =
$DIC->language();
79 $this->ctrl =
$DIC->ctrl();
80 $this->
user = $DIC->user();
81 $this->ui =
$DIC->ui();
82 $this->lng =
$DIC->language();
83
85
86 $this->lng->loadLanguageModule("like");
87
89 }
initJavascript()
Init javascript.
References $data, $DIC, data, initJavascript(), and user().
◆ executeCommand()
ilLikeGUI::executeCommand |
( |
| ) |
|
Execute command.
- Returns
- string
Definition at line 123 of file class.ilLikeGUI.php.
124 {
126
127 $next_class =
$ilCtrl->getNextClass($this);
128 $cmd =
$ilCtrl->getCmd(
"getHTML");
129
130 switch ($next_class) {
131 default:
132 if (in_array($cmd, array("getHTML", "renderEmoticons", "renderModal", "saveExpression"))) {
133 return $this->$cmd();
134 }
135 break;
136 }
137 return "";
138 }
References $ctrl, and $ilCtrl.
◆ getExpressionText()
static ilLikeGUI::getExpressionText |
( |
|
$a_const | ) |
|
|
static |
◆ getGlyphForConst()
ilLikeGUI::getGlyphForConst |
( |
|
$a_const | ) |
|
|
protected |
◆ getHTML()
Get HTML.
- Parameters
-
| $a_obj_id | |
| $a_obj_type | |
int | $a_sub_obj_id | |
string | $a_sub_obj_type | |
int | $a_news_id | |
- Returns
- string
- Exceptions
-
Definition at line 151 of file class.ilLikeGUI.php.
152 {
153 $f = $this->ui->factory();
154 $r = $this->ui->renderer();
157
158 $tpl =
new ilTemplate(
"tpl.like.html",
true,
true,
"Services/Like");
159
160
161 $modal_asyn_url =
$ctrl->getLinkTarget($this,
"renderModal",
"",
true,
false);
162 $modal =
$f->modal()->roundtrip(
'',
$f->legacy(
""))
163 ->withAsyncRenderUrl($modal_asyn_url);
164
165 $modal_show_sig_id = $modal->getShowSignal()->getId();
166 $this->ctrl->setParameter($this, "modal_show_sig_id", $modal_show_sig_id);
168 $tpl->setVariable(
"EMO_COUNTERS", $emo_counters .
$r->render($modal));
169
170
171
172
173 $popover =
$f->popover()->standard(
$f->legacy(
''))->withTitle(
'');
174 $ctrl->setParameter($this,
"repl_sig", $popover->getReplaceContentSignal()->getId());
175 $asyn_url =
$ctrl->getLinkTarget($this,
"renderEmoticons",
"",
true,
false);
176 $popover = $popover->withAsyncContentUrl($asyn_url);
177 $button =
$f->button()->shy(
$lng->txt(
"like"),
'#')
178 ->withOnClick($popover->getShowSignal());
179
180 $tpl->setVariable(
"LIKE",
$r->render([$popover, $button]));
181
183 }
renderEmoCounters($modal_signal=null)
Render emo counters.
special template class to simplify handling of ITX/PEAR
References $ctrl, $f, $lng, $r, $tpl, and renderEmoCounters().
◆ initJavascript()
ilLikeGUI::initJavascript |
( |
| ) |
|
|
protected |
Init javascript.
Definition at line 94 of file class.ilLikeGUI.php.
95 {
96 $this->main_tpl->addJavaScript("./Services/Like/js/Like.js");
97 }
Referenced by __construct().
◆ renderEmoCounters()
ilLikeGUI::renderEmoCounters |
( |
|
$modal_signal = null | ) |
|
|
protected |
Render emo counters.
- Parameters
-
- Returns
- string
- Exceptions
-
Definition at line 192 of file class.ilLikeGUI.php.
193 {
195
196 $tpl =
new ilTemplate(
"tpl.emo_counters.html",
true,
true,
"Services/Like");
197 $f = $this->ui->factory();
198 $r = $this->ui->renderer();
199
200 $cnts = $this->
data->getExpressionCounts(
201 $this->obj_id,
202 $this->obj_type,
203 $this->sub_obj_id,
204 $this->sub_obj_type,
205 $this->news_id
206 );
207 $comps = array();
208 foreach ($this->
data->getExpressionTypes() as $k =>
$txt) {
209 if ($cnts[$k] > 0) {
211 if ($modal_signal !== null) {
212 $glyph = $glyph->withOnClick($modal_signal);
213 }
214 $comps[] = $glyph->withCounter(
$f->counter()->status($cnts[$k]));
215 }
216 }
217
219 $tpl->setVariable(
"MODAL_TRIGGER",
$r->renderAsync($comps));
220 } else {
221 $tpl->setVariable(
"MODAL_TRIGGER",
$r->render($comps));
222 }
223 if ($modal_signal !== null) {
224 $tpl->setVariable(
"ID", $this->dom_id);
225 }
226
227 if (count($comps) > 0 && $modal_signal !== null) {
228 $tpl->setVariable(
"SEP",
$r->render(
$f->divider()->vertical()));
229 }
230
232 }
getGlyphForConst($a_const)
Get glyph for const.
References $ctrl, $f, $ilCtrl, $r, $tpl, $txt, data, and getGlyphForConst().
Referenced by getHTML(), renderModal(), and saveExpression().
◆ renderEmoticons()
ilLikeGUI::renderEmoticons |
( |
| ) |
|
Render emoticons.
Definition at line 262 of file class.ilLikeGUI.php.
263 {
265 $r = $this->ui->renderer();
266
267 $ilCtrl->saveParameter($this,
"modal_show_sig_id");
268
269 $tpl =
new ilTemplate(
"tpl.emoticons.html",
true,
true,
"Services/Like");
270 $tpl->setVariable(
"ID", $this->dom_id);
271
272 $url =
$ilCtrl->getLinkTarget($this,
"",
"",
true);
273 foreach ($this->
data->getExpressionTypes() as $k =>
$txt) {
275
276 if ($this->
data->isExpressionSet(
277 $this->user->getId(),
278 $k,
279 $this->obj_id,
280 $this->obj_type,
281 $this->sub_obj_id,
282 $this->sub_obj_type,
283 $this->news_id
284 )) {
285 $g = $g->withHighlight();
286 }
287
288 $g = $g->withAdditionalOnLoadCode(
function (
$id) use ($k,
$url) {
289 return
290 "$('#" .
$id .
"').click(function() { il.Like.toggle('" .
$url .
"','" .
$id .
"','" . $this->dom_id .
"'," . $k .
");});";
291 });
292 $glyphs[] = $g;
293 }
294
295 $tpl->setVariable(
"GLYPHS",
$r->renderAsync($glyphs));
296
299 }
if(!array_key_exists('StateId', $_REQUEST)) $id
References $ctrl, $id, $ilCtrl, $r, $tpl, $txt, $url, data, exit, and getGlyphForConst().
◆ renderModal()
ilLikeGUI::renderModal |
( |
| ) |
|
Render modal.
- Exceptions
-
Definition at line 343 of file class.ilLikeGUI.php.
344 {
346
347 $f = $this->ui->factory();
348 $r = $this->ui->renderer();
349
350
351 $list_items = [];
352 foreach ($this->
data->getExpressionEntries(
353 $this->obj_id,
354 $this->obj_type,
355 $this->sub_obj_id,
356 $this->sub_obj_type,
357 $this->news_id
358 ) as $exp) {
360
361 $image =
$f->image()->responsive(
362 ilObjUser::_getPersonalPicturePath($exp["user_id"]),
364 );
365
367
368 $list_items[] =
$f->item()->standard(
$name)
369 ->withDescription(
$r->render($g) .
" " .
371 ->withLeadImage($image);
372 }
373
374 $std_list =
$f->panel()->listing()->standard(
"", array(
375 $f->item()->group(
"", $list_items)
376 ));
377
379
380
381 $modal =
$f->modal()->roundtrip(
'', [
$header, $std_list]);
382 echo
$r->render($modal);
384 }
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 getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
References $f, $header, $name, $r, $user, data, exit, ilDatePresentation\formatDate(), getGlyphForConst(), ilUserUtil\getNamePresentation(), IL_CAL_DATETIME, and renderEmoCounters().
◆ saveExpression()
ilLikeGUI::saveExpression |
( |
| ) |
|
|
protected |
Save expresseion.
- Exceptions
-
Definition at line 306 of file class.ilLikeGUI.php.
307 {
308 $exp_key = (int)
$_GET[
"exp"];
309 $exp_val = (int)
$_GET[
"val"];
311 $show_signal = new \ILIAS\UI\Implementation\Component\Signal($modal_show_sig_id);
312
313 if ($exp_val) {
314 $this->
data->addExpression(
315 $this->
user->getId(),
316 $exp_key,
317 $this->obj_id,
318 $this->obj_type,
319 $this->sub_obj_id,
320 $this->sub_obj_type,
321 $this->news_id
322 );
323 } else {
324 $this->
data->removeExpression(
325 $this->
user->getId(),
326 $exp_key,
327 $this->obj_id,
328 $this->obj_type,
329 $this->sub_obj_id,
330 $this->sub_obj_type,
331 $this->news_id
332 );
333 }
336 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
References $_GET, data, exit, renderEmoCounters(), ilUtil\stripSlashes(), and user().
◆ setObject()
ilLikeGUI::setObject |
( |
|
$a_obj_id, |
|
|
|
$a_obj_type, |
|
|
|
$a_sub_obj_id = 0 , |
|
|
|
$a_sub_obj_type = "" , |
|
|
|
$a_news_id = 0 |
|
) |
| |
Set Object.
- Parameters
-
int | $a_obj_id | Object ID |
string | $a_obj_type | Object Type |
int | $a_sub_obj_id | Subobject ID |
string | $a_sub_obj_type | Subobject Type |
Definition at line 108 of file class.ilLikeGUI.php.
109 {
110 $this->obj_id = $a_obj_id;
111 $this->obj_type = $a_obj_type;
112 $this->sub_obj_id = $a_sub_obj_id;
113 $this->sub_obj_type = $a_sub_obj_type;
114 $this->news_id = $a_news_id;
115 $this->dom_id = "like_" . $this->obj_id . "_" . $this->obj_type . "_" . $this->sub_obj_id . "_" .
117 }
References $news_id.
◆ $ctrl
◆ $dom_id
◆ $language
◆ $lng
◆ $news_id
◆ $obj_id
◆ $obj_type
◆ $sub_obj_id
◆ $sub_obj_type
◆ $user
The documentation for this class was generated from the following file: