ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ilNewsForContextTableGUI($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  //$this->setCloseCommand($ilCtrl->getParentReturnByClass("ilnewsitemgui"));
37  }
38 
43  protected function fillRow($a_set)
44  {
45  global $lng, $ilCtrl, $ilAccess;
46 
47  $news_set = new ilSetting("news");
48  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
49 
50  // user
51  if ($a_set["user_id"] > 0)
52  {
53  $this->tpl->setCurrentBlock("user_info");
54  $user_obj = new ilObjUser($a_set["user_id"]);
55  $this->tpl->setVariable("VAL_AUTHOR", $user_obj->getLogin());
56  $this->tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
57  $this->tpl->parseCurrentBlock();
58  }
59 
60  // access
61  if ($enable_internal_rss)
62  {
63  $this->tpl->setCurrentBlock("access");
64  $this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
65  if ($a_set["visibility"] == NEWS_PUBLIC ||
66  ($a_set["priority"] == 0 &&
67  ilBlockSetting::_lookup("news", "public_notifications",
68  0, $a_set["context_obj_id"])))
69  {
70  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
71  }
72  else
73  {
74  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
75  }
76  $this->tpl->parseCurrentBlock();
77  }
78 
79  // last update
80  if ($a_set["creation_date"] != $a_set["update_date"])
81  {
82  $this->tpl->setCurrentBlock("ni_update");
83  $this->tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update"));
84  $this->tpl->setVariable("VAL_LAST_UPDATE",
85  ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"],IL_CAL_DATETIME)));
86  $this->tpl->parseCurrentBlock();
87  }
88 
89  // creation date
90  $this->tpl->setVariable("VAL_CREATION_DATE",
91  ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"],IL_CAL_DATETIME)));
92  $this->tpl->setVariable("TXT_CREATED", $lng->txt("created"));
93 
94  // title
95  $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
96 
97  // content
98  if ($a_set["content"] != "")
99  {
100  $this->tpl->setCurrentBlock("content");
101  $this->tpl->setVariable("VAL_CONTENT",
102  ilUtil::shortenText($a_set["content"], 80, true, true), true);
103  $this->tpl->parseCurrentBlock();
104  }
105 
106  $perm_ref_id = ($this->perm_ref_id > 0)
107  ? $this->perm_ref_id
108  : $a_set["ref_id"];
109 
110  if ($ilAccess->checkAccess("write", "", $perm_ref_id))
111  {
112  $this->tpl->setCurrentBlock("edit");
113  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
114  $ilCtrl->setParameterByClass("ilnewsitemgui", "news_item_id", $a_set["id"]);
115  $this->tpl->setVariable("CMD_EDIT",
116  $ilCtrl->getLinkTargetByClass("ilnewsitemgui", "editNewsItem"));
117  $this->tpl->parseCurrentBlock();
118  }
119 
120  // context
121  $this->tpl->setVariable("CONTEXT",
122  $lng->txt("obj_".$a_set["context_obj_type"]).":<br />".
123  ilObject::_lookupTitle($a_set["context_obj_id"]));
124 
125  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
126  }
127 
128 }
129 ?>
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
const NEWS_PUBLIC
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
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.
global $lng
Definition: privfeed.php:40
TableGUI class for table NewsForContext.
setFormAction($a_form_action)
Set Form action parameter.
fillRow($a_set)
Standard Version of Fill Row.
ilNewsForContextTableGUI($a_parent_obj, $a_parent_cmd="", $a_perm_ref_id=0)