ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 

Static Public Member Functions

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

Protected Member Functions

 __construct (ilNewsItem $a_news_item, $a_news_ref_id)
 Constructor. More...
 

Protected Attributes

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

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 
)
protected

Constructor.

$param ilNewsItem $a_news_item

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

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

63  {
64  global $DIC;
65 
66  $this->lng = $DIC->language();
67  $this->ctrl = $DIC->ctrl();
68  $this->setNewsItem($a_news_item);
69  $this->user = $DIC->user();
70  $this->obj_def = $DIC["objDefinition"];
71  $this->news_item_ref_id = $a_news_ref_id;
72 
73  $this->ref_id = (int) $_GET["ref_id"];
74  }
$_GET["client_id"]
user()
Definition: user.php:4
global $DIC
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 131 of file class.ilNewsTimelineItemGUI.php.

References getNewsItem(), and IL_CAL_DATETIME.

Referenced by render().

132  {
133  $i = $this->getNewsItem();
134  return new ilDateTime($i->getCreationDate(), IL_CAL_DATETIME);
135  }
const IL_CAL_DATETIME
Date and time handling
+ 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 
)
static

Get instance.

Parameters
ilNewsItem$a_news_itemnews item
Returns
ilNewsTimelineItemGUI

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

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

83  {
84  return new self($a_news_item, $a_news_ref_id);
85  }
+ Here is the caller graph for this function:

◆ getNewsItem()

ilNewsTimelineItemGUI::getNewsItem ( )

Get news item.

Returns
ilNewsItem news item

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

References $news_item.

Referenced by getDateTime(), and render().

+ 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 123 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 141 of file class.ilNewsTimelineItemGUI.php.

References $tpl, ilObject\_exists(), ilObject\_getIcon(), ilObjUser\_getPersonalPicturePath(), ilObjMediaObject\_getURL(), ilObject\_lookupTitle(), ilAdvancedSelectionListGUI\DOWN_ARROW_DARK, ilDatePresentation\formatDate(), getDateTime(), ilObjMediaObject\getMediaItem(), ilUserUtil\getNamePresentation(), getNewsItem(), ilNewsRendererFactory\getRenderer(), getUserEditAll(), IL_CAL_DATETIME, NEWS_AUDIO, ilMediaPlayerGUI\setFile(), and user().

