27 protected \ILIAS\News\InternalGUIService
$gui;
28 protected \ILIAS\Notes\Service
$notes;
47 $this->like_gui = $a_like_gui;
48 $this->
lng = $DIC->language();
49 $this->
ctrl = $DIC->ctrl();
51 $this->
user = $DIC->user();
52 $this->obj_def = $DIC[
"objDefinition"];
53 $this->news_item_ref_id = $a_news_ref_id;
55 $this->std_request = $DIC->news()
59 $this->ref_id = $this->std_request->getRefId();
60 $this->gui = $DIC->news()
63 $this->notes = $DIC->notes();
71 return new self($a_news_item, $a_news_ref_id, $a_like_gui);
76 $this->news_item = $a_val;
89 $this->user_edit_all = $a_val;
109 $tpl =
new ilTemplate(
"tpl.timeline_item.html",
true,
true,
"Services/News");
110 $ui_factory = $this->gui->ui()->factory();
111 $ui_renderer = $this->gui->ui()->renderer();
114 $news_renderer->setLanguage($this->
lng->getLangKey());
115 $news_renderer->setNewsItem($i, $this->news_item_ref_id);
117 $obj_id = $i->getContextObjId();
120 if ($i->getCreationDate() !== $i->getUpdateDate()) {
121 $tpl->setCurrentBlock(
"edited");
123 $tpl->setVariable(
"TXT_EDITED", $this->
lng->txt(
"cont_news_edited"));
124 if ($i->getUpdateUserId() > 0 && ($i->getUpdateUserId() !== $i->getUserId())) {
126 $i->getUpdateUserId(),
129 $this->
ctrl->getLinkTargetByClass(
"ilnewstimelinegui")
133 $tpl->parseCurrentBlock();
137 if ($this->news_item_ref_id > 0 && $this->ref_id !== $this->news_item_ref_id) {
138 $tpl->setCurrentBlock(
"object");
141 $tpl->setVariable(
"OBJ_HREF", $news_renderer->getObjectLink());
142 $tpl->parseCurrentBlock();
148 $tpl->setCurrentBlock(
"player");
149 $tpl->setVariable(
"PLAYER", $media);
150 $tpl->parseCurrentBlock();
153 $p = $this->gui->profile();
154 $tpl->setVariable(
"USER_AVATAR", $this->gui->ui()->renderer()->render(
155 $p->getAvatar($i->getUserId())
163 $tpl->setVariable(
"CONTENT", $news_renderer->getTimelineContent());
165 $tpl->setVariable(
"TXT_USR", $p->getNamePresentation(
168 $this->
ctrl->getLinkTargetByClass(
"ilnewstimelinegui")
176 if ($i->getPriority() === 1 && ($i->getUserId() === $this->
user->getId() || $this->
getUserEditAll())) {
177 if (!$news_renderer->preventEditing()) {
178 $actions[] = $ui_factory->button()->shy(
179 $this->
lng->txt(
"edit"),
182 return "document.getElementById('$id').addEventListener('click', () => {il.News.edit(" . $i->getId() .
");});";
184 $actions[] = $ui_factory->button()->shy(
185 $this->
lng->txt(
"delete"),
188 return "document.getElementById('$id').addEventListener('click', () => {il.News.delete(" . $i->getId() .
");});";
192 foreach ($news_renderer->getTimelineActions() as $action) {
193 $actions[] = $action;
195 $dd = $ui_factory->dropdown()->standard($actions);
196 $tpl->setVariable(
"ACTIONS", $ui_renderer->render($dd));
208 $ui_factory = $DIC->ui()->factory();
209 $ui_renderer = $DIC->ui()->renderer();
211 if (in_array($mime, [
"image/jpeg",
"image/svg+xml",
"image/gif",
"image/png"])) {
212 $item_id =
"il-news-modal-img-" . $i->
getId();
213 $title = basename($media_path);
214 $image = $ui_renderer->render($ui_factory->image()->responsive($media_path, $title));
216 $img_tpl =
new ilTemplate(
"tpl.news_timeline_image_file.html",
true,
true,
"Services/News");
217 $img_tpl->setVariable(
"ITEM_ID", $item_id);
218 $img_tpl->setVariable(
"IMAGE", $image);
220 $html = $img_tpl->get();
221 } elseif (in_array($mime, [
"video/mp4",
"video/youtube",
"video/vimeo"])) {
222 $video = $ui_factory->player()->video($media_path);
223 $html = $ui_renderer->render($video);
224 } elseif (in_array($mime, [
"audio/mpeg"])) {
225 $audio = $ui_factory->player()->audio($media_path);
226 $html = $ui_renderer->render($audio);
227 } elseif (in_array($mime, [
"application/pdf"])) {
228 $this->
ctrl->setParameterByClass(
"ilnewstimelinegui",
"news_id", $i->
getId());
229 $link = $ui_factory->link()->standard(
230 basename($media_path),
231 $this->
ctrl->getLinkTargetByClass(
"ilnewstimelinegui",
"downloadMob")
233 $html = $ui_renderer->render($link);
234 $this->
ctrl->setParameterByClass(
"ilnewstimelinegui",
"news_id", null);
248 $ui_factory = $DIC->ui()->factory();
249 $ui_renderer = $DIC->ui()->renderer();
253 if (in_array($mime, [
"image/jpeg",
"image/svg+xml",
"image/gif",
"image/png"])) {
254 $title = basename($media_path);
255 $item_id =
"il-news-modal-img-" . $i->
getId();
256 $image = $ui_renderer->render($ui_factory->image()->responsive($media_path, $title));
258 $modal->setId($item_id);
260 $modal->setBody($image);
261 $modal->setHeading($title);
262 $modal_html = $modal->getHTML();
272 $this->
ctrl->setParameterByClass(
"ilnewstimelinegui",
"news_id", $i->getId());
273 $this->like_gui->setObject(
274 $i->getContextObjId(),
275 $i->getContextObjType(),
276 $i->getContextSubObjId(),
277 (string) $i->getContextSubObjType(),
280 $html = $this->
ctrl->getHTML($this->like_gui);
283 $notes_obj_type = ($i->getContextSubObjType() ==
"")
284 ? $i->getContextObjType()
285 : $i->getContextSubObjType();
286 $comments_gui = $this->notes->gui()->getCommentsGUI(
287 $i->getContextObjId(),
288 $i->getContextSubObjId(),
292 $comments_gui->setDefaultCommand(
"getWidget");
293 $comments_gui->setShowEmptyListMessage(
false);
294 $comments_gui->setShowHeader(
false);
295 $html .= $comments_gui->getWidget();
298 $this->
ctrl->setParameterByClass(
"ilnewstimelinegui",
"news_id", $this->std_request->getNewsId());
309 if (strcasecmp(
"Reference", $med->getLocationType()) === 0) {
310 $media_path = $med->getLocation();
Single news timeline item.
renderMediaModal(ilNewsItem $i)
getUserEditAll()
Get user can edit other users postings.
getDateTime()
Get datetime.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
ILIAS Notes Service $notes
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
__construct(ilNewsItem $a_news_item, int $a_news_ref_id, ilLikeGUI $a_like_gui)
renderMedia(ilNewsItem $i)
withOnLoadCode(Closure $binder)
static getRenderer(string $a_context_obj_type)
parses the objects.xml it handles the xml-description of all ilias objects
setUserEditAll(bool $a_val)
Set user can edit other users postings.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
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:
static _lookupTitle(int $obj_id)
static determineNewsTitle(string $a_context_obj_type, string $a_title, bool $a_content_is_lang_var, int $a_agg_ref_id=0, array $a_aggregation=[], ?ilLanguage $lng=null)
Determine title for news item entry.
getMediaPath(ilNewsItem $i)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS News InternalGUIService $gui
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A news item can be created by different sources.
static getInstance(ilNewsItem $a_news_item, int $a_news_ref_id, ilLikeGUI $a_like_gui)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
User interface for like feature.
setNewsItem(ilNewsItem $a_val)
StandardGUIRequest $std_request
ilObjectDefinition $obj_def