ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilNewsTimelineItemGUI Class Reference

Single news timeline item. More...

+ Inheritance diagram for ilNewsTimelineItemGUI:
+ Collaboration diagram for ilNewsTimelineItemGUI:

Public Member Functions

 setNewsItem (ilNewsItem $a_val)
 
 getNewsItem ()
 
 setUserEditAll (bool $a_val)
 Set user can edit other users postings. More...
 
 getUserEditAll ()
 Get user can edit other users postings. More...
 
 getDateTime ()
 Get datetime. More...
 
 render ()
 Render item. More...
 
 renderFooter ()
 
 render ()
 Render item. More...
 
 getDateTime ()
 Get datetime. More...
 

Static Public Member Functions

static getInstance (ilNewsItem $a_news_item, int $a_news_ref_id, ilLikeGUI $a_like_gui)
 

Protected Member Functions

 __construct (ilNewsItem $a_news_item, int $a_news_ref_id, ilLikeGUI $a_like_gui)
 
 renderMedia (ilNewsItem $i)
 
 renderMediaModal (ilNewsItem $i)
 
 getMediaPath (ilNewsItem $i)
 

Protected Attributes

ILIAS News InternalGUIService $gui
 
ILIAS Notes Service $notes
 
ilLanguage $lng
 
ilNewsItem $news_item
 
ilObjectDefinition $obj_def
 
ilObjUser $user
 
bool $user_edit_all
 
int $news_item_ref_id
 
int $ref_id
 
ilCtrl $ctrl
 
ilLikeGUI $like_gui
 
StandardGUIRequest $std_request
 
array $item_image = []
 
array $item_modal = []
 

Detailed Description

Single news timeline item.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 25 of file class.ilNewsTimelineItemGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilNewsTimelineItemGUI::__construct ( ilNewsItem  $a_news_item,
int  $a_news_ref_id,
ilLikeGUI  $a_like_gui 
)
protected

Definition at line 48 of file class.ilNewsTimelineItemGUI.php.

