ILIAS  Release_5_0_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->setTitle($lng->txt("notes"));
31  $this->setAvailableDetailLevels(3);
32  }
33 
39  static function getBlockType()
40  {
41  return self::$block_type;
42  }
43 
49  static function isRepositoryObject()
50  {
51  return false;
52  }
53 
57  static function getScreenMode()
58  {
59  switch($_GET["cmd"])
60  {
61  case "showNote":
62  return IL_SCREEN_CENTER;
63  break;
64 
65  default:
66  return IL_SCREEN_SIDE;
67  break;
68  }
69  }
70 
74  function &executeCommand()
75  {
76  global $ilCtrl;
77 
78  $next_class = $ilCtrl->getNextClass();
79  $cmd = $ilCtrl->getCmd("getHTML");
80 
81  return $this->$cmd();
82  }
83 
84  function getHTML()
85  {
86  if ($this->getCurrentDetailLevel() == 0)
87  {
88  return "";
89  }
90  else
91  {
92  return parent::getHTML();
93  }
94  }
95 
99  function fillDataSection()
100  {
101  global $ilUser;
102 
103  include_once("Services/Notes/classes/class.ilNote.php");
104  $this->notes = ilNote::_getLastNotesOfUser();
105 
106  if ($this->getCurrentDetailLevel() > 1 && count($this->notes) > 0)
107  {
108  $this->setRowTemplate("tpl.pd_notes_overview.html", "Services/Notes");
109  $this->getListRowData();
110  //$this->setColSpan(2);
112  }
113  else
114  {
115  $this->setEnableNumInfo(false);
116  if (count($this->notes) == 0)
117  {
118  $this->setEnableDetailRow(false);
119  }
120  $this->setDataSection($this->getOverview());
121  }
122  }
123 
124 
128  function getListRowData()
129  {
130  global $ilUser, $lng, $ilCtrl;
131 
132  $data = array();
133 
134  foreach($this->notes as $note)
135  {
136  switch ($note->getLabel())
137  {
138  case IL_NOTE_UNLABELED:
139  $img = ilUtil::getImagePath("note_unlabeled.svg");
140  $alt = $lng->txt("note");
141  break;
142 
143  case IL_NOTE_IMPORTANT:
144  $img = ilUtil::getImagePath("note_unlabeled.svg");
145  $alt = $lng->txt("note").", ".$lng->txt("important");
146  break;
147 
148  case IL_NOTE_QUESTION:
149  $img = ilUtil::getImagePath("note_unlabeled.svg");
150  $alt = $lng->txt("note").", ".$lng->txt("question");
151  break;
152 
153  case IL_NOTE_PRO:
154  $img = ilUtil::getImagePath("note_unlabeled.svg");
155  $alt = $lng->txt("note").", ".$lng->txt("pro");
156  break;
157 
158  case IL_NOTE_CONTRA:
159  $img = ilUtil::getImagePath("note_unlabeled.svg");
160  $alt = $lng->txt("note").", ".$lng->txt("contra");
161  break;
162  }
163 
164  // details
165  $target = $note->getObject();
166 
167  // new notes do not have subject anymore
168  $title = $note->getSubject();
169  if(!$title)
170  {
171  $title = ilUtil::shortenText($note->getText(), 75, true, true);
172  }
173 
174  $data[] = array(
175  "subject" => $title,
176  "img" => $img,
177  "alt" => $alt,
178  "text" => ilUtil::shortenText($note->getText(), 150, true, true),
179  "date" => $note->getCreationDate(),
180  "id" => $note->getId(),
181  "obj_type" => $target["obj_type"],
182  "obj_id" => $target["obj_id"],
183  "rep_obj_id" => $target["rep_obj_id"]);
184  }
185 
186  $this->setData($data);
187  }
188 
192  function fillRow($a_set)
193  {
194  global $ilUser, $ilCtrl, $lng;
195 
196  include_once("Services/Notes/classes/class.ilNoteGUI.php");
197  if (!is_object($this->note_gui))
198  {
199  $this->note_gui = new ilNoteGUI(0,0,"");
200  $this->note_gui->enableTargets();
201  }
202 
203  //if ($this->getCurrentDetailLevel() > 2)
204  //{
205  // $this->tpl->setVariable("VAL_SUBJECT", "<b>".$a_set["subject"]."</b>");
206  //}
207  //else
208  //{
209  $this->tpl->setVariable("VAL_SUBJECT", $a_set["subject"]);
210  //}
211 
212  // link subject to show note function
213  $ilCtrl->setParameter($this, "rel_obj", $a_set["rep_obj_id"]);
214  $ilCtrl->setParameter($this, "note_id", $a_set["id"]);
215  $ilCtrl->setParameter($this, "note_type", IL_NOTE_PRIVATE);
216  $this->tpl->setVariable("HREF_SHOW_NOTE",
217  $ilCtrl->getLinkTarget($this, "showNote"));
218  $this->tpl->setVariable("IMG_NOTE", $a_set["img"]);
219  $this->tpl->setVariable("ALT_NOTE", $a_set["alt"]);
220  $ilCtrl->clearParameters($this);
221 
222  // details
223  if ($this->getCurrentDetailLevel() > 2)
224  {
225  $this->tpl->setCurrentBlock("details");
226  if (substr($a_set["text"], 0, 40) != substr($a_set["text"], 0, 40))
227  {
228  $this->tpl->setVariable("NOTE_TEXT", $a_set["text"]);
229  }
230  $this->tpl->setVariable("VAL_DATE",
232  $this->tpl->parseCurrentBlock();
233 
234  // target objects
235  $this->note_gui->showTargets($this->tpl, $a_set["rep_obj_id"], $a_set["id"],
236  $a_set["obj_type"], $a_set["obj_id"]);
237 
238  // edit button
239  $this->tpl->setCurrentBlock("edit_note");
240  $this->tpl->setVariable("TXT_EDIT_NOTE", $lng->txt("edit"));
241  $ilCtrl->setParameterByClass("ilnotegui", "rel_obj", $a_set["rep_obj_id"]);
242  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $a_set["id"]);
243  $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
244  $this->tpl->setVariable("LINK_EDIT_NOTE",
245  $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilpdnotesgui", "ilnotegui"), "editNoteForm")
246  ."#note_edit");
247  $this->tpl->parseCurrentBlock();
248  }
249  $ilCtrl->clearParametersByClass("ilnotegui");
250  }
251 
255  function getOverview()
256  {
257  global $ilUser, $lng, $ilCtrl;
258 
259  return '<div class="small">'.((int) count($this->notes))." ".$lng->txt("notes")."</div>";
260  }
261 
265  function showNote()
266  {
267  global $lng, $ilCtrl;
268 
269  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
270  $note_gui = new ilNoteGUI();
271  $note_gui->enableTargets();
272  include_once("./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
273  $content_block = new ilPDContentBlockGUI();
274  $content_block->setContent($note_gui->getPDNoteHTML($_GET["note_id"]));
275  $content_block->setTitle($lng->txt("note"));
276  $content_block->setColSpan(2);
277  $content_block->addHeaderCommand($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"),
278  $lng->txt("selected_items_back"));
279 
280  return $content_block->getHTML();
281  }
282 
283 }
284 
285 ?>