27 protected \ILIAS\Like\InternalGUIService
$gui;
29 protected \ILIAS\DI\UIServices
$ui;
49 ?
$DIC->ui()->mainTemplate()
52 $this->gui =
$DIC->like()->internal()->gui();
54 $this->
lng = $DIC->language();
55 $this->
ctrl = $DIC->ctrl();
56 $this->
user = $DIC->user();
57 $this->
ui = $DIC->ui();
61 $this->
lng->loadLanguageModule(
"like");
73 $this->gui->initFetch();
75 $this->main_tpl->addJavaScript(
"../components/ILIAS/Like/resources/Like.js");
77 $this->main_tpl->addJavaScript(
"assets/js/Like.js");
84 int $a_sub_obj_id = 0,
85 string $a_sub_obj_type =
"",
88 $this->obj_id = $a_obj_id;
89 $this->obj_type = $a_obj_type;
90 $this->sub_obj_id = $a_sub_obj_id;
91 $this->sub_obj_type = $a_sub_obj_type;
92 $this->news_id = $a_news_id;
93 $this->dom_id =
"like_" . $this->obj_id .
"_" . $this->obj_type .
"_" . $this->sub_obj_id .
"_" .
99 $ilCtrl = $this->ctrl;
101 $next_class = $ilCtrl->getNextClass($this);
102 $cmd = $ilCtrl->getCmd(
"getHTML");
104 switch ($next_class) {
106 if (in_array($cmd, array(
"getHTML",
"renderEmoticons",
"renderModal",
"saveExpression"))) {
107 return $this->$cmd();
116 $f = $this->
ui->factory();
117 $r = $this->
ui->renderer();
121 $tpl =
new ilTemplate(
"tpl.like.html",
true,
true,
"components/ILIAS/Like");
124 $modal_asyn_url = $ctrl->
getLinkTarget($this,
"renderModal",
"",
true,
false);
125 $modal =
$f->modal()->roundtrip(
'',
$f->legacy()->content(
""))
126 ->withAsyncRenderUrl($modal_asyn_url);
128 $modal_show_sig_id = $modal->getShowSignal()->getId();
129 $this->
ctrl->setParameter($this,
"modal_show_sig_id", $modal_show_sig_id);
130 $emo_counters = $this->renderEmoCounters($modal->getShowSignal());
131 $tpl->setVariable(
"EMO_COUNTERS", $emo_counters . $r->render($modal));
136 $popover =
$f->popover()->standard(
$f->legacy()->content(
''))->withTitle(
'');
137 $ctrl->
setParameter($this,
"repl_sig", $popover->getReplaceContentSignal()->getId());
138 $asyn_url = $ctrl->
getLinkTarget($this,
"renderEmoticons",
"",
true,
false);
139 $popover = $popover->withAsyncContentUrl($asyn_url);
140 $button =
$f->button()->shy(
$lng->txt(
"like"),
'#')
141 ->withOnClick($popover->getShowSignal());
143 $tpl->setVariable(
"LIKE", $r->render([$popover, $button]));
154 bool $unavailable =
false
156 $ilCtrl = $this->
ctrl;
158 $tpl =
new ilTemplate(
"tpl.emo_counters.html",
true,
true,
"components/ILIAS/Like");
159 $f = $this->
ui->factory();
160 $r = $this->
ui->renderer();
162 $cnts = $this->data->getExpressionCounts(
170 foreach ($this->data->getExpressionTypes() as $k =>
$txt) {
172 $glyph = $this->getGlyphForConst($k, $unavailable);
173 if ($modal_signal !==
null) {
174 $glyph = $glyph->withOnClick($modal_signal);
176 $comps[] = $glyph->withCounter(
$f->counter()->status($cnts[$k]));
180 if ($ilCtrl->isAsynch()) {
181 $tpl->setVariable(
"MODAL_TRIGGER", $r->renderAsync($comps));
183 $tpl->setVariable(
"MODAL_TRIGGER", $r->render($comps));
185 if ($modal_signal !==
null) {
186 $tpl->setVariable(
"ID", $this->dom_id);
189 if (count($comps) > 0 && $modal_signal !==
null) {
190 $tpl->setVariable(
"SEP", $r->render(
$f->divider()->vertical()));
198 bool $unavailable =
false
219 $like = $like->withUnavailableAction();
229 $ilCtrl = $this->ctrl;
230 $r = $this->
ui->renderer();
233 $ilCtrl->saveParameter($this,
"modal_show_sig_id");
235 $tpl =
new ilTemplate(
"tpl.emoticons.html",
true,
true,
"components/ILIAS/Like");
236 $tpl->setVariable(
"ID", $this->dom_id);
238 $url = $ilCtrl->getLinkTarget($this,
"",
"",
true);
239 foreach ($this->data->getExpressionTypes() as $k =>
$txt) {
240 $g = $this->getGlyphForConst($k);
242 if ($this->data->isExpressionSet(
243 $this->user->getId(),
251 $g = $g->withHighlight();
254 $g = $g->withAdditionalOnLoadCode(
function (
$id) use ($k,
$url) {
256 "$('#" .
$id .
"').click(function() { il.Like.toggle('" .
$url .
"','" .
$id .
"','" . $this->dom_id .
"'," . $k .
");});";
261 $tpl->setVariable(
"GLYPHS", $r->renderAsync($glyphs));
273 $exp_key = $this->request->getExpressionKey();
274 $exp_val = $this->request->getValue();
275 $modal_show_sig_id = $this->request->getModalSignalId();
276 $show_signal = new \ILIAS\UI\Implementation\Component\Signal($modal_show_sig_id);
279 $this->data->addExpression(
280 $this->
user->getId(),
289 $this->data->removeExpression(
290 $this->
user->getId(),
299 echo $this->renderEmoCounters($show_signal);
314 $f = $this->
ui->factory();
315 $r = $this->
ui->renderer();
320 $glyph_renderings = [];
321 foreach ($this->data->getExpressionEntries(
330 $image =
$f->image()->responsive(
335 $g = $this->getGlyphForConst($exp[
"expression"],
true);
336 $placeholder =
"###" . $exp[
"expression"] .
"###";
337 $glyph_renderings[$placeholder] = $r->render($g);
339 $list_items[] =
$f->item()->standard($name)
340 ->withDescription($placeholder .
" " .
342 ->withLeadImage($image);
345 $std_list =
$f->panel()->listing()->standard(
"", array(
346 $f->item()->group(
"", $list_items)
349 $header =
$f->legacy()->content($this->renderEmoCounters(
null,
true));
352 $modal =
$f->modal()->roundtrip(
'', [$header, $std_list]);
353 $html = $r->render($modal);
354 foreach ($glyph_renderings as $pl => $gl) {
355 $html = str_replace($pl, $gl, $html);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Class ilCtrl provides processing control methods.
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User interface for like feature.
StandardGUIRequest $request
saveExpression()
Save expression (asynch)
setObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id=0, string $a_sub_obj_type="", int $a_news_id=0)
renderEmoCounters(?ILIAS\UI\Component\Signal $modal_signal=null, bool $unavailable=false)
Render emo counters.
getGlyphForConst(int $a_const, bool $unavailable=false)
static getExpressionText(int $a_const)
Get expression text for const.
ilGlobalTemplateInterface $main_tpl
renderModal()
Render modal (asynch)
__construct(\ilLikeData $data, ?\ilTemplate $main_tpl=null)
renderEmoticons()
Render emoticons (asynch)
ILIAS Like InternalGUIService $gui
static _getPersonalPicturePath(int $a_usr_id, string $a_size='small', bool $a_force_pic=false)
special template class to simplify handling of ITX/PEAR
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.