ILIAS  release_4-4 Revision
class.ilPortfolioPageGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
5 
19 {
20  const EMBEDDED_NO_OUTPUT = -99;
21 
22  protected $js_onload_code = array();
23  protected $additional = array();
24 
28  function __construct($a_portfolio_id, $a_id = 0, $a_old_nr = 0, $a_enable_comments = true)
29  {
30  global $tpl;
31 
32  $this->portfolio_id = (int)$a_portfolio_id;
33  $this->enable_comments = (bool)$a_enable_comments;
34 
35  parent::__construct($this->getParentType(), $a_id, $a_old_nr);
36  $this->getPageObject()->setPortfolioId($this->portfolio_id);
37 
38  // content style
39  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
40 
41  $tpl->setCurrentBlock("SyntaxStyle");
42  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
44  $tpl->parseCurrentBlock();
45 
46  $tpl->setCurrentBlock("ContentStyle");
47  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
49  $tpl->parseCurrentBlock();
50  }
51 
52  function getParentType()
53  {
54  return "prtf";
55  }
56 
57  protected function getPageContentUserId($a_user_id)
58  {
59  // user id from content-xml
60  return $a_user_id;
61  }
62 
66  function &executeCommand()
67  {
68  global $ilCtrl, $ilUser;
69 
70  $next_class = $this->ctrl->getNextClass($this);
71  $cmd = $this->ctrl->getCmd();
72 
73  switch($next_class)
74  {
75  case "ilobjbloggui":
76  // we need the wsp-id for the keywords
77  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
78  $wsp_tree = new ilWorkspaceTree($ilUser->getId());
79  $blog_obj_id = (int)$this->getPageObject()->getTitle();
80  $blog_node_id = $wsp_tree->lookupNodeId($blog_obj_id);
81 
82  include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
83  $blog_gui = new ilObjBlogGUI($blog_node_id, ilObjBlogGUI::WORKSPACE_NODE_ID);
84  $blog_gui->disableNotes(!$this->enable_comments);
85  return $ilCtrl->forwardCommand($blog_gui);
86 
87  case "ilcalendarmonthgui":
88  // booking action
89  if($cmd && $cmd != "preview")
90  {
91  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
92  $month_gui = new ilCalendarMonthGUI(new ilDate());
93  return $ilCtrl->forwardCommand($month_gui);
94  }
95  // calendar month navigation
96  else
97  {
98  $ilCtrl->setParameter($this, "cmd", "preview");
99  return self::EMBEDDED_NO_OUTPUT;
100  }
101 
102  case "ilpageobjectgui":
103  die("Deprecated. ilPortfolioPage gui forwarding to ilpageobject");
104  return;
105 
106  default:
107  $this->setPresentationTitle($this->getPageObject()->getTitle());
108  return parent::executeCommand();
109  }
110  }
111 
117  function showPage()
118  {
119  global $ilUser;
120 
121  if(!$this->getPageObject())
122  {
123  return;
124  }
125 
126  switch($this->getPageObject()->getType())
127  {
129  return $this->renderBlog($ilUser->getId(), (int)$this->getPageObject()->getTitle());
130 
131  default:
132  $this->setTemplateOutput(false);
133  // $this->setPresentationTitle($this->getPageObject()->getTitle());
134  $output = parent::showPage();
135 
136  return $output;
137  }
138  }
139 
146  function getTabs($a_activate = "")
147  {
148  if(!$this->embedded)
149  {
150  parent::getTabs($a_activate);
151  }
152  }
153 
159  function setEmbedded($a_value)
160  {
161  $this->embedded = (bool)$a_value;
162  }
163 
169  function setAdditional($a_additional)
170  {
171  $this->additional = $a_additional;
172  }
173 
179  function getAdditional()
180  {
181  return $this->additional;
182  }
183 
184  function getJsOnloadCode()
185  {
186  return $this->js_onload_code;
187  }
188 
189  function postOutputProcessing($a_output)
190  {
191  $parts = array(
192  "Profile" => array("0-9", "a-z", "0-9a-z_;\W"), // user, mode, fields
193  "Verification" => array("0-9", "a-z", "0-9"), // user, type, id
194  "Blog" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
195  "BlogTeaser" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
196  "Skills" => array("0-9", "0-9"), // user, skill id
197  "SkillsTeaser" => array("0-9", "0-9"), // user, skill id
198  "ConsultationHours" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
199  "ConsultationHoursTeaser" => array("0-9", "a-z", "0-9;\W") // user, mode, group ids
200  );
201 
202  foreach($parts as $type => $def)
203  {
204  $def = implode("]+)#([", $def);
205  if(preg_match_all("/".$this->pl_start.$type."#([".$def.
206  "]+)".$this->pl_end."/", $a_output, $blocks))
207  {
208  foreach($blocks[0] as $idx => $block)
209  {
210  switch($type)
211  {
212  case "Profile":
213  case "Blog":
214  case "BlogTeaser":
215  case "Skills":
216  case "SkillsTeaser":
217  case "ConsultationHours":
218  case "ConsultationHoursTeaser":
219  $subs = null;
220  if(trim($blocks[3][$idx]))
221  {
222  foreach(explode(";", $blocks[3][$idx]) as $sub)
223  {
224  if(trim($sub))
225  {
226  $subs[] = trim($sub);
227  }
228  }
229  }
230  $snippet = $this->{"render".$type}($blocks[1][$idx],
231  $blocks[2][$idx], $subs);
232  break;
233 
234  default:
235  $snippet = $this->{"render".$type}($blocks[1][$idx],
236  $blocks[2][$idx], $blocks[3][$idx]);
237  break;
238  }
239 
240  $snippet = $this->renderPageElement($type, $snippet);
241  $a_output = str_replace($block, $snippet, $a_output);
242  }
243  }
244  }
245 
246  return $a_output;
247  }
248 
249  protected function renderPageElement($a_type, $a_html)
250  {
251  return trim($a_html);
252  }
253 
254  protected function renderTeaser($a_type, $a_title, $a_options = null)
255  {
256  $options = "";
257  if($a_options)
258  {
259  $options = '<div class="il_Footer">'.$this->lng->txt("prtf_page_element_teaser_settings").
260  ": ".$a_options.'</div>';
261  }
262 
263  return '<div style="margin:5px" class="ilBox"><h3>'.$a_title.'</h3>'.
264  '<div class="il_Description_no_margin">'.$this->lng->txt("prtf_page_element_teaser_".$a_type).'</div>'.
265  $options.'</div>';
266  }
267 
268  protected function renderProfile($a_user_id, $a_type, array $a_fields = null)
269  {
270  global $ilCtrl;
271 
272  $user_id = $this->getPageContentUserId($a_user_id);
273 
274  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
275  $pub_profile = new ilPublicUserProfileGUI($user_id);
276  $pub_profile->setEmbedded(true, ($this->getOutputMode() == "offline"));
277 
278  // full circle: additional was set in the original public user profile call
279  $pub_profile->setAdditional($this->getAdditional());
280 
281  if($a_type == "manual" && sizeof($a_fields))
282  {
283  $prefs = array();
284  foreach($a_fields as $field)
285  {
286  $field = trim($field);
287  if($field)
288  {
289  $prefs["public_".$field] = "y";
290  }
291  }
292 
293  $pub_profile->setCustomPrefs($prefs);
294  }
295 
296  if($this->getOutputMode() != "offline")
297  {
298  return $ilCtrl->getHTML($pub_profile);
299  }
300  else
301  {
302  return $pub_profile->getEmbeddable();
303  }
304  }
305 
306  protected function renderVerification($a_user_id, $a_type, $a_id)
307  {
308  global $objDefinition;
309 
310  // not used
311  // $user_id = $this->getPageContentUserId($a_user_id);
312 
313  $class = "ilObj".$objDefinition->getClassName($a_type)."GUI";
314  include_once $objDefinition->getLocation($a_type)."/class.".$class.".php";
315  $verification = new $class($a_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
316 
317  // direct download link
318  $this->ctrl->setParameter($this, "dlid", $a_id);
319  $url = $this->ctrl->getLinkTarget($this, "dl".$a_type);
320  $this->ctrl->setParameter($this, "dlid", "");
321 
322  return $verification->render(true, $url);
323  }
324 
325  protected function dltstv()
326  {
327  $id = $_GET["dlid"];
328  if($id)
329  {
330  include_once "Modules/Test/classes/class.ilObjTestVerificationGUI.php";
332  $verification->downloadFromPortfolioPage($this->getPageObject());
333  }
334  }
335 
336  protected function dlexcv()
337  {
338  $id = $_GET["dlid"];
339  if($id)
340  {
341  include_once "Modules/Exercise/classes/class.ilObjExerciseVerificationGUI.php";
343  $verification->downloadFromPortfolioPage($this->getPageObject());
344  }
345  }
346 
347  protected function dlcrsv()
348  {
349  $id = $_GET["dlid"];
350  if($id)
351  {
352  include_once "Modules/Course/classes/Verification/class.ilObjCourseVerificationGUI.php";
354  $verification->downloadFromPortfolioPage($this->getPageObject());
355  }
356  }
357 
358  protected function dlscov()
359  {
360  $id = $_GET["dlid"];
361  if($id)
362  {
363  include_once "Modules/ScormAicc/classes/Verification/class.ilObjSCORMVerificationGUI.php";
365  $verification->downloadFromPortfolioPage($this->getPageObject());
366  }
367  }
368 
369  protected function renderBlog($a_user_id, $a_blog_id, array $a_posting_ids = null)
370  {
371  global $ilCtrl;
372 
373  // not used
374  // $user_id = $this->getPageContentUserId($a_user_id);
375 
376  // full blog (separate tab/page)
377  if(!$a_posting_ids)
378  {
379  include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
380  $blog = new ilObjBlogGUI($a_blog_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
381  $blog->disableNotes(!$this->enable_comments);
382  $blog->setContentStyleSheet();
383 
384  if($this->getOutputMode() != "offline")
385  {
386  return $ilCtrl->getHTML($blog);
387  }
388  else
389  {
390 
391  }
392  }
393  // embedded postings
394  else
395  {
396  $html = array();
397 
398  include_once "Modules/Blog/classes/class.ilObjBlog.php";
399  $html[] = ilObjBlog::_lookupTitle($a_blog_id);
400 
401  include_once "Modules/Blog/classes/class.ilBlogPostingGUI.php";
402  foreach($a_posting_ids as $post)
403  {
404  $page = new ilBlogPostingGUI(0, null, $post);
405  if($this->getOutputMode() != "offline")
406  {
407  $page->setOutputMode(IL_PAGE_PREVIEW);
408  }
409  else
410  {
411  $page->setOutputMode("offline");
412  }
413  $html[] = $page->showPage();
414  }
415 
416  return implode("\n", $html);
417  }
418  }
419 
420  protected function renderBlogTeaser($a_user_id, $a_blog_id, array $a_posting_ids = null)
421  {
422  // not used
423  // $user_id = $this->getPageContentUserId($a_user_id);
424 
425  $postings = "";
426  if($a_posting_ids)
427  {
428  $postings = array("<ul>");
429  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
430  foreach($a_posting_ids as $post)
431  {
432  $post = new ilBlogPosting($post);
433  $postings[] = "<li>".$post->getTitle()." - ".
434  ilDatePresentation::formatDate($post->getCreated())."</li>";
435  }
436  $postings[] = "</ul>";
437  $postings = implode("\n", $postings);
438  }
439 
440  return $this->renderTeaser("blog", $this->lng->txt("obj_blog").' "'.
441  ilObject::_lookupTitle($a_blog_id).'"', $postings);
442  }
443 
444  protected function renderSkills($a_user_id, $a_skills_id)
445  {
446  if($this->getOutputMode() == "preview")
447  {
448  return $this->renderSkillsTeaser($a_user_id, $a_skills_id);
449  }
450 
451  $user_id = $this->getPageContentUserId($a_user_id);
452 
453  include_once "Services/Skill/classes/class.ilPersonalSkillsGUI.php";
454  $gui = new ilPersonalSkillsGUI();
455  if($this->getOutputMode() == "offline")
456  {
457  $gui->setOfflineMode("./files/");
458  }
459  $html = $gui->getSkillHTML($a_skills_id, $user_id);
460 
461  if($this->getOutputMode() == "offline")
462  {
463  $js = $gui->getTooltipsJs();
464  if(sizeof($js))
465  {
466  $this->js_onload_code = array_merge($this->js_onload_code, $js);
467  }
468  }
469 
470  return $html;
471  }
472 
473  protected function renderSkillsTeaser($a_user_id, $a_skills_id)
474  {
475  // not used
476  // $user_id = $this->getPageContentUserId($a_user_id);
477 
478  include_once "Services/Skill/classes/class.ilSkillTreeNode.php";
479 
480  return $this->renderTeaser("skills", $this->lng->txt("skills").' "'.
481  ilSkillTreeNode::_lookupTitle($a_skills_id).'"');
482  }
483 
484  protected function renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids)
485  {
486  // not used
487  // $user_id = $this->getPageContentUserId($a_user_id);
488 
489  if($a_mode == "auto")
490  {
491  $mode = $this->lng->txt("cont_cach_mode_automatic");
492  $groups = null;
493  }
494  else
495  {
496  $mode = $this->lng->txt("cont_cach_mode_manual");
497 
498  include_once "Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php";
499  $groups = array();
500  foreach($a_group_ids as $grp_id)
501  {
502  $groups[] = ilConsultationHourGroups::lookupTitle($grp_id);
503  }
504  $groups = " (".implode(", ", $groups).")";
505  }
506 
507  $this->lng->loadLanguageModule("dateplaner");
508  return $this->renderTeaser("consultation_hours",
509  $this->lng->txt("app_consultation_hours"), $mode.$groups);
510  }
511 
512  protected function renderConsultationHours($a_user_id, $a_mode, $a_group_ids)
513  {
514  global $ilUser;
515 
516  if($this->getOutputMode() == "preview")
517  {
518  return $this->renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids);
519  }
520 
521  if($this->getOutputMode() == "offline")
522  {
523  return;
524  }
525 
526  $user_id = $this->getPageContentUserId($a_user_id);
527 
528  // only if not owner
529  if($ilUser->getId() != $user_id)
530  {
531  $_GET["bkid"] = $user_id;
532  }
533 
534  if($a_mode != "manual")
535  {
536  $a_group_ids = null;
537  }
538 
539  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
540  ilCalendarCategories::_getInstance()->setCHUserId($user_id);
542 
543  if(!$_REQUEST["seed"])
544  {
545  $seed = new ilDate(time(), IL_CAL_UNIX);
546  }
547  else
548  {
549  $seed = new ilDate($_REQUEST["seed"], IL_CAL_DATE);
550  }
551 
552  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
553  $month_gui = new ilCalendarMonthGUI($seed);
554 
555  // custom schedule filter: handle booking group ids
556  include_once('./Services/Calendar/classes/class.ilCalendarScheduleFilterBookings.php');
557  $filter = new ilCalendarScheduleFilterBookings($user_id, $a_group_ids);
558  $month_gui->addScheduleFilter($filter);
559 
560  $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem','delos.css','Services/Calendar'));
561 
562  $this->lng->loadLanguageModule("dateplaner");
563  return '<h3>'.$this->lng->txt("app_consultation_hours").'</h3>'.
564  $this->ctrl->getHTML($month_gui);
565  }
566 }
567 
568 ?>
renderBlog($a_user_id, $a_blog_id, array $a_posting_ids=null)
const IL_PAGE_PREVIEW
__construct($a_portfolio_id, $a_id=0, $a_old_nr=0, $a_enable_comments=true)
Constructor.
getPageObject()
Get Page Object.
Class ilBlogPosting.
Calendar schedule filter for consultation hour bookings.
static _lookupTitle($a_id)
setTemplateOutput($a_output=true)
static lookupTitle($a_group_id)
Lookup group title.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
getAdditional()
Get Additonal Information.
Class ilBlogPosting GUI class.
Class ilPageObjectGUI.
$cmd
Definition: sahs_server.php:35
setEmbedded($a_value)
Set embedded mode: will suppress tabs.
static _lookupTitle($a_id)
lookup object title
Portfolio page gui class.
const IL_CAL_UNIX
getSyntaxStylePath()
get syntax style path
Tree handler for personal workspace.
global $ilCtrl
Definition: ilias.php:18
Personal skills GUI class.
GUI class for course verification.
GUI class for public user profile presentation.
Class for single dates.
if(!is_array($argv)) $options
Class ilObjBlogGUI.
getTabs($a_activate="")
Set all tabs.
GUI class for exercise verification.
renderSkills($a_user_id, $a_skills_id)
renderBlogTeaser($a_user_id, $a_blog_id, array $a_posting_ids=null)
static formatDate(ilDateTime $date)
Format a date public.
renderSkillsTeaser($a_user_id, $a_skills_id)
setPresentationTitle($a_title="")
static _getInstance($a_usr_id=0)
get singleton instance
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
const IL_CAL_DATE
global $ilUser
Definition: imgupload.php:15
GUI class for test verification.
getContentStylePath($a_style_id)
get content style path
setAdditional($a_additional)
Set Additonal Information.
renderTeaser($a_type, $a_title, $a_options=null)
renderVerification($a_user_id, $a_type, $a_id)
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
renderPageElement($a_type, $a_html)
renderProfile($a_user_id, $a_type, array $a_fields=null)
& executeCommand()
execute command
GUI class for scorm verification.
renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids)
renderConsultationHours($a_user_id, $a_mode, $a_group_ids)