ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
20 public function getType()
21 {
22 return "prtt";
23 }
24
25 public function executeCommand()
26 {
27 global $ilNavigationHistory;
28
29 $this->tpl->getStandardTemplate();
30
31 // add entry to navigation history
32 if(!$this->getCreationMode() &&
33 $this->getAccessHandler()->checkAccess("read", "", $this->node_id))
34 {
35 $link = $this->ctrl->getLinkTarget($this, "view");
36 $ilNavigationHistory->addItem($this->node_id, $link, "prtt");
37 }
38
39 $next_class = $this->ctrl->getNextClass($this);
40 $cmd = $this->ctrl->getCmd("view");
41
42 switch($next_class)
43 {
44 case 'ilportfoliotemplatepagegui':
45 $this->determinePageCall(); // has to be done before locator!
46 $this->prepareOutput();
47 $this->handlePageCall($cmd);
48 break;
49
50 case "ilnotegui";
51 $this->preview();
52 break;
53
54 case "ilinfoscreengui":
55 $this->prepareOutput();
56 $this->addHeaderAction("view");
57 $this->infoScreenForward();
58 break;
59
60 case "ilcommonactiondispatchergui":
61 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
63 $this->ctrl->forwardCommand($gui);
64 break;
65
66 case "ilpermissiongui":
67 $this->prepareOutput();
68 $this->tabs_gui->activateTab("id_permissions");
69 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
70 $perm_gui = new ilPermissionGUI($this);
71 $this->ctrl->forwardCommand($perm_gui);
72 break;
73
74 case "ilobjectcopygui":
75 include_once "./Services/Object/classes/class.ilObjectCopyGUI.php";
76 $cp = new ilObjectCopyGUI($this);
77 $cp->setType("prtt");
78 $this->ctrl->forwardCommand($cp);
79 break;
80
81 case 'ilexportgui':
82 $this->prepareOutput();
83 $this->tabs_gui->activateTab("export");
84 include_once("./Services/Export/classes/class.ilExportGUI.php");
85 $exp_gui = new ilExportGUI($this);
86 $exp_gui->addFormat("xml");
87 $this->ctrl->forwardCommand($exp_gui);
88 break;
89
90 case "ilobjstylesheetgui":
91 include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
92 $this->ctrl->setReturn($this, "editStyleProperties");
93 $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
94 $style_gui->omitLocator();
95 if ($cmd == "create" || $_GET["new_type"]=="sty")
96 {
97 $style_gui->setCreationMode(true);
98 }
99
100 if ($cmd == "confirmedDelete")
101 {
102 $this->object->setStyleSheetId(0);
103 $this->object->update();
104 }
105
106 $ret = $this->ctrl->forwardCommand($style_gui);
107
108 if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
109 {
110 $style_id = $ret;
111 $this->object->setStyleSheetId($style_id);
112 $this->object->update();
113 $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
114 }
115 break;
116
117 default:
118 $this->addHeaderAction($cmd);
120 }
121 }
122
123 protected function setTabs()
124 {
125 global $ilHelp;
126
127 $ilHelp->setScreenIdComponent("prtt");
128
129 if($this->checkPermissionBool("write"))
130 {
131 $this->tabs_gui->addTab("pages",
132 $this->lng->txt("content"),
133 $this->ctrl->getLinkTarget($this, "view"));
134 }
135
136 if ($this->checkPermissionBool("read"))
137 {
138 $this->tabs_gui->addTab("id_info",
139 $this->lng->txt("info_short"),
140 $this->ctrl->getLinkTargetByClass(array("ilobjportfoliotemplategui", "ilinfoscreengui"), "showSummary"));
141 }
142
143 if($this->checkPermissionBool("write"))
144 {
145 $this->tabs_gui->addTab("settings",
146 $this->lng->txt("settings"),
147 $this->ctrl->getLinkTarget($this, "edit"));
148
149 $this->tabs_gui->addTab("export",
150 $this->lng->txt("export"),
151 $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
152 }
153
154 if ($this->checkPermissionBool("read"))
155 {
156 $this->tabs_gui->addNonTabbedLink("preview",
157 $this->lng->txt("user_profile_preview"),
158 $this->ctrl->getLinkTarget($this, "preview"));
159 }
160
161 // will add permissions if needed
163 }
164
170 function infoScreen()
171 {
172 $this->ctrl->setCmd("showSummary");
173 $this->ctrl->setCmdClass("ilinfoscreengui");
174 $this->infoScreenForward();
175 }
176
181 {
182 global $ilTabs, $ilErr, $ilToolbar;
183
184 $ilTabs->activateTab("id_info");
185
186 if (!$this->checkPermissionBool("visible"))
187 {
188 $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
189 }
190
191 if ($this->checkPermissionBool("read"))
192 {
193 $this->lng->loadLanguageModule("cntr");
194
195 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
196 $button = ilLinkButton::getInstance();
197 $button->setPrimary(true);
198 $button->setCaption("prtf_create_portfolio_from_template");
199 $button->setUrl($this->ctrl->getLinkTarget($this, "createfromtemplate"));
200 $ilToolbar->addButtonInstance($button);
201 }
202
203 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
204 $info = new ilInfoScreenGUI($this);
205
206 $info->enablePrivateNotes();
207
208 if ($this->checkPermissionBool("read"))
209 {
210 $info->enableNews();
211 }
212
213 // no news editing for files, just notifications
214 $info->enableNewsEditing(false);
215 if ($this->checkPermissionBool("write"))
216 {
217 $news_set = new ilSetting("news");
218 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
219
220 if ($enable_internal_rss)
221 {
222 $info->setBlockProperty("news", "settings", true);
223 $info->setBlockProperty("news", "public_notifications_option", true);
224 }
225 }
226
227 // standard meta data
228 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
229
230 $this->ctrl->forwardCommand($info);
231 }
232
233
234 //
235 // CREATE/EDIT
236 //
237
238 protected function initDidacticTemplate(ilPropertyFormGUI $a_form)
239 {
240 global $ilUser;
241
242 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
244 if(sizeof($all))
245 {
246 $opts = array(""=>$this->lng->txt("please_select"));
247 foreach($all as $item)
248 {
249 $opts[$item["id"]] = $item["title"];
250 }
251 $prtf = new ilSelectInputGUI($this->lng->txt("prtf_create_template_from_portfolio"), "prtf");
252 $prtf->setInfo($this->lng->txt("prtf_create_template_from_portfolio_info"));
253 $prtf->setOptions($opts);
254 $a_form->addItem($prtf);
255 }
256
257 // yeah, I know.
258 return $a_form;
259 }
260
261 protected function afterSave(ilObject $a_new_object)
262 {
263 if($_POST["prtf"])
264 {
265 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
266 $source = new ilObjPortfolio($_POST["prtf"], false);
267
268 ilObjPortfolio::clonePagesAndSettings($source, $a_new_object);
269 }
270
271 ilUtil::sendSuccess($this->lng->txt("prtt_portfolio_created"), true);
272 $this->ctrl->setParameter($this, "prt_id", $a_new_object->getId());
273 $this->ctrl->redirect($this, "view");
274 }
275
276 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
277 {
278 // activation/availability
279
280 include_once "Services/Object/classes/class.ilObjectActivation.php";
281 $this->lng->loadLanguageModule('rep');
282
284 $section->setTitle($this->lng->txt('rep_activation_availability'));
285 $a_form->addItem($section);
286
287 // additional info only with multiple references
288 $act_obj_info = $act_ref_info = "";
289 if(sizeof(ilObject::_getAllReferences($this->object->getId())) > 1)
290 {
291 $act_obj_info = ' '.$this->lng->txt('rep_activation_online_object_info');
292 $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
293 }
294
295 $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'),'online');
296 $online->setInfo($this->lng->txt('prtt_activation_online_info').$act_obj_info);
297 $a_form->addItem($online);
298
299 $act_type = new ilCheckboxInputGUI($this->lng->txt('rep_visibility_until'),'access_type');
300 // $act_type->setInfo($this->lng->txt('prtt_availability_until_info'));
301
302 $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
303 include_once "Services/Form/classes/class.ilDateDurationInputGUI.php";
304 $dur = new ilDateDurationInputGUI($this->lng->txt("rep_time_period"), "access_period");
305 $dur->setShowTime(true);
306 $date = $this->object->getActivationStartDate();
307 $dur->setStart(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
308 $dur->setStartText($this->lng->txt('rep_activation_limited_start'));
309 $date = $this->object->getActivationEndDate();
310 $dur->setEnd(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
311 $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
312 $act_type->addSubItem($dur);
313
314 $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'access_visiblity');
315 $visible->setInfo($this->lng->txt('prtt_activation_limited_visibility_info'));
316 $act_type->addSubItem($visible);
317
318 $a_form->addItem($act_type);
319
321 $section->setTitle($this->lng->txt('properties'));
322 $a_form->addItem($section);
323
324 parent::initEditCustomForm($a_form);
325 }
326
327 protected function getEditFormCustomValues(array &$a_values)
328 {
329 $a_values["online"] = $this->object->isOnline();
330 $a_values["access_type"] = $this->object->isActivationLimited();
331 $a_values["access_visiblity"] = $this->object->getActivationVisibility();
332
333 parent::getEditFormCustomValues($a_values);
334 }
335
336 public function updateCustom(ilPropertyFormGUI $a_form)
337 {
338 $this->object->setOnline($a_form->getInput("online"));
339
340 // activation
341 if($a_form->getInput("access_type"))
342 {
343 $this->object->setActivationLimited(true);
344 $this->object->setActivationVisibility($a_form->getInput("access_visiblity"));
345
346 $period = $a_form->getItemByPostVar("access_period");
347 $this->object->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
348 $this->object->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
349 }
350 else
351 {
352 $this->object->setActivationLimited(false);
353 }
354
355 parent::updateCustom($a_form);
356 }
357
358
359 //
360 // PAGES
361 //
362
370 protected function getPageInstance($a_page_id = null, $a_portfolio_id = null)
371 {
372 if(!$a_portfolio_id && $this->object)
373 {
374 $a_portfolio_id = $this->object->getId();
375 }
376 include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
377 $page = new ilPortfolioTemplatePage($a_page_id);
378 $page->setPortfolioId($a_portfolio_id);
379 return $page;
380 }
381
388 protected function getPageGUIInstance($a_page_id)
389 {
390 include_once("Modules/Portfolio/classes/class.ilPortfolioTemplatePageGUI.php");
391 $page_gui = new ilPortfolioTemplatePageGUI(
392 $this->object->getId(),
393 $a_page_id,
394 0,
395 $this->object->hasPublicComments()
396 );
397 $page_gui->setAdditional($this->getAdditional());
398 return $page_gui;
399 }
400
401 public function getPageGUIClassName()
402 {
403 return "ilportfoliotemplatepagegui";
404 }
405
407 {
408 $old = new ilRadioOption($this->lng->txt("prtf_existing_portfolio"), "old");
409 $a_tgt->addOption($old);
410
411 $options = array();
413 foreach($all as $id => $title)
414 {
415 $options[$id] = $title;
416 }
417 $prtf = new ilSelectInputGUI($this->lng->txt("obj_prtt"), "prtf");
418 $prtf->setRequired(true);
419 $prtf->setOptions($options);
420 $old->addSubItem($prtf);
421
422 // no option to create new template here
423 $a_tgt->setValue("old");
424 }
425
426
427 //
428 // BLOG
429 //
430
437 public function initBlogForm()
438 {
439 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
440 $form = new ilPropertyFormGUI();
441 $form->setFormAction($this->ctrl->getFormAction($this));
442
443 $obj = new ilTextInputGUI($this->lng->txt("title"), "blog");
444 $obj->setRequired(true);
445 $form->addItem($obj);
446
447 // save and cancel commands
448 $form->setTitle($this->lng->txt("prtf_add_blog").": ".
449 $this->object->getTitle());
450 $form->addCommandButton("saveBlog", $this->lng->txt("save"));
451 $form->addCommandButton("view", $this->lng->txt("cancel"));
452
453 return $form;
454 }
455
459 public function saveBlog()
460 {
461 $form = $this->initBlogForm();
462 if ($form->checkInput() && $this->checkPermissionBool("write"))
463 {
464 $page = $this->getPageInstance();
466 $page->setTitle($form->getInput("blog"));
467 $page->create();
468
469 ilUtil::sendSuccess($this->lng->txt("prtf_blog_page_created"), true);
470 $this->ctrl->redirect($this, "view");
471 }
472
473 $this->tabs_gui->clearTargets();
474 $this->tabs_gui->setBackTarget($this->lng->txt("back"),
475 $this->ctrl->getLinkTarget($this, "view"));
476
477 $form->setValuesByPost();
478 $this->tpl->setContent($form->getHtml());
479 }
480
481
482 //
483 // TRANSMOGRIFIER
484 //
485
486 function preview($a_return = false, $a_content = false, $a_show_notes = true)
487 {
488 if(!$this->checkPermissionBool("write") &&
489 $this->checkPermissionBool("read"))
490 {
491 $this->lng->loadLanguageModule("cntr");
492
493 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
494 $button = ilLinkButton::getInstance();
495 $button->setPrimary(true);
496 $button->setCaption("prtf_create_portfolio_from_template");
497 $button->setUrl($this->ctrl->getLinkTarget($this, "createfromtemplate"));
498 $this->tpl->setHeaderActionMenu($button->render());
499 }
500
501 return parent::preview($a_return , $a_content, $a_show_notes);
502 }
503
504 public function createFromTemplate()
505 {
506 $this->ctrl->setParameterByClass("ilobjportfoliogui", "prtt_pre", $this->object->getId());
507 $this->ctrl->redirectByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui", "ilobjportfoliogui"), "create");
508 }
509
510 public static function _goto($a_target)
511 {
512 $id = explode("_", $a_target);
513
514 $_GET["baseClass"] = "ilRepositoryGUI";
515 $_GET["ref_id"] = $id[0];
516 $_GET["cmd"] = "preview";
517
518 include("ilias.php");
519 exit;
520 }
521}
522
523?>
$section
Definition: Utf8Test.php:84
$_GET["client_id"]
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 property in a property form.
This class represents a section header 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)
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.
initCopyPageFormOptions(ilFormPropertyGUI $a_tgt)
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.
getPageInstance($a_page_id=null, $a_portfolio_id=null)
Get portfolio template page instance.
initBlogForm()
Init blog template page form.
static getAvailablePortfolioTemplates($a_permission="read")
static getPortfoliosOfUser($a_user_id)
Get views of user.
Class ilObjStyleSheetGUI.
setTabs()
create tabs (repository/workspace switch)
getAccessHandler()
Get access handler.
& executeCommand()
execute command
prepareOutput()
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
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 an option in a radio group.
This class represents a selection list property in a property form.
ILIAS Setting Class.
This class represents a text property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
$info
Definition: example_052.php:80
exit
Definition: login.php:54
$cmd
Definition: sahs_server.php:35
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15