ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilNewsTimelineItemGUI Class Reference

Single news timeline item. More...

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

Public Member Functions

 setNewsItem (ilNewsItem $a_val)
 Set news item. More...
 
 getNewsItem ()
 Get news item. More...
 
 setUserEditAll ($a_val)
 Set user can edit other users postings. More...
 
 getUserEditAll ()
 Get user can edit other users postings. More...
 
 getDateTime ()
 Get datetime.
Returns
ilDateTime timestamp
More...
 
 render ()
 Render item.
Returns
string html
More...
 
 renderFooter ()
 Render footer. More...
 

Static Public Member Functions

static getInstance (ilNewsItem $a_news_item, $a_news_ref_id, \ilLikeGUI $a_like_gui)
 Get instance. More...
 

Protected Member Functions

 __construct (ilNewsItem $a_news_item, $a_news_ref_id, \ilLikeGUI $a_like_gui)
 Constructor. More...
 
 renderMedia (ilNewsItem $i)
 Render media. More...
 
 renderMediaModal (ilNewsItem $i)
 Render media. More...
 
 getMediaPath (ilNewsItem $i)
 

Protected Attributes

 $lng
 
 $news_item
 
 $obj_def
 
 $user
 
 $user_edit_all
 
 $news_item_ref_id
 
 $ref_id
 
 $ctrl
 
 $like_gui
 

Detailed Description

Single news timeline item.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
ilNewsItem$a_news_item
$a_news_ref_id
ilLikeGUI$a_like_gui

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

References $_GET, $DIC, setNewsItem(), and user().