52 {
53 global $DIC;
54
55 $this->like_gui = $a_like_gui;
56 $this->lng = $DIC->language();
57 $this->ctrl = $DIC->ctrl();
58 $this->setNewsItem($a_news_item);
59 $this->user = $DIC->user();
60 $this->obj_def = $DIC["objDefinition"];
61 $this->news_item_ref_id = $a_news_ref_id;
62
63 $this->std_request = $DIC->news()
64 ->internal()
65 ->gui()
66 ->standardRequest();
67 $this->ref_id = $this->std_request->getRefId();
68 $this->gui = $DIC->news()
69 ->internal()
70 ->gui();
71 $this->notes = $DIC->notes();
72 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), setNewsItem(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDateTime()

ilNewsTimelineItemGUI::getDateTime ( )

Get datetime.

Returns
ilDateTime timestamp

Implements ilTimelineItemInt.

Definition at line 108 of file class.ilNewsTimelineItemGUI.php.

108 : ilDateTime
109 {
110 $i = $this->getNewsItem();
111 return new ilDateTime($i->getCreationDate(), IL_CAL_DATETIME);
112 }
const IL_CAL_DATETIME
@classDescription Date and time handling

References IL_CAL_DATETIME.

◆ getInstance()

static ilNewsTimelineItemGUI::getInstance ( ilNewsItem  $a_news_item,
int  $a_news_ref_id,
ilLikeGUI  $a_like_gui 
)
static

Definition at line 74 of file class.ilNewsTimelineItemGUI.php.

78 : self {
79 return new self($a_news_item, $a_news_ref_id, $a_like_gui);
80 }

Referenced by ilNewsTimelineGUI\getHTML(), and ilNewsTimelineGUI\loadMore().

+ Here is the caller graph for this function:

◆ getMediaPath()

ilNewsTimelineItemGUI::getMediaPath ( ilNewsItem  $i)
protected

Definition at line 313 of file class.ilNewsTimelineItemGUI.php.

313 : string
314 {
315 $media_path = "";
316 if ($i->getMobId() > 0) {
317 $mob = new ilObjMediaObject($i->getMobId());
318 $media_path = $mob->getStandardSrc();
319 }
320 return $media_path;
321 }

References ilNewsItem\getMobId().

+ Here is the call graph for this function:

◆ getNewsItem()

ilNewsTimelineItemGUI::getNewsItem ( )

Definition at line 87 of file class.ilNewsTimelineItemGUI.php.

88 {
89 return $this->news_item;
90 }
A news item can be created by different sources.

◆ getUserEditAll()

ilNewsTimelineItemGUI::getUserEditAll ( )

Get user can edit other users postings.

Definition at line 103 of file class.ilNewsTimelineItemGUI.php.

103 : bool
104 {
106 }

◆ render()

ilNewsTimelineItemGUI::render ( )

Render item.

Returns
string html

Implements ilTimelineItemInt.

Definition at line 114 of file class.ilNewsTimelineItemGUI.php.

114 : string
115 {
116 $i = $this->getNewsItem();
117 $tpl = new ilTemplate("tpl.timeline_item.html", true, true, "components/ILIAS/News");
118 $ui_factory = $this->gui->ui()->factory();
119 $ui_renderer = $this->gui->ui()->renderer();
120
121 $news_renderer = ilNewsRendererFactory::getRenderer($i->getContextObjType());
122 $news_renderer->setLanguage($this->lng->getLangKey());
123 $news_renderer->setNewsItem($i, $this->news_item_ref_id);
124
125 $obj_id = $i->getContextObjId();
126
127 // edited?
128 if ($i->getCreationDate() !== $i->getUpdateDate()) {
129 $tpl->setCurrentBlock("edited");
130 $update_date = new ilDateTime($i->getUpdateDate(), IL_CAL_DATETIME);
131 $tpl->setVariable("TXT_EDITED", $this->lng->txt("cont_news_edited"));
132 if ($i->getUpdateUserId() > 0 && ($i->getUpdateUserId() !== $i->getUserId())) {
133 $tpl->setVariable("TXT_USR_EDITED", ilUserUtil::getNamePresentation(
134 $i->getUpdateUserId(),
135 false,
136 true,
137 $this->ctrl->getLinkTargetByClass("ilnewstimelinegui")
138 ) . " - ");
139 }
140 $tpl->setVariable("TIME_EDITED", ilDatePresentation::formatDate($update_date));
141 $tpl->parseCurrentBlock();
142 }
143
144 // context object link
145 if ($this->news_item_ref_id > 0 && $this->ref_id !== $this->news_item_ref_id) {
146 $tpl->setCurrentBlock("object");
147 $tpl->setVariable("OBJ_TITLE", ilObject::_lookupTitle($obj_id));
148 $tpl->setVariable("OBJ_IMG", ilObject::_getIcon($obj_id));
149 $tpl->setVariable("OBJ_HREF", $news_renderer->getObjectLink());
150 $tpl->parseCurrentBlock();
151 }
152
153 // media
154 if ($i->getMobId() > 0 && ilObject::_exists($i->getMobId())) {
155 $media = $this->renderMedia($i);
156 $tpl->setCurrentBlock("player");
157 $tpl->setVariable("PLAYER", $media);
158 $tpl->parseCurrentBlock();
159 }
160
161 $p = $this->gui->profile();
162 $tpl->setVariable("USER_AVATAR", $this->gui->ui()->renderer()->render(
163 $p->getAvatar($i->getUserId())
164 ));
165 $tpl->setVariable(
166 "TITLE",
167 ilNewsItem::determineNewsTitle($i->getContextObjType(), $i->getTitle(), $i->getContentIsLangVar())
168 );
169
170 // content
171 $tpl->setVariable("CONTENT", $news_renderer->getTimelineContent());
172
173 $tpl->setVariable("TXT_USR", $p->getNamePresentation(
174 $i->getUserId(),
175 true,
176 $this->ctrl->getLinkTargetByClass("ilnewstimelinegui")
177 ));
178
179 $tpl->setVariable("TIME", ilDatePresentation::formatDate($this->getDateTime()));
180
181 // actions
182 $actions = [];
183
184 if ($i->getPriority() === 1 && ($i->getUserId() === $this->user->getId() || $this->getUserEditAll())) {
185 if (!$news_renderer->preventEditing()) {
186 $actions[] = $ui_factory->button()->shy(
187 $this->lng->txt("edit"),
188 ""
189 )->withOnLoadCode(static function ($id) use ($i) {
190 return "document.getElementById('$id').addEventListener('click', () => {il.News.edit(" . $i->getId() . ");});";
191 });
192 $actions[] = $ui_factory->button()->shy(
193 $this->lng->txt("delete"),
194 ""
195 )->withOnLoadCode(static function ($id) use ($i) {
196 return "document.getElementById('$id').addEventListener('click', () => {il.News.delete(" . $i->getId() . ");});";
197 });
198 }
199 }
200 foreach ($news_renderer->getTimelineActions() as $action) {
201 $actions[] = $action;
202 }
203 $dd = $ui_factory->dropdown()->standard($actions);
204 $tpl->setVariable("ACTIONS", $ui_renderer->render($dd));
205
206 return $tpl->get();
207 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
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.
static getRenderer(string $a_context_obj_type)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupTitle(int $obj_id)
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:

References $id, ilObject\_exists(), ilObject\_getIcon(), ilObject\_lookupTitle(), ilNewsItem\determineNewsTitle(), ilDatePresentation\formatDate(), ilUserUtil\getNamePresentation(), ilNewsRendererFactory\getRenderer(), IL_CAL_DATETIME, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ renderFooter()

ilNewsTimelineItemGUI::renderFooter ( )

Definition at line 278 of file class.ilNewsTimelineItemGUI.php.

278 : string
279 {
280 $i = $this->getNewsItem();
281
282 // like
283 $this->ctrl->setParameterByClass("ilnewstimelinegui", "news_id", $i->getId());
284 $this->like_gui->setObject(
285 $i->getContextObjId(),
286 $i->getContextObjType(),
287 $i->getContextSubObjId(),
288 (string) $i->getContextSubObjType(),
289 $i->getId()
290 );
291 $html = $this->ctrl->getHTML($this->like_gui);
292
293 // comments
294 $notes_obj_type = ($i->getContextSubObjType() == "")
295 ? $i->getContextObjType()
296 : $i->getContextSubObjType();
297 $comments_gui = $this->notes->gui()->getCommentsGUI(
298 $i->getContextObjId(),
299 $i->getContextSubObjId(),
300 $notes_obj_type,
301 $i->getId()
302 );
303 $comments_gui->setDefaultCommand("getWidget");
304 $comments_gui->setShowEmptyListMessage(false);
305 $comments_gui->setShowHeader(false);
306 $html .= $comments_gui->getWidget();
307 //$html .= $this->ctrl->getHTML($comments_gui);
308
309 $this->ctrl->setParameterByClass("ilnewstimelinegui", "news_id", $this->std_request->getNewsId());
310 return $html . $this->renderMediaModal($i);
311 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ renderMedia()

ilNewsTimelineItemGUI::renderMedia ( ilNewsItem  $i)
protected

Definition at line 209 of file class.ilNewsTimelineItemGUI.php.

209 : string
210 {
211 $media_path = $this->getMediaPath($i);
212 $mime = ilObjMediaObject::getMimeType($media_path);
213
214 $ui_factory = $this->gui->ui()->factory();
215 $ui_renderer = $this->gui->ui()->renderer();
216
217 if (in_array($mime, ["image/jpeg", "image/svg+xml", "image/gif", "image/png"])) {
218 if (isset($this->item_image[$i->getId()]) && isset($this->item_modal[$i->getId()])) {
219 $image = $this->item_image[$i->getId()];
220 } else {
221 $title = basename($media_path);
222 $image = $ui_factory->image()->responsive($media_path, $title);
223 $modal_page = $ui_factory->modal()->lightboxImagePage($image, $title);
224 $modal = $ui_factory->modal()->lightbox($modal_page);
225 $image = $image->withAction($modal->getShowSignal());
226 $this->item_image[$i->getId()] = $image;
227 $this->item_modal[$i->getId()] = $modal;
228 }
229 $html = $ui_renderer->render($image);
230 } elseif (in_array($mime, ["video/mp4", "video/youtube", "video/vimeo"])) {
231 $video = $ui_factory->player()->video($media_path);
232 $html = $ui_renderer->render($video);
233 } elseif (in_array($mime, ["audio/mpeg"])) {
234 $audio = $ui_factory->player()->audio($media_path);
235 $html = $ui_renderer->render($audio);
236 } elseif (in_array($mime, ["application/pdf"])) {
237 $this->ctrl->setParameterByClass("ilnewstimelinegui", "news_id", $i->getId());
238 $link = $ui_factory->link()->standard(
239 basename($media_path),
240 $this->ctrl->getLinkTargetByClass("ilnewstimelinegui", "downloadMob")
241 );
242 $html = $ui_renderer->render($link);
243 $this->ctrl->setParameterByClass("ilnewstimelinegui", "news_id", null);
244 } else {
245 $html = "";
246 }
247 return $html;
248 }
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file

References ILIAS\Repository\ctrl(), ilNewsItem\getId(), and ilObjMediaObject\getMimeType().

+ Here is the call graph for this function:

◆ renderMediaModal()

ilNewsTimelineItemGUI::renderMediaModal ( ilNewsItem  $i)
protected

Definition at line 250 of file class.ilNewsTimelineItemGUI.php.

250 : string
251 {
252 $ui_factory = $this->gui->ui()->factory();
253 $ui_renderer = $this->gui->ui()->renderer();
254
255 if (isset($this->item_image[$i->getId()]) && isset($this->item_modal[$i->getId()])) {
256 $modal = $this->item_modal[$i->getId()];
257 return $ui_renderer->render($modal);
258 }
259
260 $media_path = $this->getMediaPath($i);
261 $mime = ilObjMediaObject::getMimeType($media_path);
262
263 $modal_html = "";
264
265 if (in_array($mime, ["image/jpeg", "image/svg+xml", "image/gif", "image/png"])) {
266 $title = basename($media_path);
267 $image = $ui_factory->image()->responsive($media_path, $title);
268 $modal_page = $ui_factory->modal()->lightboxImagePage($image, $title);
269 $modal = $ui_factory->modal()->lightbox($modal_page);
270 $image = $image->withAction($modal->getShowSignal());
271 $this->item_image[$i->getId()] = $image;
272 $this->item_modal[$i->getId()] = $modal;
273 $modal_html = $ui_renderer->render($modal);
274 }
275 return $modal_html;
276 }

References ilNewsItem\getId(), and ilObjMediaObject\getMimeType().

+ Here is the call graph for this function:

◆ setNewsItem()

ilNewsTimelineItemGUI::setNewsItem ( ilNewsItem  $a_val)

Definition at line 82 of file class.ilNewsTimelineItemGUI.php.

82 : void
83 {
84 $this->news_item = $a_val;
85 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setUserEditAll()

ilNewsTimelineItemGUI::setUserEditAll ( bool  $a_val)

Set user can edit other users postings.

Definition at line 95 of file class.ilNewsTimelineItemGUI.php.

95 : void
96 {
97 $this->user_edit_all = $a_val;
98 }

Field Documentation

◆ $ctrl

ilCtrl ilNewsTimelineItemGUI::$ctrl
protected

Definition at line 36 of file class.ilNewsTimelineItemGUI.php.

◆ $gui

ILIAS News InternalGUIService ilNewsTimelineItemGUI::$gui
protected

Definition at line 27 of file class.ilNewsTimelineItemGUI.php.

◆ $item_image

array ilNewsTimelineItemGUI::$item_image = []
protected

Definition at line 42 of file class.ilNewsTimelineItemGUI.php.

◆ $item_modal

array ilNewsTimelineItemGUI::$item_modal = []
protected

Definition at line 46 of file class.ilNewsTimelineItemGUI.php.

◆ $like_gui

ilLikeGUI ilNewsTimelineItemGUI::$like_gui
protected

Definition at line 37 of file class.ilNewsTimelineItemGUI.php.

◆ $lng

ilLanguage ilNewsTimelineItemGUI::$lng
protected

Definition at line 29 of file class.ilNewsTimelineItemGUI.php.

◆ $news_item

ilNewsItem ilNewsTimelineItemGUI::$news_item
protected

Definition at line 30 of file class.ilNewsTimelineItemGUI.php.

◆ $news_item_ref_id

int ilNewsTimelineItemGUI::$news_item_ref_id
protected

Definition at line 34 of file class.ilNewsTimelineItemGUI.php.

◆ $notes

ILIAS Notes Service ilNewsTimelineItemGUI::$notes
protected

Definition at line 28 of file class.ilNewsTimelineItemGUI.php.

◆ $obj_def

ilObjectDefinition ilNewsTimelineItemGUI::$obj_def
protected

Definition at line 31 of file class.ilNewsTimelineItemGUI.php.

◆ $ref_id

int ilNewsTimelineItemGUI::$ref_id
protected

Definition at line 35 of file class.ilNewsTimelineItemGUI.php.

◆ $std_request

StandardGUIRequest ilNewsTimelineItemGUI::$std_request
protected

Definition at line 38 of file class.ilNewsTimelineItemGUI.php.

◆ $user

ilObjUser ilNewsTimelineItemGUI::$user
protected

Definition at line 32 of file class.ilNewsTimelineItemGUI.php.

◆ $user_edit_all

bool ilNewsTimelineItemGUI::$user_edit_all
protected

Definition at line 33 of file class.ilNewsTimelineItemGUI.php.


The documentation for this class was generated from the following file: