ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjBibliographicGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
22 {
23  use \ILIAS\Modules\OrgUnit\ARHelper\DIC;
24  const P_ENTRY_ID = 'entry_id';
25  const CMD_SHOW_CONTENT = 'showContent';
26  const CMD_SEND_FILE = "sendFile";
27  const TAB_CONTENT = "content";
28  const SUB_TAB_FILTER = "filter";
29  const CMD_VIEW = "view";
30  const TAB_EXPORT = "export";
31  const TAB_SETTINGS = self::SUBTAB_SETTINGS;
32  const TAB_ID_RECORDS = "id_records";
33  const TAB_ID_PERMISSIONS = "id_permissions";
34  const TAB_ID_INFO = "id_info";
35  const CMD_SHOW_DETAILS = "showDetails";
36  const CMD_EDIT = "edit";
37  const SUBTAB_SETTINGS = "settings";
38  const CMD_EDIT_OBJECT = 'editObject';
39  const CMD_UPDATE_OBJECT = 'updateObject';
43  public $object;
47  protected $facade;
55  protected $field_factory;
59  protected $filter_factory;
63  protected $type_factory;
67  protected $cmd = self::CMD_SHOW_CONTENT;
68 
69 
75  public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
76  {
77  global $DIC;
78 
79  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
80  $DIC->language()->loadLanguageModule('bibl');
81  $DIC->language()->loadLanguageModule('content');
82  $DIC->language()->loadLanguageModule('obj');
83  $DIC->language()->loadLanguageModule('cntr');
84 
85  if (is_object($this->object)) {
86  $this->facade = new ilBiblFactoryFacade($this->object);
87  }
88  }
89 
90 
96  public function getStandardCmd()
97  {
98  return self::CMD_VIEW;
99  }
100 
101 
109  public function getType()
110  {
111  return "bibl";
112  }
113 
114 
118  public function executeCommand()
119  {
120  global $DIC;
121  $ilNavigationHistory = $DIC['ilNavigationHistory'];
122 
123  // Navigation History
124  $link = $this->dic()->ctrl()->getLinkTarget($this, $this->getStandardCmd());
125  if ($this->object != null) {
126  $ilNavigationHistory->addItem($this->object->getRefId(), $link, "bibl");
127  $this->addHeaderAction();
128  }
129 
130  // general Access Check, especially for single entries not matching the object
131  if ($this->object instanceof ilObjBibliographic && !$DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
132  $this->handleNonAccess();
133  }
134 
135  $next_class = $this->dic()->ctrl()->getNextClass($this);
136  $this->cmd = $this->dic()->ctrl()->getCmd();
137  switch ($next_class) {
138  case strtolower(ilInfoScreenGUI::class):
139  $this->prepareOutput();
140  $this->dic()->tabs()->activateTab(self::TAB_ID_INFO);
141  $this->infoScreenForward();
142  break;
143  case strtolower(ilCommonActionDispatcherGUI::class):
145  $this->ctrl->forwardCommand($gui);
146  break;
147  case strtolower(ilPermissionGUI::class):
148  $this->prepareOutput();
149  $this->dic()->tabs()->activateTab(self::TAB_ID_PERMISSIONS);
150  $this->ctrl->forwardCommand(new ilPermissionGUI($this));
151  break;
152  case strtolower(ilObjectCopyGUI::class):
153  $cp = new ilObjectCopyGUI($this);
154  $cp->setType('bibl');
155  $this->dic()['tpl']->loadStandardTemplate();
156  $this->ctrl->forwardCommand($cp);
157  break;
158  case strtolower(ilObjFileGUI::class):
159  $this->prepareOutput();
160  $this->dic()->tabs()->setTabActive(self::TAB_ID_RECORDS);
161  $this->ctrl->forwardCommand(new ilObjFile($this));
162  break;
163  case strtolower(ilExportGUI::class):
164  $this->prepareOutput();
165  $this->dic()->tabs()->setTabActive(self::TAB_EXPORT);
166  $exp_gui = new ilExportGUI($this);
167  $exp_gui->addFormat("xml");
168  $this->ctrl->forwardCommand($exp_gui);
169  break;
170  case strtolower(ilBiblFieldFilterGUI::class):
171  $this->prepareOutput();
172  $this->dic()->tabs()->setTabActive(self::TAB_SETTINGS);
173  $this->initSubTabs();
174  $this->tabs_gui->activateSubTab(self::SUB_TAB_FILTER);
175  $this->ctrl->forwardCommand(new ilBiblFieldFilterGUI($this->facade));
176  break;
177  default:
178  $this->prepareOutput();
179  $cmd = $this->ctrl->getCmd(self::CMD_SHOW_CONTENT);
180  switch ($cmd) {
181  case 'edit':
182  case 'update':
183  case self::CMD_EDIT_OBJECT:
184  case self::CMD_UPDATE_OBJECT:
185  $this->initSubTabs();
186  $this->tabs_gui->activateSubTab(self::SUBTAB_SETTINGS);
187  $this->{$cmd}();
188  break;
189  default:
190  $this->{$cmd}();
191  break;
192  }
193  break;
194  }
195 
196  return true;
197  }
198 
199 
205  public function infoScreen()
206  {
207  $this->ctrl->setCmd("showSummary");
208  $this->ctrl->setCmdClass(ilInfoScreenGUI::class);
209  $this->infoScreenForward();
210  }
211 
212 
216  public function infoScreenForward()
217  {
218  global $DIC;
219 
220  if (!$this->checkPermissionBoolAndReturn("visible") && !$this->checkPermissionBoolAndReturn('read')) {
221  ilUtil::sendFailure($DIC['lng']->txt("msg_no_perm_read"), true);
222  $this->ctrl->redirectByClass('ilDashboardGUI', '');
223  }
224  $DIC->tabs()->activateTab(self::TAB_ID_INFO);
225  $info = new ilInfoScreenGUI($this);
226  $info->enablePrivateNotes();
227  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
228  $this->ctrl->forwardCommand($info);
229  }
230 
231 
232  /*
233  * addLocatorItems
234  */
235  public function addLocatorItems()
236  {
237  global $DIC;
238  $ilLocator = $DIC['ilLocator'];
239  if (is_object($this->object)) {
240  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
241  }
242  }
243 
244 
251  public static function _goto($a_target)
252  {
253  global $DIC;
254 
255  $id = explode("_", $a_target);
256  $DIC->ctrl()->initBaseClass(ilRepositoryGUI::class);
257  $DIC->ctrl()->setParameterByClass(ilObjBibliographicGUI::class, "ref_id", $id[0]);
258  // Detail-View
259  if ($id[1]) {
260  $DIC->ctrl()
261  ->setParameterByClass(ilObjBibliographicGUI::class, ilObjBibliographicGUI::P_ENTRY_ID, $id[1]);
262  $DIC->ctrl()->redirectByClass(
263  array(
264  ilRepositoryGUI::class,
265  ilObjBibliographicGUI::class,
266  ),
267  self::CMD_SHOW_DETAILS
268  );
269  } else {
270  $DIC->ctrl()->redirectByClass(
271  array(
272  ilRepositoryGUI::class,
273  ilObjBibliographicGUI::class,
274  ),
275  self::CMD_VIEW
276  );
277  }
278  }
279 
280 
286  protected function initCreationForms($a_new_type)
287  {
288  global $DIC;
289 
290  $forms = parent::initCreationForms($a_new_type);
291  // Add File-Upload
292  $in_file = new ilFileInputGUI($DIC->language()->txt("bibliography_file"), "bibliographic_file");
293  $in_file->setSuffixes(array("ris", "bib", "bibtex"));
294  $in_file->setRequired(true);
295  $forms[self::CFORM_NEW]->addItem($in_file);
296  $this->ctrl->saveParameterByClass('ilobjrootfoldergui', 'new_type');
297  $forms[self::CFORM_NEW]->setFormAction($this->ctrl->getFormActionByClass('ilobjrootfoldergui', "save"));
298 
299  return $forms;
300  }
301 
302 
303  public function save()
304  {
305  global $DIC;
306 
307  $form = $this->initCreationForms($this->getType());
308  if ($form[self::CFORM_NEW]->checkInput()) {
309  parent::save();
310  } else {
311  $form = $form[self::CFORM_NEW];
312  $form->setValuesByPost();
313  $DIC->ui()->mainTemplate()->setContent($form->getHtml());
314  }
315  }
316 
317 
321  protected function afterSave(ilObject $a_new_object)
322  {
326  assert($a_new_object instanceof ilObjBibliographic);
327  $a_new_object->doUpdate();
328  $this->addNews($a_new_object->getId(), 'created');
329  $this->ctrl->redirect($this, self::CMD_EDIT);
330  }
331 
332 
339  public function setTabs()
340  {
341  global $DIC;
342 
343  $ilHelp = $DIC['ilHelp'];
347  $ilHelp->setScreenIdComponent('bibl');
348  // info screen
349  if ($DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
350  $DIC->tabs()->addTab(
351  self::TAB_CONTENT,
352  $DIC->language()
353  ->txt(self::TAB_CONTENT),
354  $this->ctrl->getLinkTarget($this, self::CMD_SHOW_CONTENT)
355  );
356  }
357  // info screen
358  if ($DIC->access()->checkAccess('visible', "", $this->object->getRefId())
359  || $DIC->access()->checkAccess('read', "", $this->object->getRefId())
360  ) {
361  $DIC->tabs()->addTab(
362  self::TAB_ID_INFO,
363  $DIC->language()
364  ->txt("info_short"),
365  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
366  );
367  }
368  // settings
369  if ($DIC->access()->checkAccess('write', "", $this->object->getRefId())) {
370  $DIC->tabs()->addTab(
371  self::SUBTAB_SETTINGS,
372  $DIC->language()
373  ->txt(self::SUBTAB_SETTINGS),
374  $this->ctrl->getLinkTarget($this, self::CMD_EDIT_OBJECT)
375  );
376  }
377  // export
378  if ($DIC->access()->checkAccess("write", "", $this->object->getRefId())) {
379  $DIC->tabs()->addTab(
380  self::TAB_EXPORT,
381  $DIC->language()
382  ->txt(self::TAB_EXPORT),
383  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
384  );
385  }
386  // edit permissions
387  if ($DIC->access()->checkAccess('edit_permission', "", $this->object->getRefId())) {
388  $DIC->tabs()->addTab(
389  self::TAB_ID_PERMISSIONS,
390  $DIC->language()
391  ->txt("perm_settings"),
392  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm")
393  );
394  }
395  }
396 
397 
398  protected function initSubTabs()
399  {
400  global $DIC;
401  $DIC->tabs()->addSubTab(
402  self::SUBTAB_SETTINGS,
403  $DIC->language()
404  ->txt(self::SUBTAB_SETTINGS),
405  $this->ctrl->getLinkTarget($this, self::CMD_EDIT_OBJECT)
406  );
407  $DIC->tabs()->addSubTab(
408  self::SUB_TAB_FILTER,
409  $DIC->language()
410  ->txt("bibl_filter"),
411  $this->ctrl->getLinkTargetByClass(ilBiblFieldFilterGUI::class, ilBiblFieldFilterGUI::CMD_STANDARD)
412  );
413  }
414 
415 
421  public function editObject()
422  {
423  $tpl = $this->tpl;
424  $ilTabs = $this->tabs_gui;
426 
427  if (!$this->checkPermissionBool("write")) {
428  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
429  }
430 
431  $ilTabs->activateTab("settings");
432 
433  $form = $this->initEditForm();
434  $values = $this->getEditFormValues();
435  if ($values) {
436  $form->setValuesByArray($values, true);
437  }
438 
439  $this->addExternalEditFormCustom($form);
440 
441  $tpl->setContent($form->getHTML());
442  }
443 
444 
445  public function initEditForm()
446  {
447  global $DIC;
448 
449  $form = parent::initEditForm();
450  // Add File-Upload
451  $in_file = new ilFileInputGUI(
452  $DIC->language()
453  ->txt("bibliography_file"),
454  "bibliographic_file"
455  );
456  $in_file->setSuffixes(array("ris", "bib", "bibtex"));
457  $in_file->setRequired(false);
458  $cb_override = new ilCheckboxInputGUI(
459  $DIC->language()
460  ->txt("override_entries"),
461  "override_entries"
462  );
463  $cb_override->addSubItem($in_file);
464 
465  $form->addItem($cb_override);
466 
467  $section_appearance = new ilFormSectionHeaderGUI();
468  $section_appearance->setTitle($this->lng->txt('cont_presentation'));
469  $form->addItem($section_appearance);
470  $DIC->object()->commonSettings()->legacyForm($form, $this->object)->addTileImage();
471 
472  $form->setFormAction($DIC->ctrl()->getFormAction($this, "save"));
473 
474  return $form;
475  }
476 
477 
481  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
482  {
483  global $DIC;
484 
485  $DIC->tabs()->activateTab(self::SUBTAB_SETTINGS);
486  // is_online
487  $cb = new ilCheckboxInputGUI($DIC->language()->txt("online"), "is_online");
488  $a_form->addItem($cb);
489  }
490 
491 
497  public function getEditFormCustomValues(array &$a_values)
498  {
499  $a_values["is_online"] = $this->object->getOnline();
500 
501  return $a_values;
502  }
503 
504 
505  public function render()
506  {
507  $this->showContent();
508  }
509 
510 
514  public function showContent()
515  {
516  global $DIC;
517 
518  // if user has read permission and object is online OR user has write permissions
519  $read_access = $DIC->access()->checkAccess('read', "", $this->object->getRefId());
520  $online = $this->object->getOnline();
521  $write_access = $DIC->access()->checkAccess('write', "", $this->object->getRefId());
522  if (($read_access && $online) || $write_access) {
523  $DIC->tabs()->activateTab(self::TAB_CONTENT);
524 
526  $b->setCaption('download_original_file');
527  $b->setUrl($DIC->ctrl()->getLinkTargetByClass(self::class, self::CMD_SEND_FILE));
528  $b->setPrimary(true);
529  $DIC->toolbar()->addButtonInstance($b);
530 
531  $table = new ilBiblEntryTableGUI($this, $this->facade);
532  $html = $table->getHTML();
533  $DIC->ui()->mainTemplate()->setContent($html);
534 
535  //Permanent Link
536  $DIC->ui()->mainTemplate()->setPermanentLink("bibl", $this->object->getRefId());
537  } else {
538  $object_title = ilObject::_lookupTitle(ilObject::_lookupObjId($_GET["ref_id"]));
540  sprintf(
541  $DIC->language()
542  ->txt("msg_no_perm_read_item"),
543  $object_title
544  ),
545  true
546  );
547  //redirect to repository without any parameters
548  $this->handleNonAccess();
549  }
550  }
551 
552 
553  protected function applyFilter()
554  {
555  $table = new ilBiblEntryTableGUI($this, $this->facade);
556  $table->writeFilterToSession();
557  $table->resetOffset();
558  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
559  }
560 
561 
562  protected function resetFilter()
563  {
564  $table = new ilBiblEntryTableGUI($this, $this->facade);
565  $table->resetFilter();
566  $table->resetOffset();
567  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
568  }
569 
570 
574  public function sendFile()
575  {
576  global $DIC;
577 
578  if ($DIC['ilAccess']->checkAccess('read', "", $this->object->getRefId())) {
579  $file_path = $this->object->getLegacyAbsolutePath();
580  if ($file_path) {
581  if (is_file($file_path)) {
582  ilFileDelivery::deliverFileAttached($file_path, $this->object->getFilename(), 'application/octet-stream');
583  } else {
584  ilUtil::sendFailure($DIC['lng']->txt("file_not_found"));
585  $this->showContent();
586  }
587  }
588  } else {
589  $this->handleNonAccess();
590  }
591  }
592 
593 
594  public function showDetails()
595  {
596  global $DIC;
597 
598  if ($DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
599  $id = $DIC->http()->request()->getQueryParams()[self::P_ENTRY_ID];
600  $entry = $this->facade->entryFactory()
601  ->findByIdAndTypeString($id, $this->object->getFileTypeAsString());
602  $bibGUI = new ilBiblEntryDetailPresentationGUI($entry, $this->facade);
603 
604  $DIC->ui()->mainTemplate()->setContent($bibGUI->getHTML());
605  } else {
606  $this->handleNonAccess();
607  }
608  }
609 
610 
611  public function view()
612  {
613  $this->showContent();
614  }
615 
616 
620  public function updateCustom(ilPropertyFormGUI $a_form)
621  {
622  global $DIC;
623 
624  if ($DIC->access()->checkAccess('write', "", $this->object->getRefId())) {
625  if ($this->object->getOnline() != $a_form->getInput("is_online")) {
626  $this->object->setOnline($a_form->getInput("is_online"));
627  }
628 
629  if (!empty($_FILES['bibliographic_file']['name'])) {
630  $this->addNews($this->object->getId(), 'updated');
631  }
632 
633  $DIC->object()->commonSettings()->legacyForm($a_form, $this->object)->saveTileImage();
634  } else {
635  $this->handleNonAccess();
636  }
637  }
638 
639 
640  public function toggleNotification()
641  {
642  global $DIC;
643 
644  switch ($_GET["ntf"]) {
645  case 1:
648  $DIC->user()
649  ->getId(),
651  false
652  );
653  break;
654  case 2:
657  $DIC->user()
658  ->getId(),
660  true
661  );
662  break;
663  }
664  $DIC->ctrl()->redirect($this, "");
665  }
666 
667 
671  public function addNews($obj_id, $change = 'created')
672  {
673  global $DIC;
674 
675  $ilNewsItem = new ilNewsItem();
676  $ilNewsItem->setTitle($DIC->language()->txt('news_title_' . $change));
677  $ilNewsItem->setPriority(NEWS_NOTICE);
678  $ilNewsItem->setContext($obj_id, $this->getType());
679  $ilNewsItem->setUserId($DIC->user()->getId());
680  $ilNewsItem->setVisibility(NEWS_USERS);
681  $ilNewsItem->setContentTextIsLangVar(false);
682  $ilNewsItem->create();
683  }
684 
685 
686 
692  public function addToDesk()
693  {
694  $this->addToDeskObject();
695  }
696 
697 
703  public function removeFromDesk()
704  {
705  $this->removeFromDeskObject();
706  }
707 
708 
712  protected function afterImport(ilObject $a_new_object)
713  {
717  $a_new_object->parseFileToDatabase();
718 
719  parent::afterImport($a_new_object);
720  }
721 
722 
723  private function handleNonAccess()
724  {
725  global $DIC;
726 
727  unset($_GET);
728  ilUtil::sendFailure($DIC->language()->txt("no_permission"), true);
730  }
731 }
infoScreenForward()
show information screen
Class ilObjBibliographicGUI.
Class ilInfoScreenGUI.
removeFromDesk()
Remove from desktop.
This class represents a property form user interface.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
New implementation of ilObjectGUI.
GUI class for the workflow of copying objects.
$_GET["client_id"]
This class represents a section header in a property form.
This class represents a file property in a property form.
updateCustom(ilPropertyFormGUI $a_form)
updateSettings
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
This class represents a checkbox property in a property form.
static _lookupTitle($a_id)
lookup object title
addItem($a_item)
Add Item (Property, SectionHeader).
Class ilDataCollectionField.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
sendFile()
provide file as a download
addExternalEditFormCustom(ilPropertyFormGUI $a_form)
Export User Interface Class.
static deliverFileAttached($path_to_file, $download_file_name='', $mime_type='', $delete_file=false)
void
getId()
get object id public
Class ilBiblFieldFilterGUI.
static _lookupObjId($a_id)
const NEWS_NOTICE
static setNotification($type, $user_id, $id, $status=true)
Set notification status for object and user.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
removeFromDeskObject()
Remove from desktop public.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setTabs()
create tabs (repository/workspace switch)
addNews($obj_id, $change='created')
getEditFormValues()
Get values for edit form.
initEditCustomForm(ilPropertyFormGUI $a_form)
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
__construct(Container $dic, ilPlugin $plugin)
showContent()
shows the overview page with all entries in a table
$DIC
Definition: xapitoken.php:46
addToDeskObject()
Add desktop item public.
prepareOutput($a_show_subobjects=true)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
const NEWS_USERS
Class ilObjBibliographic.
Class ilBiblEntryDetailPresentationGUI.
Class ilBiblFactoryFacade.
addHeaderAction()
Add header action menu.
setSuffixes($a_suffixes)
Set Accepted Suffixes.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
afterImport(ilObject $a_new_object)
Post (successful) object import hook.
static _goto($a_target)
_goto Deep link
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...