74 $this->main_tpl = ($main_tpl == null)
75 ? $DIC->ui()->mainTemplate()
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();
86 $this->lng->loadLanguageModule(
"like");
96 $this->main_tpl->addJavaScript(
"./Services/Like/js/Like.js");
108 public function setObject($a_obj_id, $a_obj_type, $a_sub_obj_id = 0, $a_sub_obj_type =
"", $a_news_id = 0)
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 .
"_" .
127 $next_class =
$ilCtrl->getNextClass($this);
128 $cmd =
$ilCtrl->getCmd(
"getHTML");
130 switch ($next_class) {
132 if (in_array($cmd, array(
"getHTML",
"renderEmoticons",
"renderModal",
"saveExpression"))) {
133 return $this->$cmd();
153 $f = $this->ui->factory();
154 $r = $this->ui->renderer();
158 $tpl =
new ilTemplate(
"tpl.like.html",
true,
true,
"Services/Like");
161 $modal_asyn_url =
$ctrl->getLinkTarget($this,
"renderModal",
"",
true,
false);
162 $modal =
$f->modal()->roundtrip(
'',
$f->legacy(
""))
163 ->withAsyncRenderUrl($modal_asyn_url);
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));
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());
180 $tpl->setVariable(
"LIKE",
$r->render([$popover, $button]));
196 $tpl =
new ilTemplate(
"tpl.emo_counters.html",
true,
true,
"Services/Like");
197 $f = $this->ui->factory();
198 $r = $this->ui->renderer();
200 $cnts = $this->
data->getExpressionCounts(
208 foreach ($this->
data->getExpressionTypes() as $k =>
$txt) {
211 if ($modal_signal !== null) {
212 $glyph = $glyph->withOnClick($modal_signal);
214 $comps[] = $glyph->withCounter(
$f->counter()->status($cnts[$k]));
219 $tpl->setVariable(
"MODAL_TRIGGER",
$r->renderAsync($comps));
221 $tpl->setVariable(
"MODAL_TRIGGER",
$r->render($comps));
223 if ($modal_signal !== null) {
224 $tpl->setVariable(
"ID", $this->dom_id);
227 if (count($comps) > 0 && $modal_signal !== null) {
228 $tpl->setVariable(
"SEP",
$r->render(
$f->divider()->vertical()));
243 $f = $this->ui->factory();
265 $r = $this->ui->renderer();
267 $ilCtrl->saveParameter($this,
"modal_show_sig_id");
269 $tpl =
new ilTemplate(
"tpl.emoticons.html",
true,
true,
"Services/Like");
270 $tpl->setVariable(
"ID", $this->dom_id);
272 $url =
$ilCtrl->getLinkTarget($this,
"",
"",
true);
273 foreach ($this->
data->getExpressionTypes() as $k =>
$txt) {
276 if ($this->
data->isExpressionSet(
277 $this->user->getId(),
285 $g = $g->withHighlight();
288 $g = $g->withAdditionalOnLoadCode(
function (
$id) use ($k,
$url) {
290 "$('#" .
$id .
"').click(function() { il.Like.toggle('" .
$url .
"','" .
$id .
"','" . $this->dom_id .
"'," . $k .
");});";
295 $tpl->setVariable(
"GLYPHS",
$r->renderAsync($glyphs));
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);
314 $this->
data->addExpression(
315 $this->
user->getId(),
324 $this->
data->removeExpression(
325 $this->
user->getId(),
347 $f = $this->ui->factory();
348 $r = $this->ui->renderer();
352 foreach ($this->
data->getExpressionEntries(
361 $image =
$f->image()->responsive(
362 ilObjUser::_getPersonalPicturePath($exp[
"user_id"]),
368 $list_items[] =
$f->item()->standard(
$name)
369 ->withDescription(
$r->render($g) .
" " .
371 ->withLeadImage($image);
374 $std_list =
$f->panel()->listing()->standard(
"", array(
375 $f->item()->group(
"", $list_items)
381 $modal =
$f->modal()->roundtrip(
'', [
$header, $std_list]);
411 $lng = $DIC->language();
initJavascript()
Init javascript.
static getExpressionText($a_const)
Get unicode for const.
if(!array_key_exists('StateId', $_REQUEST)) $id
renderModal()
Render modal.
renderEmoticons()
Render emoticons.
Data class for like feature.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
setObject($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="", $a_news_id=0)
Set Object.
executeCommand()
Execute command.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
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:
renderEmoCounters($modal_signal=null)
Render emo counters.
getGlyphForConst($a_const)
Get glyph for const.
__construct(\ilLikeData $data, \ilTemplate $main_tpl=null)
ilLikeGUI constructor.
User interface for like feature.
saveExpression()
Save expresseion.