ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPDNotesBlockGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 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/Block/classes/class.ilBlockGUI.php");
25 
35 {
36  static $block_type = "pdnotes";
37 
41  function ilPDNotesBlockGUI()
42  {
43  global $ilCtrl, $lng, $ilUser;
44 
46 
47  $this->setLimit(5);
48  $this->setImage(ilUtil::getImagePath("icon_note_s.gif"));
49  $this->setTitle($lng->txt("notes"));
50  $this->setAvailableDetailLevels(3);
51  }
52 
58  static function getBlockType()
59  {
60  return self::$block_type;
61  }
62 
68  static function isRepositoryObject()
69  {
70  return false;
71  }
72 
76  static function getScreenMode()
77  {
78  switch($_GET["cmd"])
79  {
80  case "showNote":
81  return IL_SCREEN_CENTER;
82  break;
83 
84  default:
85  return IL_SCREEN_SIDE;
86  break;
87  }
88  }
89 
93  function &executeCommand()
94  {
95  global $ilCtrl;
96 
97  $next_class = $ilCtrl->getNextClass();
98  $cmd = $ilCtrl->getCmd("getHTML");
99 
100  return $this->$cmd();
101  }
102 
103  function getHTML()
104  {
105  if ($this->getCurrentDetailLevel() == 0)
106  {
107  return "";
108  }
109  else
110  {
111  return parent::getHTML();
112  }
113  }
114 
118  function fillDataSection()
119  {
120  global $ilUser;
121 
122  include_once("Services/Notes/classes/class.ilNote.php");
123  $this->notes = ilNote::_getLastNotesOfUser();
124 
125  if ($this->getCurrentDetailLevel() > 1 && count($this->notes) > 0)
126  {
127  $this->setRowTemplate("tpl.pd_notes_overview.html", "Services/Notes");
128  $this->getListRowData();
129  //$this->setColSpan(2);
131  }
132  else
133  {
134  $this->setEnableNumInfo(false);
135  if (count($this->notes) == 0)
136  {
137  $this->setEnableDetailRow(false);
138  }
139  $this->setDataSection($this->getOverview());
140  }
141  }
142 
143 
147  function getListRowData()
148  {
149  global $ilUser, $lng, $ilCtrl;
150 
151  $data = array();
152 
153  foreach($this->notes as $note)
154  {
155  switch ($note->getLabel())
156  {
157  case IL_NOTE_UNLABELED:
158  $img = ilUtil::getImagePath("note_unlabeled.gif");
159  $alt = $lng->txt("note");
160  break;
161 
162  case IL_NOTE_IMPORTANT:
163  $img = ilUtil::getImagePath("note_important.gif");
164  $alt = $lng->txt("note").", ".$lng->txt("important");
165  break;
166 
167  case IL_NOTE_QUESTION:
168  $img = ilUtil::getImagePath("note_question.gif");
169  $alt = $lng->txt("note").", ".$lng->txt("question");
170  break;
171 
172  case IL_NOTE_PRO:
173  $img = ilUtil::getImagePath("note_pro.gif");
174  $alt = $lng->txt("note").", ".$lng->txt("pro");
175  break;
176 
177  case IL_NOTE_CONTRA:
178  $img = ilUtil::getImagePath("note_contra.gif");
179  $alt = $lng->txt("note").", ".$lng->txt("contra");
180  break;
181  }
182 
183  // details
184  $target = $note->getObject();
185 
186  $data[] = array(
187  "subject" => $note->getSubject(),
188  "img" => $img,
189  "alt" => $alt,
190  "text" => ilUtil::shortenText($note->getText(), 150, true, true),
191  "date" => $note->getCreationDate(),
192  "id" => $note->getId(),
193  "obj_type" => $target["obj_type"],
194  "obj_id" => $target["obj_id"],
195  "rep_obj_id" => $target["rep_obj_id"]);
196  }
197 
198  $this->setData($data);
199  }
200 
204  function fillRow($a_set)
205  {
206  global $ilUser, $ilCtrl, $lng;
207 
208  include_once("Services/Notes/classes/class.ilNoteGUI.php");
209  if (!is_object($this->note_gui))
210  {
211  $this->note_gui = new ilNoteGUI(0,0,"");
212  $this->note_gui->enableTargets();
213  }
214 
215  //if ($this->getCurrentDetailLevel() > 2)
216  //{
217  // $this->tpl->setVariable("VAL_SUBJECT", "<b>".$a_set["subject"]."</b>");
218  //}
219  //else
220  //{
221  $this->tpl->setVariable("VAL_SUBJECT", $a_set["subject"]);
222  //}
223 
224  // link subject to show note function
225  $ilCtrl->setParameter($this, "rel_obj", $a_set["rep_obj_id"]);
226  $ilCtrl->setParameter($this, "note_id", $a_set["id"]);
227  $ilCtrl->setParameter($this, "note_type", IL_NOTE_PRIVATE);
228  $this->tpl->setVariable("HREF_SHOW_NOTE",
229  $ilCtrl->getLinkTarget($this, "showNote"));
230  $this->tpl->setVariable("IMG_NOTE", $a_set["img"]);
231  $this->tpl->setVariable("ALT_NOTE", $a_set["alt"]);
232  $ilCtrl->clearParameters($this);
233 
234  // details
235  if ($this->getCurrentDetailLevel() > 2)
236  {
237  $this->tpl->setCurrentBlock("details");
238  $this->tpl->setVariable("NOTE_TEXT", $a_set["text"]);
239  $this->tpl->setVariable("VAL_DATE",
241  $this->tpl->parseCurrentBlock();
242 
243  // target objects
244  $this->note_gui->showTargets($this->tpl, $a_set["rep_obj_id"], $a_set["id"],
245  $a_set["obj_type"], $a_set["obj_id"]);
246 
247  // edit button
248  $this->tpl->setCurrentBlock("edit_note");
249  $this->tpl->setVariable("TXT_EDIT_NOTE", $lng->txt("edit"));
250  $ilCtrl->setParameterByClass("ilnotegui", "rel_obj", $a_set["rep_obj_id"]);
251  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $a_set["id"]);
252  $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
253  $this->tpl->setVariable("LINK_EDIT_NOTE",
254  $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilpdnotesgui", "ilnotegui"), "editNoteForm")
255  ."#note_edit");
256  $this->tpl->parseCurrentBlock();
257  }
258  $ilCtrl->clearParametersByClass("ilnotegui");
259  }
260 
264  function getOverview()
265  {
266  global $ilUser, $lng, $ilCtrl;
267 
268  return '<div class="small">'.((int) count($this->notes))." ".$lng->txt("notes")."</div>";
269  }
270 
274  function showNote()
275  {
276  global $lng, $ilCtrl;
277 
278  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
279  $note_gui = new ilNoteGUI();
280  $note_gui->enableTargets();
281  include_once("./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
282  $content_block = new ilPDContentBlockGUI();
283  $content_block->setContent($note_gui->getPDNoteHTML($_GET["note_id"]));
284  $content_block->setTitle($lng->txt("note"));
285  $content_block->setColSpan(2);
286  $content_block->setImage(ilUtil::getImagePath("icon_note.gif"));
287  $content_block->addHeaderCommand($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"),
288  $lng->txt("selected_items_back"));
289 
290  return $content_block->getHTML();
291  }
292 
293 }
294 
295 ?>