70  {
71  global $DIC;
72 
73  $this->like_gui = $a_like_gui;
74 
75  $this->lng = $DIC->language();
76  $this->ctrl = $DIC->ctrl();
77  $this->setNewsItem($a_news_item);
78  $this->user = $DIC->user();
79  $this->obj_def = $DIC["objDefinition"];
80  $this->news_item_ref_id = $a_news_ref_id;
81 
82  $this->ref_id = (int) $_GET["ref_id"];
83  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
user()
Definition: user.php:4
setNewsItem(ilNewsItem $a_val)
Set news item.
+ Here is the call graph for this function:

Member Function Documentation

◆ getDateTime()

ilNewsTimelineItemGUI::getDateTime ( )

Get datetime.

Returns
ilDateTime timestamp

Implements ilTimelineItemInt.

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

References $i, getNewsItem(), and IL_CAL_DATETIME.

Referenced by render().

141  {
142  $i = $this->getNewsItem();
143  return new ilDateTime($i->getCreationDate(), IL_CAL_DATETIME);
144  }
const IL_CAL_DATETIME
Date and time handling
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstance()

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

Get instance.

Parameters
ilNewsItem$a_news_itemnews item
Returns
ilNewsTimelineItemGUI

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

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

92  {
93  return new self($a_news_item, $a_news_ref_id, $a_like_gui);
94  }
+ Here is the caller graph for this function:

◆ getMediaPath()

ilNewsTimelineItemGUI::getMediaPath ( ilNewsItem  $i)
protected
Parameters
ilNewsItem$i
Returns
string

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

References ilObjMediaObject\_getURL(), ilObjMediaObject\getMediaItem(), and ilNewsItem\getMobId().

Referenced by renderMedia(), and renderMediaModal().

379  {
380  $media_path = "";
381  if ($i->getMobId() > 0) {
382  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
383  include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
384  $mob = new ilObjMediaObject($i->getMobId());
385  $med = $mob->getMediaItem("Standard");
386  if (strcasecmp("Reference", $med->getLocationType()) == 0) {
387  $media_path = $med->getLocation();
388  } else {
389  $media_path = ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation();
390  }
391  }
392  return $media_path;
393  }
& getMediaItem($a_purpose)
get item for media purpose
getMobId()
Get MobId.
static _getURL($a_mob_id)
get directory for files of media object (static)
Class ilObjMediaObject.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNewsItem()

ilNewsTimelineItemGUI::getNewsItem ( )

Get news item.

Returns
ilNewsItem news item

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

References $news_item.

Referenced by getDateTime(), render(), and renderFooter().

+ Here is the caller graph for this function:

◆ getUserEditAll()

ilNewsTimelineItemGUI::getUserEditAll ( )

Get user can edit other users postings.

Returns
bool user can edit all postings

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

References $user_edit_all.

Referenced by render().

+ Here is the caller graph for this function:

◆ render()

ilNewsTimelineItemGUI::render ( )

Render item.

Returns
string html

Implements ilTimelineItemInt.

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

References $i, $list, $tpl, ilObject\_exists(), ilObject\_lookupTitle(), ilNewsItem\determineNewsTitle(), ilAdvancedSelectionListGUI\DOWN_ARROW_DARK, ilDatePresentation\formatDate(), getDateTime(), ilUserUtil\getNamePresentation(), getNewsItem(), ilNewsRendererFactory\getRenderer(), getUserEditAll(), IL_CAL_DATETIME, renderMedia(), and user().

151  {
152  $i = $this->getNewsItem();
153  $tpl = new ilTemplate("tpl.timeline_item.html", true, true, "Services/News");
154 
155  include_once("./Services/News/classes/class.ilNewsRendererFactory.php");
156  $news_renderer = ilNewsRendererFactory::getRenderer($i->getContextObjType());
157  $news_renderer->setLanguage($this->lng->getLangKey());
158  $news_renderer->setNewsItem($i, $this->news_item_ref_id);
159 
160  $obj_id = $i->getContextObjId();
161 
162  // edited?
163  if ($i->getCreationDate() != $i->getUpdateDate()) {
164  $tpl->setCurrentBlock("edited");
165  $update_date = new ilDateTime($i->getUpdateDate(), IL_CAL_DATETIME);
166  $tpl->setVariable("TXT_EDITED", $this->lng->txt("cont_news_edited"));
167  if ($i->getUpdateUserId() > 0 && ($i->getUpdateUserId() != $i->getUserId())) {
168  include_once("./Services/User/classes/class.ilUserUtil.php");
169  $tpl->setVariable("TXT_USR_EDITED", ilUserUtil::getNamePresentation(
170  $i->getUpdateUserId(),
171  false,
172  true,
173  $this->ctrl->getLinkTargetByClass("ilnewstimelinegui")
174  ) . " - ");
175  }
176  include_once("./Services/Calendar/classes/class.ilDatePresentation.php");
177  $tpl->setVariable("TIME_EDITED", ilDatePresentation::formatDate($update_date));
178  $tpl->parseCurrentBlock();
179  }
180 
181 
182  // context object link
183  include_once("./Services/Link/classes/class.ilLink.php");
184  if ($this->news_item_ref_id > 0 && $this->ref_id != $this->news_item_ref_id) {
185  $tpl->setCurrentBlock("object");
186  $tpl->setVariable("OBJ_TITLE", ilObject::_lookupTitle($obj_id));
187  $tpl->setVariable("OBJ_IMG", ilObject::_getIcon($obj_id));
188  $tpl->setVariable("OBJ_HREF", $news_renderer->getObjectLink());
189  $tpl->parseCurrentBlock();
190  }
191 
192  // media
193  if ($i->getMobId() > 0 && ilObject::_exists($i->getMobId())) {
194  $media = $this->renderMedia($i);
195  $tpl->setCurrentBlock("player");
196  $tpl->setVariable("PLAYER", $media);
197  $tpl->parseCurrentBlock();
198  }
199 
200  $tpl->setVariable("USER_IMAGE", ilObjUser::_getPersonalPicturePath($i->getUserId(), "xsmall"));
201  $tpl->setVariable(
202  "TITLE",
203  ilNewsItem::determineNewsTitle($i->getContextObjType(), $i->getTitle(), $i->getContentIsLangVar())
204  );
205 
206  // content
207  $tpl->setVariable("CONTENT", $news_renderer->getTimelineContent());
208 
209  include_once("./Services/User/classes/class.ilUserUtil.php");
210  $tpl->setVariable("TXT_USR", ilUserUtil::getNamePresentation(
211  $i->getUserId(),
212  false,
213  true,
214  $this->ctrl->getLinkTargetByClass("ilnewstimelinegui")
215  ));
216 
217  include_once("./Services/Calendar/classes/class.ilDatePresentation.php");
218  $tpl->setVariable("TIME", ilDatePresentation::formatDate($this->getDateTime()));
219 
220  // actions
221  include_once("Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
223  $list->setListTitle("");
224  $list->setId("news_tl_act_" . $i->getId());
225  //$list->setSelectionHeaderClass("small");
226  //$list->setItemLinkClass("xsmall");
227  //$list->setLinksMode("il_ContainerItemCommand2");
229  $list->setUseImages(false);
230 
231  if ($i->getPriority() == 1 && ($i->getUserId() == $this->user->getId() || $this->getUserEditAll())) {
232  $list->addItem(
233  $this->lng->txt("edit"),
234  "",
235  "",
236  "",
237  "",
238  "",
239  "",
240  false,
241  "il.News.edit(" . $i->getId() . ");"
242  );
243  $list->addItem(
244  $this->lng->txt("delete"),
245  "",
246  "",
247  "",
248  "",
249  "",
250  "",
251  false,
252  "il.News.delete(" . $i->getId() . ");"
253  );
254  }
255 
256  $news_renderer->addTimelineActions($list);
257 
258  $tpl->setVariable("ACTIONS", $list->getHTML());
259 
260  return $tpl->get();
261  }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
getUserEditAll()
Get user can edit other users postings.
getDateTime()
Get datetime.ilDateTime timestamp
const IL_CAL_DATETIME
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
$tpl
Definition: ilias.php:10
static _lookupTitle($a_id)
lookup object title
renderMedia(ilNewsItem $i)
Render media.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
user()
Definition: user.php:4
special template class to simplify handling of ITX/PEAR
Date and time handling
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:
User interface class for advanced drop-down selection lists.
static getRenderer($a_context_obj_type)
Get renderer.
$i
Definition: disco.tpl.php:19
static determineNewsTitle( $a_context_obj_type, $a_title, $a_content_is_lang_var, $a_agg_ref_id=0, $a_aggregation="")
Determine title for news item entry.
+ Here is the call graph for this function:

◆ renderFooter()

ilNewsTimelineItemGUI::renderFooter ( )

Render footer.

Exceptions
ilCtrlException

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

References $_GET, $html, $i, getNewsItem(), renderMediaModal(), and ilNoteGUI\setDefaultCommand().

339  {
340  $i = $this->getNewsItem();
341 
342  // like
343  $this->ctrl->setParameterByClass("ilnewstimelinegui", "news_id", $i->getId());
344  $this->like_gui->setObject(
345  $i->getContextObjId(),
346  $i->getContextObjType(),
347  $i->getContextSubObjId(),
348  $i->getContextSubObjType(),
349  $i->getId()
350  );
351  $html = $this->ctrl->getHTML($this->like_gui);
352 
353  // comments
354  $notes_obj_type = ($i->getContextSubObjType() == "")
355  ? $i->getContextObjType()
356  : $i->getContextSubObjType();
357  $note_gui = new ilNoteGUI(
358  $i->getContextObjId(),
359  $i->getContextSubObjId(),
360  $notes_obj_type,
361  false,
362  $i->getId()
363  );
364  $note_gui->setDefaultCommand("getWidget");
365 
366  //ilNoteGUI::getListCommentsJSCall($this->ajax_hash, $redraw_js)
367  $html .= $this->ctrl->getHTML($note_gui);
368 
369  $this->ctrl->setParameterByClass("ilnewstimelinegui", "news_id", $_GET["news_id"]);
370 
371  return $html . $this->renderMediaModal($i);
372  }
renderMediaModal(ilNewsItem $i)
Render media.
$_GET["client_id"]
Notes GUI class.
$i
Definition: disco.tpl.php:19
$html
Definition: example_001.php:87
setDefaultCommand($a_val)
Set default command.
+ Here is the call graph for this function:

◆ renderMedia()

ilNewsTimelineItemGUI::renderMedia ( ilNewsItem  $i)
protected

Render media.

Parameters

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

References $DIC, $html, $title, ilNewsItem\getId(), getMediaPath(), and ilObjMediaObject\getMimeType().

Referenced by render().

270  {
271  global $DIC;
272 
273  $media_path = $this->getMediaPath($i);
274  $mime = ilObjMediaObject::getMimeType($media_path);
275 
276  $ui_factory = $DIC->ui()->factory();
277  $ui_renderer = $DIC->ui()->renderer();
278 
279  if (in_array($mime, array("image/jpeg", "image/svg+xml", "image/gif", "image/png"))) {
280  $item_id = "il-news-modal-img-" . $i->getId();
281  $title = basename($media_path);
282  $image = $ui_renderer->render($ui_factory->image()->responsive($media_path, $title));
283 
284  $img_tpl = new ilTemplate("tpl.news_timeline_image_file.html", true, true, "Services/News");
285  $img_tpl->setVariable("ITEM_ID", $item_id);
286  $img_tpl->setVariable("IMAGE", $image);
287 
288  $html = $img_tpl->get();
289  } elseif (in_array($mime, array("audio/mpeg", "audio/ogg", "video/mp4", "video/x-flv", "video/webm"))) {
290  $mp = new ilMediaPlayerGUI();
291  $mp->setFile($media_path);
292  $mp->setDisplayHeight(200);
293  $html = $mp->getMediaPlayerHtml();
294  } else {
295  // download?
296  $html = "";
297  }
298  return $html;
299  }
static getMimeType($a_file, $a_external=null)
get mime type for file
global $DIC
Definition: saml.php:7
getId()
Get Id.
special template class to simplify handling of ITX/PEAR
User interface for media player.
$html
Definition: example_001.php:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderMediaModal()

ilNewsTimelineItemGUI::renderMediaModal ( ilNewsItem  $i)
protected

Render media.

Parameters
ilNewsItem
Returns
string

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

References $DIC, $title, ilNewsItem\getId(), ilModalGUI\getInstance(), getMediaPath(), ilObjMediaObject\getMimeType(), and ilModalGUI\TYPE_LARGE.

Referenced by renderFooter().

308  {
309  global $DIC;
310 
311  $media_path = $this->getMediaPath($i);
312  $mime = ilObjMediaObject::getMimeType($media_path);
313 
314  $ui_factory = $DIC->ui()->factory();
315  $ui_renderer = $DIC->ui()->renderer();
316 
317  $modal_html = "";
318 
319  if (in_array($mime, array("image/jpeg", "image/svg+xml", "image/gif", "image/png"))) {
320  $title = basename($media_path);
321  $item_id = "il-news-modal-img-" . $i->getId();
322  $image = $ui_renderer->render($ui_factory->image()->responsive($media_path, $title));
323  $modal = ilModalGUI::getInstance();
324  $modal->setId($item_id);
325  $modal->setType(ilModalGUI::TYPE_LARGE);
326  $modal->setBody($image);
327  $modal->setHeading($title);
328  $modal_html = $modal->getHTML();
329  }
330  return $modal_html;
331  }
static getMimeType($a_file, $a_external=null)
get mime type for file
global $DIC
Definition: saml.php:7
getId()
Get Id.
static getInstance()
Get instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setNewsItem()

ilNewsTimelineItemGUI::setNewsItem ( ilNewsItem  $a_val)

Set news item.

Parameters
ilNewsItem$a_valnews item

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

Referenced by __construct().

103  {
104  $this->news_item = $a_val;
105  }
+ Here is the caller graph for this function:

◆ setUserEditAll()

ilNewsTimelineItemGUI::setUserEditAll (   $a_val)

Set user can edit other users postings.

Parameters
bool$a_valuser can edit all postings

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

123  {
124  $this->user_edit_all = $a_val;
125  }

Field Documentation

◆ $ctrl

ilNewsTimelineItemGUI::$ctrl
protected

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

◆ $like_gui

ilNewsTimelineItemGUI::$like_gui
protected

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

◆ $lng

ilNewsTimelineItemGUI::$lng
protected

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

◆ $news_item

ilNewsTimelineItemGUI::$news_item
protected

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

Referenced by getNewsItem().

◆ $news_item_ref_id

ilNewsTimelineItemGUI::$news_item_ref_id
protected

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

◆ $obj_def

ilNewsTimelineItemGUI::$obj_def
protected

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

◆ $ref_id

ilNewsTimelineItemGUI::$ref_id
protected

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

◆ $user

ilNewsTimelineItemGUI::$user
protected

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

◆ $user_edit_all

ilNewsTimelineItemGUI::$user_edit_all
protected

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

Referenced by getUserEditAll().


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