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");
70 $this->main_tpl->addJavaScript(
"./Services/Like/js/Like.js");
76 int $a_sub_obj_id = 0,
77 string $a_sub_obj_type =
"",
80 $this->obj_id = $a_obj_id;
81 $this->obj_type = $a_obj_type;
82 $this->sub_obj_id = $a_sub_obj_id;
83 $this->sub_obj_type = $a_sub_obj_type;
84 $this->news_id = $a_news_id;
85 $this->dom_id =
"like_" . $this->obj_id .
"_" . $this->obj_type .
"_" . $this->sub_obj_id .
"_" .
94 $cmd = $ilCtrl->getCmd(
"getHTML");
96 switch ($next_class) {
98 if (in_array($cmd, array(
"getHTML",
"renderEmoticons",
"renderModal",
"saveExpression"))) {
108 $f = $this->
ui->factory();
109 $r = $this->
ui->renderer();
113 $tpl =
new ilTemplate(
"tpl.like.html",
true,
true,
"Services/Like");
116 $modal_asyn_url = $ctrl->
getLinkTarget($this,
"renderModal",
"",
true,
false);
117 $modal =
$f->modal()->roundtrip(
'',
$f->legacy(
""))
118 ->withAsyncRenderUrl($modal_asyn_url);
120 $modal_show_sig_id = $modal->getShowSignal()->getId();
121 $this->
ctrl->setParameter($this,
"modal_show_sig_id", $modal_show_sig_id);
123 $tpl->setVariable(
"EMO_COUNTERS", $emo_counters .
$r->render($modal));
128 $popover =
$f->popover()->standard(
$f->legacy(
''))->withTitle(
'');
129 $ctrl->
setParameter($this,
"repl_sig", $popover->getReplaceContentSignal()->getId());
130 $asyn_url = $ctrl->
getLinkTarget($this,
"renderEmoticons",
"",
true,
false);
131 $popover = $popover->withAsyncContentUrl($asyn_url);
132 $button =
$f->button()->shy($lng->
txt(
"like"),
'#')
133 ->withOnClick($popover->getShowSignal());
135 $tpl->setVariable(
"LIKE",
$r->render([$popover, $button]));
146 bool $unavailable =
false 150 $tpl =
new ilTemplate(
"tpl.emo_counters.html",
true,
true,
"Services/Like");
151 $f = $this->
ui->factory();
152 $r = $this->
ui->renderer();
154 $cnts = $this->data->getExpressionCounts(
162 foreach ($this->data->getExpressionTypes() as $k =>
$txt) {
165 if ($modal_signal !== null) {
166 $glyph = $glyph->withOnClick($modal_signal);
168 $comps[] = $glyph->withCounter(
$f->counter()->status($cnts[$k]));
172 if ($ilCtrl->isAsynch()) {
173 $tpl->setVariable(
"MODAL_TRIGGER",
$r->renderAsync($comps));
175 $tpl->setVariable(
"MODAL_TRIGGER",
$r->render($comps));
177 if ($modal_signal !== null) {
178 $tpl->setVariable(
"ID", $this->dom_id);
181 if (count($comps) > 0 && $modal_signal !== null) {
182 $tpl->setVariable(
"SEP",
$r->render(
$f->divider()->vertical()));
190 bool $unavailable =
false 192 $f = $this->
ui->factory();
211 $like = $like->withUnavailableAction();
222 $r = $this->
ui->renderer();
225 $ilCtrl->saveParameter($this,
"modal_show_sig_id");
227 $tpl =
new ilTemplate(
"tpl.emoticons.html",
true,
true,
"Services/Like");
228 $tpl->setVariable(
"ID", $this->dom_id);
230 $url = $ilCtrl->getLinkTarget($this,
"",
"",
true);
231 foreach ($this->data->getExpressionTypes() as $k =>
$txt) {
234 if ($this->data->isExpressionSet(
235 $this->user->getId(),
243 $g = $g->withHighlight();
246 $g = $g->withAdditionalOnLoadCode(
function (
$id) use ($k,
$url) {
248 "$('#" .
$id .
"').click(function() { il.Like.toggle('" .
$url .
"','" .
$id .
"','" . $this->dom_id .
"'," . $k .
");});";
253 $tpl->setVariable(
"GLYPHS",
$r->renderAsync($glyphs));
265 $exp_key = $this->request->getExpressionKey();
266 $exp_val = $this->request->getValue();
267 $modal_show_sig_id = $this->request->getModalSignalId();
268 $show_signal = new \ILIAS\UI\Implementation\Component\Signal($modal_show_sig_id);
271 $this->data->addExpression(
272 $this->
user->getId(),
281 $this->data->removeExpression(
282 $this->
user->getId(),
306 $f = $this->
ui->factory();
307 $r = $this->
ui->renderer();
312 $glyph_renderings = [];
313 foreach ($this->data->getExpressionEntries(
322 $image =
$f->image()->responsive(
328 $placeholder =
"###" . $exp[
"expression"] .
"###";
329 $glyph_renderings[$placeholder] =
$r->render($g);
331 $list_items[] =
$f->item()->standard($name)
332 ->withDescription($placeholder .
" " .
334 ->withLeadImage($image);
337 $std_list =
$f->panel()->listing()->standard(
"", array(
338 $f->item()->group(
"", $list_items)
344 $modal =
$f->modal()->roundtrip(
'', [$header, $std_list]);
345 $html =
$r->render($modal);
346 foreach ($glyph_renderings as $pl => $gl) {
347 $html = str_replace($pl, $gl, $html);
361 $lng = $DIC->language();
__construct(\ilLikeData $data, ?\ilTemplate $main_tpl=null)
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)
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:
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)
ilGlobalTemplateInterface $main_tpl
User interface for like feature.
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
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)