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, initJavascript(), ui(), 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, |
|
|
|
$unavailable = false |
|
) |
| |
|
protected |
Get glyph for const.
- Parameters
-
- Returns
- \ILIAS\UI\Component\Glyph\Glyph|null
Definition at line 241 of file class.ilLikeGUI.php.
242 {
243 $f = $this->
ui->factory();
244 $like = null;
245 switch ($a_const) {
253 }
254 if ($unavailable) {
255 $like = $like->withUnavailableAction();
256 }
257 return $like;
258 }
References Vendor\Package\$f, ilLikeData\TYPE_ANGRY, ilLikeData\TYPE_ASTOUNDED, ilLikeData\TYPE_DISLIKE, ilLikeData\TYPE_LAUGH, ilLikeData\TYPE_LIKE, ilLikeData\TYPE_LOVE, ilLikeData\TYPE_SAD, and ui().
Referenced by renderEmoCounters(), renderEmoticons(), and renderModal().
◆ 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, $unavailable=false)
Render emo counters.
special template class to simplify handling of ITX/PEAR
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
References $ctrl, Vendor\Package\$f, $lng, $tpl, renderEmoCounters(), and ui().
◆ 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 , |
|
|
|
$unavailable = false |
|
) |
| |
|
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, $unavailable=false)
Get glyph for const.
References $ctrl, Vendor\Package\$f, $ilCtrl, $tpl, $txt, getGlyphForConst(), and ui().
Referenced by getHTML(), renderModal(), and saveExpression().
◆ renderEmoticons()
ilLikeGUI::renderEmoticons |
( |
| ) |
|
Render emoticons.
Definition at line 265 of file class.ilLikeGUI.php.
266 {
268 $r = $this->
ui->renderer();
269
270 $ilCtrl->saveParameter($this,
"modal_show_sig_id");
271
272 $tpl =
new ilTemplate(
"tpl.emoticons.html",
true,
true,
"Services/Like");
273 $tpl->setVariable(
"ID", $this->dom_id);
274
275 $url =
$ilCtrl->getLinkTarget($this,
"",
"",
true);
276 foreach ($this->data->getExpressionTypes() as $k =>
$txt) {
278
279 if ($this->data->isExpressionSet(
280 $this->user->getId(),
281 $k,
282 $this->obj_id,
283 $this->obj_type,
284 $this->sub_obj_id,
285 $this->sub_obj_type,
286 $this->news_id
287 )) {
288 $g = $g->withHighlight();
289 }
290
291 $g = $g->withAdditionalOnLoadCode(
function ($id) use ($k,
$url) {
292 return
293 "$('#" . $id .
"').click(function() { il.Like.toggle('" .
$url .
"','" . $id .
"','" . $this->dom_id .
"'," . $k .
");});";
294 });
295 $glyphs[] = $g;
296 }
297
298 $tpl->setVariable(
"GLYPHS", $r->renderAsync($glyphs));
299
302 }
References $ctrl, $ilCtrl, $tpl, $txt, $url, exit, getGlyphForConst(), and ui().
◆ renderModal()
ilLikeGUI::renderModal |
( |
| ) |
|
Render modal.
- Exceptions
-
Definition at line 346 of file class.ilLikeGUI.php.
347 {
349
350 $f = $this->
ui->factory();
351 $r = $this->
ui->renderer();
352
353
354 $list_items = [];
355 foreach ($this->data->getExpressionEntries(
356 $this->obj_id,
357 $this->obj_type,
358 $this->sub_obj_id,
359 $this->sub_obj_type,
360 $this->news_id
361 ) as $exp) {
363
364 $image =
$f->image()->responsive(
367 );
368
370
371 $list_items[] =
$f->item()->standard(
$name)
372 ->withDescription($r->render($g) . " " .
374 ->withLeadImage($image);
375 }
376
377 $std_list =
$f->panel()->listing()->standard(
"", array(
378 $f->item()->group(
"", $list_items)
379 ));
380
382
383
384 $modal =
$f->modal()->roundtrip(
'', [$header, $std_list]);
385 echo $r->render($modal);
387 }
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 _getPersonalPicturePath( $a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
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 Vendor\Package\$f, $name, $user, ilObjUser\_getPersonalPicturePath(), exit, ilDatePresentation\formatDate(), getGlyphForConst(), ilUserUtil\getNamePresentation(), IL_CAL_DATETIME, renderEmoCounters(), and ui().
◆ saveExpression()
ilLikeGUI::saveExpression |
( |
| ) |
|
|
protected |
Save expresseion.
- Exceptions
-
Definition at line 309 of file class.ilLikeGUI.php.
310 {
311 $exp_key = (int)
$_GET[
"exp"];
312 $exp_val = (int)
$_GET[
"val"];
314 $show_signal = new \ILIAS\UI\Implementation\Component\Signal($modal_show_sig_id);
315
316 if ($exp_val) {
317 $this->data->addExpression(
318 $this->
user->getId(),
319 $exp_key,
320 $this->obj_id,
321 $this->obj_type,
322 $this->sub_obj_id,
323 $this->sub_obj_type,
324 $this->news_id
325 );
326 } else {
327 $this->data->removeExpression(
328 $this->
user->getId(),
329 $exp_key,
330 $this->obj_id,
331 $this->obj_type,
332 $this->sub_obj_id,
333 $this->sub_obj_type,
334 $this->news_id
335 );
336 }
339 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
References $_GET, 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: