ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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->ctrl->forwardCommand($gui);
86 break;
87
88 case "ilpermissiongui":
89 $this->prepareOutput();
90 $this->tabs_gui->activateTab("id_permissions");
91 $perm_gui = new ilPermissionGUI($this);
92 $this->ctrl->forwardCommand($perm_gui);
93 break;
94
95 case "ilobjectcopygui":
96 $this->prepareOutput();
97 $cp = new ilObjectCopyGUI($this);
98 $cp->setType("prtt");
99 $this->ctrl->forwardCommand($cp);
100 break;
101
102 case 'ilexportgui':
103 $this->prepareOutput();
104 $this->tabs_gui->activateTab("export");
105 $exp_gui = new ilExportGUI($this);
106 $exp_gui->addFormat("xml");
107 $this->ctrl->forwardCommand($exp_gui);
108 break;
109
110 case "ilobjstylesheetgui":
111 $this->ctrl->setReturn($this, "editStyleProperties");
112 $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
113 $style_gui->omitLocator();
114 if ($cmd == "create" || $_GET["new_type"] == "sty") {
115 $style_gui->setCreationMode(true);
116 }
117
118 if ($cmd == "confirmedDelete") {
119 $this->object->setStyleSheetId(0);
120 $this->object->update();
121 }
122
123 $ret = $this->ctrl->forwardCommand($style_gui);
124
125 if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle") {
126 $style_id = $ret;
127 $this->object->setStyleSheetId($style_id);
128 $this->object->update();
129 $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
130 }
131 break;
132
133 default:
134 $this->addHeaderAction($cmd);
136 }
137 }
138
139 protected function setTabs()
140 {
141 $ilHelp = $this->help;
142
143 $ilHelp->setScreenIdComponent("prtt");
144
145 if ($this->checkPermissionBool("write")) {
146 $this->tabs_gui->addTab(
147 "pages",
148 $this->lng->txt("content"),
149 $this->ctrl->getLinkTarget($this, "view")
150 );
151 }
152
153 if ($this->checkPermissionBool("read")) {
154 $this->tabs_gui->addTab(
155 "id_info",
156 $this->lng->txt("info_short"),
157 $this->ctrl->getLinkTargetByClass(array("ilobjportfoliotemplategui", "ilinfoscreengui"), "showSummary")
158 );
159 }
160
161 if ($this->checkPermissionBool("write")) {
162 $this->tabs_gui->addTab(
163 "settings",
164 $this->lng->txt("settings"),
165 $this->ctrl->getLinkTarget($this, "edit")
166 );
167
168 $this->tabs_gui->addTab(
169 "export",
170 $this->lng->txt("export"),
171 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
172 );
173 }
174
175 if ($this->checkPermissionBool("read")) {
176 $this->tabs_gui->addNonTabbedLink(
177 "preview",
178 $this->lng->txt("user_profile_preview"),
179 $this->ctrl->getLinkTarget($this, "preview")
180 );
181 }
182
183 // will add permissions if needed
185 }
186
192 public function infoScreen()
193 {
194 $this->ctrl->setCmd("showSummary");
195 $this->ctrl->setCmdClass("ilinfoscreengui");
196 $this->infoScreenForward();
197 }
198
202 public function infoScreenForward()
203 {
204 $ilTabs = $this->tabs;
205 $ilToolbar = $this->toolbar;
206
207 $ilTabs->activateTab("id_info");
208
209 $this->checkPermission("visible");
210
211 if ($this->checkPermissionBool("read")) {
212 $this->lng->loadLanguageModule("cntr");
213
214 $button = ilLinkButton::getInstance();
215 $button->setPrimary(true);
216 $button->setCaption("prtf_create_portfolio_from_template");
217 $button->setUrl($this->ctrl->getLinkTarget($this, "createfromtemplate"));
218 $ilToolbar->addButtonInstance($button);
219 }
220
221 $info = new ilInfoScreenGUI($this);
222
223 $info->enablePrivateNotes();
224
225 if ($this->checkPermissionBool("read")) {
226 $info->enableNews();
227 }
228
229 // no news editing for files, just notifications
230 $info->enableNewsEditing(false);
231 if ($this->checkPermissionBool("write")) {
232 $news_set = new ilSetting("news");
233 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
234
235 if ($enable_internal_rss) {
236 $info->setBlockProperty("news", "settings", true);
237 $info->setBlockProperty("news", "public_notifications_option", true);
238 }
239 }
240
241 // standard meta data
242 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
243
244 $this->ctrl->forwardCommand($info);
245 }
246
247
248 //
249 // CREATE/EDIT
250 //
251
252 protected function initDidacticTemplate(ilPropertyFormGUI $a_form)
253 {
255
257 if (sizeof($all)) {
258 $opts = array("" => $this->lng->txt("please_select"));
259 foreach ($all as $item) {
260 $opts[$item["id"]] = $item["title"];
261 }
262 $prtf = new ilSelectInputGUI($this->lng->txt("prtf_create_template_from_portfolio"), "prtf");
263 $prtf->setInfo($this->lng->txt("prtf_create_template_from_portfolio_info"));
264 $prtf->setOptions($opts);
265 $a_form->addItem($prtf);
266 }
267
268 // yeah, I know.
269 return $a_form;
270 }
271
272 protected function afterSave(ilObject $a_new_object)
273 {
274 if ($_POST["prtf"]) {
275 $source = new ilObjPortfolio($_POST["prtf"], false);
276
278 }
279
280 ilUtil::sendSuccess($this->lng->txt("prtt_portfolio_created"), true);
281 $this->ctrl->setParameter($this, "prt_id", $a_new_object->getId());
282 $this->ctrl->redirect($this, "view");
283 }
284
285 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
286 {
287 $obj_service = $this->object_service;
288 // activation/availability
289
290 $this->lng->loadLanguageModule('rep');
291
293 $section->setTitle($this->lng->txt('rep_activation_availability'));
294 $a_form->addItem($section);
295
296 // additional info only with multiple references
297 $act_obj_info = $act_ref_info = "";
298 if (sizeof(ilObject::_getAllReferences($this->object->getId())) > 1) {
299 $act_obj_info = ' ' . $this->lng->txt('rep_activation_online_object_info');
300 $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
301 }
302
303 $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'online');
304 $online->setInfo($this->lng->txt('prtt_activation_online_info') . $act_obj_info);
305 $a_form->addItem($online);
306
307 $dur = new ilDateDurationInputGUI($this->lng->txt("rep_visibility_until"), "access_period");
308 $dur->setShowTime(true);
309 $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
310 $a_form->addItem($dur);
311
312 $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'access_visiblity');
313 $visible->setInfo($this->lng->txt('prtt_activation_limited_visibility_info'));
314 $dur->addSubItem($visible);
315
317 $section->setTitle($this->lng->txt('obj_presentation'));
318 $a_form->addItem($section);
319
320 // tile image
321 $obj_service->commonSettings()->legacyForm($a_form, $this->object)->addTileImage();
322
323
324 parent::initEditCustomForm($a_form);
325
326 $tit = $a_form->getItemByPostVar("title");
327 $tit->setInfo($this->lng->txt('prtt_title_info'));
328 }
329
330 protected function getEditFormCustomValues(array &$a_values)
331 {
332 $a_values["online"] = $this->object->isOnline();
333 $a_values["access_period"]["start"] = $this->object->getActivationStartDate()
334 ? new ilDateTime($this->object->getActivationStartDate(), IL_CAL_UNIX)
335 : null;
336 $a_values["access_period"]["end"] = $this->object->getActivationEndDate()
337 ? new ilDateTime($this->object->getActivationEndDate(), IL_CAL_UNIX)
338 : null;
339 $a_values["access_visiblity"] = $this->object->getActivationVisibility();
340
341 parent::getEditFormCustomValues($a_values);
342 }
343
344 public function updateCustom(ilPropertyFormGUI $a_form)
345 {
346 $obj_service = $this->object_service;
347
348 $this->object->setOnline($a_form->getInput("online"));
349
350 // activation
351 $period = $a_form->getItemByPostVar("access_period");
352 if ($period->getStart() && $period->getEnd()) {
353 $this->object->setActivationLimited(true);
354 $this->object->setActivationVisibility($a_form->getInput("access_visiblity"));
355 $this->object->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
356 $this->object->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
357 } else {
358 $this->object->setActivationLimited(false);
359 }
360
361 parent::updateCustom($a_form);
362
363 $obj_service->commonSettings()->legacyForm($a_form, $this->object)->saveTileImage();
364 }
365
366
367 //
368 // PAGES
369 //
370
378 protected function getPageInstance($a_page_id = null, $a_portfolio_id = null)
379 {
380 if (!$a_portfolio_id && $this->object) {
381 $a_portfolio_id = $this->object->getId();
382 }
383 $page = new ilPortfolioTemplatePage($a_page_id);
384 $page->setPortfolioId($a_portfolio_id);
385 return $page;
386 }
387
394 protected function getPageGUIInstance($a_page_id)
395 {
396 $page_gui = new ilPortfolioTemplatePageGUI(
397 $this->object->getId(),
398 $a_page_id,
399 0,
400 $this->object->hasPublicComments()
401 );
402 $page_gui->setAdditional($this->getAdditional());
403 return $page_gui;
404 }
405
406 public function getPageGUIClassName()
407 {
408 return "ilportfoliotemplatepagegui";
409 }
410
411 protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form)
412 {
413 // always existing prtft
414 $hi = new ilHiddenInputGUI("target");
415 $hi->setValue("old");
416 $a_form->addItem($hi);
417
418 $options = array();
420 foreach ($all as $id => $title) {
421 $options[$id] = $title;
422 }
423 $prtf = new ilSelectInputGUI($this->lng->txt("obj_prtt"), "prtf");
424 $prtf->setRequired(true);
425 $prtf->setOptions($options);
426 $a_form->addItem($prtf);
427 }
428
429
430 //
431 // BLOG
432 //
433
440 public function initBlogForm()
441 {
442 $form = new ilPropertyFormGUI();
443 $form->setFormAction($this->ctrl->getFormAction($this));
444
445 $obj = new ilTextInputGUI($this->lng->txt("title"), "blog");
446 $obj->setRequired(true);
447 $form->addItem($obj);
448
449 // save and cancel commands
450 $form->setTitle($this->lng->txt("prtf_add_blog") . ": " .
451 $this->object->getTitle());
452 $form->addCommandButton("saveBlog", $this->lng->txt("save"));
453 $form->addCommandButton("view", $this->lng->txt("cancel"));
454
455 return $form;
456 }
457
461 public function saveBlog()
462 {
463 $form = $this->initBlogForm();
464 if ($form->checkInput() && $this->checkPermissionBool("write")) {
465 $page = $this->getPageInstance();
467 $page->setTitle($form->getInput("blog"));
468 $page->create();
469
470 ilUtil::sendSuccess($this->lng->txt("prtf_blog_page_created"), true);
471 $this->ctrl->redirect($this, "view");
472 }
473
474 $this->tabs_gui->clearTargets();
475 $this->tabs_gui->setBackTarget(
476 $this->lng->txt("back"),
477 $this->ctrl->getLinkTarget($this, "view")
478 );
479
480 $form->setValuesByPost();
481 $this->tpl->setContent($form->getHtml());
482 }
483
484
485 //
486 // TRANSMOGRIFIER
487 //
488
489 public function preview($a_return = false, $a_content = false, $a_show_notes = true)
490 {
491 if (!$this->checkPermissionBool("write") &&
492 $this->checkPermissionBool("read")) {
493 $this->lng->loadLanguageModule("cntr");
494
495 $button = ilLinkButton::getInstance();
496 $button->setPrimary(true);
497 $button->setCaption("prtf_create_portfolio_from_template");
498 $button->setUrl($this->ctrl->getLinkTarget($this, "createfromtemplate"));
499 $this->tpl->setHeaderActionMenu($button->render());
500 }
501
502 return parent::preview($a_return, $a_content, $a_show_notes);
503 }
504
505 public function createFromTemplateOld()
506 {
507 $this->ctrl->setParameterByClass("ilobjportfoliogui", "prtt_pre", $this->object->getId());
508 $this->ctrl->redirectByClass(array("ilDashboardGUI", "ilportfoliorepositorygui", "ilobjportfoliogui"), "create");
509 }
510
511 public function createFromTemplate()
512 {
513 $this->ctrl->setParameterByClass("ilobjportfoliogui", "prtt_pre", $this->object->getId());
514 $this->ctrl->redirectByClass(array("ilDashboardGUI", "ilportfoliorepositorygui", "ilobjportfoliogui"), "createFromTemplateDirect");
515 }
516
517 public static function _goto($a_target)
518 {
520 global $DIC;
521
522 $access = $DIC->access();
523 $ctrl = $DIC->ctrl();
524
525 $id = explode("_", $a_target);
526 $ref_id = $id[0];
527
528 $ctrl->setParameterByClass("ilRepositoryGUI", "ref_id", $ref_id);
529 if ($access->checkAccess("read", "", $ref_id)) {
530 $ctrl->redirectByClass("ilRepositoryGUI", "preview");
531 } else {
532 $ctrl->redirectByClass("ilRepositoryGUI", "infoScreen");
533 }
534 }
535}
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.
help()
Definition: help.php:2
$source
Definition: metadata.php:76
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$ilUser
Definition: imgupload.php:18
$a_content
Definition: workflow.php:93
$DIC
Definition: xapitoken.php:46