ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_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  // activation/availability
301 
302  include_once "Services/Object/classes/class.ilObjectActivation.php";
303  $this->lng->loadLanguageModule('rep');
304 
306  $section->setTitle($this->lng->txt('rep_activation_availability'));
307  $a_form->addItem($section);
308 
309  // additional info only with multiple references
310  $act_obj_info = $act_ref_info = "";
311  if (sizeof(ilObject::_getAllReferences($this->object->getId())) > 1) {
312  $act_obj_info = ' ' . $this->lng->txt('rep_activation_online_object_info');
313  $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
314  }
315 
316  $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'online');
317  $online->setInfo($this->lng->txt('prtt_activation_online_info') . $act_obj_info);
318  $a_form->addItem($online);
319 
320  include_once "Services/Form/classes/class.ilDateDurationInputGUI.php";
321  $dur = new ilDateDurationInputGUI($this->lng->txt("rep_visibility_until"), "access_period");
322  $dur->setShowTime(true);
323  $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
324  $a_form->addItem($dur);
325 
326  $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'access_visiblity');
327  $visible->setInfo($this->lng->txt('prtt_activation_limited_visibility_info'));
328  $dur->addSubItem($visible);
329 
331  $section->setTitle($this->lng->txt('properties'));
332  $a_form->addItem($section);
333 
334  parent::initEditCustomForm($a_form);
335  }
336 
337  protected function getEditFormCustomValues(array &$a_values)
338  {
339  $a_values["online"] = $this->object->isOnline();
340  $a_values["access_period"]["start"] = $this->object->getActivationStartDate()
341  ? new ilDateTime($this->object->getActivationStartDate(), IL_CAL_UNIX)
342  : null;
343  $a_values["access_period"]["end"] = $this->object->getActivationEndDate()
344  ? new ilDateTime($this->object->getActivationEndDate(), IL_CAL_UNIX)
345  : null;
346  $a_values["access_visiblity"] = $this->object->getActivationVisibility();
347 
348  parent::getEditFormCustomValues($a_values);
349  }
350 
351  public function updateCustom(ilPropertyFormGUI $a_form)
352  {
353  $this->object->setOnline($a_form->getInput("online"));
354 
355  // activation
356  $period = $a_form->getItemByPostVar("access_period");
357  if ($period->getStart() && $period->getEnd()) {
358  $this->object->setActivationLimited(true);
359  $this->object->setActivationVisibility($a_form->getInput("access_visiblity"));
360  $this->object->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX));
361  $this->object->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX));
362  } else {
363  $this->object->setActivationLimited(false);
364  }
365 
366  parent::updateCustom($a_form);
367  }
368 
369 
370  //
371  // PAGES
372  //
373 
381  protected function getPageInstance($a_page_id = null, $a_portfolio_id = null)
382  {
383  if (!$a_portfolio_id && $this->object) {
384  $a_portfolio_id = $this->object->getId();
385  }
386  include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
387  $page = new ilPortfolioTemplatePage($a_page_id);
388  $page->setPortfolioId($a_portfolio_id);
389  return $page;
390  }
391 
398  protected function getPageGUIInstance($a_page_id)
399  {
400  include_once("Modules/Portfolio/classes/class.ilPortfolioTemplatePageGUI.php");
401  $page_gui = new ilPortfolioTemplatePageGUI(
402  $this->object->getId(),
403  $a_page_id,
404  0,
405  $this->object->hasPublicComments()
406  );
407  $page_gui->setAdditional($this->getAdditional());
408  return $page_gui;
409  }
410 
411  public function getPageGUIClassName()
412  {
413  return "ilportfoliotemplatepagegui";
414  }
415 
416  protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form)
417  {
418  // always existing prtft
419  $hi = new ilHiddenInputGUI("target");
420  $hi->setValue("old");
421  $a_form->addItem($hi);
422 
423  $options = array();
425  foreach ($all as $id => $title) {
426  $options[$id] = $title;
427  }
428  $prtf = new ilSelectInputGUI($this->lng->txt("obj_prtt"), "prtf");
429  $prtf->setRequired(true);
430  $prtf->setOptions($options);
431  $a_form->addItem($prtf);
432  }
433 
434 
435  //
436  // BLOG
437  //
438 
445  public function initBlogForm()
446  {
447  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
448  $form = new ilPropertyFormGUI();
449  $form->setFormAction($this->ctrl->getFormAction($this));
450 
451  $obj = new ilTextInputGUI($this->lng->txt("title"), "blog");
452  $obj->setRequired(true);
453  $form->addItem($obj);
454 
455  // save and cancel commands
456  $form->setTitle($this->lng->txt("prtf_add_blog") . ": " .
457  $this->object->getTitle());
458  $form->addCommandButton("saveBlog", $this->lng->txt("save"));
459  $form->addCommandButton("view", $this->lng->txt("cancel"));
460 
461  return $form;
462  }
463 
467  public function saveBlog()
468  {
469  $form = $this->initBlogForm();
470  if ($form->checkInput() && $this->checkPermissionBool("write")) {
471  $page = $this->getPageInstance();
473  $page->setTitle($form->getInput("blog"));
474  $page->create();
475 
476  ilUtil::sendSuccess($this->lng->txt("prtf_blog_page_created"), true);
477  $this->ctrl->redirect($this, "view");
478  }
479 
480  $this->tabs_gui->clearTargets();
481  $this->tabs_gui->setBackTarget(
482  $this->lng->txt("back"),
483  $this->ctrl->getLinkTarget($this, "view")
484  );
485 
486  $form->setValuesByPost();
487  $this->tpl->setContent($form->getHtml());
488  }
489 
490 
491  //
492  // TRANSMOGRIFIER
493  //
494 
495  public function preview($a_return = false, $a_content = false, $a_show_notes = true)
496  {
497  if (!$this->checkPermissionBool("write") &&
498  $this->checkPermissionBool("read")) {
499  $this->lng->loadLanguageModule("cntr");
500 
501  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
502  $button = ilLinkButton::getInstance();
503  $button->setPrimary(true);
504  $button->setCaption("prtf_create_portfolio_from_template");
505  $button->setUrl($this->ctrl->getLinkTarget($this, "createfromtemplate"));
506  $this->tpl->setHeaderActionMenu($button->render());
507  }
508 
509  return parent::preview($a_return, $a_content, $a_show_notes);
510  }
511 
512  public function createFromTemplate()
513  {
514  $this->ctrl->setParameterByClass("ilobjportfoliogui", "prtt_pre", $this->object->getId());
515  $this->ctrl->redirectByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui", "ilobjportfoliogui"), "create");
516  }
517 
518  public static function _goto($a_target)
519  {
520  $id = explode("_", $a_target);
521 
522  $_GET["baseClass"] = "ilRepositoryGUI";
523  $_GET["ref_id"] = $id[0];
524  $_GET["cmd"] = "preview";
525 
526  include("ilias.php");
527  exit;
528  }
529 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getPageInstance($a_page_id=null, $a_portfolio_id=null)
Get portfolio template page instance.
initDidacticTemplate(ilPropertyFormGUI $a_form)
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Class ilInfoScreenGUI.
getItemByPostVar($a_post_var)
Get Item by POST variable.
executeCommand()
execute command
This class represents a selection list property in a property form.
This class represents a property form user interface.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
GUI class for the workflow of copying objects.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
This class represents a section header in a property form.
static getPortfoliosOfUser($a_user_id)
Get views of user.
getAccessHandler()
Get access handler.
initBlogForm()
Init blog template page form.
if(!array_key_exists('StateId', $_REQUEST)) $id
static clonePagesAndSettings(ilObjPortfolioBase $a_source, ilObjPortfolioBase $a_target, array $a_recipe=null)
Build template from portfolio and vice versa.
This class represents a checkbox property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
const IL_CAL_UNIX
infoScreenForward()
show information screen
user()
Definition: user.php:4
getPageGUIInstance($a_page_id)
Get portfolio template page gui instance.
static _getAllReferences($a_id)
get all reference ids of object
setInfo($a_info)
Set Information Text.
$section
Definition: Utf8Test.php:83
Export User Interface Class.
This class represents a hidden form property in a property form.
input GUI for a time span (start and end date)
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
if(isset($_POST['submit'])) $form
getId()
get object id public
$a_content
Definition: workflow.php:93
initEditCustomForm(ilPropertyFormGUI $a_form)
omitLocator($a_omit=true)
getAdditional()
Get Additonal Information.
This class represents a text property in a property form.
Date and time handling
$ilUser
Definition: imgupload.php:18
Page for portfolio template.
static getAvailablePortfolioTemplates($a_permission="read")
setShowTime($a_showtime)
Set Show Time Information.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
Portfolio template view gui class.
Create styles array
The data for the language used.
Portfolio view gui base class.
setTabs()
create tabs (repository/workspace switch)
saveBlog()
Create new portfolio blog template page.
initCopyPageFormOptions(ilPropertyFormGUI $a_form)
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
Create new PHPExcel object
obj_idprivate
preview($a_return=false, $a_content=false, $a_show_notes=true)
setAdditional($a_additional)
Set Additonal Information.
Class ilObjStyleSheetGUI.
$ret
Definition: parser.php:6
prepareOutput($a_show_subobjects=true)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
$source
Definition: linkback.php:22
$info
Definition: index.php:5
addHeaderAction()
Add header action menu.
$_POST["username"]
setRequired($a_required)
Set Required.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
Portfolio template page gui class.