ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjPortfolioTemplateGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once('./Modules/Portfolio/classes/class.ilObjPortfolioBaseGUI.php');
5
19{
23 protected $nav_history;
24
28 protected $help;
29
33 protected $tabs;
34
35
39 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $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()
52 {
53 return "prtt";
54 }
55
56 public function executeCommand()
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
70 switch ($next_class) {
71 case 'ilportfoliotemplatepagegui':
72 $this->determinePageCall(); // has to be done before locator!
73 $this->prepareOutput();
74 $this->handlePageCall($cmd);
75 break;
76
77 case "ilnotegui":
78 $this->preview();
79 break;
80
81 case "ilinfoscreengui":
82 $this->prepareOutput();
83 $this->addHeaderAction("view");
84 $this->infoScreenForward();
85 break;
86
87 case "ilcommonactiondispatchergui":
88 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
90 $this->ctrl->forwardCommand($gui);
91 break;
92
93 case "ilpermissiongui":
94 $this->prepareOutput();
95 $this->tabs_gui->activateTab("id_permissions");
96 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
97 $perm_gui = new ilPermissionGUI($this);
98 $this->ctrl->forwardCommand($perm_gui);
99 break;
100
101 case "ilobjectcopygui":
102 $this->prepareOutput();
103 include_once "./Services/Object/classes/class.ilObjectCopyGUI.php";
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 include_once("./Services/Export/classes/class.ilExportGUI.php");
113 $exp_gui = new ilExportGUI($this);
114 $exp_gui->addFormat("xml");
115 $this->ctrl->forwardCommand($exp_gui);
116 break;
117
118 case "ilobjstylesheetgui":
119 include_once("./Services/Style/Content/classes/class.ilObjStyleSheetGUI.php");
120 $this->ctrl->setReturn($this, "editStyleProperties");
121 $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
122 $style_gui->omitLocator();
123 if ($cmd == "create" || $_GET["new_type"] == "sty") {
124 $style_gui->setCreationMode(true);
125 }
126
127 if ($cmd == "confirmedDelete") {
128 $this->object->setStyleSheetId(0);
129 $this->object->update();
130 }
131
132 $ret = $this->ctrl->forwardCommand($style_gui);
133
134 if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle") {
135 $style_id = $ret;
136 $this->object->setStyleSheetId($style_id);
137 $this->object->update();
138 $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
139 }
140 break;
141
142 default:
143 $this->addHeaderAction($cmd);
145 }
146 }
147
148 protected function setTabs()
149 {
150 $ilHelp = $this->help;
151
152 $ilHelp->setScreenIdComponent("prtt");
153
154 if ($this->checkPermissionBool("write")) {
155 $this->tabs_gui->addTab(
156 "pages",
157 $this->lng->txt("content"),
158 $this->ctrl->getLinkTarget($this, "view")
159 );
160 }
161
162 if ($this->checkPermissionBool("read")) {
163 $this->tabs_gui->addTab(
164 "id_info",
165 $this->lng->txt("info_short"),
166 $this->ctrl->getLinkTargetByClass(array("ilobjportfoliotemplategui", "ilinfoscreengui"), "showSummary")
167 );
168 }
169
170 if ($this->checkPermissionBool("write")) {
171 $this->tabs_gui->addTab(
172 "settings",
173 $this->lng->txt("settings"),
174 $this->ctrl->getLinkTarget($this, "edit")
175 );
176
177 $this->tabs_gui->addTab(
178 "export",
179 $this->lng->txt("export"),
180 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
181 );
182 }
183
184 if ($this->checkPermissionBool("read")) {
185 $this->tabs_gui->addNonTabbedLink(
186 "preview",
187 $this->lng->txt("user_profile_preview"),
188 $this->ctrl->getLinkTarget($this, "preview")
189 );
190 }
191
192 // will add permissions if needed
194 }
195
201 public function infoScreen()
202 {
203 $this->ctrl->setCmd("showSummary");
204 $this->ctrl->setCmdClass("ilinfoscreengui");
205 $this->infoScreenForward();
206 }
207
211 public function infoScreenForward()
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 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
224 $button = ilLinkButton::getInstance();
225 $button->setPrimary(true);
226 $button->setCaption("prtf_create_portfolio_from_template");
227 $button->setUrl($this->ctrl->getLinkTarget($this, "createfromtemplate"));
228 $ilToolbar->addButtonInstance($button);
229 }
230
231 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
232 $info = new ilInfoScreenGUI($this);
233
234 $info->enablePrivateNotes();
235
236 if ($this->checkPermissionBool("read")) {
237 $info->enableNews();
238 }
239
240 // no news editing for files, just notifications
241 $info->enableNewsEditing(false);
242 if ($this->checkPermissionBool("write")) {
243 $news_set = new ilSetting("news");
244 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
245
246 if ($enable_internal_rss) {
247 $info->setBlockProperty("news", "settings", true);
248 $info->setBlockProperty("news", "public_notifications_option", true);
249 }
250 }
251
252 // standard meta data
253 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
254
255 $this->ctrl->forwardCommand($info);
256 }
257
258
259 //
260 // CREATE/EDIT
261 //
262
263 protected function initDidacticTemplate(ilPropertyFormGUI $a_form)
264 {
266
267 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
269 if (sizeof($all)) {
270 $opts = array("" => $this->lng->txt("please_select"));
271 foreach ($all as $item) {
272 $opts[$item["id"]] = $item["title"];
273 }
274 $prtf = new ilSelectInputGUI($this->lng->txt("prtf_create_template_from_portfolio"), "prtf");
275 $prtf->setInfo($this->lng->txt("prtf_create_template_from_portfolio_info"));
276 $prtf->setOptions($opts);
277 $a_form->addItem($prtf);
278 }
279
280 // yeah, I know.
281 return $a_form;
282 }
283
284 protected function afterSave(ilObject $a_new_object)
285 {
286 if ($_POST["prtf"]) {
287 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
288 $source = new ilObjPortfolio($_POST["prtf"], false);
289
291 }
292
293 ilUtil::sendSuccess($this->lng->txt("prtt_portfolio_created"), true);
294 $this->ctrl->setParameter($this, "prt_id", $a_new_object->getId());
295 $this->ctrl->redirect($this, "view");
296 }
297
298 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
299 {
300 $obj_service = $this->object_service;
301 // activation/availability
302
303 include_once "Services/Object/classes/class.ilObjectActivation.php";
304 $this->lng->loadLanguageModule('rep');
305
307 $section->setTitle($this->lng->txt('rep_activation_availability'));
308 $a_form->addItem($section);
309
310 // additional info only with multiple references
311 $act_obj_info = $act_ref_info = "";
312 if (sizeof(ilObject::_getAllReferences($this->object->getId())) > 1) {
313 $act_obj_info = ' ' . $this->lng->txt('rep_activation_online_object_info');
314 $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
315 }
316
317 $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'online');
318 $online->setInfo($this->lng->txt('prtt_activation_online_info') . $act_obj_info);
319 $a_form->addItem($online);
320
321 include_once "Services/Form/classes/class.ilDateDurationInputGUI.php";
322 $dur = new ilDateDurationInputGUI($this->lng->txt("rep_visibility_until"), "access_period");
323 $dur->setShowTime(true);
324 $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
325 $a_form->addItem($dur);
326
327 $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'access_visiblity');
328 $visible->setInfo($this->lng->txt('prtt_activation_limited_visibility_info'));
329 $dur->addSubItem($visible);
330
332 $section->setTitle($this->lng->txt('obj_presentation'));
333 $a_form->addItem($section);
334
335 // tile image
336 $obj_service->commonSettings()->legacyForm($a_form, $this->object)->addTileImage();
337
338
339 parent::initEditCustomForm($a_form);
340
341 $tit = $a_form->getItemByPostVar("title");
342 $tit->setInfo($this->lng->txt('prtt_title_info'));
343 }
344
345 protected function getEditFormCustomValues(array &$a_values)
346 {
347 $a_values["online"] = $this->object->isOnline();
348 $a_values["access_period"]["start"] = $this->object->getActivationStartDate()
349 ? new ilDateTime($this->object->getActivationStartDate(), IL_CAL_UNIX)
350 : null;
351 $a_values["access_period"]["end"] = $this->object->getActivationEndDate()
352 ? new ilDateTime($this->object->getActivationEndDate(), IL_CAL_UNIX)
353 : null;
354 $a_values["access_visiblity"] = $this->object->getActivationVisibility();
355
356 parent::getEditFormCustomValues($a_values);
357 }
358
359 public function updateCustom(ilPropertyFormGUI $a_form)
360 {
361 $obj_service = $this->object_service;
362
363 $this->object->setOnline($a_form->getInput("online"));
364
365 // activation
366 $period = $a_form->getItemByPostVar("access_period");
367 if ($period->getStart() && $period->getEnd()) {
368 $this->object->setActivationLimited(true);
369 $this->object->setActivationVisibility($a_form->getInput("access_visiblity"));
370 $this->object->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
371 $this->object->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
372 } else {
373 $this->object->setActivationLimited(false);
374 }
375
376 parent::updateCustom($a_form);
377
378 $obj_service->commonSettings()->legacyForm($a_form, $this->object)->saveTileImage();
379 }
380
381
382 //
383 // PAGES
384 //
385
393 protected function getPageInstance($a_page_id = null, $a_portfolio_id = null)
394 {
395 if (!$a_portfolio_id && $this->object) {
396 $a_portfolio_id = $this->object->getId();
397 }
398 include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
399 $page = new ilPortfolioTemplatePage($a_page_id);
400 $page->setPortfolioId($a_portfolio_id);
401 return $page;
402 }
403
410 protected function getPageGUIInstance($a_page_id)
411 {
412 include_once("Modules/Portfolio/classes/class.ilPortfolioTemplatePageGUI.php");
413 $page_gui = new ilPortfolioTemplatePageGUI(
414 $this->object->getId(),
415 $a_page_id,
416 0,
417 $this->object->hasPublicComments()
418 );
419 $page_gui->setAdditional($this->getAdditional());
420 return $page_gui;
421 }
422
423 public function getPageGUIClassName()
424 {
425 return "ilportfoliotemplatepagegui";
426 }
427
428 protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form)
429 {
430 // always existing prtft
431 $hi = new ilHiddenInputGUI("target");
432 $hi->setValue("old");
433 $a_form->addItem($hi);
434
435 $options = array();
437 foreach ($all as $id => $title) {
439 }
440 $prtf = new ilSelectInputGUI($this->lng->txt("obj_prtt"), "prtf");
441 $prtf->setRequired(true);
442 $prtf->setOptions($options);
443 $a_form->addItem($prtf);
444 }
445
446
447 //
448 // BLOG
449 //
450
457 public function initBlogForm()
458 {
459 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
460 $form = new ilPropertyFormGUI();
461 $form->setFormAction($this->ctrl->getFormAction($this));
462
463 $obj = new ilTextInputGUI($this->lng->txt("title"), "blog");
464 $obj->setRequired(true);
465 $form->addItem($obj);
466
467 // save and cancel commands
468 $form->setTitle($this->lng->txt("prtf_add_blog") . ": " .
469 $this->object->getTitle());
470 $form->addCommandButton("saveBlog", $this->lng->txt("save"));
471 $form->addCommandButton("view", $this->lng->txt("cancel"));
472
473 return $form;
474 }
475
479 public function saveBlog()
480 {
481 $form = $this->initBlogForm();
482 if ($form->checkInput() && $this->checkPermissionBool("write")) {
483 $page = $this->getPageInstance();
485 $page->setTitle($form->getInput("blog"));
486 $page->create();
487
488 ilUtil::sendSuccess($this->lng->txt("prtf_blog_page_created"), true);
489 $this->ctrl->redirect($this, "view");
490 }
491
492 $this->tabs_gui->clearTargets();
493 $this->tabs_gui->setBackTarget(
494 $this->lng->txt("back"),
495 $this->ctrl->getLinkTarget($this, "view")
496 );
497
498 $form->setValuesByPost();
499 $this->tpl->setContent($form->getHtml());
500 }
501
502
503 //
504 // TRANSMOGRIFIER
505 //
506
507 public function preview($a_return = false, $a_content = false, $a_show_notes = true)
508 {
509 if (!$this->checkPermissionBool("write") &&
510 $this->checkPermissionBool("read")) {
511 $this->lng->loadLanguageModule("cntr");
512
513 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
514 $button = ilLinkButton::getInstance();
515 $button->setPrimary(true);
516 $button->setCaption("prtf_create_portfolio_from_template");
517 $button->setUrl($this->ctrl->getLinkTarget($this, "createfromtemplate"));
518 $this->tpl->setHeaderActionMenu($button->render());
519 }
520
521 return parent::preview($a_return, $a_content, $a_show_notes);
522 }
523
524 public function createFromTemplateOld()
525 {
526 $this->ctrl->setParameterByClass("ilobjportfoliogui", "prtt_pre", $this->object->getId());
527 $this->ctrl->redirectByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui", "ilobjportfoliogui"), "create");
528 }
529
530 public function createFromTemplate()
531 {
532 $this->ctrl->setParameterByClass("ilobjportfoliogui", "prtt_pre", $this->object->getId());
533 $this->ctrl->redirectByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui", "ilobjportfoliogui"), "createFromTemplateDirect");
534 }
535
536 public static function _goto($a_target)
537 {
538 $id = explode("_", $a_target);
539
540 $_GET["baseClass"] = "ilRepositoryGUI";
541 $_GET["ref_id"] = $id[0];
542 $_GET["cmd"] = "preview";
543
544 include("ilias.php");
545 exit;
546 }
547}
user()
Definition: user.php:4
$section
Definition: Utf8Test.php:83
$source
Definition: linkback.php:22
exit
Definition: backend.php:16
$_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.
if(!array_key_exists('StateId', $_REQUEST)) $id
$info
Definition: index.php:5
$ret
Definition: parser.php:6
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$a_content
Definition: workflow.php:93