ILIAS  Release_4_4_x_branch Revision 61816
 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.png"));
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.png");
141  $alt = $lng->txt("note");
142  break;
143 
144  case IL_NOTE_IMPORTANT:
145  $img = ilUtil::getImagePath("note_important.png");
146  $alt = $lng->txt("note").", ".$lng->txt("important");
147  break;
148 
149  case IL_NOTE_QUESTION:
150  $img = ilUtil::getImagePath("note_question.png");
151  $alt = $lng->txt("note").", ".$lng->txt("question");
152  break;
153 
154  case IL_NOTE_PRO:
155  $img = ilUtil::getImagePath("note_pro.png");
156  $alt = $lng->txt("note").", ".$lng->txt("pro");
157  break;
158 
159  case IL_NOTE_CONTRA:
160  $img = ilUtil::getImagePath("note_contra.png");
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  if (substr($a_set["text"], 0, 40) != substr($a_set["text"], 0, 40))
228  {
229  $this->tpl->setVariable("NOTE_TEXT", $a_set["text"]);
230  }
231  $this->tpl->setVariable("VAL_DATE",
233  $this->tpl->parseCurrentBlock();
234 
235  // target objects
236  $this->note_gui->showTargets($this->tpl, $a_set["rep_obj_id"], $a_set["id"],
237  $a_set["obj_type"], $a_set["obj_id"]);
238 
239  // edit button
240  $this->tpl->setCurrentBlock("edit_note");
241  $this->tpl->setVariable("TXT_EDIT_NOTE", $lng->txt("edit"));
242  $ilCtrl->setParameterByClass("ilnotegui", "rel_obj", $a_set["rep_obj_id"]);
243  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $a_set["id"]);
244  $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
245  $this->tpl->setVariable("LINK_EDIT_NOTE",
246  $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilpdnotesgui", "ilnotegui"), "editNoteForm")
247  ."#note_edit");
248  $this->tpl->parseCurrentBlock();
249  }
250  $ilCtrl->clearParametersByClass("ilnotegui");
251  }
252 
256  function getOverview()
257  {
258  global $ilUser, $lng, $ilCtrl;
259 
260  return '<div class="small">'.((int) count($this->notes))." ".$lng->txt("notes")."</div>";
261  }
262 
266  function showNote()
267  {
268  global $lng, $ilCtrl;
269 
270  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
271  $note_gui = new ilNoteGUI();
272  $note_gui->enableTargets();
273  include_once("./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
274  $content_block = new ilPDContentBlockGUI();
275  $content_block->setContent($note_gui->getPDNoteHTML($_GET["note_id"]));
276  $content_block->setTitle($lng->txt("note"));
277  $content_block->setColSpan(2);
278  $content_block->setImage(ilUtil::getImagePath("icon_note.png"));
279  $content_block->addHeaderCommand($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"),
280  $lng->txt("selected_items_back"));
281 
282  return $content_block->getHTML();
283  }
284 
285 }
286 
287 ?>