ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilNewsForContextTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("Services/Table/classes/class.ilTable2GUI.php");
5 
15 {
16 
17  function __construct($a_parent_obj, $a_parent_cmd = "", $a_perm_ref_id = 0)
18  {
19  global $ilCtrl, $lng;
20 
21  parent::__construct($a_parent_obj, $a_parent_cmd);
22 
23  $this->perm_ref_id = $a_perm_ref_id;
24 
25  $this->addColumn("", "f", "1");
26  $this->addColumn($lng->txt("news_news_item_content"));
27  $this->addColumn($lng->txt("news_attached_to"));
28  $this->addColumn($lng->txt("access"));
29  $this->addColumn($lng->txt("author"));
30  $this->addColumn($lng->txt("created"));
31  $this->addColumn($lng->txt("last_update"));
32  $this->addColumn($lng->txt("actions"));
33  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
34  $this->setRowTemplate("tpl.table_row_news_for_context.html",
35  "Services/News");
36  }
37 
42  protected function fillRow($a_set)
43  {
44  global $lng, $ilCtrl, $ilAccess;
45 
46  $news_set = new ilSetting("news");
47  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
48 
49  // user
50  if ($a_set["user_id"] > 0)
51  {
52  $this->tpl->setCurrentBlock("user_info");
53  $user_obj = new ilObjUser($a_set["user_id"]);
54  $this->tpl->setVariable("VAL_AUTHOR", $user_obj->getLogin());
55  $this->tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
56  $this->tpl->parseCurrentBlock();
57  }
58 
59  // access
60  if ($enable_internal_rss)
61  {
62  $this->tpl->setCurrentBlock("access");
63  $this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
64  if ($a_set["visibility"] == NEWS_PUBLIC ||
65  ($a_set["priority"] == 0 &&
66  ilBlockSetting::_lookup("news", "public_notifications",
67  0, $a_set["context_obj_id"])))
68  {
69  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
70  }
71  else
72  {
73  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
74  }
75  $this->tpl->parseCurrentBlock();
76  }
77 
78  // last update
79  if ($a_set["creation_date"] != $a_set["update_date"])
80  {
81  $this->tpl->setCurrentBlock("ni_update");
82  $this->tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update"));
83  $this->tpl->setVariable("VAL_LAST_UPDATE",
84  ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"],IL_CAL_DATETIME)));
85  $this->tpl->parseCurrentBlock();
86  }
87 
88  // creation date
89  $this->tpl->setVariable("VAL_CREATION_DATE",
90  ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"],IL_CAL_DATETIME)));
91  $this->tpl->setVariable("TXT_CREATED", $lng->txt("created"));
92 
93  // title
94  $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
95 
96  // content
97  if ($a_set["content"] != "")
98  {
99  $this->tpl->setCurrentBlock("content");
100  $this->tpl->setVariable("VAL_CONTENT",
101  ilUtil::shortenText($a_set["content"], 80, true, true), true);
102  $this->tpl->parseCurrentBlock();
103  }
104 
105  $perm_ref_id = ($this->perm_ref_id > 0)
106  ? $this->perm_ref_id
107  : $a_set["ref_id"];
108 
109  if ($ilAccess->checkAccess("write", "", $perm_ref_id))
110  {
111  $this->tpl->setCurrentBlock("edit");
112  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
113  $ilCtrl->setParameterByClass("ilnewsitemgui", "news_item_id", $a_set["id"]);
114  $this->tpl->setVariable("CMD_EDIT",
115  $ilCtrl->getLinkTargetByClass("ilnewsitemgui", "editNewsItem"));
116  $this->tpl->parseCurrentBlock();
117  }
118 
119  // context
120  $this->tpl->setVariable("CONTEXT",
121  $lng->txt("obj_".$a_set["context_obj_type"]).":<br />".
122  ilObject::_lookupTitle($a_set["context_obj_id"]));
123 
124  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
125  }
126 
127 }
128 ?>
ILIAS Setting Class.
const IL_CAL_DATETIME
static shortenText($a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static _lookupTitle($a_id)
lookup object title
global $ilCtrl
Definition: ilias.php:18
Class ilTable2GUI.
const NEWS_PUBLIC
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
global $lng
Definition: privfeed.php:17
TableGUI class for table NewsForContext.
fillRow($a_set)
Standard Version of Fill Row.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
__construct($a_parent_obj, $a_parent_cmd="", $a_perm_ref_id=0)