ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjPortfolioTemplateGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
15{
19 protected $nav_history;
20
24 protected $help;
25
29 protected $tabs;
30
31
35 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
36 {
37 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
38 global $DIC;
39
40 $this->nav_history = $DIC["ilNavigationHistory"];
41 $this->help = $DIC["ilHelp"];
42 $this->tabs = $DIC->tabs();
43 $this->toolbar = $DIC->toolbar();
44 $this->user = $DIC->user();
45 }
46
47 public function getType()
48 {
49 return "prtt";
50 }
51
52 public function executeCommand()
53 {
54 $ilNavigationHistory = $this->nav_history;
55
56 // add entry to navigation history
57 if (!$this->getCreationMode() &&
58 $this->getAccessHandler()->checkAccess("read", "", $this->node_id)) {
59 $link = $this->ctrl->getLinkTarget($this, "view");
60 $ilNavigationHistory->addItem($this->node_id, $link, "prtt");
61 }
62
63 $next_class = $this->ctrl->getNextClass($this);
64 $cmd = $this->ctrl->getCmd("view");
65
66 switch ($next_class) {
67 case 'ilportfoliotemplatepagegui':
68 $this->determinePageCall(); // has to be done before locator!
69 $this->prepareOutput();
70 $this->handlePageCall($cmd);
71 break;
72
73 case "ilnotegui":
74 $this->preview();
75 break;
76
77 case "ilinfoscreengui":
78 $this->prepareOutput();
79 $this->addHeaderAction("view");
80 $this->infoScreenForward();
81 break;
82
83 case "ilcommonactiondispatchergui":
85 $this->prepareOutput();
86 $this->ctrl->forwardCommand($gui);
87 break;
88
89 case "ilpermissiongui":
90 $this->prepareOutput();
91 $this->tabs_gui->activateTab("id_permissions");
92 $perm_gui = new ilPermissionGUI($this);
93 $this->ctrl->forwardCommand($perm_gui);
94 break;
95
96 case "ilobjectcopygui":
97 $this->prepareOutput();
98 $cp = new ilObjectCopyGUI($this);
99 $cp->setType("prtt");
100 $this->ctrl->forwardCommand($cp);
101 break;
102
103 case 'ilexportgui':
104 $this->prepareOutput();
105 $this->tabs_gui->activateTab("export");
106 $exp_gui = new ilExportGUI($this);
107 $exp_gui->addFormat("xml");
108 $this->ctrl->forwardCommand($exp_gui);
109 break;
110
111 case "ilobjstylesheetgui":
112 $this->ctrl->setReturn($this, "editStyleProperties");
113 $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
114 $style_gui->omitLocator();
115 if ($cmd == "create" || $_GET["new_type"] == "sty") {
116 $style_gui->setCreationMode(true);
117 }
118
119 if ($cmd == "confirmedDelete") {
120 $this->object->setStyleSheetId(0);
121 $this->object->update();
122 }
123
124 $ret = $this->ctrl->forwardCommand($style_gui);
125
126 if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle") {
127 $style_id = $ret;
128 $this->object->setStyleSheetId($style_id);
129 $this->object->update();
130 $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
131 }
132 break;
133
134 default:
135 $this->addHeaderAction($cmd);
137 }
138 }
139
140 protected function setTabs()
141 {
142 $ilHelp = $this->help;
143
144 $ilHelp->setScreenIdComponent("prtt");
145
146 if ($this->checkPermissionBool("write")) {
147 $this->tabs_gui->addTab(
148 "pages",
149 $this->lng->txt("content"),
150 $this->ctrl->getLinkTarget($this, "view")
151 );
152 }
153
154 if ($this->checkPermissionBool("read")) {
155 $this->tabs_gui->addTab(
156 "id_info",
157 $this->lng->txt("info_short"),
158 $this->ctrl->getLinkTargetByClass(array("ilobjportfoliotemplategui", "ilinfoscreengui"), "showSummary")
159 );
160 }
161
162 if ($this->checkPermissionBool("write")) {
163 $this->tabs_gui->addTab(
164 "settings",
165 $this->lng->txt("settings"),
166 $this->ctrl->getLinkTarget($this, "edit")
167 );
168
169 $this->tabs_gui->addTab(
170 "export",
171 $this->lng->txt("export"),
172 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
173 );
174 }
175
176 if ($this->checkPermissionBool("read")) {
177 $this->tabs_gui->addNonTabbedLink(
178 "preview",
179 $this->lng->txt("preview"),
180 $this->ctrl->getLinkTarget($this, "preview")
181 );
182 }
183
184 // will add permissions if needed
186 }
187
193 public function infoScreen()
194 {
195 $this->ctrl->setCmd("showSummary");
196 $this->ctrl->setCmdClass("ilinfoscreengui");
197 $this->infoScreenForward();
198 }
199
203 public function infoScreenForward()
204 {
205 $ilTabs = $this->tabs;
206 $ilToolbar = $this->toolbar;
207
208 $ilTabs->activateTab("id_info");
209
210 $this->checkPermission("visible");
211
212 if ($this->checkPermissionBool("read")) {
213 $this->lng->loadLanguageModule("cntr");
214
215 $button = ilLinkButton::getInstance();
216 $button->setPrimary(true);
217 $button->setCaption("prtf_create_portfolio_from_template");
218 $button->setUrl($this->ctrl->getLinkTarget($this, "createfromtemplate"));
219 $ilToolbar->addButtonInstance($button);
220 }
221
222 $info = new ilInfoScreenGUI($this);
223
224 $info->enablePrivateNotes();
225
226 if ($this->checkPermissionBool("read")) {
227 $info->enableNews();
228 }
229
230 // no news editing for files, just notifications
231 $info->enableNewsEditing(false);
232 if ($this->checkPermissionBool("write")) {
233 $news_set = new ilSetting("news");
234 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
235
236 if ($enable_internal_rss) {
237 $info->setBlockProperty("news", "settings", true);
238 $info->setBlockProperty("news", "public_notifications_option", true);
239 }
240 }
241
242 // standard meta data
243 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
244
245 $this->ctrl->forwardCommand($info);
246 }
247
248
249 //
250 // CREATE/EDIT
251 //
252
253 protected function initDidacticTemplate(ilPropertyFormGUI $a_form)
254 {
256
258 if (sizeof($all)) {
259 $opts = array("" => $this->lng->txt("please_select"));
260 foreach ($all as $item) {
261 $opts[$item["id"]] = $item["title"];
262 }
263 $prtf = new ilSelectInputGUI($this->lng->txt("prtf_create_template_from_portfolio"), "prtf");
264 $prtf->setInfo($this->lng->txt("prtf_create_template_from_portfolio_info"));
265 $prtf->setOptions($opts);
266 $a_form->addItem($prtf);
267 }
268
269 // yeah, I know.
270 return $a_form;
271 }
272
273 protected function afterSave(ilObject $a_new_object)
274 {
275 if ($_POST["prtf"]) {
276 $source = new ilObjPortfolio($_POST["prtf"], false);
277
279 }
280
281 ilUtil::sendSuccess($this->lng->txt("prtt_portfolio_created"), true);
282 $this->ctrl->setParameter($this, "prt_id", $a_new_object->getId());
283 $this->ctrl->redirect($this, "view");
284 }
285
286 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
287 {
288 $obj_service = $this->object_service;
289 // activation/availability
290
291 $this->lng->loadLanguageModule('rep');
292
294 $section->setTitle($this->lng->txt('rep_activation_availability'));
295 $a_form->addItem($section);
296
297 // additional info only with multiple references
298 $act_obj_info = $act_ref_info = "";
299 if (sizeof(ilObject::_getAllReferences($this->object->getId())) > 1) {
300 $act_obj_info = ' ' . $this->lng->txt('rep_activation_online_object_info');
301 $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
302 }
303
304 $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'online');
305 $online->setInfo($this->lng->txt('prtt_activation_online_info') . $act_obj_info);
306 $a_form->addItem($online);
307
308 $dur = new ilDateDurationInputGUI($this->lng->txt("rep_visibility_until"), "access_period");
309 $dur->setShowTime(true);
310 $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
311 $a_form->addItem($dur);
312
313 $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'access_visiblity');
314 $visible->setInfo($this->lng->txt('prtt_activation_limited_visibility_info'));
315 $dur->addSubItem($visible);
316
318 $section->setTitle($this->lng->txt('obj_presentation'));
319 $a_form->addItem($section);
320
321 // tile image
322 $obj_service->commonSettings()->legacyForm($a_form, $this->object)->addTileImage();
323
324
325 parent::initEditCustomForm($a_form);
326
327 $tit = $a_form->getItemByPostVar("title");
328 $tit->setInfo($this->lng->txt('prtt_title_info'));
329 }
330
331 protected function getEditFormCustomValues(array &$a_values)
332 {
333 $a_values["online"] = $this->object->isOnline();
334 $a_values["access_period"]["start"] = $this->object->getActivationStartDate()
335 ? new ilDateTime($this->object->getActivationStartDate(), IL_CAL_UNIX)
336 : null;
337 $a_values["access_period"]["end"] = $this->object->getActivationEndDate()
338 ? new ilDateTime($this->object->getActivationEndDate(), IL_CAL_UNIX)
339 : null;
340 $a_values["access_visiblity"] = $this->object->getActivationVisibility();
341
342 parent::getEditFormCustomValues($a_values);
343 }
344
345 public function updateCustom(ilPropertyFormGUI $a_form)
346 {
347 $obj_service = $this->object_service;
348
349 $this->object->setOnline($a_form->getInput("online"));
350
351 // activation
352 $period = $a_form->getItemByPostVar("access_period");
353 if ($period->getStart() && $period->getEnd()) {
354 $this->object->setActivationLimited(true);
355 $this->object->setActivationVisibility($a_form->getInput("access_visiblity"));
356 $this->object->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
357 $this->object->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
358 } else {
359 $this->object->setActivationLimited(false);
360 }
361
362 parent::updateCustom($a_form);
363
364 $obj_service->commonSettings()->legacyForm($a_form, $this->object)->saveTileImage();
365 }
366
367
368 //
369 // PAGES
370 //
371
379 protected function getPageInstance($a_page_id = null, $a_portfolio_id = null)
380 {
381 if (!$a_portfolio_id && $this->object) {
382 $a_portfolio_id = $this->object->getId();
383 }
384 $page = new ilPortfolioTemplatePage($a_page_id);
385 $page->setPortfolioId($a_portfolio_id);
386 return $page;
387 }
388
395 protected function getPageGUIInstance($a_page_id)
396 {
397 $page_gui = new ilPortfolioTemplatePageGUI(
398 $this->object->getId(),
399 $a_page_id,
400 0,
401 $this->object->hasPublicComments()
402 );
403 $page_gui->setAdditional($this->getAdditional());
404 return $page_gui;
405 }
406
407 public function getPageGUIClassName()
408 {
409 return "ilportfoliotemplatepagegui";
410 }
411
412 protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form)
413 {
414 // always existing prtft
415 $hi = new ilHiddenInputGUI("target");
416 $hi->setValue("old");
417 $a_form->addItem($hi);
418
419 $options = array();
421 foreach ($all as $id => $title) {
422 $options[$id] = $title;
423 }
424 $prtf = new ilSelectInputGUI($this->lng->txt("obj_prtt"), "prtf");
425 $prtf->setRequired(true);
426 $prtf->setOptions($options);
427 $a_form->addItem($prtf);
428 }
429
430
431 //
432 // BLOG
433 //
434
441 public function initBlogForm()
442 {
443 $form = new ilPropertyFormGUI();
444 $form->setFormAction($this->ctrl->getFormAction($this));
445
446 $obj = new ilTextInputGUI($this->lng->txt("title"), "blog");
447 $obj->setRequired(true);
448 $form->addItem($obj);
449
450 // save and cancel commands
451 $form->setTitle($this->lng->txt("prtf_add_blog") . ": " .
452 $this->object->getTitle());
453 $form->addCommandButton("saveBlog", $this->lng->txt("save"));
454 $form->addCommandButton("view", $this->lng->txt("cancel"));
455
456 return $form;
457 }
458
462 public function saveBlog()
463 {
464 $form = $this->initBlogForm();
465 if ($form->checkInput() && $this->checkPermissionBool("write")) {
466 $page = $this->getPageInstance();
468 $page->setTitle($form->getInput("blog"));
469 $page->create();
470
471 ilUtil::sendSuccess($this->lng->txt("prtf_blog_page_created"), true);
472 $this->ctrl->redirect($this, "view");
473 }
474
475 $this->tabs_gui->clearTargets();
476 $this->tabs_gui->setBackTarget(
477 $this->lng->txt("back"),
478 $this->ctrl->getLinkTarget($this, "view")
479 );
480
481 $form->setValuesByPost();
482 $this->tpl->setContent($form->getHtml());
483 }
484
485
486 //
487 // TRANSMOGRIFIER
488 //
489
490 public function preview($a_return = false, $a_content = false, $a_show_notes = true)
491 {
492 if (!$this->checkPermissionBool("write") &&
493 $this->checkPermissionBool("read")) {
494 $this->lng->loadLanguageModule("cntr");
495
496 $button = ilLinkButton::getInstance();
497 $button->setPrimary(true);
498 $button->setCaption("prtf_create_portfolio_from_template");
499 $button->setUrl($this->ctrl->getLinkTarget($this, "createfromtemplate"));
500 $this->tpl->setHeaderActionMenu($button->render());
501 }
502
503 return parent::preview($a_return, $a_content, $a_show_notes);
504 }
505
506 public function createFromTemplateOld()
507 {
508 $this->ctrl->setParameterByClass("ilobjportfoliogui", "prtt_pre", $this->object->getId());
509 $this->ctrl->redirectByClass(array("ilDashboardGUI", "ilportfoliorepositorygui", "ilobjportfoliogui"), "create");
510 }
511
512 public function createFromTemplate()
513 {
514 $this->ctrl->setParameterByClass("ilobjportfoliogui", "prtt_pre", $this->object->getId());
515 $this->ctrl->redirectByClass(array("ilDashboardGUI", "ilportfoliorepositorygui", "ilobjportfoliogui"), "createFromTemplateDirect");
516 }
517
518 public static function _goto($a_target)
519 {
521 global $DIC;
522
523 $access = $DIC->access();
524 $ctrl = $DIC->ctrl();
525
526 $id = explode("_", $a_target);
527 $ref_id = $id[0];
528
529 $ctrl->setParameterByClass("ilRepositoryGUI", "ref_id", $ref_id);
530 if ($access->checkAccess("read", "", $ref_id)) {
531 $ctrl->redirectByClass("ilRepositoryGUI", "preview");
532 } else {
533 $ctrl->redirectByClass("ilRepositoryGUI", "infoScreen");
534 }
535 }
536}
user()
Definition: user.php:4
$section
Definition: Utf8Test.php:83
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
This class represents a checkbox property in a property form.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
input GUI for a time span (start and end date)
@classDescription Date and time handling
Export User Interface Class.
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
Class ilInfoScreenGUI.
static getInstance()
Factory.
Portfolio view gui base class.
getAdditional()
Get Additonal Information.
static clonePagesAndSettings(ilObjPortfolioBase $a_source, ilObjPortfolioBase $a_target, array $a_recipe=null, $copy_all=false)
Build template from portfolio and vice versa.
Portfolio template view gui class.
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
saveBlog()
Create new portfolio blog template page.
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
getPageGUIInstance($a_page_id)
Get portfolio template page gui instance.
getType()
Functions that must be overwritten.
initDidacticTemplate(ilPropertyFormGUI $a_form)
Show didactic template types.
setTabs()
create tabs (repository/workspace switch)
preview($a_return=false, $a_content=false, $a_show_notes=true)
Show user page.
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
getPageInstance($a_page_id=null, $a_portfolio_id=null)
Get portfolio template page instance.
initCopyPageFormOptions(ilPropertyFormGUI $a_form)
initBlogForm()
Init blog template page form.
static getAvailablePortfolioTemplates($a_permission="read")
static getPortfoliosOfUser($a_user_id)
Get views of user.
Class ilObjStyleSheetGUI.
executeCommand()
execute command
setTabs()
create tabs (repository/workspace switch)
getAccessHandler()
Get access handler.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
getCreationMode()
get creation mode
GUI class for the workflow of copying objects.
addHeaderAction()
Add header action menu.
Class ilObject Basic functions for all objects.
static _getAllReferences($a_id)
get all reference ids of object
getId()
get object id @access public
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
Portfolio template page gui class.
Page for portfolio template.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
getItemByPostVar($a_post_var)
Get Item by POST variable.
This class represents a selection list property in a property form.
ILIAS Setting Class.
This class represents a text property in a property form.
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
$ilUser
Definition: imgupload.php:18
$source
Definition: metadata.php:76
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6