ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjPortfolioBaseGUI.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/Object/classes/class.ilObject2GUI.php');
5 include_once('./Modules/Portfolio/classes/class.ilObjPortfolio.php');
6 include_once('./Modules/Portfolio/classes/class.ilPortfolioPage.php');
7 
16 abstract class ilObjPortfolioBaseGUI extends ilObject2GUI
17 {
21  protected $help;
22 
26  protected $main_menu;
27 
28  protected $user_id; // [int]
29  protected $additional = array();
30  protected $perma_link; // [string]
31  protected $page_id; // [int]
32  protected $page_mode; // [string] preview|edit
33 
34  public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
35  {
36  global $DIC;
37 
38  $this->user = $DIC->user();
39  $this->locator = $DIC["ilLocator"];
40  $this->toolbar = $DIC->toolbar();
41  $this->settings = $DIC->settings();
42  $this->tree = $DIC->repositoryTree();
43  $this->help = $DIC["ilHelp"];
44  $this->main_menu = $DIC["ilMainMenu"];
45  $this->tpl = $DIC["tpl"];
46  $ilUser = $DIC->user();
47 
48  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
49 
50  $this->user_id = $ilUser->getId();
51 
52  $this->lng->loadLanguageModule("prtf");
53  $this->lng->loadLanguageModule("user");
54  }
55 
56  protected function addLocatorItems()
57  {
58  $ilLocator = $this->locator;
59 
60  if ($this->object) {
61  $ilLocator->addItem(
62  strip_tags($this->object->getTitle()),
63  $this->ctrl->getLinkTarget($this, "view")
64  );
65  }
66 
67  if ($this->page_id) {
68  $page = $this->getPageInstance($this->page_id);
69  $title = $page->getTitle();
70  if ($page->getType() == ilPortfolioPage::TYPE_BLOG) {
72  }
73  $this->ctrl->setParameterByClass($this->getPageGUIClassName(), "ppage", $this->page_id);
74  $ilLocator->addItem(
75  $title,
76  $this->ctrl->getLinkTargetByClass($this->getPageGUIClassName(), "edit")
77  );
78  }
79  }
80 
81  protected function determinePageCall()
82  {
83  // edit
84  if (isset($_REQUEST["ppage"])) {
85  if (!$this->checkPermissionBool("write")) {
86  $this->ctrl->redirect($this, "view");
87  }
88 
89  $this->page_id = $_REQUEST["ppage"];
90  $this->page_mode = "edit";
91  $this->ctrl->setParameter($this, "ppage", $this->page_id);
92  return true;
93  }
94  // preview
95  else {
96  $this->page_id = $_REQUEST["user_page"];
97  $this->page_mode = "preview";
98  $this->ctrl->setParameter($this, "user_page", $this->page_id);
99  return false;
100  }
101  }
102 
103  protected function handlePageCall($a_cmd)
104  {
105  $this->tabs_gui->clearTargets();
106  $this->tabs_gui->setBackTarget(
107  $this->lng->txt("back"),
108  $this->ctrl->getLinkTarget($this, "view")
109  );
110 
111  if (!$this->page_id) {
112  $this->ctrl->redirect($this, "view");
113  }
114 
115  $page_gui = $this->getPageGUIInstance($this->page_id);
116 
117  // needed for editor
118  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
119  $this->object->getStyleSheetId(),
120  $this->getType()
121  ));
122 
123  $ret = $this->ctrl->forwardCommand($page_gui);
124 
125  if ($ret != "" && $ret !== true) {
126  // preview (fullscreen)
127  if ($this->page_mode == "preview") {
128  // embedded call which did not generate any output (e.g. calendar month navigation)
130  // suppress (portfolio) notes for blog postings
131  $this->preview(false, $ret, ($a_cmd != "previewEmbedded"));
132  } else {
133  $this->preview(false);
134  }
135  }
136  // edit
137  else {
138  $this->setContentStyleSheet();
139  $this->tpl->setContent($ret);
140  }
141  }
142  }
143 
149  public function setAdditional($a_additional)
150  {
151  $this->additional = $a_additional;
152  }
153 
159  public function getAdditional()
160  {
161  return $this->additional;
162  }
163 
170  public function setPermaLink($a_obj_id, $a_type)
171  {
172  $this->perma_link = array("obj_id"=>$a_obj_id, "type"=>$a_type);
173  }
174 
175 
176  //
177  // CREATE/EDIT
178  //
179 
180  protected function setSettingsSubTabs($a_active)
181  {
182  // #17455
183  $this->lng->loadLanguageModule($this->getType());
184 
185  // general properties
186  $this->tabs_gui->addSubTab(
187  "properties",
188  $this->lng->txt($this->getType() . "_properties"),
189  $this->ctrl->getLinkTarget($this, 'edit')
190  );
191 
192  $this->tabs_gui->addSubTab(
193  "style",
194  $this->lng->txt("obj_sty"),
195  $this->ctrl->getLinkTarget($this, 'editStyleProperties')
196  );
197 
198  $this->tabs_gui->activateSubTab($a_active);
199  }
200 
201  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
202  {
203  $this->setSettingsSubTabs("properties");
204 
205  // comments
206  $comments = new ilCheckboxInputGUI($this->lng->txt("prtf_public_comments"), "comments");
207  $a_form->addItem($comments);
208 
209  // profile picture
210  $ppic = new ilCheckboxInputGUI($this->lng->txt("prtf_profile_picture"), "ppic");
211  $a_form->addItem($ppic);
212 
213  $prfa_set = new ilSetting("prfa");
214  if ($prfa_set->get("banner")) {
215  include_once "Services/Form/classes/class.ilFileInputGUI.php";
217 
218  $dimensions = " (" . $prfa_set->get("banner_width") . "x" .
219  $prfa_set->get("banner_height") . ")";
220 
221  $img = new ilImageFileInputGUI($this->lng->txt("prtf_banner") . $dimensions, "banner");
222  $a_form->addItem($img);
223 
224  // show existing file
225  $file = $this->object->getImageFullPath(true);
226  if ($file) {
227  $img->setImage($file);
228  }
229  }
230 
231  /* #15000
232  $bg_color = new ilColorPickerInputGUI($this->lng->txt("prtf_background_color"), "bg_color");
233  $a_form->addItem($bg_color);
234 
235  $font_color = new ilColorPickerInputGUI($this->lng->txt("prtf_font_color"), "font_color");
236  $a_form->addItem($font_color);
237  */
238  }
239 
240  protected function getEditFormCustomValues(array &$a_values)
241  {
242  $a_values["comments"] = $this->object->hasPublicComments();
243  $a_values["ppic"] = $this->object->hasProfilePicture();
244  /*
245  $a_values["bg_color"] = $this->object->getBackgroundColor();
246  $a_values["font_color"] = $this->object->getFontColor();
247  */
248  }
249 
250  public function updateCustom(ilPropertyFormGUI $a_form)
251  {
252  $this->object->setPublicComments($a_form->getInput("comments"));
253  $this->object->setProfilePicture($a_form->getInput("ppic"));
254  /*
255  $this->object->setBackgroundColor($a_form->getInput("bg_color"));
256  $this->object->setFontcolor($a_form->getInput("font_color"));
257  */
258 
259  $prfa_set = new ilSetting("prfa");
260 
261  if ($_FILES["banner"]["tmp_name"]) {
262  $this->object->uploadImage($_FILES["banner"]);
263  } elseif ($prfa_set->get('banner') and $a_form->getItemByPostVar("banner")->getDeletionFlag()) {
264  $this->object->deleteImage();
265  }
266  }
267 
268 
269  //
270  // PAGES
271  //
272 
273  abstract protected function getPageInstance($a_page_id = null, $a_portfolio_id = null);
274 
275  abstract protected function getPageGUIInstance($a_page_id);
276 
277  abstract public function getPageGUIClassName();
278 
282  public function view()
283  {
284  $ilToolbar = $this->toolbar;
286  $tree = $this->tree;
287 
288  if (!$this->checkPermissionBool("write")) {
289  $this->ctrl->redirect($this, "infoScreen");
290  }
291 
292  $this->tabs_gui->activateTab("pages");
293 
294  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
295 
296  $button = ilLinkButton::getInstance();
297  $button->setCaption("prtf_add_page");
298  $button->setUrl($this->ctrl->getLinkTarget($this, "addPage"));
299  $ilToolbar->addStickyItem($button);
300 
301  if (!$ilSetting->get('disable_wsp_blogs')) {
302  $button = ilLinkButton::getInstance();
303  $button->setCaption("prtf_add_blog");
304  $button->setUrl($this->ctrl->getLinkTarget($this, "addBlog"));
305  $ilToolbar->addStickyItem($button);
306  }
307 
308 
309  // #16571
310  if ($this->getType() == "prtf") {
311  $ilToolbar->addSeparator();
312 
313  $button = ilLinkButton::getInstance();
314  $button->setCaption("export_html");
315  $button->setUrl($this->ctrl->getLinkTarget($this, "export"));
316  $ilToolbar->addButtonInstance($button);
317 
318  $button = ilLinkButton::getInstance();
319  $button->setCaption("prtf_pdf");
320  $button->setUrl($this->ctrl->getLinkTarget($this, "exportPDFSelection"));
321  $ilToolbar->addButtonInstance($button);
322  }
323 
324  include_once "Modules/Portfolio/classes/class.ilPortfolioPageTableGUI.php";
325  $table = new ilPortfolioPageTableGUI($this, "view");
326 
327  // exercise portfolio?
328  include_once "Modules/Portfolio/classes/class.ilPortfolioExerciseGUI.php";
329  $exercises = ilPortfolioExerciseGUI::checkExercise($this->user_id, $this->object->getId(), $table->dataExists());
330  if ($exercises) {
331  ilUtil::sendInfo($exercises);
332  }
333 
334  $this->tpl->setContent($table->getHTML());
335  }
336 
340  protected function addPage()
341  {
342  $ilHelp = $this->help;
343 
344  $this->tabs_gui->clearTargets();
345  $this->tabs_gui->setBackTarget(
346  $this->lng->txt("back"),
347  $this->ctrl->getLinkTarget($this, "view")
348  );
349 
350  $ilHelp->setScreenIdComponent("prtf");
351  $ilHelp->setScreenId("add_page");
352 
353 
354  $form = $this->initPageForm("create");
355  $this->tpl->setContent($form->getHTML());
356  }
357 
364  public function initPageForm($a_mode = "create")
365  {
366  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
367  $form = new ilPropertyFormGUI();
368  $form->setFormAction($this->ctrl->getFormAction($this));
369 
370  // title
371  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
372  $ti->setMaxLength(200);
373  $ti->setRequired(true);
374  $form->addItem($ti);
375 
376  // save and cancel commands
377  if ($a_mode == "create") {
378  include_once "Services/COPage/Layout/classes/class.ilPageLayout.php";
380  if ($templates) {
381  $use_template = new ilRadioGroupInputGUI($this->lng->txt("prtf_use_page_layout"), "tmpl");
382  $use_template->setRequired(true);
383  $form->addItem($use_template);
384 
385  $opt = new ilRadioOption($this->lng->txt("none"), 0);
386  $use_template->addOption($opt);
387 
388  foreach ($templates as $templ) {
389  $templ->readObject();
390 
391  $opt = new ilRadioOption($templ->getTitle() . $templ->getPreview(), $templ->getId());
392  $use_template->addOption($opt);
393  }
394  }
395 
396  $form->setTitle($this->lng->txt("prtf_add_page") . ": " .
397  $this->object->getTitle());
398  $form->addCommandButton("savePage", $this->lng->txt("save"));
399  $form->addCommandButton("view", $this->lng->txt("cancel"));
400  } else {
401  /* edit is done directly in table gui
402  $form->setTitle($this->lng->txt("prtf_edit_page"));
403  $form->addCommandButton("updatePage", $this->lng->txt("save"));
404  $form->addCommandButton("view", $this->lng->txt("cancel"));
405  */
406  }
407 
408  return $form;
409  }
410 
414  public function savePage()
415  {
416  $form = $this->initPageForm("create");
417  if ($form->checkInput() && $this->checkPermissionBool("write")) {
418  include_once("Modules/Portfolio/classes/class.ilPortfolioPage.php");
419  $page = $this->getPageInstance();
420  $page->setType(ilPortfolioPage::TYPE_PAGE);
421  $page->setTitle($form->getInput("title"));
422 
423  // use template as basis
424  $layout_id = $form->getInput("tmpl");
425  if ($layout_id) {
426  include_once("./Services/COPage/Layout/classes/class.ilPageLayout.php");
427  $layout_obj = new ilPageLayout($layout_id);
428  $page->setXMLContent($layout_obj->getXMLContent());
429  }
430 
431  $page->create();
432 
433  ilUtil::sendSuccess($this->lng->txt("prtf_page_created"), true);
434  $this->ctrl->redirect($this, "view");
435  }
436 
437  $this->tabs_gui->clearTargets();
438  $this->tabs_gui->setBackTarget(
439  $this->lng->txt("back"),
440  $this->ctrl->getLinkTarget($this, "view")
441  );
442 
443  $form->setValuesByPost();
444  $this->tpl->setContent($form->getHtml());
445  }
446 
450  protected function addBlog()
451  {
452  $ilHelp = $this->help;
453 
454  $this->tabs_gui->clearTargets();
455  $this->tabs_gui->setBackTarget(
456  $this->lng->txt("back"),
457  $this->ctrl->getLinkTarget($this, "view")
458  );
459 
460  $ilHelp->setScreenIdComponent("prtf");
461  $ilHelp->setScreenId("add_blog");
462 
463  $form = $this->initBlogForm();
464  $this->tpl->setContent($form->getHTML());
465  }
466 
467  abstract protected function initBlogForm();
468 
469  abstract protected function saveBlog();
470 
474  public function savePortfolioPagesOrdering()
475  {
476  if (!$this->checkPermissionBool("write")) {
477  return;
478  }
479 
480  $title_changes = array();
481 
482  if (is_array($_POST["order"])) {
483  foreach ($_POST["order"] as $k => $v) {
484  $page = $this->getPageInstance(ilUtil::stripSlashes($k));
485  if ($_POST["title"][$k]) {
486  $new_title = trim(ilUtil::stripSlashes($_POST["title"][$k]));
487  if ($page->getTitle() != $new_title) {
488  $title_changes[$page->getId()] = array("old" => $page->getTitle(), "new" => $new_title);
489  $page->setTitle($new_title);
490  }
491  }
492  $page->setOrderNr(ilUtil::stripSlashes($v));
493  $page->update();
494  }
495  ilPortfolioPage::fixOrdering($this->object->getId());
496  }
497 
498  $this->object->fixLinksOnTitleChange($title_changes);
499 
500  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
501  $this->ctrl->redirect($this, "view");
502  }
503 
508  {
509  if (!is_array($_POST["prtf_pages"]) || count($_POST["prtf_pages"]) == 0) {
510  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
511  $this->ctrl->redirect($this, "view");
512  } else {
513  $this->tabs_gui->activateTab("pages");
514 
515  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
516  $cgui = new ilConfirmationGUI();
517  $cgui->setFormAction($this->ctrl->getFormAction($this));
518  $cgui->setHeaderText($this->lng->txt("prtf_sure_delete_portfolio_pages"));
519  $cgui->setCancel($this->lng->txt("cancel"), "view");
520  $cgui->setConfirm($this->lng->txt("delete"), "deletePortfolioPages");
521 
522  foreach ($_POST["prtf_pages"] as $id) {
523  $page = $this->getPageInstance($id);
524  $title = $page->getTitle();
525  if ($page->getType() == ilPortfolioPage::TYPE_BLOG) {
526  $title = $this->lng->txt("obj_blog") . ": " . ilObject::_lookupTitle((int) $title);
527  }
528  $cgui->addItem("prtf_pages[]", $id, $title);
529  }
530 
531  $this->tpl->setContent($cgui->getHTML());
532  }
533  }
534 
538  public function deletePortfolioPages()
539  {
540  if (!$this->checkPermissionBool("write")) {
541  return;
542  }
543 
544  if (is_array($_POST["prtf_pages"])) {
545  foreach ($_POST["prtf_pages"] as $id) {
546  $page = $this->getPageInstance($id);
547  $page->delete();
548  }
549  }
550  ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_page_deleted"), true);
551  $this->ctrl->redirect($this, "view");
552  }
553 
557  public function preview($a_return = false, $a_content = false, $a_show_notes = true)
558  {
561 
562  $portfolio_id = $this->object->getId();
563  $user_id = $this->object->getOwner();
564 
565  $this->tabs_gui->clearTargets();
566 
567  $pages = ilPortfolioPage::getAllPortfolioPages($portfolio_id);
568  $current_page = (int) $_GET["user_page"];
569 
570  // validate current page
571  if ($pages && $current_page) {
572  $found = false;
573  foreach ($pages as $page) {
574  if ($page["id"] == $current_page) {
575  $found = true;
576  break;
577  }
578  }
579  if (!$found) {
580  $current_page = null;
581  }
582  }
583 
584  // display first page of portfolio if none given
585  if (!$current_page && $pages) {
586  $current_page = $pages;
587  $current_page = array_shift($current_page);
588  $current_page = $current_page["id"];
589  }
590 
591  // #13788 - keep page after login
592  if ($this->user_id == ANONYMOUS_USER_ID &&
593  $this->getType() == "prtf") {
594  $this->tpl->setLoginTargetPar("prtf_" . $this->object->getId() . "_" . $current_page);
595  }
596 
597  $back_caption = "";
598 
599  // public profile
600  if ($_REQUEST["back_url"]) {
601  $back = $_REQUEST["back_url"];
602  } elseif ($_GET["baseClass"] != "ilPublicUserProfileGUI" &&
603  $this->user_id && $this->user_id != ANONYMOUS_USER_ID) {
604  if (!$this->checkPermissionBool("write")) {
605  // shared
606  if ($this->getType() == "prtf") {
607  $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", $this->object->getOwner());
608  $back = $this->ctrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui"), "showOther");
609  $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", "");
610  }
611  // listgui / parent container
612  else {
613  // #12819
614  $tree = $this->tree;
615  $parent_id = $tree->getParentId($this->node_id);
616  include_once "Services/Link/classes/class.ilLink.php";
618  }
619  }
620  // owner
621  else {
622  $back = $this->ctrl->getLinkTarget($this, "view");
623  if ($this->getType() == "prtf") {
624  $back_caption = $this->lng->txt("prtf_back_to_portfolio_owner");
625  } else {
626  // #19316
627  $this->lng->loadLanguageModule("prtt");
628  $back_caption = $this->lng->txt("prtt_edit");
629  }
630  }
631  }
632 
633  $ilMainMenu = $this->main_menu;
634  $ilMainMenu->setMode(ilMainMenuGUI::MODE_TOPBAR_ONLY);
635  if ($back) {
636  // might already be set in ilPublicUserProfileGUI
637  $ilMainMenu->setTopBarBack($back, $back_caption);
638  }
639 
640  // render tabs
641  $current_blog = null;
642  if (count($pages) > 1) {
643  foreach ($pages as $p) {
644  if ($p["type"] == ilPortfolioPage::TYPE_BLOG) {
645  // needed for blog comments (see below)
646  if ($p["id"] == $current_page) {
647  $current_blog = (int) $p["title"];
648  }
649  include_once "Modules/Blog/classes/class.ilObjBlog.php";
650  $p["title"] = ilObjBlog::_lookupTitle($p["title"]);
651  }
652 
653  $this->ctrl->setParameter($this, "user_page", $p["id"]);
654  $this->tabs_gui->addTab(
655  "user_page_" . $p["id"],
656  $p["title"],
657  $this->ctrl->getLinkTarget($this, "preview")
658  );
659  }
660 
661  $this->tabs_gui->activateTab("user_page_" . $current_page);
662  }
663 
664  $this->ctrl->setParameter($this, "user_page", $current_page);
665 
666  if (!$a_content) {
667  // #18291
668  if ($current_page) {
669  // get current page content
670  $page_gui = $this->getPageGUIInstance($current_page);
671  $page_gui->setEmbedded(true);
672 
673  $content = $this->ctrl->getHTML($page_gui);
674  }
675  } else {
676  $content = $a_content;
677  }
678 
679  if ($a_return && $this->checkPermissionBool("write")) {
680  return $content;
681  }
682 
683  // blog posting comments are handled within the blog
684  $notes = "";
685  if ($a_show_notes && $this->object->hasPublicComments() && !$current_blog && $current_page) {
686  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
687  $note_gui = new ilNoteGUI($portfolio_id, $current_page, "pfpg");
688  $note_gui->setRepositoryMode(false);
689  $note_gui->enablePublicNotes(true);
690  $note_gui->enablePrivateNotes(false);
691 
692  $note_gui->enablePublicNotesDeletion(($this->user_id == $user_id) &&
693  $ilSetting->get("comments_del_tutor", 1));
694 
695  $next_class = $this->ctrl->getNextClass($this);
696  if ($next_class == "ilnotegui") {
697  $notes = $this->ctrl->forwardCommand($note_gui);
698  } else {
699  $notes = $note_gui->getNotesHTML();
700  }
701  }
702 
703  if ($this->perma_link === null) {
704  if ($this->getType() == "prtf") {
705  $this->tpl->setPermanentLink($this->getType(), $this->object->getId(), "_" . $current_page);
706  } else {
707  $this->tpl->setPermanentLink($this->getType(), $this->object->getRefId());
708  }
709  } else {
710  $this->tpl->setPermanentLink($this->perma_link["type"], $this->perma_link["obj_id"]);
711  }
712 
713  // #18208 - see ilPortfolioTemplatePageGUI::getPageContentUserId()
714  if ($this->getType() == "prtt" && !$this->checkPermissionBool("write")) {
715  $user_id = $ilUser->getId();
716  }
717 
718  self::renderFullscreenHeader($this->object, $this->tpl, $user_id);
719 
720  // #13564
721  $this->ctrl->setParameter($this, "user_page", "");
722  $this->tpl->setTitleUrl($this->ctrl->getLinkTarget($this, "preview"));
723  $this->ctrl->setParameter($this, "user_page", $this->page_id);
724 
725  // blog pages do their own (page) style handling
726  if (!$current_blog) {
727  $content = '<div id="ilCOPageContent" class="ilc_page_cont_PageContainer">' .
728  '<div class="ilc_page_Page">' .
729  $content .
730  '</div></div>';
731 
732  $this->setContentStyleSheet($this->tpl);
733  }
734 
735  // #10717
736  $this->tpl->setContent($content .
737  '<div class="ilClearFloat">' . $notes . '</div>');
738  }
739 
747  public static function renderFullscreenHeader($a_portfolio, $a_tpl, $a_user_id, $a_export = false)
748  {
749  global $DIC;
750 
751  $ilUser = $DIC->user();
752 
753  if (!$a_export) {
754  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
756  $a_portfolio->getType(),
757  ($a_portfolio->getType() == "prtt")
758  ? $a_portfolio->getRefId()
759  : $a_portfolio->getId(),
760  $a_portfolio->getId(),
761  $ilUser->getId()
762  );
763  }
764 
765  $name = ilObjUser::_lookupName($a_user_id);
766  $name = $name["lastname"] . ", " . ($t = $name["title"] ? $t . " " : "") . $name["firstname"];
767 
768  // show banner?
769  $banner = $banner_width = $banner_height = false;
770  $prfa_set = new ilSetting("prfa");
771  if ($prfa_set->get("banner")) {
772  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
773  $banner = ilWACSignedPath::signFile($a_portfolio->getImageFullPath());
774  $banner_width = $prfa_set->get("banner_width");
775  $banner_height = $prfa_set->get("banner_height");
776  if ($a_export) {
777  $banner = basename($banner);
778  }
779  }
780 
781  // profile picture
782  $ppic = null;
783  if ($a_portfolio->hasProfilePicture()) {
784  $ppic = ilObjUser::_getPersonalPicturePath($a_user_id, "xsmall", true, true);
785  if ($a_export) {
786  $ppic = basename($ppic);
787  }
788  }
789 
790  $a_tpl->resetHeaderBlock(false);
791  // $a_tpl->setBackgroundColor($a_portfolio->getBackgroundColor());
792  $a_tpl->setBanner($banner, $banner_width, $banner_height, $a_export);
793  $a_tpl->setTitleIcon($ppic);
794  $a_tpl->setTitle($a_portfolio->getTitle());
795  // $a_tpl->setTitleColor($a_portfolio->getFontColor());
796  $a_tpl->setDescription($name);
797 
798  // to get rid of locator in portfolio template preview
799  $a_tpl->setVariable("LOCATOR", "");
800 
801  // :TODO: obsolete?
802  // $a_tpl->setBodyClass("std ilExternal ilPortfolio");
803  }
804 
805  public function export()
806  {
807  include_once "Modules/Portfolio/classes/class.ilPortfolioHTMLExport.php";
808  $export = new ilPortfolioHTMLExport($this, $this->object);
809  $zip = $export->buildExportFile();
810 
811  ilUtil::deliverFile($zip, $this->object->getTitle() . ".zip", '', false, true);
812  }
813 
814 
818  public function copyPageForm($a_form = null)
819  {
820  if (!is_array($_POST["prtf_pages"]) || count($_POST["prtf_pages"]) == 0) {
821  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
822  $this->ctrl->redirect($this, "view");
823  } else {
824  $this->tabs_gui->activateTab("pages");
825 
826  if (!$a_form) {
827  $a_form = $this->initCopyPageForm();
828  }
829 
830  foreach ($_POST["prtf_pages"] as $page_id) {
831  $item = new ilHiddenInputGUI("prtf_pages[]");
832  $item->setValue($page_id);
833  $a_form->addItem($item);
834  }
835 
836  $this->tpl->setContent($a_form->getHTML());
837  }
838  }
839 
840  public function copyPage()
841  {
842  $form = $this->initCopyPageForm();
843  if ($form->checkInput()) {
844  // existing
845  if ($form->getInput("target") == "old") {
846  $portfolio_id = $form->getInput("prtf");
847  }
848  // new
849  else {
850  $portfolio = new ilObjPortfolio();
851  $portfolio->setTitle($form->getInput("title"));
852  $portfolio->create();
853  $portfolio_id = $portfolio->getId();
854  }
855 
856  // copy page(s)
857  foreach ($_POST["prtf_pages"] as $page_id) {
858  $source = $this->getPageInstance($page_id);
859  $target = $this->getPageInstance(null, $portfolio_id);
860  $target->setXMLContent($source->copyXmlContent(true)); // copy mobs
861  $target->setType($source->getType());
862  $target->setTitle($source->getTitle());
863  $target->create();
864  }
865 
866  ilUtil::sendSuccess($this->lng->txt("prtf_pages_copied"), true);
867  $this->ctrl->redirect($this, "view");
868  }
869 
870  $form->setValuesByPost();
871  $this->copyPageForm($form);
872  }
873 
874  abstract protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form);
875 
876  public function initCopyPageForm()
877  {
878  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
879  $form = new ilPropertyFormGUI();
880  $form->setFormAction($this->ctrl->getFormAction($this));
881  $form->setTitle($this->lng->txt("prtf_copy_page"));
882 
884 
885  $form->addCommandButton("copyPage", $this->lng->txt("save"));
886  $form->addCommandButton("view", $this->lng->txt("cancel"));
887 
888  return $form;
889  }
890 
891 
895 
896  public function setContentStyleSheet($a_tpl = null)
897  {
898  $tpl = $this->tpl;
899 
900  if ($a_tpl != null) {
901  $ctpl = $a_tpl;
902  } else {
903  $ctpl = $tpl;
904  }
905 
906  $ctpl->setCurrentBlock("ContentStyle");
907  $ctpl->setVariable(
908  "LOCATION_CONTENT_STYLESHEET",
909  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
910  );
911  $ctpl->parseCurrentBlock();
912  }
913 
914  public function editStyleProperties()
915  {
916  $this->checkPermission("write");
917 
918  $this->tabs_gui->activateTab("settings");
919  $this->setSettingsSubTabs("style");
920 
921  $form = $this->initStylePropertiesForm();
922  $this->tpl->setContent($form->getHTML());
923  }
924 
925  public function initStylePropertiesForm()
926  {
928 
929  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
930  $this->lng->loadLanguageModule("style");
931 
932  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
933  $form = new ilPropertyFormGUI();
934 
935  $fixed_style = $ilSetting->get("fixed_content_style_id");
936  $style_id = $this->object->getStyleSheetId();
937 
938  if ($fixed_style > 0) {
939  $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
940  $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" .
941  $this->lng->txt("global_fixed") . ")");
942  $form->addItem($st);
943  } else {
945  true,
946  false,
947  $_GET["ref_id"]
948  );
949 
950  $st_styles[0] = $this->lng->txt("default");
951  ksort($st_styles);
952 
953  if ($style_id > 0) {
954  // individual style
955  if (!ilObjStyleSheet::_lookupStandard($style_id)) {
956  $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
957  $st->setValue(ilObject::_lookupTitle($style_id));
958  $form->addItem($st);
959 
960  // delete command
961  $form->addCommandButton("editStyle", $this->lng->txt("style_edit_style"));
962  $form->addCommandButton("deleteStyle", $this->lng->txt("style_delete_style"));
963  }
964  }
965 
966  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id)) {
967  $style_sel = new ilSelectInputGUI(
968  $this->lng->txt("style_current_style"),
969  "style_id"
970  );
971  $style_sel->setOptions($st_styles);
972  $style_sel->setValue($style_id);
973  $form->addItem($style_sel);
974 
975  $form->addCommandButton("saveStyleSettings", $this->lng->txt("save"));
976  $form->addCommandButton("createStyle", $this->lng->txt("sty_create_ind_style"));
977  }
978  }
979 
980  $form->setTitle($this->lng->txt($this->getType() . "_style"));
981  $form->setFormAction($this->ctrl->getFormAction($this));
982 
983  return $form;
984  }
985 
986  public function createStyle()
987  {
988  $this->ctrl->redirectByClass("ilobjstylesheetgui", "create");
989  }
990 
991  public function editStyle()
992  {
993  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
994  }
995 
996  public function deleteStyle()
997  {
998  $this->ctrl->redirectByClass("ilobjstylesheetgui", "delete");
999  }
1000 
1001  public function saveStyleSettings()
1002  {
1004 
1005  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1006  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
1007  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
1008  || $this->object->getStyleSheetId() == 0)) {
1009  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
1010  $this->object->update();
1011 
1012  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1013  }
1014  $this->ctrl->redirect($this, "editStyleProperties");
1015  }
1016 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _lookupName($a_user_id)
lookup user name
static getAllPortfolioPages($a_portfolio_id)
Get pages of portfolio.
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
This class represents an option in a radio group.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
confirmPortfolioPageDeletion()
Confirm portfolio deletion.
getItemByPostVar($a_post_var)
Get Item by POST variable.
static _lookupTitle($a_id)
This class represents a selection list property in a property form.
Portfolio HTML exporter class.
This class represents a property form user interface.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
New implementation of ilObjectGUI.
view()
Show list of portfolio pages.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
setPermaLink($a_obj_id, $a_type)
Set custom perma link (used in public profile?)
if(!array_key_exists('StateId', $_REQUEST)) $id
This class represents a checkbox property in a property form.
static fixOrdering($a_portfolio_id)
Fix ordering.
addPage()
Show portfolio page creation form.
static _lookupTitle($a_id)
lookup object title
static _getStandardStyles( $a_exclude_default_style=false, $a_include_deactivated=false, $a_scope=0)
Get standard styles.
addItem($a_item)
Add Item (Property, SectionHeader).
savePage()
Create new portfolio page.
Class ilPageLayout.
user()
Definition: user.php:4
static _lookupStandard($a_id)
Lookup standard flag.
Notes GUI class.
deletePortfolioPages()
Delete portfolio pages.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$a_type
Definition: workflow.php:92
savePortfolioPagesOrdering()
Save ordering of portfolio pages.
This class represents a hidden form property in a property form.
if($format !==null) $name
Definition: metadata.php:146
This class represents a property in a property form.
if(isset($_POST['submit'])) $form
$a_content
Definition: workflow.php:93
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
static setPersonalWorkspaceQuotaCheck($a_value)
setAdditional($a_additional)
Set Additonal Information (used in public profile?)
getType()
Functions that must be overwritten.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
getAdditional()
Get Additonal Information.
initCopyPageFormOptions(ilPropertyFormGUI $a_form)
This class represents a text property in a property form.
initPageForm($a_mode="create")
Init portfolio page form.
$ilUser
Definition: imgupload.php:18
setMaxLength($a_maxlength)
Set Max Length.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static signFile($path_to_file)
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
static getContentStylePath($a_style_id, $add_random=true)
get content style path
setOptions($a_options)
Set Options.
addBlog()
Show portfolio blog page creation form.
Create styles array
The data for the language used.
getPageGUIInstance($a_page_id)
Portfolio view gui base class.
This class represents an image file property in a property form.
static checkExercise($a_user_id, $a_obj_id, $a_add_submit=false)
settings()
Definition: settings.php:2
This class represents a non editable value in a property form.
static renderFullscreenHeader($a_portfolio, $a_tpl, $a_user_id, $a_export=false)
Render banner, user name.
Create new PHPExcel object
obj_idprivate
global $ilSetting
Definition: privfeed.php:17
$ret
Definition: parser.php:6
static activeLayouts($a_special_page=false, $a_module=null)
Get active layouts.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
$source
Definition: linkback.php:22
if(empty($password)) $table
Definition: pwgen.php:24
getPageInstance($a_page_id=null, $a_portfolio_id=null)
initEditCustomForm(ilPropertyFormGUI $a_form)
preview($a_return=false, $a_content=false, $a_show_notes=true)
Show user page.
updateCustom(ilPropertyFormGUI $a_form)
$_POST["username"]
setRequired($a_required)
Set Required.
copyPageForm($a_form=null)
Select target portfolio for page(s) copy.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
Confirmation screen class.