ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
19  protected $ctrl;
20 
24  protected $access;
25 
26 
27  public function __construct($a_parent_obj, $a_parent_cmd = "", $a_perm_ref_id = 0)
28  {
29  global $DIC;
30 
31  $this->ctrl = $DIC->ctrl();
32  $this->lng = $DIC->language();
33  $this->access = $DIC->access();
34  $ilCtrl = $DIC->ctrl();
35  $lng = $DIC->language();
36 
37  parent::__construct($a_parent_obj, $a_parent_cmd);
38 
39  $this->perm_ref_id = $a_perm_ref_id;
40 
41  $this->addColumn("", "f", "1");
42  $this->addColumn($lng->txt("news_news_item_content"));
43  $this->addColumn($lng->txt("news_attached_to"));
44  $this->addColumn($lng->txt("access"));
45  $this->addColumn($lng->txt("author"));
46  $this->addColumn($lng->txt("created"));
47  $this->addColumn($lng->txt("last_update"));
48  $this->addColumn($lng->txt("actions"));
49  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
50  $this->setRowTemplate(
51  "tpl.table_row_news_for_context.html",
52  "Services/News"
53  );
54  }
55 
60  protected function fillRow($a_set)
61  {
62  $lng = $this->lng;
64  $ilAccess = $this->access;
65 
66  $news_set = new ilSetting("news");
67  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
68 
69  // user
70  if ($a_set["user_id"] > 0) {
71  $this->tpl->setCurrentBlock("user_info");
72  $user_obj = new ilObjUser($a_set["user_id"]);
73  $this->tpl->setVariable("VAL_AUTHOR", $user_obj->getLogin());
74  $this->tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
75  $this->tpl->parseCurrentBlock();
76  }
77 
78  // access
79  if ($enable_internal_rss) {
80  $this->tpl->setCurrentBlock("access");
81  $this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
82  if ($a_set["visibility"] == NEWS_PUBLIC ||
83  ($a_set["priority"] == 0 &&
85  "news",
86  "public_notifications",
87  0,
88  $a_set["context_obj_id"]
89  ))) {
90  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
91  } else {
92  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
93  }
94  $this->tpl->parseCurrentBlock();
95  }
96 
97  // last update
98  if ($a_set["creation_date"] != $a_set["update_date"]) {
99  $this->tpl->setCurrentBlock("ni_update");
100  $this->tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update"));
101  $this->tpl->setVariable(
102  "VAL_LAST_UPDATE",
103  ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"], IL_CAL_DATETIME))
104  );
105  $this->tpl->parseCurrentBlock();
106  }
107 
108  // creation date
109  $this->tpl->setVariable(
110  "VAL_CREATION_DATE",
111  ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"], IL_CAL_DATETIME))
112  );
113  $this->tpl->setVariable("TXT_CREATED", $lng->txt("created"));
114 
115  // title
116  $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
117 
118  // content
119  if ($a_set["content"] != "") {
120  $this->tpl->setCurrentBlock("content");
121  $this->tpl->setVariable(
122  "VAL_CONTENT",
123  ilUtil::shortenText($a_set["content"], 80, true, true),
124  true
125  );
126  $this->tpl->parseCurrentBlock();
127  }
128 
129  $perm_ref_id = ($this->perm_ref_id > 0)
130  ? $this->perm_ref_id
131  : $a_set["ref_id"];
132 
133  if ($ilAccess->checkAccess("write", "", $perm_ref_id)) {
134  $this->tpl->setCurrentBlock("edit");
135  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
136  $ilCtrl->setParameterByClass("ilnewsitemgui", "news_item_id", $a_set["id"]);
137  $this->tpl->setVariable(
138  "CMD_EDIT",
139  $ilCtrl->getLinkTargetByClass("ilnewsitemgui", "editNewsItem")
140  );
141  $this->tpl->parseCurrentBlock();
142  }
143 
144  // context
145  $this->tpl->setVariable(
146  "CONTEXT",
147  $lng->txt("obj_" . $a_set["context_obj_type"]) . ":<br />" .
148  ilObject::_lookupTitle($a_set["context_obj_id"])
149  );
150 
151  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
152  }
153 }
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
const IL_CAL_DATETIME
global $DIC
Definition: saml.php:7
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
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.
Date and time handling
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
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.
TableGUI class for table NewsForContext.
fillRow($a_set)
Standard Version of Fill Row.
__construct($a_parent_obj, $a_parent_cmd="", $a_perm_ref_id=0)