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