ILIAS  Release_4_2_x_branch Revision 61807
 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  // new notes do not have subject anymore
169  $title = $note->getSubject();
170  if(!$title)
171  {
172  $title = ilUtil::shortenText($note->getText(), 75, true, true);
173  }
174 
175  $data[] = array(
176  "subject" => $title,
177  "img" => $img,
178  "alt" => $alt,
179  "text" => ilUtil::shortenText($note->getText(), 150, true, true),
180  "date" => $note->getCreationDate(),
181  "id" => $note->getId(),
182  "obj_type" => $target["obj_type"],
183  "obj_id" => $target["obj_id"],
184  "rep_obj_id" => $target["rep_obj_id"]);
185  }
186 
187  $this->setData($data);
188  }
189 
193  function fillRow($a_set)
194  {
195  global $ilUser, $ilCtrl, $lng;
196 
197  include_once("Services/Notes/classes/class.ilNoteGUI.php");
198  if (!is_object($this->note_gui))
199  {
200  $this->note_gui = new ilNoteGUI(0,0,"");
201  $this->note_gui->enableTargets();
202  }
203 
204  //if ($this->getCurrentDetailLevel() > 2)
205  //{
206  // $this->tpl->setVariable("VAL_SUBJECT", "<b>".$a_set["subject"]."</b>");
207  //}
208  //else
209  //{
210  $this->tpl->setVariable("VAL_SUBJECT", $a_set["subject"]);
211  //}
212 
213  // link subject to show note function
214  $ilCtrl->setParameter($this, "rel_obj", $a_set["rep_obj_id"]);
215  $ilCtrl->setParameter($this, "note_id", $a_set["id"]);
216  $ilCtrl->setParameter($this, "note_type", IL_NOTE_PRIVATE);
217  $this->tpl->setVariable("HREF_SHOW_NOTE",
218  $ilCtrl->getLinkTarget($this, "showNote"));
219  $this->tpl->setVariable("IMG_NOTE", $a_set["img"]);
220  $this->tpl->setVariable("ALT_NOTE", $a_set["alt"]);
221  $ilCtrl->clearParameters($this);
222 
223  // details
224  if ($this->getCurrentDetailLevel() > 2)
225  {
226  $this->tpl->setCurrentBlock("details");
227  $this->tpl->setVariable("NOTE_TEXT", $a_set["text"]);
228  $this->tpl->setVariable("VAL_DATE",
230  $this->tpl->parseCurrentBlock();
231 
232  // target objects
233  $this->note_gui->showTargets($this->tpl, $a_set["rep_obj_id"], $a_set["id"],
234  $a_set["obj_type"], $a_set["obj_id"]);
235 
236  // edit button
237  $this->tpl->setCurrentBlock("edit_note");
238  $this->tpl->setVariable("TXT_EDIT_NOTE", $lng->txt("edit"));
239  $ilCtrl->setParameterByClass("ilnotegui", "rel_obj", $a_set["rep_obj_id"]);
240  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $a_set["id"]);
241  $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
242  $this->tpl->setVariable("LINK_EDIT_NOTE",
243  $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilpdnotesgui", "ilnotegui"), "editNoteForm")
244  ."#note_edit");
245  $this->tpl->parseCurrentBlock();
246  }
247  $ilCtrl->clearParametersByClass("ilnotegui");
248  }
249 
253  function getOverview()
254  {
255  global $ilUser, $lng, $ilCtrl;
256 
257  return '<div class="small">'.((int) count($this->notes))." ".$lng->txt("notes")."</div>";
258  }
259 
263  function showNote()
264  {
265  global $lng, $ilCtrl;
266 
267  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
268  $note_gui = new ilNoteGUI();
269  $note_gui->enableTargets();
270  include_once("./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
271  $content_block = new ilPDContentBlockGUI();
272  $content_block->setContent($note_gui->getPDNoteHTML($_GET["note_id"]));
273  $content_block->setTitle($lng->txt("note"));
274  $content_block->setColSpan(2);
275  $content_block->setImage(ilUtil::getImagePath("icon_note.gif"));
276  $content_block->addHeaderCommand($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"),
277  $lng->txt("selected_items_back"));
278 
279  return $content_block->getHTML();
280  }
281 
282 }
283 
284 ?>