ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPDNewsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("Services/Table/classes/class.ilTable2GUI.php");
25 
35 {
36 
37  function ilPDNewsTableGUI($a_parent_obj, $a_parent_cmd = "")
38  {
39  global $ilCtrl, $lng;
40 
41  parent::__construct($a_parent_obj, $a_parent_cmd);
42 
43  $this->addColumn("");
44  //$this->addColumn($lng->txt("date"), "creation_date", "1");
45  //$this->addColumn($lng->txt("news_news_item_content"), "");
46  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
47  $this->setRowTemplate("tpl.table_row_pd_news.html",
48  "Services/News");
49  $this->setDefaultOrderField("update_date");
50  $this->setDefaultOrderDirection("desc");
51  $this->setEnableTitle(false);
52  $this->setEnableHeader(false);
53  //$this->setCloseCommand($ilCtrl->getParentReturnByClass("ilpdnewsgui"));
54  }
55 
60  protected function fillRow($a_set)
61  {
62  global $lng, $ilCtrl;
63 
64  $news_set = new ilSetting("news");
65  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
66 
67  // context
68  $obj_id = ilObject::_lookupObjId($a_set["ref_id"]);
69  $obj_type = ilObject::_lookupType($obj_id);
70  $obj_title = ilObject::_lookupTitle($obj_id);
71 
72  // user
73  if ($a_set["user_id"] > 0)
74  {
75  $this->tpl->setCurrentBlock("user_info");
76  if ($obj_type == "frm")
77  {
78  include_once("./Modules/Forum/classes/class.ilForumProperties.php");
79  if (ilForumProperties::_isAnonymized($a_set["context_obj_id"]))
80  {
81  if ($a_set["context_sub_obj_type"] == "pos" &&
82  $a_set["context_sub_obj_id"] > 0)
83  {
84  include_once("./Modules/Forum/classes/class.ilForumPost.php");
85  $post = new ilForumPost($a_set["context_sub_obj_id"]);
86  if ($post->getUserAlias() != "") $this->tpl->setVariable("VAL_AUTHOR", ilUtil::stripSlashes($post->getUserAlias()));
87  else $this->tpl->setVariable("VAL_AUTHOR", $lng->txt("forums_anonymous"));
88  }
89  else
90  {
91  $this->tpl->setVariable("VAL_AUTHOR", $lng->txt("forums_anonymous"));
92  }
93  }
94  else
95  {
96  if (ilObject::_exists($a_set["user_id"]))
97  {
98  $user_obj = new ilObjUser($a_set["user_id"]);
99  $this->tpl->setVariable("VAL_AUTHOR", $user_obj->getLogin());
100  }
101  }
102  }
103  else
104  {
105  if (ilObject::_exists($a_set["user_id"]))
106  {
107  $user_obj = new ilObjUser($a_set["user_id"]);
108  $this->tpl->setVariable("VAL_AUTHOR", $user_obj->getLogin());
109  }
110  }
111  $this->tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
112  $this->tpl->parseCurrentBlock();
113  }
114 
115  // media player
116  if ($a_set["content_type"] == NEWS_AUDIO &&
117  $a_set["mob_id"] > 0 && ilObject::_exists($a_set["mob_id"]))
118  {
119  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
120  include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
121  $mob = new ilObjMediaObject($a_set["mob_id"]);
122  $med = $mob->getMediaItem("Standard");
123  $mpl = new ilMediaPlayerGUI();
124  $mpl->setFile(ilObjMediaObject::_getDirectory($a_set["mob_id"])."/".
125  $med->getLocation());
126  $this->tpl->setCurrentBlock("player");
127  $this->tpl->setVariable("PLAYER",
128  $mpl->getMp3PlayerHtml());
129  $this->tpl->parseCurrentBlock();
130  }
131 
132  // access
133  if ($enable_internal_rss)
134  {
135  $this->tpl->setCurrentBlock("access");
136  include_once("./Services/Block/classes/class.ilBlockSetting.php");
137  $this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
138  if ($a_set["visibility"] == NEWS_PUBLIC ||
139  ($a_set["priority"] == 0 &&
140  ilBlockSetting::_lookup("news", "public_notifications",
141  0, $obj_id)))
142  {
143  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
144  }
145  else
146  {
147  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
148  }
149  $this->tpl->parseCurrentBlock();
150  }
151 
152  // content
153  if ($a_set["content"] != "")
154  {
155  $this->tpl->setCurrentBlock("content");
156  $this->tpl->setVariable("VAL_CONTENT", ilUtil::makeClickable($a_set["content"], true));
157  $this->tpl->parseCurrentBlock();
158  }
159  if ($a_set["content_long"] != "")
160  {
161  $this->tpl->setCurrentBlock("long");
162  $this->tpl->setVariable("VAL_LONG_CONTENT", ilUtil::makeClickable($a_set["content_long"], true));
163  $this->tpl->parseCurrentBlock();
164  }
165  if ($a_set["update_date"] != $a_set["creation_date"]) // update date
166  {
167  $this->tpl->setCurrentBlock("ni_update");
168  $this->tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update"));
169  $this->tpl->setVariable("VAL_LAST_UPDATE",
170  ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"],IL_CAL_DATETIME)));
171  $this->tpl->parseCurrentBlock();
172  }
173 
174  // forum hack, not nice
175  $add = "";
176  if ($obj_type == "frm" && $a_set["context_sub_obj_type"] == "pos"
177  && $a_set["context_sub_obj_id"] > 0)
178  {
179  include_once("./Modules/Forum/classes/class.ilObjForumAccess.php");
180  $pos = $a_set["context_sub_obj_id"];
182  if ($thread > 0)
183  {
184  $add = "_".$thread."_".$pos;
185  }
186  }
187  $url_target = "./goto.php?client_id=".rawurlencode(CLIENT_ID)."&target=".
188  $obj_type."_".$a_set["ref_id"].$add;
189  $this->tpl->setCurrentBlock("context");
190  $cont_loc = new ilLocatorGUI();
191  $cont_loc->addContextItems($a_set["ref_id"], true);
192  $this->tpl->setVariable("CONTEXT_LOCATOR",
193  $cont_loc->getHTML());
194  $this->tpl->setVariable("HREF_CONTEXT_TITLE", $url_target);
195  $this->tpl->setVariable("CONTEXT_TITLE", $obj_title);
196  $this->tpl->setVariable("IMG_CONTEXT_TITLE",
197  ilUtil::getImagePath("icon_".$obj_type."_b.gif"));
198  $this->tpl->parseCurrentBlock();
199 
200  $this->tpl->setVariable("HREF_TITLE", $url_target);
201 
202  // title
203  if ($a_set["content_is_lang_var"])
204  {
205  $this->tpl->setVariable("VAL_TITLE", $lng->txt($a_set["title"]));
206  }
207  else
208  {
209  $this->tpl->setVariable("VAL_TITLE", ilUtil::stripSlashes($a_set["title"])); // title
210  }
211 
212  // creation date
213  $this->tpl->setVariable("VAL_CREATION_DATE",
214  ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"],IL_CAL_DATETIME)));
215  $this->tpl->setVariable("TXT_CREATED", $lng->txt("created"));
216 
217  $this->tpl->parseCurrentBlock();
218  }
219 
220 }
221 ?>