142  {
143  $i = $this->getNewsItem();
144  $tpl = new ilTemplate("tpl.timeline_item.html", true, true, "Services/News");
145 
146  include_once("./Services/News/classes/class.ilNewsRendererFactory.php");
147  $news_renderer = ilNewsRendererFactory::getRenderer($i->getContextObjType());
148  $news_renderer->setLanguage($this->lng->getLangKey());
149  $news_renderer->setNewsItem($i, $this->news_item_ref_id);
150 
151  $obj_id = $i->getContextObjId();
152 
153  // edited?
154  if ($i->getCreationDate() != $i->getUpdateDate())
155  {
156  $tpl->setCurrentBlock("edited");
157  $update_date = new ilDateTime($i->getUpdateDate(), IL_CAL_DATETIME);
158  $tpl->setVariable("TXT_EDITED", $this->lng->txt("cont_news_edited"));
159  if ($i->getUpdateUserId() > 0 && ($i->getUpdateUserId() != $i->getUserId()))
160  {
161  include_once("./Services/User/classes/class.ilUserUtil.php");
162  $tpl->setVariable("TXT_USR_EDITED", ilUserUtil::getNamePresentation($i->getUpdateUserId(), false, true,
163  $this->ctrl->getLinkTargetByClass("ilnewstimelinegui")) . " - ");
164  }
165  include_once("./Services/Calendar/classes/class.ilDatePresentation.php");
166  $tpl->setVariable("TIME_EDITED", ilDatePresentation::formatDate($update_date));
167  $tpl->parseCurrentBlock();
168  }
169 
170 
171  // context object link
172  include_once("./Services/Link/classes/class.ilLink.php");
173  if ($this->news_item_ref_id > 0 && $this->ref_id != $this->news_item_ref_id)
174  {
175  $tpl->setCurrentBlock("object");
176  $tpl->setVariable("OBJ_TITLE", ilObject::_lookupTitle($obj_id));
177  $tpl->setVariable("OBJ_IMG", ilObject::_getIcon($obj_id));
178  $tpl->setVariable("OBJ_HREF", $news_renderer->getObjectLink());
179  $tpl->parseCurrentBlock();
180  }
181 
182  // media
183  if ($i->getContentType() == NEWS_AUDIO &&
184  $i->getMobId() > 0 && ilObject::_exists($i->getMobId()))
185  {
186  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
187  include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
188  $mob = new ilObjMediaObject($i->getMobId());
189  $med = $mob->getMediaItem("Standard");
190  $mpl = new ilMediaPlayerGUI("news_pl_".$i->getMobId());
191  if (strcasecmp("Reference", $med->getLocationType()) == 0)
192  $mpl->setFile($med->getLocation());
193  else
194  $mpl->setFile(ilObjMediaObject::_getURL($mob->getId())."/".$med->getLocation());
195  $mpl->setDisplayHeight($med->getHeight());
196  //$mpl->setDisplayWidth("100%");
197  //$mpl->setDisplayHeight("320");
198  $tpl->setCurrentBlock("player");
199  $tpl->setVariable("PLAYER",
200  $mpl->getMp3PlayerHtml());
201  $tpl->parseCurrentBlock();
202  }
203 
204 
205  $tpl->setVariable("USER_IMAGE", ilObjUser::_getPersonalPicturePath($i->getUserId(), "xsmall"));
206  if (!$i->getContentIsLangVar())
207  {
208  $tpl->setVariable("TITLE", $i->getTitle());
209  }
210  else
211  {
212  $tpl->setVariable("TITLE", $this->lng->txt($i->getTitle()));
213  }
214 
215  // content
216  $tpl->setVariable("CONTENT", $news_renderer->getTimelineContent());
217 
218  include_once("./Services/User/classes/class.ilUserUtil.php");
219  $tpl->setVariable("TXT_USR", ilUserUtil::getNamePresentation($i->getUserId(), false, true,
220  $this->ctrl->getLinkTargetByClass("ilnewstimelinegui")));
221 
222  include_once("./Services/Calendar/classes/class.ilDatePresentation.php");
223  $tpl->setVariable("TIME", ilDatePresentation::formatDate($this->getDateTime()));
224 
225  // actions
226  include_once("Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
227  $list = new ilAdvancedSelectionListGUI();
228  $list->setListTitle("");
229  $list->setId("news_tl_act_".$i->getId());
230  //$list->setSelectionHeaderClass("small");
231  //$list->setItemLinkClass("xsmall");
232  //$list->setLinksMode("il_ContainerItemCommand2");
233  $list->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
234  $list->setUseImages(false);
235 
236  if ($i->getPriority() == 1 && ($i->getUserId() == $this->user->getId() || $this->getUserEditAll()))
237  {
238  $list->addItem($this->lng->txt("edit"), "", "", "", "", "",
239  "", false, "il.News.edit(" . $i->getId() . ");");
240  $list->addItem($this->lng->txt("delete"), "", "", "", "", "",
241  "", false, "il.News.delete(" . $i->getId() . ");");
242  }
243 
244  $news_renderer->addTimelineActions($list);
245 
246  $tpl->setVariable("ACTIONS", $list->getHTML());
247 
248 
249  return $tpl->get();
250  }
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
getUserEditAll()
Get user can edit other users postings.
getDateTime()
Get datetime.ilDateTime timestamp
& getMediaItem($a_purpose)
get item for media purpose
const IL_CAL_DATETIME
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
setFile($a_file)
Set File.
static _lookupTitle($a_id)
lookup object title
static _getURL($a_mob_id)
get directory for files of media object (static)
user()
Definition: user.php:4
global $tpl
Definition: ilias.php:8
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)
Default behaviour is:
special template class to simplify handling of ITX/PEAR
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
Class ilObjMediaObject.
User interface class for advanced drop-down selection lists.
User interface for media player.
static getRenderer($a_context_obj_type)
Get renderer.
static _getPersonalPicturePath($a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
const NEWS_AUDIO
+ Here is the call graph for this function:

◆ setNewsItem()

ilNewsTimelineItemGUI::setNewsItem ( ilNewsItem  $a_val)

Set news item.

Parameters
ilNewsItem$a_valnews item

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

Referenced by __construct().

94  {
95  $this->news_item = $a_val;
96  }
+ 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 113 of file class.ilNewsTimelineItemGUI.php.

114  {
115  $this->user_edit_all = $a_val;
116  }

Field Documentation

◆ $ctrl

ilNewsTimelineItemGUI::$ctrl
protected

Definition at line 55 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: