ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
23  protected $obj_definition;
24 
28  protected $tree;
29 
30  const EMBEDDED_NO_OUTPUT = -99;
31 
32  protected $js_onload_code = array();
33  protected $additional = array();
34  protected $export_material = array("js"=>array(), "images"=>array(), "files"=>array());
35 
36  protected static $initialized = 0;
37 
41  public function __construct($a_portfolio_id, $a_id = 0, $a_old_nr = 0, $a_enable_comments = true)
42  {
43  global $DIC;
44 
45  $this->tpl = $DIC["tpl"];
46  $this->ctrl = $DIC->ctrl();
47  $this->user = $DIC->user();
48  $this->obj_definition = $DIC["objDefinition"];
49  $this->access = $DIC->access();
50  $this->tree = $DIC->repositoryTree();
51  $this->lng = $DIC->language();
52  $tpl = $DIC["tpl"];
53 
54  $this->portfolio_id = (int) $a_portfolio_id;
55  $this->enable_comments = (bool) $a_enable_comments;
56 
57  parent::__construct($this->getParentType(), $a_id, $a_old_nr);
58  $this->getPageObject()->setPortfolioId($this->portfolio_id);
59 
60  // content style
61  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
62 
63  $tpl->setCurrentBlock("SyntaxStyle");
64  $tpl->setVariable(
65  "LOCATION_SYNTAX_STYLESHEET",
67  );
68  $tpl->parseCurrentBlock();
69 
70  $tpl->setCurrentBlock("ContentStyle");
71  $tpl->setVariable(
72  "LOCATION_CONTENT_STYLESHEET",
74  );
75  $tpl->setVariable(
76  "LOCATION_ADDITIONAL_STYLESHEET",
78  );
79  $tpl->parseCurrentBlock();
80  }
81 
82  public function getParentType()
83  {
84  return "prtf";
85  }
86 
87  protected function getPageContentUserId($a_user_id)
88  {
89  // user id from content-xml
90  return $a_user_id;
91  }
92 
96  public function executeCommand()
97  {
100 
101  $next_class = $this->ctrl->getNextClass($this);
102  $cmd = $this->ctrl->getCmd();
103 
104  switch ($next_class) {
105  case "ilobjbloggui":
106  // #12879 - we need the wsp-id for the keywords
107  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
108  $wsp_tree = new ilWorkspaceTree($ilUser->getId());
109  $blog_obj_id = (int) $this->getPageObject()->getTitle();
110  $blog_node_id = $wsp_tree->lookupNodeId($blog_obj_id);
111 
112  include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
113  $blog_gui = new ilObjBlogGUI($blog_node_id, ilObjBlogGUI::WORKSPACE_NODE_ID);
114  $blog_gui->disableNotes(!$this->enable_comments);
115  $blog_gui->prtf_embed = true; // disables prepareOutput()/getStandardTemplate() in blog
116  return $ilCtrl->forwardCommand($blog_gui);
117 
118  case "ilcalendarmonthgui":
119 
120 
121  // booking action
122  if ($cmd && $cmd != "preview") {
123  $categories = ilCalendarCategories::_getInstance();
124  if ($categories->getMode() == 0) {
125  if ($_GET['chuid']) {
126  $categories->setCHUserId((int) $_GET['chuid']);
127  }
128  $categories->initialize(ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION, null, true);
129  }
130 
131  if ($_GET['seed']) {
132  $seed = new ilDate((string) $_GET['seed'], IL_CAL_DATE);
133  } else {
134  $seed = new ilDate(time(), IL_CAL_UNIX);
135  }
136 
137  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
138  $month_gui = new ilCalendarMonthGUI($seed);
139  return $ilCtrl->forwardCommand($month_gui);
140  }
141  // calendar month navigation
142  else {
143  $ilCtrl->setParameter($this, "cmd", "preview");
144  return self::EMBEDDED_NO_OUTPUT;
145  }
146 
147  // no break
148  case "ilpageobjectgui":
149  die("Deprecated. ilPortfolioPage gui forwarding to ilpageobject");
150  return;
151 
152  default:
153  $this->setPresentationTitle($this->getPageObject()->getTitle());
154  return parent::executeCommand();
155  }
156  }
157 
163  public function showPage()
164  {
166 
167  if (!$this->getPageObject()) {
168  return;
169  }
170 
171  switch ($this->getPageObject()->getType()) {
173  return $this->renderBlog($ilUser->getId(), (int) $this->getPageObject()->getTitle());
174 
175  default:
176  $this->setTemplateOutput(false);
177  // $this->setPresentationTitle($this->getPageObject()->getTitle());
178  $output = parent::showPage();
179 
180  return $output;
181  }
182  }
183 
190  public function getTabs($a_activate = "")
191  {
192  if (!$this->embedded) {
193  parent::getTabs($a_activate);
194  }
195  }
196 
202  public function setEmbedded($a_value)
203  {
204  $this->embedded = (bool) $a_value;
205  }
206 
212  public function setAdditional($a_additional)
213  {
214  $this->additional = $a_additional;
215  }
216 
222  public function getAdditional()
223  {
224  return $this->additional;
225  }
226 
227  public function getJsOnloadCode()
228  {
229  return $this->js_onload_code;
230  }
231 
232  public function postOutputProcessing($a_output)
233  {
234  $parts = array(
235  "Profile" => array("0-9", "a-z", "0-9a-z_;\W"), // user, mode, fields
236  "Verification" => array("0-9", "a-z", "0-9"), // user, type, id
237  "Blog" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
238  "BlogTeaser" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
239  "Skills" => array("0-9", "0-9"), // user, skill id
240  "SkillsTeaser" => array("0-9", "0-9"), // user, skill id
241  "ConsultationHours" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
242  "ConsultationHoursTeaser" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
243  "MyCourses" => array("0-9", "a-z*"), // user, sort
244  "MyCoursesTeaser" => array("0-9", "a-z*") // user, sort
245  );
246 
247  foreach ($parts as $type => $def) {
248  // #15732 - allow optional parts
249  $def_parts = array();
250  foreach ($def as $part) {
251  $is_opt = (substr($part, -1) == "*");
252  if (!$is_opt) {
253  $def_parts[] = "#";
254  $end_marker = "+";
255  } else {
256  $def_parts[] = "#*";
257  $end_marker = "*";
258  $part = substr($part, 0, -1);
259  }
260  $def_parts[] = "([" . $part . "]" . $end_marker . ")";
261  }
262  $def = implode("", $def_parts);
263 
264  if (preg_match_all(
265  "/" . $this->pl_start . $type . $def . $this->pl_end . "/",
266  $a_output,
267  $blocks
268  )) {
269  foreach ($blocks[0] as $idx => $block) {
270  switch ($type) {
271  case "Profile":
272  case "Blog":
273  case "BlogTeaser":
274  case "Skills":
275  case "SkillsTeaser":
276  case "ConsultationHours":
277  case "ConsultationHoursTeaser":
278  case "MyCourses":
279  case "MyCoursesTeaser":
280  $subs = null;
281  if (trim($blocks[3][$idx])) {
282  foreach (explode(";", $blocks[3][$idx]) as $sub) {
283  if (trim($sub)) {
284  $subs[] = trim($sub);
285  }
286  }
287  }
288  $snippet = $this->{"render" . $type}(
289  $blocks[1][$idx],
290  $blocks[2][$idx],
291  $subs
292  );
293  break;
294 
295  default:
296  $snippet = $this->{"render" . $type}(
297  $blocks[1][$idx],
298  $blocks[2][$idx],
299  $blocks[3][$idx]
300  );
301  break;
302  }
303 
304  $snippet = $this->renderPageElement($type, $snippet);
305  $a_output = str_replace($block, $snippet, $a_output);
306  }
307  }
308  }
309 
310  $a_output = $this->makePlaceHoldersClickable($a_output);
311 
312  return $a_output;
313  }
314 
315  protected function renderPageElement($a_type, $a_html)
316  {
317  return trim($a_html);
318  }
319 
320  protected function renderTeaser($a_type, $a_title, $a_options = null)
321  {
322  $options = "";
323  if ($a_options) {
324  $options = '<div class="il_Footer">' . $this->lng->txt("prtf_page_element_teaser_settings") .
325  ": " . $a_options . '</div>';
326  }
327 
328  return '<div style="margin:5px" class="ilBox"><h3>' . $a_title . '</h3>' .
329  '<div class="il_Description_no_margin">' . $this->lng->txt("prtf_page_element_teaser_" . $a_type) . '</div>' .
330  $options . '</div>';
331  }
332 
333  protected function renderProfile($a_user_id, $a_type, array $a_fields = null)
334  {
336 
337  $user_id = $this->getPageContentUserId($a_user_id);
338 
339  if ($this->getOutputMode() == "offline") {
340  // profile picture is done in ilPortfolioHTMLExport
341 
342  $this->export_material["js"][] = "http://maps.google.com/maps/api/js?sensor=false";
343  $this->export_material["js"][] = "./Services/Maps/js/ServiceGoogleMaps.js";
344  $this->export_material["js"][] = "./Services/Maps/js/OpenLayers.js";
345  $this->export_material["js"][] = "./Services/Maps/js/ServiceOpenLayers.js";
346  }
347 
348  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
349  $pub_profile = new ilPublicUserProfileGUI($user_id);
350  $pub_profile->setEmbedded(true, ($this->getOutputMode() == "offline"));
351 
352  // full circle: additional was set in the original public user profile call
353  $pub_profile->setAdditional($this->getAdditional());
354 
355  if ($a_type == "manual" && sizeof($a_fields)) {
356  $prefs = array();
357  foreach ($a_fields as $field) {
358  $field = trim($field);
359  if ($field) {
360  $prefs["public_" . $field] = "y";
361  }
362  }
363 
364  $pub_profile->setCustomPrefs($prefs);
365  }
366 
367  if ($this->getOutputMode() != "offline") {
368  return $ilCtrl->getHTML($pub_profile);
369  } else {
370  return $pub_profile->getEmbeddable();
371  }
372  }
373 
374  protected function renderVerification($a_user_id, $a_type, $a_id)
375  {
376  $objDefinition = $this->obj_definition;
377 
378  // not used
379  // $user_id = $this->getPageContentUserId($a_user_id);
380 
381  $class = "ilObj" . $objDefinition->getClassName($a_type) . "GUI";
382  include_once $objDefinition->getLocation($a_type) . "/class." . $class . ".php";
383  $verification = new $class($a_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
384 
385  if ($this->getOutputMode() == "print") {
386  $url = $this->getPagePermaLink();
387  } elseif ($this->getOutputMode() != "offline") {
388  // direct download link
389  $this->ctrl->setParameter($this, "dlid", $a_id);
390  $url = $this->ctrl->getLinkTarget($this, "dl" . $a_type);
391  $this->ctrl->setParameter($this, "dlid", "");
392  } else {
393  $file = $verification->object->getFilePath();
394  $url = "files/" . basename($file);
395 
396  $this->export_material["files"][] = $file;
397  }
398 
399  return $verification->render(true, $url);
400  }
401 
402  protected function dltstv()
403  {
404  $id = $_GET["dlid"];
405  if ($id) {
406  include_once "Modules/Test/classes/class.ilObjTestVerificationGUI.php";
408  $verification->downloadFromPortfolioPage($this->getPageObject());
409  }
410  }
411 
412  protected function dlexcv()
413  {
414  $id = $_GET["dlid"];
415  if ($id) {
416  include_once "Modules/Exercise/classes/class.ilObjExerciseVerificationGUI.php";
418  $verification->downloadFromPortfolioPage($this->getPageObject());
419  }
420  }
421 
422  protected function dlcrsv()
423  {
424  $id = $_GET["dlid"];
425  if ($id) {
426  include_once "Modules/Course/classes/Verification/class.ilObjCourseVerificationGUI.php";
428  $verification->downloadFromPortfolioPage($this->getPageObject());
429  }
430  }
431 
432  protected function dlscov()
433  {
434  $id = $_GET["dlid"];
435  if ($id) {
436  include_once "Modules/ScormAicc/classes/Verification/class.ilObjSCORMVerificationGUI.php";
438  $verification->downloadFromPortfolioPage($this->getPageObject());
439  }
440  }
441 
442  protected function renderBlog($a_user_id, $a_blog_id, array $a_posting_ids = null)
443  {
445 
446  // not used
447  // $user_id = $this->getPageContentUserId($a_user_id);
448 
449  // full blog (separate tab/page)
450  if (!$a_posting_ids) {
451  include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
452  $blog = new ilObjBlogGUI($a_blog_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
453  $blog->disableNotes(!$this->enable_comments);
454  $blog->setContentStyleSheet();
455 
456  if ($this->getOutputMode() != "offline") {
457  return $ilCtrl->getHTML($blog);
458  } else {
459  }
460  }
461  // embedded postings
462  else {
463  $html = array();
464 
465  include_once "Modules/Blog/classes/class.ilObjBlog.php";
466  $html[] = ilObjBlog::_lookupTitle($a_blog_id);
467 
468  include_once "Modules/Blog/classes/class.ilBlogPostingGUI.php";
469  foreach ($a_posting_ids as $post) {
470  $page = new ilBlogPostingGUI(0, null, $post);
471  if ($this->getOutputMode() != "offline") {
472  $page->setOutputMode(IL_PAGE_PREVIEW);
473  } else {
474  $page->setOutputMode("offline");
475  }
476  $html[] = $page->showPage();
477  }
478 
479  return implode("\n", $html);
480  }
481  }
482 
483  protected function renderBlogTeaser($a_user_id, $a_blog_id, array $a_posting_ids = null)
484  {
485  // not used
486  // $user_id = $this->getPageContentUserId($a_user_id);
487 
488  $postings = "";
489  if ($a_posting_ids) {
490  $postings = array("<ul>");
491  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
492  foreach ($a_posting_ids as $post) {
493  $post = new ilBlogPosting($post);
494  $postings[] = "<li>" . $post->getTitle() . " - " .
495  ilDatePresentation::formatDate($post->getCreated()) . "</li>";
496  }
497  $postings[] = "</ul>";
498  $postings = implode("\n", $postings);
499  }
500 
501  return $this->renderTeaser("blog", $this->lng->txt("obj_blog") . ' "' .
502  ilObject::_lookupTitle($a_blog_id) . '"', $postings);
503  }
504 
505  protected function renderSkills($a_user_id, $a_skills_id)
506  {
507  if ($this->getOutputMode() == "preview") {
508  return $this->renderSkillsTeaser($a_user_id, $a_skills_id);
509  }
510 
511  $user_id = $this->getPageContentUserId($a_user_id);
512 
513  include_once "Services/Skill/classes/class.ilPersonalSkillsGUI.php";
514  $gui = new ilPersonalSkillsGUI();
515  if ($this->getOutputMode() == "offline") {
516  $gui->setOfflineMode("./files/");
517  }
518  $html = $gui->getSkillHTML($a_skills_id, $user_id);
519 
520  return $html;
521  }
522 
523  protected function renderSkillsTeaser($a_user_id, $a_skills_id)
524  {
525  // not used
526  // $user_id = $this->getPageContentUserId($a_user_id);
527 
528  include_once "Services/Skill/classes/class.ilSkillTreeNode.php";
529 
530  return $this->renderTeaser("skills", $this->lng->txt("skills") . ' "' .
531  ilSkillTreeNode::_lookupTitle($a_skills_id) . '"');
532  }
533 
534  protected function renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids)
535  {
536  // not used
537  // $user_id = $this->getPageContentUserId($a_user_id);
538 
539  if ($a_mode == "auto") {
540  $mode = $this->lng->txt("cont_cach_mode_automatic");
541  $groups = null;
542  } else {
543  $mode = $this->lng->txt("cont_cach_mode_manual");
544 
545  include_once "Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php";
546  $groups = array();
547  foreach ($a_group_ids as $grp_id) {
548  $groups[] = ilConsultationHourGroups::lookupTitle($grp_id);
549  }
550  $groups = " (" . implode(", ", $groups) . ")";
551  }
552 
553  $this->lng->loadLanguageModule("dateplaner");
554  return $this->renderTeaser(
555  "consultation_hours",
556  $this->lng->txt("app_consultation_hours"),
557  $mode . $groups
558  );
559  }
560 
561  protected function renderConsultationHours($a_user_id, $a_mode, $a_group_ids)
562  {
564 
565  if ($this->getOutputMode() == "preview") {
566  return $this->renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids);
567  }
568 
569  if ($this->getOutputMode() == "offline") {
570  return;
571  }
572 
573  if ($this->getOutputMode() == "print") {
574  return;
575  }
576 
577  $user_id = $this->getPageContentUserId($a_user_id);
578 
579  // only if not owner
580  if ($ilUser->getId() != $user_id) {
581  $_GET["bkid"] = $user_id;
582  }
583 
584  if ($a_mode != "manual") {
585  $a_group_ids = null;
586  }
587 
588  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
589  ilCalendarCategories::_getInstance()->setCHUserId($user_id);
591 
592  if (!$_REQUEST["seed"]) {
593  $seed = new ilDate(time(), IL_CAL_UNIX);
594  } else {
595  $seed = new ilDate($_REQUEST["seed"], IL_CAL_DATE);
596  }
597 
598  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
599  $month_gui = new ilCalendarMonthGUI($seed);
600  $month_gui->setConsulationHoursUserId($user_id);
601 
602  // custom schedule filter: handle booking group ids
603  include_once('./Services/Calendar/classes/class.ilCalendarScheduleFilterBookings.php');
604  $filter = new ilCalendarScheduleFilterBookings($user_id, $a_group_ids);
605  $month_gui->addScheduleFilter($filter);
606 
607  $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem', 'delos.css', 'Services/Calendar'));
608 
609  $this->lng->loadLanguageModule("dateplaner");
610  return '<h3>' . $this->lng->txt("app_consultation_hours") . '</h3>' .
611  $this->ctrl->getHTML($month_gui);
612  }
613 
614  protected function isMyCoursesActive()
615  {
616  $prfa_set = new ilSetting("prfa");
617  return (bool) $prfa_set->get("mycrs", true);
618  }
619 
620  protected function renderMyCoursesTeaser($a_user_id, $a_default_sorting)
621  {
622  // not used
623  // $user_id = $this->getPageContentUserId($a_user_id);
624 
625  $title = $this->isMyCoursesActive()
626  ? "my_courses"
627  : "my_courses_inactive";
628 
629  return $this->renderTeaser(
630  $title,
631  $this->lng->txt("prtf_page_element_my_courses_title")
632  );
633  }
634 
635  protected function renderMyCourses($a_user_id, $a_default_sorting)
636  {
637  $ilAccess = $this->access;
640 
641  if ($this->getOutputMode() == "preview") {
642  return $this->renderMyCoursesTeaser($a_user_id, $a_default_sorting);
643  }
644 
645  if (!$this->isMyCoursesActive()) {
646  return;
647  }
648 
649  $img_path = null;
650  if ($this->getOutputMode() == "offline") {
651  $this->export_material["images"][] = "./templates/default/images/icon_crs.svg";
652  $this->export_material["images"][] = "./templates/default/images/icon_lobj.svg";
653  $this->export_material["images"][] = "./templates/default/images/scorm/complete.svg";
654  $this->export_material["images"][] = "./templates/default/images/scorm/not_attempted.svg";
655  $this->export_material["images"][] = "./templates/default/images/scorm/failed.svg";
656  $this->export_material["images"][] = "./templates/default/images/scorm/incomplete.svg";
657 
658  $img_path = "images/";
659  }
660 
661  $user_id = $this->getPageContentUserId($a_user_id);
662 
663  // sorting pref
664  if ($_POST["srt"] &&
665  in_array($_POST["srt"], array("alpha", "loc"))) {
666  $ilUser->writePref("prtf_mcrs_sort", $_POST["srt"]);
667  }
668  $sorting = $ilUser->getPref("prtf_mcrs_sort");
669  if (!$sorting) {
670  $sorting = $a_default_sorting;
671  }
672 
673  $data = $this->getCoursesOfUser($user_id, ($sorting == "loc"));
674  if (sizeof($data)) {
675  if ($sorting != "loc") {
676  $data = ilUtil::sortArray($data, "title", "ASC");
677  } else {
678  $data = ilUtil::sortArray($data, "path_sort", "ASC");
679  }
680 
681  $tpl = new ilTemplate("tpl.pc_my_courses.html", true, true, "Modules/Portfolio");
682  $tpl->setVariable("TITLE", $this->lng->txt("prtf_page_element_my_courses_title"));
683  $tpl->setVariable("INFO", $this->lng->txt("prtf_page_element_my_courses_info")); // #14464
684 
685  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
686  $this->lng->loadLanguageModule("trac");
687  $this->lng->loadLanguageModule("crs");
688 
689  include_once("./Services/Container/classes/class.ilContainerObjectiveGUI.php");
690  include_once("./Services/Link/classes/class.ilLink.php");
691 
692  // sorting
693  if ($this->getOutputMode() != "print") {
694  $options = array(
695  "alpha" => $this->lng->txt("cont_mycourses_sortorder_alphabetical"),
696  "loc" => $this->lng->txt("cont_mycourses_sortorder_location")
697  );
698  $tpl->setVariable("SORT_SELECT", ilUtil::formSelect(
699  $sorting,
700  "srt",
701  $options,
702  false,
703  true,
704  0,
705  "",
706  array("onchange" => "form.submit()")
707  ));
708  $tpl->setVariable("SORT_FORM", $this->getCourseSortAction($ilCtrl));
709  }
710 
711  $old_path = null;
712 
713  foreach ($data as $course) {
714  if ($sorting == "loc") {
715  if ($course["path"] != $old_path) {
716  $tpl->setCurrentBlock("path_bl");
717  $tpl->setVariable("PATH", $course["path"]);
718  $tpl->parseCurrentBlock();
719 
720  $old_path = $course["path"];
721  }
722  }
723 
724  if (isset($course["lp_status"])) {
725  $lp_icon = ilLearningProgressBaseGUI::_getImagePathForStatus($course["lp_status"]);
726  $lp_alt = ilLearningProgressBaseGUI::_getStatusText($course["lp_status"]);
727 
728  if ($img_path) {
729  $lp_icon = $img_path . basename($lp_icon);
730  }
731 
732  $tpl->setCurrentBlock("lp_bl");
733  $tpl->setVariable("LP_ICON_URL", $lp_icon);
734  $tpl->setVariable("LP_ICON_ALT", $lp_alt);
735  $tpl->parseCurrentBlock();
736  }
737 
738  $do_links = false;
739  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
740  $do_links = $ilAccess->checkAccessOfUser($ilUser->getId(), "read", "", $course["ref_id"], "crs") ||
741  ($ilAccess->checkAccessOfUser($ilUser->getId(), "visible", "", $course["ref_id"], "crs") &&
742  $ilAccess->checkAccessOfUser($ilUser->getId(), "join", "", $course["ref_id"], "crs"));
743  }
744 
745  if (isset($course["objectives"])) {
746  include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
747  $loc_settings = ilLOSettings::getInstanceByObjId($course["obj_id"]);
748  $has_initial_test = (bool) $loc_settings->getInitialTest();
749 
750  foreach ($course["objectives"] as $objtv) {
751  if ($do_links) {
752  $params = array("oobj"=>$objtv["id"]);
753  $url = ilLink::_getLink($course["ref_id"], "crs", $params);
754 
755  // #15510
756  $url .= "#objtv_acc_" . $objtv["id"];
757 
758  if ($this->getOutputMode() != "print") {
759  $tpl->touchBlock("objective_dnone");
760  }
761 
762  $tpl->setCurrentBlock("objective_link_bl");
763 
764  if (trim($objtv["desc"])) {
765  $desc = nl2br($objtv["desc"]);
766  $tt_id = "objtvtt_" . $objtv["id"] . "_" . ((int) self::$initialized);
767 
768  include_once "Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
769  ilToolTipGUI::addTooltip($tt_id, $desc, "", "bottom center", "top center", false);
770 
771  $tpl->setVariable("OBJECTIVE_LINK_ID", $tt_id);
772  }
773 
774  $tpl->setVariable("OBJECTIVE_LINK_URL", $url);
775  $tpl->setVariable("OBJECTIVE_LINK_TITLE", $objtv["title"]);
776  $tpl->parseCurrentBlock();
777  } else {
778  $tpl->setCurrentBlock("objective_nolink_bl");
779  $tpl->setVariable("OBJECTIVE_NOLINK_TITLE", $objtv["title"]);
780  $tpl->parseCurrentBlock();
781  }
782 
783  $objtv_icon = ilUtil::getTypeIconPath("lobj", $objtv["id"]);
784  if ($img_path) {
785  $objtv_icon = $img_path . basename($objtv_icon);
786  }
787 
788  $tpl->setCurrentBlock("objective_bl");
789  $tpl->setVariable("OBJTV_ICON_URL", $objtv_icon);
790  $tpl->setVariable("OBJTV_ICON_ALT", $this->lng->txt("crs_objectives"));
791 
792  if ($objtv["type"]) {
793  $tpl->setVariable(
794  "LP_OBJTV_PROGRESS",
795  ilContainerObjectiveGUI::buildObjectiveProgressBar($has_initial_test, $objtv["id"], $objtv, true, false, (int) self::$initialized)
796  );
797  }
798 
799  $tpl->parseCurrentBlock();
800  }
801 
802  $tpl->setCurrentBlock("objectives_bl");
803  $tpl->setVariable("OBJTV_LIST_CRS_ID", $course["obj_id"]);
804  $tpl->parseCurrentBlock();
805  }
806 
807  // always check against current user
808  if ($do_links) {
809  $tpl->setCurrentBlock("course_link_bl");
810  $tpl->setVariable("COURSE_LINK_TITLE", $course["title"]);
811  $tpl->setVariable("COURSE_LINK_URL", ilLink::_getLink($course["ref_id"]));
812  $tpl->parseCurrentBlock();
813  } else {
814  $tpl->setCurrentBlock("course_nolink_bl");
815  $tpl->setVariable("COURSE_NOLINK_TITLE", $course["title"]);
816  $tpl->parseCurrentBlock();
817  }
818 
819  $crs_icon = ilUtil::getTypeIconPath("crs", $course["obj_id"]);
820  if ($img_path) {
821  $crs_icon = $img_path . basename($crs_icon);
822  }
823 
824  $tpl->setCurrentBlock("course_bl");
825 
826  if (isset($course["objectives"])) {
827  $tpl->setVariable("TOGGLE_CLASS", "ilPCMyCoursesToggle");
828  } else {
829  $tpl->setVariable("NO_TOGGLE", ' style="visibility:hidden;"');
830  }
831 
832  $tpl->setVariable("CRS_ICON_URL", $crs_icon);
833  $tpl->setVariable("CRS_ICON_ALT", $this->lng->txt("obj_crs"));
834  $tpl->parseCurrentBlock();
835  }
836 
837  // #15508
838  if (!self::$initialized) {
839  $GLOBALS["tpl"]->addJavaScript("Modules/Portfolio/js/ilPortfolio.js");
840  $GLOBALS["tpl"]->addOnLoadCode("ilPortfolio.init()");
841  }
842  self::$initialized++;
843 
844  return $tpl->get();
845  }
846  }
847 
854  protected function getCourseSortAction($ctrl)
855  {
856  return $ctrl->getFormActionByClass("ilobjportfoliogui", "preview");
857  }
858 
859 
860  protected function getCoursesOfUser($a_user_id, $a_add_path = false)
861  {
862  $tree = $this->tree;
863 
864  // see ilPDSelectedItemsBlockGUI
865 
866  include_once 'Modules/Course/classes/class.ilObjCourseAccess.php';
867  include_once 'Services/Membership/classes/class.ilParticipants.php';
868  $items = ilParticipants::_getMembershipByType($a_user_id, 'crs');
869 
870  $repo_title = $tree->getNodeData(ROOT_FOLDER_ID);
871  $repo_title = $repo_title["title"];
872  if ($repo_title == "ILIAS") {
873  $repo_title = $this->lng->txt("repository");
874  }
875 
876  $references = $lp_obj_refs = array();
877  foreach ($items as $obj_id) {
878  $ref_id = ilObject::_getAllReferences($obj_id);
879  if (is_array($ref_id) && count($ref_id)) {
880  $ref_id = array_pop($ref_id);
881  if (!$tree->isDeleted($ref_id)) {
882  $visible = false;
883  $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false);
884  if ($active && $visible) {
885  $references[$ref_id] = array(
886  'ref_id' => $ref_id,
887  'obj_id' => $obj_id,
888  'title' => ilObject::_lookupTitle($obj_id)
889  );
890 
891  if ($a_add_path) {
892  $path = array();
893  foreach ($tree->getPathFull($ref_id) as $item) {
894  $path[] = $item["title"];
895  }
896  // top level comes first
897  if (sizeof($path) == 2) {
898  $path[0] = 0;
899  } else {
900  $path[0] = 1;
901  }
902  $references[$ref_id]["path_sort"] = implode("__", $path);
903  array_shift($path);
904  array_pop($path);
905  if (!sizeof($path)) {
906  array_unshift($path, $repo_title);
907  }
908  $references[$ref_id]["path"] = implode(" &rsaquo; ", $path);
909  }
910 
911  $lp_obj_refs[$obj_id] = $ref_id;
912  }
913  }
914  }
915  }
916 
917  // get lp data for valid courses
918 
919  if (sizeof($lp_obj_refs)) {
920  // listing the objectives should NOT depend on any LP status / setting
921  include_once 'Modules/Course/classes/class.ilObjCourse.php';
922  foreach ($lp_obj_refs as $obj_id => $ref_id) {
923  // only if set in DB (default mode is not relevant
925  $references[$ref_id]["objectives"] = $this->parseObjectives($obj_id, $a_user_id);
926  }
927  }
928 
929  // LP must be active, personal and not anonymized
930  include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
934  // see ilLPProgressTableGUI
935  include_once "Services/Tracking/classes/class.ilTrQuery.php";
936  include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
937  $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs);
938  foreach ($lp_data as $item) {
939  $ref_id = $item["ref_ids"];
940  $references[$ref_id]["lp_status"] = $item["status"];
941  }
942  }
943  }
944 
945  return $references;
946  }
947 
948  protected function parseObjectives($a_obj_id, $a_user_id)
949  {
950  $res = array();
951 
952  // we need the collection for the correct order
953  include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
954  include_once "Services/Tracking/classes/collection/class.ilLPCollectionOfObjectives.php";
956  $coll_objtv = $coll_objtv->getItems();
957  if ($coll_objtv) {
958  // #13373
959  $lo_results = $this->parseLOUserResults($a_obj_id, $a_user_id);
960 
961  include_once "Modules/Course/classes/Objectives/class.ilLOTestAssignments.php";
962  $lo_ass = ilLOTestAssignments::getInstance($a_obj_id);
963 
964  $tmp = array();
965 
966  include_once "Modules/Course/classes/class.ilCourseObjective.php";
967  foreach ($coll_objtv as $objective_id) {
968  $title = ilCourseObjective::lookupObjectiveTitle($objective_id, true);
969 
970  $tmp[$objective_id] = array(
971  "id" => $objective_id,
972  "title" => $title["title"],
973  "desc" => $title["description"],
974  "itest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL),
975  "qtest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED)
976  );
977 
978  if (array_key_exists($objective_id, $lo_results)) {
979  $lo_result = $lo_results[$objective_id];
980  $tmp[$objective_id]["user_id"] = $lo_result["user_id"];
981  $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"];
982  $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"];
983  $tmp[$objective_id]["status"] = $lo_result["status"];
984  $tmp[$objective_id]["type"] = $lo_result["type"];
985  $tmp[$objective_id]["initial"] = $lo_result["initial"];
986  }
987  }
988 
989  // order
990  foreach ($coll_objtv as $objtv_id) {
991  $res[] = $tmp[$objtv_id];
992  }
993  }
994 
995  return $res;
996  }
997 
998  // see ilContainerObjectiveGUI::parseLOUserResults()
999  protected function parseLOUserResults($a_course_obj_id, $a_user_id)
1000  {
1001  $res = array();
1002 
1003  include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
1004  $lur = new ilLOUserResults($a_course_obj_id, $a_user_id);
1005  foreach ($lur->getCourseResultsForUserPresentation() as $objective_id => $types) {
1006  // show either initial or qualified for objective
1007  if (isset($types[ilLOUserResults::TYPE_INITIAL])) {
1008  $initial_status = $types[ilLOUserResults::TYPE_INITIAL]["status"];
1009  }
1010 
1011  // qualified test has priority
1012  if (isset($types[ilLOUserResults::TYPE_QUALIFIED])) {
1015  $result["initial"] = $types[ilLOUserResults::TYPE_INITIAL];
1016  } else {
1019  }
1020 
1021  $result["initial_status"] = $initial_status;
1022 
1023  $res[$objective_id] = $result;
1024  }
1025 
1026  return $res;
1027  }
1028 
1029  public function getExportMaterial()
1030  {
1031  return $this->export_material;
1032  }
1033 
1040  public function makePlaceHoldersClickable($a_html)
1041  {
1042  $ilCtrl = $this->ctrl;
1043  $lng = $this->lng;
1044  $ilUser = $this->user;
1045 
1046  $c_pos = 0;
1047  $start = strpos($a_html, "{{{{{PlaceHolder#");
1048  if (is_int($start)) {
1049  $end = strpos($a_html, "}}}}}", $start);
1050  }
1051  $i = 1;
1052  while ($end > 0) {
1053  $param = substr($a_html, $start + 17, $end - $start - 17);
1054  $param = explode("#", $param);
1055 
1056  $html = $param[2];
1057  switch ($param[2]) {
1058  case "Text":
1059  $html = $lng->txt("cont_text_placeh");
1060  break;
1061 
1062  case "Media":
1063  $html = $lng->txt("cont_media_placeh");
1064  break;
1065 
1066  case "Question":
1067  $html = $lng->txt("cont_question_placeh");
1068  break;
1069 
1070  case "Verification":
1071  $html = $lng->txt("cont_verification_placeh");
1072  break;
1073  }
1074 
1075  // only if not owner
1076  if ($ilUser->getId() == ilObjPortfolio::_lookupOwner($this->portfolio_id)
1077  && $this->getOutputMode() == "presentation") {
1078  switch ($param[2]) {
1079  case "Text":
1080  $ilCtrl->setParameterByClass("ilportfoliopagegui", "prt_id", $_GET["prt_id"]);
1081  $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", $this->getId());
1082  $ilCtrl->setParameterByClass("ilportfoliopagegui", "pl_pc_id", $param[0]);
1083  $ilCtrl->setParameterByClass("ilportfoliopagegui", "pl_hier_id", $param[1]);
1084  $href = $ilCtrl->getLinkTargetByClass("ilportfoliopagegui", "insertJSAtPlaceholder");
1085  $html = "<a href='" . $href . "'>" . $html . "</a>";
1086  break;
1087 
1088  case "Media":
1089  $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "prt_id", $_GET["prt_id"]);
1090  $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "ppage", $this->getId());
1091  $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "pl_pc_id", $param[0]);
1092  $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "pl_hier_id", $param[1]);
1093  $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "subCmd", "insertNew");
1094  $href = $ilCtrl->getLinkTargetByClass(array("ilPortfolioPageGUI", "ilPageEditorGUI", "ilPCPlaceHolderGUI", "ilpcmediaobjectgui"), "insert");
1095  $html = "<a href='" . $href . "'>" . $html . "</a>";
1096  break;
1097  }
1098  }
1099 
1100  $h2 = substr($a_html, 0, $start) .
1101  $html .
1102  substr($a_html, $end + 5);
1103  $a_html = $h2;
1104  $i++;
1105 
1106  $start = strpos($a_html, "{{{{{PlaceHolder#", $start + 5);
1107  $end = 0;
1108  if (is_int($start)) {
1109  $end = strpos($a_html, "}}}}}", $start);
1110  }
1111  }
1112  return $a_html;
1113  }
1114 
1121  public function getViewPageLink()
1122  {
1123  global $DIC;
1124 
1125  $ctrl = $DIC->ctrl();
1126 
1127  $ctrl->setParameterByClass("ilobjportfoliogui", "user_page", $_GET["ppage"]);
1128  return $ctrl->getLinkTargetByClass("ilobjportfoliogui", "preview");
1129  }
1130 
1137  public function getViewPageText()
1138  {
1139  return $this->lng->txt("preview");
1140  }
1141 
1148  public function getPagePermaLink()
1149  {
1150  include_once("./Services/Link/classes/class.ilLink.php");
1152  $href = ilLink::_getStaticLink($pid, "prtf", true, "_" . $this->getId());
1153  return $href;
1154  }
1155 }
getCoursesOfUser($a_user_id, $a_add_path=false)
$params
Definition: disable.php:11
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static getInstanceByObjId($a_obj_id)
get singleton instance
static getInstance($a_container_id)
Get instance by container id.
renderBlog($a_user_id, $a_blog_id, array $a_posting_ids=null)
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
const IL_PAGE_PREVIEW
const IL_CRS_VIEW_OBJECTIVE
static getPlaceHolderStylePath()
get placeholder style path (for Page Layouts)
__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)
$result
setTemplateOutput($a_output=true)
static _getImagePathForStatus($a_status)
Get image path for status.
executeCommand()
execute command
$type
static lookupTitle($a_group_id)
Lookup group title.
global $DIC
Definition: saml.php:7
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
renderMyCourses($a_user_id, $a_default_sorting)
getAdditional()
Get Additonal Information.
Class ilBlogPosting GUI class.
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
Class ilPageObjectGUI.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
$end
Definition: saml1-acs.php:18
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static findPortfolioForPage($a_page_id)
Get portfolio id of page id.
setEmbedded($a_value)
Set embedded mode: will suppress tabs.
if(!array_key_exists('StateId', $_REQUEST)) $id
static _lookupTitle($a_id)
lookup object title
Portfolio page gui class.
static _lookupViewMode($a_id)
lookup view mode of container
static getObjectsStatusForUser($a_user_id, array $obj_refs)
const IL_CAL_UNIX
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
user()
Definition: user.php:4
static _lookupOwner($a_id)
static _getAllReferences($a_id)
get all reference ids of object
Tree handler for personal workspace.
global $ilCtrl
Definition: ilias.php:18
getViewPageLink()
Get view page link.
$a_type
Definition: workflow.php:92
Personal skills GUI class.
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
GUI class for course verification.
GUI class for public user profile presentation.
static _enabledLearningProgress()
check wether learing progress is enabled or not
Class for single dates.
foreach($_POST as $key=> $value) $res
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)
makePlaceHoldersClickable($a_html)
Modify page content after xsl.
special template class to simplify handling of ITX/PEAR
renderSkillsTeaser($a_user_id, $a_skills_id)
getViewPageText()
Get view page link.
$post
Definition: post.php:34
setPresentationTitle($a_title="")
$ilUser
Definition: imgupload.php:18
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true)
get content style path
static _getInstance($a_usr_id=0)
get singleton instance
Create styles array
The data for the language used.
static buildObjectiveProgressBar($a_has_initial_test, $a_objective_id, array $a_lo_result, $a_list_mode=false, $a_sub=false, $a_tt_suffix=null)
Render progressbar(s) for given objective and result data.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
const IL_CAL_DATE
GUI class for test verification.
renderMyCoursesTeaser($a_user_id, $a_default_sorting)
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
setAdditional($a_additional)
Set Additonal Information.
renderTeaser($a_type, $a_title, $a_options=null)
renderVerification($a_user_id, $a_type, $a_id)
$i
Definition: disco.tpl.php:19
$def
Definition: croninfo.php:21
parseObjectives($a_obj_id, $a_user_id)
$url
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
renderPageElement($a_type, $a_html)
getCourseSortAction($ctrl)
Get course sort action.
static _isActivated($a_obj_id, &$a_visible_flag=null, $a_mind_member_view=true)
Is activated?
renderProfile($a_user_id, $a_type, array $a_fields=null)
GUI class for scorm verification.
$_POST["username"]
$html
Definition: example_001.php:87
parseLOUserResults($a_course_obj_id, $a_user_id)
getPagePermaLink()
Get page perma link.
renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids)
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
renderConsultationHours($a_user_id, $a_mode, $a_group_ids)