28 protected \ILIAS\DI\UIServices
$ui;
47 $this->main_tpl = ($main_tpl == null)
48 ? $DIC->ui()->mainTemplate()
51 $this->
lng = $DIC->language();
52 $this->
ctrl = $DIC->ctrl();
53 $this->
user = $DIC->user();
54 $this->
ui = $DIC->ui();
58 $this->
lng->loadLanguageModule(
"like");
69 $this->main_tpl->addJavaScript(
"./Services/Like/js/Like.js");
75 int $a_sub_obj_id = 0,
76 string $a_sub_obj_type =
"",
79 $this->obj_id = $a_obj_id;
80 $this->obj_type = $a_obj_type;
81 $this->sub_obj_id = $a_sub_obj_id;
82 $this->sub_obj_type = $a_sub_obj_type;
83 $this->news_id = $a_news_id;
84 $this->dom_id =
"like_" . $this->obj_id .
"_" . $this->obj_type .
"_" . $this->sub_obj_id .
"_" .
93 $cmd = $ilCtrl->getCmd(
"getHTML");
95 switch ($next_class) {
97 if (in_array($cmd, array(
"getHTML",
"renderEmoticons",
"renderModal",
"saveExpression"))) {
107 $f = $this->
ui->factory();
108 $r = $this->
ui->renderer();
112 $tpl =
new ilTemplate(
"tpl.like.html",
true,
true,
"Services/Like");
115 $modal_asyn_url = $ctrl->
getLinkTarget($this,
"renderModal",
"",
true,
false);
116 $modal =
$f->modal()->roundtrip(
'',
$f->legacy(
""))
117 ->withAsyncRenderUrl($modal_asyn_url);
119 $modal_show_sig_id = $modal->getShowSignal()->getId();
120 $this->
ctrl->setParameter($this,
"modal_show_sig_id", $modal_show_sig_id);
122 $tpl->setVariable(
"EMO_COUNTERS", $emo_counters . $r->render($modal));
127 $popover =
$f->popover()->standard(
$f->legacy(
''))->withTitle(
'');
128 $ctrl->
setParameter($this,
"repl_sig", $popover->getReplaceContentSignal()->getId());
129 $asyn_url = $ctrl->
getLinkTarget($this,
"renderEmoticons",
"",
true,
false);
130 $popover = $popover->withAsyncContentUrl($asyn_url);
131 $button =
$f->button()->shy($lng->
txt(
"like"),
'#')
132 ->withOnClick($popover->getShowSignal());
134 $tpl->setVariable(
"LIKE", $r->render([$popover, $button]));
145 bool $unavailable =
false 149 $tpl =
new ilTemplate(
"tpl.emo_counters.html",
true,
true,
"Services/Like");
150 $f = $this->
ui->factory();
151 $r = $this->
ui->renderer();
153 $cnts = $this->data->getExpressionCounts(
161 foreach ($this->data->getExpressionTypes() as $k =>
$txt) {
164 if ($modal_signal !== null) {
165 $glyph = $glyph->withOnClick($modal_signal);
167 $comps[] = $glyph->withCounter(
$f->counter()->status($cnts[$k]));
171 if ($ilCtrl->isAsynch()) {
172 $tpl->setVariable(
"MODAL_TRIGGER", $r->renderAsync($comps));
174 $tpl->setVariable(
"MODAL_TRIGGER", $r->render($comps));
176 if ($modal_signal !== null) {
177 $tpl->setVariable(
"ID", $this->dom_id);
180 if (count($comps) > 0 && $modal_signal !== null) {
181 $tpl->setVariable(
"SEP", $r->render(
$f->divider()->vertical()));
189 bool $unavailable =
false 191 $f = $this->
ui->factory();
203 $like = $like->withUnavailableAction();
214 $r = $this->
ui->renderer();
217 $ilCtrl->saveParameter($this,
"modal_show_sig_id");
219 $tpl =
new ilTemplate(
"tpl.emoticons.html",
true,
true,
"Services/Like");
220 $tpl->setVariable(
"ID", $this->dom_id);
222 $url = $ilCtrl->getLinkTarget($this,
"",
"",
true);
223 foreach ($this->data->getExpressionTypes() as $k =>
$txt) {
226 if ($this->data->isExpressionSet(
227 $this->user->getId(),
235 $g = $g->withHighlight();
238 $g = $g->withAdditionalOnLoadCode(
function (
$id) use ($k,
$url) {
240 "$('#" .
$id .
"').click(function() { il.Like.toggle('" .
$url .
"','" .
$id .
"','" . $this->dom_id .
"'," . $k .
");});";
245 $tpl->setVariable(
"GLYPHS", $r->renderAsync($glyphs));
257 $exp_key = $this->request->getExpressionKey();
258 $exp_val = $this->request->getValue();
259 $modal_show_sig_id = $this->request->getModalSignalId();
260 $show_signal = new \ILIAS\UI\Implementation\Component\Signal($modal_show_sig_id);
263 $this->data->addExpression(
264 $this->
user->getId(),
273 $this->data->removeExpression(
274 $this->
user->getId(),
298 $f = $this->
ui->factory();
299 $r = $this->
ui->renderer();
304 $glyph_renderings = [];
305 foreach ($this->data->getExpressionEntries(
314 $image =
$f->image()->responsive(
320 $placeholder =
"###" . $exp[
"expression"] .
"###";
321 $glyph_renderings[$placeholder] = $r->render($g);
323 $list_items[] =
$f->item()->standard(
$name)
324 ->withDescription($placeholder .
" " .
326 ->withLeadImage($image);
329 $std_list =
$f->panel()->listing()->standard(
"", array(
330 $f->item()->group(
"", $list_items)
336 $modal =
$f->modal()->roundtrip(
'', [$header, $std_list]);
337 $html = $r->render($modal);
338 foreach ($glyph_renderings as $pl => $gl) {
339 $html = str_replace($pl, $gl, $html);
353 $lng = $DIC->language();
__construct(\ilLikeData $data, ?\ilTemplate $main_tpl=null)
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="ilpublicuserprofilegui")
Default behaviour is:
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
static getExpressionText(int $a_const)
Get expression text for const.
renderModal()
Render modal (asynch)
renderEmoCounters(ILIAS\UI\Component\Signal $modal_signal=null, bool $unavailable=false)
Render emo counters.
renderEmoticons()
Render emoticons (asynch)
StandardGUIRequest $request
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getGlyphForConst(int $a_const, bool $unavailable=false)
getNextClass($a_gui_class=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getPersonalPicturePath(int $a_usr_id, string $a_size="small", bool $a_force_pic=false, bool $a_prevent_no_photo_image=false, bool $html_export=false)
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
ilGlobalTemplateInterface $main_tpl
User interface for like feature.
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)
saveExpression()
Save expression (asynch)