ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
5include_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"));
37 }
38
44 public static function getBlockType()
45 {
46 return self::$block_type;
47 }
48
54 public static function isRepositoryObject()
55 {
56 return false;
57 }
58
62 public static function getScreenMode()
63 {
64 switch ($_GET["cmd"]) {
65 case "showNote":
66 return IL_SCREEN_CENTER;
67 break;
68
69 default:
70 return IL_SCREEN_SIDE;
71 break;
72 }
73 }
74
78 public function executeCommand()
79 {
81
82 $next_class = $ilCtrl->getNextClass();
83 $cmd = $ilCtrl->getCmd("getHTML");
84
85 return $this->$cmd();
86 }
87
88 public function getHTML()
89 {
90 if ($this->getCurrentDetailLevel() == 0) {
91 return "";
92 } else {
93 return parent::getHTML();
94 }
95 }
96
100 public function fillDataSection()
101 {
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 $this->setRowTemplate("tpl.pd_notes_overview.html", "Services/Notes");
109 $this->getListRowData();
110 //$this->setColSpan(2);
111 parent::fillDataSection();
112 } else {
113 $this->setEnableNumInfo(false);
114 if (count($this->notes) == 0) {
115 $this->setEnableDetailRow(false);
116 }
117 $this->setDataSection($this->getOverview());
118 }
119 }
120
121
125 public function getListRowData()
126 {
130
131 $data = array();
132
133 foreach ($this->notes as $note) {
134 switch ($note->getLabel()) {
136 $img = ilUtil::getImagePath("note_unlabeled.svg");
137 $alt = $lng->txt("note");
138 break;
139
141 $img = ilUtil::getImagePath("note_unlabeled.svg");
142 $alt = $lng->txt("note") . ", " . $lng->txt("important");
143 break;
144
145 case IL_NOTE_QUESTION:
146 $img = ilUtil::getImagePath("note_unlabeled.svg");
147 $alt = $lng->txt("note") . ", " . $lng->txt("question");
148 break;
149
150 case IL_NOTE_PRO:
151 $img = ilUtil::getImagePath("note_unlabeled.svg");
152 $alt = $lng->txt("note") . ", " . $lng->txt("pro");
153 break;
154
155 case IL_NOTE_CONTRA:
156 $img = ilUtil::getImagePath("note_unlabeled.svg");
157 $alt = $lng->txt("note") . ", " . $lng->txt("contra");
158 break;
159 }
160
161 // details
162 $target = $note->getObject();
163
164 // new notes do not have subject anymore
165 $title = $note->getSubject();
166 if (!$title) {
167 $title = ilUtil::shortenText($note->getText(), 75, true, true);
168 }
169
170 $data[] = array(
171 "subject" => $title,
172 "img" => $img,
173 "alt" => $alt,
174 "text" => ilUtil::shortenText($note->getText(), 150, true, true),
175 "date" => $note->getCreationDate(),
176 "id" => $note->getId(),
177 "obj_type" => $target["obj_type"],
178 "obj_id" => $target["obj_id"],
179 "rep_obj_id" => $target["rep_obj_id"]);
180 }
181
182 $this->setData($data);
183 }
184
188 public function fillRow($a_set)
189 {
193
194 include_once("Services/Notes/classes/class.ilNoteGUI.php");
195 if (!is_object($this->note_gui)) {
196 $this->note_gui = new ilNoteGUI(0, 0, "");
197 $this->note_gui->enableTargets();
198 }
199
200 $this->tpl->setVariable("VAL_SUBJECT", $a_set["subject"]);
201
202 // link subject to show note function
203 $ilCtrl->setParameter($this, "rel_obj", $a_set["rep_obj_id"]);
204 $ilCtrl->setParameter($this, "note_id", $a_set["id"]);
205 $ilCtrl->setParameter($this, "note_type", IL_NOTE_PRIVATE);
206 $this->tpl->setVariable(
207 "HREF_SHOW_NOTE",
208 $ilCtrl->getLinkTarget($this, "showNote")
209 );
210 $this->tpl->setVariable("IMG_NOTE", $a_set["img"]);
211 $this->tpl->setVariable("ALT_NOTE", $a_set["alt"]);
212 $ilCtrl->clearParameters($this);
213
214 // details
215 if ($this->getCurrentDetailLevel() > 2) {
216 $this->tpl->setCurrentBlock("details");
217 if (substr($a_set["text"], 0, 40) != substr($a_set["text"], 0, 40)) {
218 $this->tpl->setVariable("NOTE_TEXT", $a_set["text"]);
219 }
220 $this->tpl->setVariable(
221 "VAL_DATE",
223 );
224 $this->tpl->parseCurrentBlock();
225
226 // target objects
227 $this->note_gui->showTargets(
228 $this->tpl,
229 $a_set["rep_obj_id"],
230 $a_set["id"],
231 $a_set["obj_type"],
232 $a_set["obj_id"]
233 );
234
235 // edit button
236 $this->tpl->setCurrentBlock("edit_note");
237 $this->tpl->setVariable("TXT_EDIT_NOTE", $lng->txt("edit"));
238 $ilCtrl->setParameterByClass("ilnotegui", "rel_obj", $a_set["rep_obj_id"]);
239 $ilCtrl->setParameterByClass("ilnotegui", "note_id", $a_set["id"]);
240 $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
241 $this->tpl->setVariable(
242 "LINK_EDIT_NOTE",
243 $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilpdnotesgui", "ilnotegui"), "editNoteForm")
244 . "#note_edit"
245 );
246 $this->tpl->parseCurrentBlock();
247 }
248 $ilCtrl->clearParametersByClass("ilnotegui");
249 }
250
254 public function getOverview()
255 {
259
260 return '<div class="small">' . ((int) count($this->notes)) . " " . $lng->txt("notes") . "</div>";
261 }
262
266 public function showNote()
267 {
270
271 include_once("./Services/Notes/classes/class.ilNoteGUI.php");
272 $note_gui = new ilNoteGUI();
273 $note_gui->enableTargets();
274 include_once("./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
275 $content_block = new ilPDContentBlockGUI();
276 $content_block->setContent($note_gui->getPDNoteHTML($_GET["note_id"]));
277 $content_block->setTitle($lng->txt("note"));
278 $content_block->setColSpan(2);
279 $content_block->addHeaderCommand(
280 $ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"),
281 $lng->txt("selected_items_back")
282 );
283
284 return $content_block->getHTML();
285 }
286}
user()
Definition: user.php:4
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_SCREEN_SIDE
const IL_SCREEN_CENTER
const IL_CAL_DATETIME
const IL_NOTE_PRO
const IL_NOTE_UNLABELED
Definition: class.ilNote.php:7
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
const IL_NOTE_CONTRA
const IL_NOTE_QUESTION
Definition: class.ilNote.php:9
const IL_NOTE_IMPORTANT
Definition: class.ilNote.php:8
This class represents a block method of a block.
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
setLimit($a_limit)
Set Limit.
getCurrentDetailLevel()
Get Current Detail Level.
setAvailableDetailLevels($a_max, $a_min=0)
Set Available Detail Levels.
setEnableDetailRow($a_enabledetailrow)
Set EnableDetailRow.
setData($a_data)
Set Data.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
setTitle($a_title)
Set Title.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
Notes GUI class.
static _getLastNotesOfUser()
get last notes of current user
BlockGUI class for (centered) Content on Personal Desktop.
BlockGUI class for Personal Desktop Notes block.
showNote()
show single note
static getScreenMode()
Get Screen Mode for current command.
getListRowData()
Get list data.
fillDataSection()
Fill data section.
static isRepositoryObject()
Get block type.
fillRow($a_set)
get flat bookmark list for personal desktop
getHTML()
Handle config status.
executeCommand()
execute command
static getBlockType()
Get block type.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18