ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjPortfolioTemplateGUI.php
Go to the documentation of this file.
1<?php
2
20
34{
36 protected ilHelpGUI $help;
37 protected ilTabsGUI $tabs;
38
39 public function __construct(
40 int $a_id = 0,
41 int $a_id_type = self::REPOSITORY_NODE_ID,
42 int $a_parent_node_id = 0
43 ) {
44 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
45 global $DIC;
46
47 $this->nav_history = $DIC["ilNavigationHistory"];
48 $this->help = $DIC["ilHelp"];
49 $this->tabs = $DIC->tabs();
50 $this->toolbar = $DIC->toolbar();
51 $this->user = $DIC->user();
52 }
53
54 public function getType(): string
55 {
56 return "prtt";
57 }
58
59 public function executeCommand(): void
60 {
61 $ilNavigationHistory = $this->nav_history;
62
63 // add entry to navigation history
64 if (!$this->getCreationMode() &&
65 $this->getAccessHandler()->checkAccess("read", "", $this->node_id)) {
66 $link = $this->ctrl->getLinkTarget($this, "view");
67 $ilNavigationHistory->addItem($this->node_id, $link, "prtt");
68 }
69
70 $next_class = $this->ctrl->getNextClass($this);
71 $cmd = $this->ctrl->getCmd("view");
72 switch ($next_class) {
73 case 'ilportfoliotemplatepagegui':
74 $this->determinePageCall(); // has to be done before locator!
75 $this->prepareOutput();
76 $this->handlePageCall($cmd);
77 break;
78
79 case "ilcommentgui":
80 $this->preview();
81 break;
82
83 case "ilinfoscreengui":
84 $this->prepareOutput();
85 $this->addHeaderAction();
86 $this->infoScreenForward();
87 break;
88
89 case "ilcommonactiondispatchergui":
91 $this->prepareOutput();
92 $this->ctrl->forwardCommand($gui);
93 break;
94
95 case "ilpermissiongui":
96 $this->prepareOutput();
97 $this->tabs_gui->activateTab("id_permissions");
98 $perm_gui = new ilPermissionGUI($this);
99 $this->ctrl->forwardCommand($perm_gui);
100 break;
101
102 case "ilobjectcopygui":
103 $this->prepareOutput();
104 $cp = new ilObjectCopyGUI($this);
105 $cp->setType("prtt");
106 $this->ctrl->forwardCommand($cp);
107 break;
108
109 case 'ilexportgui':
110 $this->prepareOutput();
111 $this->tabs_gui->activateTab("export");
112 $exp_gui = new ilExportGUI($this);
113 $exp_gui->addFormat("xml");
114 $this->ctrl->forwardCommand($exp_gui);
115 break;
116
117 case "ilobjectcontentstylesettingsgui":
118 $this->checkPermission("write");
119 $this->prepareOutput();
120 $this->addHeaderAction();
121 $this->tabs_gui->activateTab("settings");
122 $this->setSettingsSubTabs("style");
123 $settings_gui = $this->content_style_gui
124 ->objectSettingsGUIForRefId(
125 null,
126 $this->object->getRefId()
127 );
128 $this->ctrl->forwardCommand($settings_gui);
129 break;
130
131 case "ilobjectmetadatagui":
132 $this->checkPermission("write");
133 $this->prepareOutput();
134 $this->addHeaderAction();
135 $this->tabs_gui->activateTab("advmd");
136 $md_gui = new ilObjectMetaDataGUI($this->object, "pfpg");
137 $this->ctrl->forwardCommand($md_gui);
138 break;
139
140 case strtolower(SettingsGUI::class):
141 $this->checkPermission("write");
142 $this->prepareOutput();
143 $this->addHeaderAction();
144 $this->tabs_gui->activateTab("settings");
145 $this->setSettingsSubTabs("properties");
146 $gui = $this->gui->settings()->settingsGUI(
147 $this->object->getId(),
148 true,
149 $this->ref_id
150 );
151 $this->ctrl->forwardCommand($gui);
152 break;
153
154 default:
155 $this->addHeaderAction();
157 }
158 }
159
160 protected function setTabs(): void
161 {
162 $ilHelp = $this->help;
163
164 $ilHelp->setScreenIdComponent("prtt");
165
166 if ($this->checkPermissionBool("write")) {
167 $this->tabs_gui->addTab(
168 "pages",
169 $this->lng->txt("content"),
170 $this->ctrl->getLinkTarget($this, "view")
171 );
172 }
173
174 if ($this->checkPermissionBool("read")) {
175 $this->tabs_gui->addTab(
176 "id_info",
177 $this->lng->txt("info_short"),
178 $this->ctrl->getLinkTargetByClass(array("ilobjportfoliotemplategui", "ilinfoscreengui"), "showSummary")
179 );
180 }
181
182 if ($this->checkPermissionBool("write")) {
183 $this->tabs_gui->addTab(
184 "settings",
185 $this->lng->txt("settings"),
186 $this->ctrl->getLinkTargetByClass(SettingsGUI::class)
187 );
188
189 $mdgui = new ilObjectMetaDataGUI($this->object, "pfpg");
190 $mdtab = $mdgui->getTab();
191 if ($mdtab) {
192 $this->tabs_gui->addTab(
193 "advmd",
194 $this->lng->txt("meta_data"),
195 $mdtab
196 );
197 }
198
199 $this->tabs_gui->addTab(
200 "export",
201 $this->lng->txt("export"),
202 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
203 );
204 }
205
206 if ($this->checkPermissionBool("read")) {
207 $this->tabs_gui->addNonTabbedLink(
208 "preview",
209 $this->lng->txt("preview"),
210 $this->ctrl->getLinkTarget($this, "preview")
211 );
212 }
213
214 // will add permissions if needed
216 }
217
221 public function infoScreen(): void
222 {
223 $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
224 }
225
226 public function infoScreenForward(): void
227 {
228 $ilTabs = $this->tabs;
229 $ilToolbar = $this->toolbar;
230
231 $ilTabs->activateTab("id_info");
232
233 $this->checkPermission("visible");
234
235 if ($this->checkPermissionBool("read")) {
236 $this->lng->loadLanguageModule("cntr");
237
238 $this->gui->button(
239 $this->lng->txt("prtf_create_portfolio_from_template"),
240 $this->ctrl->getLinkTarget($this, "createfromtemplate")
241 )->primary()->toToolbar();
242 }
243
244 $info = new ilInfoScreenGUI($this);
245
246 $info->enablePrivateNotes();
247
248 if ($this->checkPermissionBool("read")) {
249 $info->enableNews();
250 }
251
252 // no news editing for files, just notifications
253 $info->enableNewsEditing(false);
254 if ($this->checkPermissionBool("write")) {
255 $news_set = new ilSetting("news");
256 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
257
258 if ($enable_internal_rss) {
259 $info->setBlockProperty("news", "settings", true);
260 $info->setBlockProperty("news", "public_notifications_option", true);
261 }
262 }
263
264 // standard meta data
265 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
266
267 $this->ctrl->forwardCommand($info);
268 }
269
270
271 //
272 // CREATE/EDIT
273 //
274
276 {
277 $ilUser = $this->user;
278
279 $all = ilObjPortfolio::getPortfoliosOfUser($ilUser->getId());
280 if (count($all)) {
281 $opts = array("" => $this->lng->txt("please_select"));
282 foreach ($all as $item) {
283 $opts[$item["id"]] = $item["title"];
284 }
285 $prtf = new ilSelectInputGUI($this->lng->txt("prtf_create_template_from_portfolio"), "prtf");
286 $prtf->setInfo($this->lng->txt("prtf_create_template_from_portfolio_info"));
287 $prtf->setOptions($opts);
288 $form->addItem($prtf);
289 }
290
291 return $form;
292 }
293
294 protected function afterSave(ilObject $new_object): void
295 {
296 if ($this->port_request->getPortfolioId() > 0) {
297 $source = new ilObjPortfolio($this->port_request->getPortfolioId(), false);
298
300 $obj = $new_object;
302 }
303
304 $this->tpl->setOnScreenMessage('success', $this->lng->txt("prtt_portfolio_created"), true);
305 $this->ctrl->setParameter($this, "prt_id", $new_object->getId());
306 $this->ctrl->redirect($this, "view");
307 }
308
309 public function edit(): void
310 {
311 $this->ctrl->redirectByClass(SettingsGUI::class);
312 }
313
314 protected function getEditFormCustomValues(array &$a_values): void
315 {
316 $a_values["online"] = $this->object->isOnline();
317 $a_values["access_period"]["start"] = $this->object->getActivationStartDate()
318 ? new ilDateTime($this->object->getActivationStartDate(), IL_CAL_UNIX)
319 : null;
320 $a_values["access_period"]["end"] = $this->object->getActivationEndDate()
321 ? new ilDateTime($this->object->getActivationEndDate(), IL_CAL_UNIX)
322 : null;
323 $a_values["access_visiblity"] = $this->object->getActivationVisibility();
324
325 $a_values['cont_custom_md'] = ilContainer::_lookupContainerSetting(
326 $this->object->getId(),
328 false
329 );
330
331 parent::getEditFormCustomValues($a_values);
332 }
333
334 protected function updateCustom(ilPropertyFormGUI $form): void
335 {
336 $obj_service = $this->object_service;
337
338 $this->object->setOnline($form->getInput("online"));
339
340 // activation
341 $period = $form->getItemByPostVar("access_period");
342 if ($period->getStart() && $period->getEnd()) {
343 $this->object->setActivationLimited(true);
344 $this->object->setActivationVisibility($form->getInput("access_visiblity"));
345 $this->object->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
346 $this->object->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
347 } else {
348 $this->object->setActivationLimited(false);
349 }
350
351 parent::updateCustom($form);
352
353 $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTileImage();
354
356 $this->object->getId(),
357 $form,
358 array(
360 )
361 );
362 }
363
364
365 //
366 // PAGES
367 //
368
372 protected function getPageInstance(
373 ?int $a_page_id = null,
374 ?int $a_portfolio_id = null
376 if (!$a_portfolio_id && $this->object) {
377 $a_portfolio_id = $this->object->getId();
378 }
379 $page = new ilPortfolioTemplatePage((int) $a_page_id);
380 $page->setPortfolioId($a_portfolio_id);
381 return $page;
382 }
383
387 protected function getPageGUIInstance(
388 int $a_page_id
390 $page_gui = new ilPortfolioTemplatePageGUI(
391 $this->object->getId(),
392 $a_page_id,
393 0,
394 $this->object->hasPublicComments()
395 );
396 $page_gui->setAdditional($this->getAdditional());
397 return $page_gui;
398 }
399
400 public function getPageGUIClassName(): string
401 {
402 return "ilportfoliotemplatepagegui";
403 }
404
405 protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form): void
406 {
407 // always existing prtft
408 $hi = new ilHiddenInputGUI("target");
409 $hi->setValue("old");
410 $a_form->addItem($hi);
411
412 $options = array();
414 foreach ($all as $id => $title) {
415 $options[$id] = $title;
416 }
417 $prtf = new ilSelectInputGUI($this->lng->txt("obj_prtt"), "prtf");
418 $prtf->setRequired(true);
419 $prtf->setOptions($options);
420 $a_form->addItem($prtf);
421 }
422
423
424 //
425 // TRANSMOGRIFIER
426 //
427
428 public function preview(
429 bool $a_return = false,
430 $a_content = false,
431 bool $a_show_notes = true
432 ): string {
433 if (!$this->checkPermissionBool("write") &&
434 $this->checkPermissionBool("read")) {
435 $this->lng->loadLanguageModule("cntr");
436 $button = $this->gui->button(
437 $this->lng->txt("prtf_create_portfolio_from_template"),
438 $this->ctrl->getLinkTarget($this, "createfromtemplate")
439 )->primary();
440 $this->tpl->setHeaderActionMenu($button->render());
441 }
442
443 return parent::preview($a_return, $a_content, $a_show_notes);
444 }
445
446 public function createFromTemplateOld(): void
447 {
448 $this->ctrl->setParameterByClass("ilobjportfoliogui", "prtt_pre", $this->object->getId());
449 $this->ctrl->redirectByClass(array("ilDashboardGUI", "ilportfoliorepositorygui", "ilobjportfoliogui"), "create");
450 }
451
452 public function createFromTemplate(): void
453 {
454 $this->ctrl->setParameterByClass("ilobjportfoliogui", "prtt_pre", $this->object->getId());
455 $this->ctrl->redirectByClass(array("ilDashboardGUI", "ilportfoliorepositorygui", "ilobjportfoliogui"), "createFromTemplateDirect");
456 }
457
458 public static function _goto(string $a_target): void
459 {
461 global $DIC;
462
463 $access = $DIC->access();
464 $ctrl = $DIC->ctrl();
465
466 $id = explode("_", $a_target);
467 $ref_id = $id[0];
468
469 $ctrl->setParameterByClass("ilRepositoryGUI", "ref_id", $ref_id);
470 if ($access->checkAccess("read", "", $ref_id)) {
471 $ctrl->redirectByClass("ilRepositoryGUI", "preview");
472 } else {
473 $ctrl->redirectByClass("ilRepositoryGUI", "infoScreen");
474 }
475 }
476}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
const IL_CAL_UNIX
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
@classDescription Date and time handling
Export User Interface Class.
Help GUI class.
setScreenIdComponent(string $a_comp)
This class represents a hidden form property in a property form.
Class ilInfoScreenGUI.
Last visited history for repository items.
Portfolio view gui base class.
ILIAS Portfolio InternalGUIService $gui
static clonePagesAndSettings(ilObjPortfolioBase $a_source, ilObjPortfolioBase $a_target, ?array $a_recipe=null, bool $copy_all=false)
Build template from portfolio and vice versa.
Portfolio template view gui class.
getPageInstance(?int $a_page_id=null, ?int $a_portfolio_id=null)
Get portfolio template page instance.
getPageGUIInstance(int $a_page_id)
Get portfolio template page gui instance.
__construct(int $a_id=0, int $a_id_type=self::REPOSITORY_NODE_ID, int $a_parent_node_id=0)
preview(bool $a_return=false, $a_content=false, bool $a_show_notes=true)
infoScreen()
this one is called from the info button in the repository
getType()
Functions that must be overwritten.
initDidacticTemplate(ilPropertyFormGUI $form)
updateCustom(ilPropertyFormGUI $form)
Insert custom update form values into object.
setTabs()
create tabs (repository/workspace switch)
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
initCopyPageFormOptions(ilPropertyFormGUI $a_form)
static getAvailablePortfolioTemplates(string $a_permission="read")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getPortfoliosOfUser(int $a_user_id)
Get portfolios of user.
executeCommand()
execute command
setTabs()
create tabs (repository/workspace switch)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
ilToolbarGUI $toolbar
GUI class for the workflow of copying objects.
ilObjectService $object_service
afterSave(ilObject $new_object)
Post (successful) object creation hook.
addHeaderAction()
Add header action menu.
Class ilObjectMetaDataGUI.
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
Class ilObject Basic functions for all objects.
setAdditional(array $a_additional)
Set Additonal Information.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
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-...
getItemByPostVar(string $a_post_var)
This class represents a selection list property in a property form.
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$info
Definition: entry_point.php:21
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26