ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPDNotesBlockGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("Services/Block/classes/class.ilBlockGUI.php");
6 
16 {
17  static $block_type = "pdnotes";
18  protected $note_gui = null;
19 
23  function ilPDNotesBlockGUI()
24  {
25  global $ilCtrl, $lng, $ilUser;
26 
28 
29  $this->setLimit(5);
30  $this->setImage(ilUtil::getImagePath("icon_note_s.gif"));
31  $this->setTitle($lng->txt("notes"));
32  $this->setAvailableDetailLevels(3);
33  }
34 
40  static function getBlockType()
41  {
42  return self::$block_type;
43  }
44 
50  static function isRepositoryObject()
51  {
52  return false;
53  }
54 
58  static function getScreenMode()
59  {
60  switch($_GET["cmd"])
61  {
62  case "showNote":
63  return IL_SCREEN_CENTER;
64  break;
65 
66  default:
67  return IL_SCREEN_SIDE;
68  break;
69  }
70  }
71 
75  function &executeCommand()
76  {
77  global $ilCtrl;
78 
79  $next_class = $ilCtrl->getNextClass();
80  $cmd = $ilCtrl->getCmd("getHTML");
81 
82  return $this->$cmd();
83  }
84 
85  function getHTML()
86  {
87  if ($this->getCurrentDetailLevel() == 0)
88  {
89  return "";
90  }
91  else
92  {
93  return parent::getHTML();
94  }
95  }
96 
100  function fillDataSection()
101  {
102  global $ilUser;
103 
104  include_once("Services/Notes/classes/class.ilNote.php");
105  $this->notes = ilNote::_getLastNotesOfUser();
106 
107  if ($this->getCurrentDetailLevel() > 1 && count($this->notes) > 0)
108  {
109  $this->setRowTemplate("tpl.pd_notes_overview.html", "Services/Notes");
110  $this->getListRowData();
111  //$this->setColSpan(2);
113  }
114  else
115  {
116  $this->setEnableNumInfo(false);
117  if (count($this->notes) == 0)
118  {
119  $this->setEnableDetailRow(false);
120  }
121  $this->setDataSection($this->getOverview());
122  }
123  }
124 
125 
129  function getListRowData()
130  {
131  global $ilUser, $lng, $ilCtrl;
132 
133  $data = array();
134 
135  foreach($this->notes as $note)
136  {
137  switch ($note->getLabel())
138  {
139  case IL_NOTE_UNLABELED:
140  $img = ilUtil::getImagePath("note_unlabeled.gif");
141  $alt = $lng->txt("note");
142  break;
143 
144  case IL_NOTE_IMPORTANT:
145  $img = ilUtil::getImagePath("note_important.gif");
146  $alt = $lng->txt("note").", ".$lng->txt("important");
147  break;
148 
149  case IL_NOTE_QUESTION:
150  $img = ilUtil::getImagePath("note_question.gif");
151  $alt = $lng->txt("note").", ".$lng->txt("question");
152  break;
153 
154  case IL_NOTE_PRO:
155  $img = ilUtil::getImagePath("note_pro.gif");
156  $alt = $lng->txt("note").", ".$lng->txt("pro");
157  break;
158 
159  case IL_NOTE_CONTRA:
160  $img = ilUtil::getImagePath("note_contra.gif");
161  $alt = $lng->txt("note").", ".$lng->txt("contra");
162  break;
163  }
164 
165  // details
166  $target = $note->getObject();
167 
168  $data[] = array(
169  "subject" => $note->getSubject(),
170  "img" => $img,
171  "alt" => $alt,
172  "text" => ilUtil::shortenText($note->getText(), 150, true, true),
173  "date" => $note->getCreationDate(),
174  "id" => $note->getId(),
175  "obj_type" => $target["obj_type"],
176  "obj_id" => $target["obj_id"],
177  "rep_obj_id" => $target["rep_obj_id"]);
178  }
179 
180  $this->setData($data);
181  }
182 
186  function fillRow($a_set)
187  {
188  global $ilUser, $ilCtrl, $lng;
189 
190  include_once("Services/Notes/classes/class.ilNoteGUI.php");
191  if (!is_object($this->note_gui))
192  {
193  $this->note_gui = new ilNoteGUI(0,0,"");
194  $this->note_gui->enableTargets();
195  }
196 
197  //if ($this->getCurrentDetailLevel() > 2)
198  //{
199  // $this->tpl->setVariable("VAL_SUBJECT", "<b>".$a_set["subject"]."</b>");
200  //}
201  //else
202  //{
203  $this->tpl->setVariable("VAL_SUBJECT", $a_set["subject"]);
204  //}
205 
206  // link subject to show note function
207  $ilCtrl->setParameter($this, "rel_obj", $a_set["rep_obj_id"]);
208  $ilCtrl->setParameter($this, "note_id", $a_set["id"]);
209  $ilCtrl->setParameter($this, "note_type", IL_NOTE_PRIVATE);
210  $this->tpl->setVariable("HREF_SHOW_NOTE",
211  $ilCtrl->getLinkTarget($this, "showNote"));
212  $this->tpl->setVariable("IMG_NOTE", $a_set["img"]);
213  $this->tpl->setVariable("ALT_NOTE", $a_set["alt"]);
214  $ilCtrl->clearParameters($this);
215 
216  // details
217  if ($this->getCurrentDetailLevel() > 2)
218  {
219  $this->tpl->setCurrentBlock("details");
220  $this->tpl->setVariable("NOTE_TEXT", $a_set["text"]);
221  $this->tpl->setVariable("VAL_DATE",
223  $this->tpl->parseCurrentBlock();
224 
225  // target objects
226  $this->note_gui->showTargets($this->tpl, $a_set["rep_obj_id"], $a_set["id"],
227  $a_set["obj_type"], $a_set["obj_id"]);
228 
229  // edit button
230  $this->tpl->setCurrentBlock("edit_note");
231  $this->tpl->setVariable("TXT_EDIT_NOTE", $lng->txt("edit"));
232  $ilCtrl->setParameterByClass("ilnotegui", "rel_obj", $a_set["rep_obj_id"]);
233  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $a_set["id"]);
234  $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
235  $this->tpl->setVariable("LINK_EDIT_NOTE",
236  $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilpdnotesgui", "ilnotegui"), "editNoteForm")
237  ."#note_edit");
238  $this->tpl->parseCurrentBlock();
239  }
240  $ilCtrl->clearParametersByClass("ilnotegui");
241  }
242 
246  function getOverview()
247  {
248  global $ilUser, $lng, $ilCtrl;
249 
250  return '<div class="small">'.((int) count($this->notes))." ".$lng->txt("notes")."</div>";
251  }
252 
256  function showNote()
257  {
258  global $lng, $ilCtrl;
259 
260  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
261  $note_gui = new ilNoteGUI();
262  $note_gui->enableTargets();
263  include_once("./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
264  $content_block = new ilPDContentBlockGUI();
265  $content_block->setContent($note_gui->getPDNoteHTML($_GET["note_id"]));
266  $content_block->setTitle($lng->txt("note"));
267  $content_block->setColSpan(2);
268  $content_block->setImage(ilUtil::getImagePath("icon_note.gif"));
269  $content_block->addHeaderCommand($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"),
270  $lng->txt("selected_items_back"));
271 
272  return $content_block->getHTML();
273  }
274 
275 }
276 
277 ?>