ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjPortfolioTemplateGUI.php
Go to the documentation of this file.
1 <?php
2 
31 {
33  protected ilHelpGUI $help;
34  protected ilTabsGUI $tabs;
35 
36  public function __construct(
37  int $a_id = 0,
38  int $a_id_type = self::REPOSITORY_NODE_ID,
39  int $a_parent_node_id = 0
40  ) {
41  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
42  global $DIC;
43 
44  $this->nav_history = $DIC["ilNavigationHistory"];
45  $this->help = $DIC["ilHelp"];
46  $this->tabs = $DIC->tabs();
47  $this->toolbar = $DIC->toolbar();
48  $this->user = $DIC->user();
49  }
50 
51  public function getType(): string
52  {
53  return "prtt";
54  }
55 
56  public function executeCommand(): void
57  {
58  $ilNavigationHistory = $this->nav_history;
59 
60  // add entry to navigation history
61  if (!$this->getCreationMode() &&
62  $this->getAccessHandler()->checkAccess("read", "", $this->node_id)) {
63  $link = $this->ctrl->getLinkTarget($this, "view");
64  $ilNavigationHistory->addItem($this->node_id, $link, "prtt");
65  }
66 
67  $next_class = $this->ctrl->getNextClass($this);
68  $cmd = $this->ctrl->getCmd("view");
69  switch ($next_class) {
70  case 'ilportfoliotemplatepagegui':
71  $this->determinePageCall(); // has to be done before locator!
72  $this->prepareOutput();
73  $this->handlePageCall($cmd);
74  break;
75 
76  case "ilcommentgui":
77  $this->preview();
78  break;
79 
80  case "ilinfoscreengui":
81  $this->prepareOutput();
82  $this->addHeaderAction();
83  $this->infoScreenForward();
84  break;
85 
86  case "ilcommonactiondispatchergui":
88  $this->prepareOutput();
89  $this->ctrl->forwardCommand($gui);
90  break;
91 
92  case "ilpermissiongui":
93  $this->prepareOutput();
94  $this->tabs_gui->activateTab("id_permissions");
95  $perm_gui = new ilPermissionGUI($this);
96  $this->ctrl->forwardCommand($perm_gui);
97  break;
98 
99  case "ilobjectcopygui":
100  $this->prepareOutput();
101  $cp = new ilObjectCopyGUI($this);
102  $cp->setType("prtt");
103  $this->ctrl->forwardCommand($cp);
104  break;
105 
106  case 'ilexportgui':
107  $this->prepareOutput();
108  $this->tabs_gui->activateTab("export");
109  $exp_gui = new ilExportGUI($this);
110  $exp_gui->addFormat("xml");
111  $this->ctrl->forwardCommand($exp_gui);
112  break;
113 
114  case "ilobjectcontentstylesettingsgui":
115  $this->checkPermission("write");
116  $this->prepareOutput();
117  $this->addHeaderAction();
118  $this->tabs_gui->activateTab("settings");
119  $this->setSettingsSubTabs("style");
120  $settings_gui = $this->content_style_gui
121  ->objectSettingsGUIForRefId(
122  null,
123  $this->object->getRefId()
124  );
125  $this->ctrl->forwardCommand($settings_gui);
126  break;
127 
128  case "ilobjectmetadatagui":
129  $this->checkPermission("write");
130  $this->prepareOutput();
131  $this->addHeaderAction();
132  $this->tabs_gui->activateTab("advmd");
133  $md_gui = new ilObjectMetaDataGUI($this->object, "pfpg");
134  $this->ctrl->forwardCommand($md_gui);
135  break;
136 
137  default:
138  $this->addHeaderAction();
140  }
141  }
142 
143  protected function setTabs(): void
144  {
145  $ilHelp = $this->help;
146 
147  $ilHelp->setScreenIdComponent("prtt");
148 
149  if ($this->checkPermissionBool("write")) {
150  $this->tabs_gui->addTab(
151  "pages",
152  $this->lng->txt("content"),
153  $this->ctrl->getLinkTarget($this, "view")
154  );
155  }
156 
157  if ($this->checkPermissionBool("read")) {
158  $this->tabs_gui->addTab(
159  "id_info",
160  $this->lng->txt("info_short"),
161  $this->ctrl->getLinkTargetByClass(array("ilobjportfoliotemplategui", "ilinfoscreengui"), "showSummary")
162  );
163  }
164 
165  if ($this->checkPermissionBool("write")) {
166  $this->tabs_gui->addTab(
167  "settings",
168  $this->lng->txt("settings"),
169  $this->ctrl->getLinkTarget($this, "edit")
170  );
171 
172  $mdgui = new ilObjectMetaDataGUI($this->object, "pfpg");
173  $mdtab = $mdgui->getTab();
174  if ($mdtab) {
175  $this->tabs_gui->addTab(
176  "advmd",
177  $this->lng->txt("meta_data"),
178  $mdtab
179  );
180  }
181 
182  $this->tabs_gui->addTab(
183  "export",
184  $this->lng->txt("export"),
185  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
186  );
187  }
188 
189  if ($this->checkPermissionBool("read")) {
190  $this->tabs_gui->addNonTabbedLink(
191  "preview",
192  $this->lng->txt("preview"),
193  $this->ctrl->getLinkTarget($this, "preview")
194  );
195  }
196 
197  // will add permissions if needed
199  }
200 
204  public function infoScreen(): void
205  {
206  $this->ctrl->setCmd("showSummary");
207  $this->ctrl->setCmdClass("ilinfoscreengui");
208  $this->infoScreenForward();
209  }
210 
211  public function infoScreenForward(): void
212  {
213  $ilTabs = $this->tabs;
214  $ilToolbar = $this->toolbar;
215 
216  $ilTabs->activateTab("id_info");
217 
218  $this->checkPermission("visible");
219 
220  if ($this->checkPermissionBool("read")) {
221  $this->lng->loadLanguageModule("cntr");
222 
223  $this->gui->button(
224  $this->lng->txt("prtf_create_portfolio_from_template"),
225  $this->ctrl->getLinkTarget($this, "createfromtemplate")
226  )->primary()->toToolbar();
227  }
228 
229  $info = new ilInfoScreenGUI($this);
230 
231  $info->enablePrivateNotes();
232 
233  if ($this->checkPermissionBool("read")) {
234  $info->enableNews();
235  }
236 
237  // no news editing for files, just notifications
238  $info->enableNewsEditing(false);
239  if ($this->checkPermissionBool("write")) {
240  $news_set = new ilSetting("news");
241  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
242 
243  if ($enable_internal_rss) {
244  $info->setBlockProperty("news", "settings", true);
245  $info->setBlockProperty("news", "public_notifications_option", true);
246  }
247  }
248 
249  // standard meta data
250  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
251 
252  $this->ctrl->forwardCommand($info);
253  }
254 
255 
256  //
257  // CREATE/EDIT
258  //
259 
261  {
262  $ilUser = $this->user;
263 
264  $all = ilObjPortfolio::getPortfoliosOfUser($ilUser->getId());
265  if (count($all)) {
266  $opts = array("" => $this->lng->txt("please_select"));
267  foreach ($all as $item) {
268  $opts[$item["id"]] = $item["title"];
269  }
270  $prtf = new ilSelectInputGUI($this->lng->txt("prtf_create_template_from_portfolio"), "prtf");
271  $prtf->setInfo($this->lng->txt("prtf_create_template_from_portfolio_info"));
272  $prtf->setOptions($opts);
273  $form->addItem($prtf);
274  }
275 
276  return $form;
277  }
278 
279  protected function afterSave(ilObject $new_object): void
280  {
281  if ($this->port_request->getPortfolioId() > 0) {
282  $source = new ilObjPortfolio($this->port_request->getPortfolioId(), false);
283 
285  $obj = $new_object;
287  }
288 
289  $this->tpl->setOnScreenMessage('success', $this->lng->txt("prtt_portfolio_created"), true);
290  $this->ctrl->setParameter($this, "prt_id", $new_object->getId());
291  $this->ctrl->redirect($this, "view");
292  }
293 
294  protected function initEditCustomForm(ilPropertyFormGUI $a_form): void
295  {
296  $obj_service = $this->object_service;
297  // activation/availability
298 
299  $this->lng->loadLanguageModule('rep');
300 
301  $section = new ilFormSectionHeaderGUI();
302  $section->setTitle($this->lng->txt('rep_activation_availability'));
303  $a_form->addItem($section);
304 
305  // additional info only with multiple references
306  $act_obj_info = $act_ref_info = "";
307  if (count(ilObject::_getAllReferences($this->object->getId())) > 1) {
308  $act_obj_info = ' ' . $this->lng->txt('rep_activation_online_object_info');
309  $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
310  }
311 
312  $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'online');
313  $online->setInfo($this->lng->txt('prtt_activation_online_info') . $act_obj_info);
314  $a_form->addItem($online);
315 
316  $dur = new ilDateDurationInputGUI($this->lng->txt("rep_time_based_availability"), "access_period");
317  $dur->setShowTime(true);
318  $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
319  $a_form->addItem($dur);
320 
321  $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'access_visiblity');
322  $visible->setInfo($this->lng->txt('prtt_activation_limited_visibility_info'));
323  $dur->addSubItem($visible);
324 
325  $section = new ilFormSectionHeaderGUI();
326  $section->setTitle($this->lng->txt('obj_presentation'));
327  $a_form->addItem($section);
328 
329  // tile image
330  $obj_service->commonSettings()->legacyForm($a_form, $this->object)->addTileImage();
331 
332 
333  parent::initEditCustomForm($a_form);
334 
336  $this->object->getId(),
337  $a_form,
338  array(
340  )
341  );
342 
343  $tit = $a_form->getItemByPostVar("title");
344  $tit->setInfo($this->lng->txt('prtt_title_info'));
345  }
346 
347  protected function getEditFormCustomValues(array &$a_values): void
348  {
349  $a_values["online"] = $this->object->isOnline();
350  $a_values["access_period"]["start"] = $this->object->getActivationStartDate()
351  ? new ilDateTime($this->object->getActivationStartDate(), IL_CAL_UNIX)
352  : null;
353  $a_values["access_period"]["end"] = $this->object->getActivationEndDate()
354  ? new ilDateTime($this->object->getActivationEndDate(), IL_CAL_UNIX)
355  : null;
356  $a_values["access_visiblity"] = $this->object->getActivationVisibility();
357 
358  $a_values['cont_custom_md'] = ilContainer::_lookupContainerSetting(
359  $this->object->getId(),
361  false
362  );
363 
364  parent::getEditFormCustomValues($a_values);
365  }
366 
367  protected function updateCustom(ilPropertyFormGUI $form): void
368  {
369  $obj_service = $this->object_service;
370 
371  $this->object->setOnline($form->getInput("online"));
372 
373  // activation
374  $period = $form->getItemByPostVar("access_period");
375  if ($period->getStart() && $period->getEnd()) {
376  $this->object->setActivationLimited(true);
377  $this->object->setActivationVisibility($form->getInput("access_visiblity"));
378  $this->object->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
379  $this->object->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
380  } else {
381  $this->object->setActivationLimited(false);
382  }
383 
384  parent::updateCustom($form);
385 
386  $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTileImage();
387 
389  $this->object->getId(),
390  $form,
391  array(
393  )
394  );
395  }
396 
397 
398  //
399  // PAGES
400  //
401 
405  protected function getPageInstance(
406  ?int $a_page_id = null,
407  ?int $a_portfolio_id = null
409  if (!$a_portfolio_id && $this->object) {
410  $a_portfolio_id = $this->object->getId();
411  }
412  $page = new ilPortfolioTemplatePage((int) $a_page_id);
413  $page->setPortfolioId($a_portfolio_id);
414  return $page;
415  }
416 
420  protected function getPageGUIInstance(
421  int $a_page_id
423  $page_gui = new ilPortfolioTemplatePageGUI(
424  $this->object->getId(),
425  $a_page_id,
426  0,
427  $this->object->hasPublicComments()
428  );
429  $page_gui->setAdditional($this->getAdditional());
430  return $page_gui;
431  }
432 
433  public function getPageGUIClassName(): string
434  {
435  return "ilportfoliotemplatepagegui";
436  }
437 
438  protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form): void
439  {
440  // always existing prtft
441  $hi = new ilHiddenInputGUI("target");
442  $hi->setValue("old");
443  $a_form->addItem($hi);
444 
445  $options = array();
447  foreach ($all as $id => $title) {
448  $options[$id] = $title;
449  }
450  $prtf = new ilSelectInputGUI($this->lng->txt("obj_prtt"), "prtf");
451  $prtf->setRequired(true);
452  $prtf->setOptions($options);
453  $a_form->addItem($prtf);
454  }
455 
456 
457  //
458  // BLOG
459  //
460 
464  protected function initBlogForm(): ilPropertyFormGUI
465  {
466  $form = new ilPropertyFormGUI();
467  $form->setFormAction($this->ctrl->getFormAction($this));
468 
469  $obj = new ilTextInputGUI($this->lng->txt("title"), "blog");
470  $obj->setRequired(true);
471  $form->addItem($obj);
472 
473  // save and cancel commands
474  $form->setTitle($this->lng->txt("prtf_add_blog") . ": " .
475  $this->object->getTitle());
476  $form->addCommandButton("saveBlog", $this->lng->txt("save"));
477  $form->addCommandButton("view", $this->lng->txt("cancel"));
478 
479  return $form;
480  }
481 
482  protected function saveBlog(): void
483  {
484  $form = $this->initBlogForm();
485  if ($form->checkInput() && $this->checkPermissionBool("write")) {
486  $page = $this->getPageInstance();
488  $page->setTitle($form->getInput("blog"));
489  $page->create(false);
490 
491  $this->tpl->setOnScreenMessage('success', $this->lng->txt("prtf_blog_page_created"), true);
492  $this->ctrl->redirect($this, "view");
493  }
494 
495  $this->tabs_gui->clearTargets();
496  $this->tabs_gui->setBackTarget(
497  $this->lng->txt("back"),
498  $this->ctrl->getLinkTarget($this, "view")
499  );
500 
501  $form->setValuesByPost();
502  $this->tpl->setContent($form->getHTML());
503  }
504 
505 
506  //
507  // TRANSMOGRIFIER
508  //
509 
510  public function preview(
511  bool $a_return = false,
512  $a_content = false,
513  bool $a_show_notes = true
514  ): string {
515  if (!$this->checkPermissionBool("write") &&
516  $this->checkPermissionBool("read")) {
517  $this->lng->loadLanguageModule("cntr");
518  $button = $this->gui->button(
519  $this->lng->txt("prtf_create_portfolio_from_template"),
520  $this->ctrl->getLinkTarget($this, "createfromtemplate")
521  )->primary();
522  $this->tpl->setHeaderActionMenu($button->render());
523  }
524 
525  return parent::preview($a_return, $a_content, $a_show_notes);
526  }
527 
528  public function createFromTemplateOld(): void
529  {
530  $this->ctrl->setParameterByClass("ilobjportfoliogui", "prtt_pre", $this->object->getId());
531  $this->ctrl->redirectByClass(array("ilDashboardGUI", "ilportfoliorepositorygui", "ilobjportfoliogui"), "create");
532  }
533 
534  public function createFromTemplate(): void
535  {
536  $this->ctrl->setParameterByClass("ilobjportfoliogui", "prtt_pre", $this->object->getId());
537  $this->ctrl->redirectByClass(array("ilDashboardGUI", "ilportfoliorepositorygui", "ilobjportfoliogui"), "createFromTemplateDirect");
538  }
539 
540  public static function _goto(string $a_target): void
541  {
543  global $DIC;
544 
545  $access = $DIC->access();
546  $ctrl = $DIC->ctrl();
547 
548  $id = explode("_", $a_target);
549  $ref_id = $id[0];
550 
551  $ctrl->setParameterByClass("ilRepositoryGUI", "ref_id", $ref_id);
552  if ($access->checkAccess("read", "", $ref_id)) {
553  $ctrl->redirectByClass("ilRepositoryGUI", "preview");
554  } else {
555  $ctrl->redirectByClass("ilRepositoryGUI", "infoScreen");
556  }
557  }
558 }
checkPermission(string $perm, string $cmd="", string $type="", int $ref_id=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilInfoScreenGUI.
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
executeCommand()
execute command
ILIAS Portfolio InternalGUIService $gui
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
GUI class for the workflow of copying objects.
getItemByPostVar(string $a_post_var)
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance) ...
static _getAllReferences(int $id)
get all reference ids for object ID
Help GUI class.
initBlogForm()
Init blog template page form.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
prepareOutput(bool $show_sub_objects=true)
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
__construct(int $a_id=0, int $a_id_type=self::REPOSITORY_NODE_ID, int $a_parent_node_id=0)
const IL_CAL_UNIX
getPageGUIInstance(int $a_page_id)
Get portfolio template page gui instance.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
static getAvailablePortfolioTemplates(string $a_permission="read")
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
global $DIC
Definition: feed.php:28
ilToolbarGUI $toolbar
Export User Interface Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static clonePagesAndSettings(ilObjPortfolioBase $a_source, ilObjPortfolioBase $a_target, ?array $a_recipe=null, bool $copy_all=false)
Build template from portfolio and vice versa.
__construct(VocabulariesInterface $vocabularies)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
initEditCustomForm(ilPropertyFormGUI $a_form)
setScreenIdComponent(string $a_comp)
static getPortfoliosOfUser(int $a_user_id)
Get portfolios of user.
ilObjectService $object_service
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
afterSave(ilObject $new_object)
Post (successful) object creation hook.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
setRequired(bool $a_required)
Last visited history for repository items.
initDidacticTemplate(ilPropertyFormGUI $form)
Portfolio view gui base class.
setTabs()
create tabs (repository/workspace switch)
preview(bool $a_return=false, $a_content=false, bool $a_show_notes=true)
initCopyPageFormOptions(ilPropertyFormGUI $a_form)
infoScreen()
this one is called from the info button in the repository
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
getPageInstance(?int $a_page_id=null, ?int $a_portfolio_id=null)
Get portfolio template page instance.
addHeaderAction()
Add header action menu.
setAdditional(array $a_additional)
Set Additonal Information.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilAccessHandler $access