ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  public static $block_type = "pdnotes";
18  protected $note_gui = null;
19 
23  public function __construct()
24  {
25  global $DIC;
26 
27  $this->ctrl = $DIC->ctrl();
28  $this->lng = $DIC->language();
29  $this->user = $DIC->user();
30  $lng = $DIC->language();
31 
32  parent::__construct();
33 
34  $this->setLimit(5);
35  $this->setTitle($lng->txt("notes"));
36  $this->setAvailableDetailLevels(3);
37  }
38 
42  public function getBlockType() : string
43  {
44  return self::$block_type;
45  }
46 
50  protected function isRepositoryObject() : bool
51  {
52  return false;
53  }
54 
58  public static function getScreenMode()
59  {
60  switch ($_GET["cmd"]) {
61  case "showNote":
62  return IL_SCREEN_CENTER;
63  break;
64 
65  default:
66  return IL_SCREEN_SIDE;
67  break;
68  }
69  }
70 
74  public function executeCommand()
75  {
77 
78  $next_class = $ilCtrl->getNextClass();
79  $cmd = $ilCtrl->getCmd("getHTML");
80 
81  return $this->$cmd();
82  }
83 
84  public function getHTML()
85  {
86  if ($this->getCurrentDetailLevel() == 0) {
87  return "";
88  } else {
89  return parent::getHTML();
90  }
91  }
92 
96  public function fillDataSection()
97  {
99 
100  include_once("Services/Notes/classes/class.ilNote.php");
101  $this->notes = ilNote::_getLastNotesOfUser();
102 
103  if ($this->getCurrentDetailLevel() > 1 && count($this->notes) > 0) {
104  $this->setRowTemplate("tpl.pd_notes_overview.html", "Services/Notes");
105  $this->getListRowData();
106  //$this->setColSpan(2);
107  parent::fillDataSection();
108  } else {
109  $this->setEnableNumInfo(false);
110  if (count($this->notes) == 0) {
111  $this->setEnableDetailRow(false);
112  }
113  $this->setDataSection($this->getOverview());
114  }
115  }
116 
117 
121  public function getListRowData()
122  {
124  $lng = $this->lng;
126 
127  $data = array();
128 
129  foreach ($this->notes as $note) {
130  switch ($note->getLabel()) {
131  case IL_NOTE_UNLABELED:
132  $img = ilUtil::getImagePath("note_unlabeled.svg");
133  $alt = $lng->txt("note");
134  break;
135 
136  case IL_NOTE_IMPORTANT:
137  $img = ilUtil::getImagePath("note_unlabeled.svg");
138  $alt = $lng->txt("note") . ", " . $lng->txt("important");
139  break;
140 
141  case IL_NOTE_QUESTION:
142  $img = ilUtil::getImagePath("note_unlabeled.svg");
143  $alt = $lng->txt("note") . ", " . $lng->txt("question");
144  break;
145 
146  case IL_NOTE_PRO:
147  $img = ilUtil::getImagePath("note_unlabeled.svg");
148  $alt = $lng->txt("note") . ", " . $lng->txt("pro");
149  break;
150 
151  case IL_NOTE_CONTRA:
152  $img = ilUtil::getImagePath("note_unlabeled.svg");
153  $alt = $lng->txt("note") . ", " . $lng->txt("contra");
154  break;
155  }
156 
157  // details
158  $target = $note->getObject();
159 
160  // new notes do not have subject anymore
161  $title = $note->getSubject();
162  if (!$title) {
163  $title = ilUtil::shortenText($note->getText(), 75, true, true);
164  }
165 
166  $data[] = array(
167  "subject" => $title,
168  "img" => $img,
169  "alt" => $alt,
170  "text" => ilUtil::shortenText($note->getText(), 150, true, true),
171  "date" => $note->getCreationDate(),
172  "id" => $note->getId(),
173  "obj_type" => $target["obj_type"],
174  "obj_id" => $target["obj_id"],
175  "rep_obj_id" => $target["rep_obj_id"]);
176  }
177 
178  $this->setData($data);
179  }
180 
184  public function fillRow($a_set)
185  {
188  $lng = $this->lng;
189 
190  include_once("Services/Notes/classes/class.ilNoteGUI.php");
191  if (!is_object($this->note_gui)) {
192  $this->note_gui = new ilNoteGUI(0, 0, "");
193  $this->note_gui->enableTargets();
194  }
195 
196  $this->tpl->setVariable("VAL_SUBJECT", $a_set["subject"]);
197 
198  // link subject to show note function
199  $ilCtrl->setParameter($this, "rel_obj", $a_set["rep_obj_id"]);
200  $ilCtrl->setParameter($this, "note_id", $a_set["id"]);
201  $ilCtrl->setParameter($this, "note_type", IL_NOTE_PRIVATE);
202  $this->tpl->setVariable(
203  "HREF_SHOW_NOTE",
204  $ilCtrl->getLinkTarget($this, "showNote")
205  );
206  $this->tpl->setVariable("IMG_NOTE", $a_set["img"]);
207  $this->tpl->setVariable("ALT_NOTE", $a_set["alt"]);
208  $ilCtrl->clearParameters($this);
209 
210  // details
211  if ($this->getCurrentDetailLevel() > 2) {
212  $this->tpl->setCurrentBlock("details");
213  if (substr($a_set["text"], 0, 40) != substr($a_set["text"], 0, 40)) {
214  $this->tpl->setVariable("NOTE_TEXT", $a_set["text"]);
215  }
216  $this->tpl->setVariable(
217  "VAL_DATE",
219  );
220  $this->tpl->parseCurrentBlock();
221 
222  // target objects
223  $note = new ilNote($a_set["id"]);
224  $this->tpl->setVariable(
225  "TARGET_OBJECTS",
226  $this->note_gui->renderTargets($note)
227  );
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(
236  "LINK_EDIT_NOTE",
237  $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilpdnotesgui", "ilnotegui"), "editNoteForm")
238  . "#note_edit"
239  );
240  $this->tpl->parseCurrentBlock();
241  }
242  $ilCtrl->clearParametersByClass("ilnotegui");
243  }
244 
248  public function getOverview()
249  {
251  $lng = $this->lng;
253 
254  return '<div class="small">' . ((int) count($this->notes)) . " " . $lng->txt("notes") . "</div>";
255  }
256 
260  public function showNote()
261  {
262  $lng = $this->lng;
264 
265  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
266  $note_gui = new ilNoteGUI();
267  $note_gui->enableTargets();
268  include_once("./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
269  $content_block = new ilPDContentBlockGUI();
270  $content_block->setContent($note_gui->getPDNoteHTML($_GET["note_id"]));
271  $content_block->setTitle($lng->txt("note"));
272  $content_block->setColSpan(2);
273  $content_block->addHeaderCommand(
274  $ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"),
275  $lng->txt("selected_items_back")
276  );
277 
278  return $content_block->getHTML();
279  }
280 }
const IL_NOTE_CONTRA
fillDataSection()
Fill data section.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
const IL_NOTE_PRO
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
const IL_CAL_DATETIME
global $DIC
Definition: saml.php:7
getListRowData()
Get list data.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
$_GET["client_id"]
BlockGUI class for Personal Desktop Notes block.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
user()
Definition: user.php:4
Note class.
Notes GUI class.
global $ilCtrl
Definition: ilias.php:18
fillRow($a_set)
get flat bookmark list for personal desktop
setTitle($a_title)
Set Title.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
executeCommand()
execute command
setData($a_data)
Set Data.
setAvailableDetailLevels($a_max, $a_min=0)
Set Available Detail Levels.
Date and time handling
$ilUser
Definition: imgupload.php:18
const IL_SCREEN_CENTER
setLimit($a_limit)
Set Limit.
static getScreenMode()
Get Screen Mode for current command.
const IL_NOTE_UNLABELED
Definition: class.ilNote.php:8
const IL_NOTE_QUESTION
showNote()
show single note
This class represents a block method of a block.
BlockGUI class for (centered) Content on Personal Desktop.
const IL_NOTE_IMPORTANT
Definition: class.ilNote.php:9
static _getLastNotesOfUser()
get last notes of current user
const IL_SCREEN_SIDE
$target
Definition: test.php:19
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
setEnableDetailRow($a_enabledetailrow)
Set EnableDetailRow.
getCurrentDetailLevel()
Get Current Detail Level.