ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
82  if (is_object($this->object)) {
83  $this->facade = new ilBiblFactoryFacade($this->object);
84  }
85  }
86 
87 
93  public function getStandardCmd()
94  {
95  return self::CMD_VIEW;
96  }
97 
98 
106  public function getType()
107  {
108  return "bibl";
109  }
110 
111 
115  public function executeCommand()
116  {
117  global $DIC;
118  $ilNavigationHistory = $DIC['ilNavigationHistory'];
119 
120  // Navigation History
121  $link = $this->dic()->ctrl()->getLinkTarget($this, $this->getStandardCmd());
122  if ($this->object != null) {
123  $ilNavigationHistory->addItem($this->object->getRefId(), $link, "bibl");
124  $this->addHeaderAction();
125  }
126 
127  // general Access Check, especially for single entries not matching the object
128  if ($this->object instanceof ilObjBibliographic && !$DIC->access()->checkAccess('visible', "", $this->object->getRefId())) {
129  $this->handleNonAccess();
130  }
131 
132  $next_class = $this->dic()->ctrl()->getNextClass($this);
133  $this->cmd = $this->dic()->ctrl()->getCmd();
134  switch ($next_class) {
135  case strtolower(ilInfoScreenGUI::class):
136  $this->prepareOutput();
137  $this->dic()->tabs()->activateTab(self::TAB_ID_INFO);
138  $this->infoScreenForward();
139  break;
140  case strtolower(ilCommonActionDispatcherGUI::class):
142  $this->ctrl->forwardCommand($gui);
143  break;
144  case strtolower(ilPermissionGUI::class):
145  $this->prepareOutput();
146  $this->dic()->tabs()->activateTab(self::TAB_ID_PERMISSIONS);
147  $this->ctrl->forwardCommand(new ilPermissionGUI($this));
148  break;
149  case strtolower(ilObjectCopyGUI::class):
150  $cp = new ilObjectCopyGUI($this);
151  $cp->setType('bibl');
152  $this->dic()['tpl']->getStandardTemplate();
153  $this->ctrl->forwardCommand($cp);
154  break;
155  case strtolower(ilObjFileGUI::class):
156  $this->prepareOutput();
157  $this->dic()->tabs()->setTabActive(self::TAB_ID_RECORDS);
158  $this->ctrl->forwardCommand(new ilObjFile($this));
159  break;
160  case strtolower(ilExportGUI::class):
161  $this->prepareOutput();
162  $this->dic()->tabs()->setTabActive(self::TAB_EXPORT);
163  $exp_gui = new ilExportGUI($this);
164  $exp_gui->addFormat("xml");
165  $this->ctrl->forwardCommand($exp_gui);
166  break;
167  case strtolower(ilBiblFieldFilterGUI::class):
168  $this->prepareOutput();
169  $this->dic()->tabs()->setTabActive(self::TAB_SETTINGS);
170  $this->initSubTabs();
171  $this->tabs_gui->activateSubTab(self::SUB_TAB_FILTER);
172  $this->ctrl->forwardCommand(new ilBiblFieldFilterGUI($this->facade));
173  break;
174  default:
175  $this->prepareOutput();
176  $cmd = $this->ctrl->getCmd(self::CMD_SHOW_CONTENT);
177  switch ($cmd) {
178  case 'edit':
179  case 'update':
180  case self::CMD_EDIT_OBJECT:
181  case self::CMD_UPDATE_OBJECT:
182  $this->initSubTabs();
183  $this->tabs_gui->activateSubTab(self::SUBTAB_SETTINGS);
184  $this->{$cmd}();
185  break;
186  default:
187  $this->{$cmd}();
188  break;
189  }
190  break;
191  }
192 
193  return true;
194  }
195 
196 
202  public function infoScreen()
203  {
204  $this->ctrl->setCmd("showSummary");
205  $this->ctrl->setCmdClass(ilInfoScreenGUI::class);
206  $this->infoScreenForward();
207  }
208 
209 
213  public function infoScreenForward()
214  {
215  global $DIC;
216 
217  if (!$this->checkPermissionBoolAndReturn("visible") && !$this->checkPermissionBoolAndReturn('read')) {
218  ilUtil::sendFailure($DIC['lng']->txt("msg_no_perm_read"), true);
219  $this->ctrl->redirectByClass('ilPersonalDesktopGUI', '');
220  }
221  $DIC->tabs()->activateTab(self::TAB_ID_INFO);
222  $info = new ilInfoScreenGUI($this);
223  $info->enablePrivateNotes();
224  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
225  $this->ctrl->forwardCommand($info);
226  }
227 
228 
229  /*
230  * addLocatorItems
231  */
232  public function addLocatorItems()
233  {
234  global $DIC;
235  $ilLocator = $DIC['ilLocator'];
236  if (is_object($this->object)) {
237  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
238  }
239  }
240 
241 
248  public static function _goto($a_target)
249  {
250  global $DIC;
251 
252  $id = explode("_", $a_target);
253  $DIC->ctrl()->initBaseClass(ilRepositoryGUI::class);
254  $DIC->ctrl()->setParameterByClass(ilObjBibliographicGUI::class, "ref_id", $id[0]);
255  // Detail-View
256  if ($id[1]) {
257  $DIC->ctrl()
258  ->setParameterByClass(ilObjBibliographicGUI::class, ilObjBibliographicGUI::P_ENTRY_ID, $id[1]);
259  $DIC->ctrl()->redirectByClass(
260  array(
261  ilRepositoryGUI::class,
262  ilObjBibliographicGUI::class,
263  ),
264  self::CMD_SHOW_DETAILS
265  );
266  } else {
267  $DIC->ctrl()->redirectByClass(
268  array(
269  ilRepositoryGUI::class,
270  ilObjBibliographicGUI::class,
271  ),
272  self::CMD_VIEW
273  );
274  }
275  }
276 
277 
283  protected function initCreationForms($a_new_type)
284  {
285  global $DIC;
286 
287  $forms = parent::initCreationForms($a_new_type);
288  // Add File-Upload
289  $in_file = new ilFileInputGUI($DIC->language()->txt("bibliography_file"), "bibliographic_file");
290  $in_file->setSuffixes(array("ris", "bib", "bibtex"));
291  $in_file->setRequired(true);
292  $forms[self::CFORM_NEW]->addItem($in_file);
293  $this->ctrl->saveParameterByClass('ilobjrootfoldergui', 'new_type');
294  $forms[self::CFORM_NEW]->setFormAction($this->ctrl->getFormActionByClass('ilobjrootfoldergui', "save"));
295 
296  return $forms;
297  }
298 
299 
300  public function save()
301  {
302  global $DIC;
303 
304  $form = $this->initCreationForms($this->getType());
305  if ($form[self::CFORM_NEW]->checkInput()) {
306  parent::save();
307  } else {
308  $form = $form[self::CFORM_NEW];
309  $form->setValuesByPost();
310  $DIC->ui()->mainTemplate()->setContent($form->getHtml());
311  }
312  }
313 
314 
318  protected function afterSave(ilObject $a_new_object)
319  {
323  assert($a_new_object instanceof ilObjBibliographic);
324  $a_new_object->doUpdate();
325  $this->addNews($a_new_object->getId(), 'created');
326  $this->ctrl->redirect($this, self::CMD_EDIT);
327  }
328 
329 
336  public function setTabs()
337  {
338  global $DIC;
339 
340  $ilHelp = $DIC['ilHelp'];
344  $ilHelp->setScreenIdComponent('bibl');
345  // info screen
346  if ($DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
347  $DIC->tabs()->addTab(
348  self::TAB_CONTENT,
349  $DIC->language()
350  ->txt(self::TAB_CONTENT),
351  $this->ctrl->getLinkTarget($this, self::CMD_SHOW_CONTENT)
352  );
353  }
354  // info screen
355  if ($DIC->access()->checkAccess('visible', "", $this->object->getRefId())
356  || $DIC->access()->checkAccess('read', "", $this->object->getRefId())
357  ) {
358  $DIC->tabs()->addTab(
359  self::TAB_ID_INFO,
360  $DIC->language()
361  ->txt("info_short"),
362  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
363  );
364  }
365  // settings
366  if ($DIC->access()->checkAccess('write', "", $this->object->getRefId())) {
367  $DIC->tabs()->addTab(
368  self::SUBTAB_SETTINGS,
369  $DIC->language()
370  ->txt(self::SUBTAB_SETTINGS),
371  $this->ctrl->getLinkTarget($this, self::CMD_EDIT_OBJECT)
372  );
373  }
374  // export
375  if ($DIC->access()->checkAccess("write", "", $this->object->getRefId())) {
376  $DIC->tabs()->addTab(
377  self::TAB_EXPORT,
378  $DIC->language()
379  ->txt(self::TAB_EXPORT),
380  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
381  );
382  }
383  // edit permissions
384  if ($DIC->access()->checkAccess('edit_permission', "", $this->object->getRefId())) {
385  $DIC->tabs()->addTab(
386  self::TAB_ID_PERMISSIONS,
387  $DIC->language()
388  ->txt("perm_settings"),
389  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm")
390  );
391  }
392  }
393 
394 
395  protected function initSubTabs()
396  {
397  global $DIC;
398  $DIC->tabs()->addSubTab(
399  self::SUBTAB_SETTINGS,
400  $DIC->language()
401  ->txt(self::SUBTAB_SETTINGS),
402  $this->ctrl->getLinkTarget($this, self::CMD_EDIT_OBJECT)
403  );
404  $DIC->tabs()->addSubTab(
405  self::SUB_TAB_FILTER,
406  $DIC->language()
407  ->txt("bibl_filter"),
408  $this->ctrl->getLinkTargetByClass(ilBiblFieldFilterGUI::class, ilBiblFieldFilterGUI::CMD_STANDARD)
409  );
410  }
411 
412 
413  public function initEditForm()
414  {
415  global $DIC;
416 
417  $form = parent::initEditForm();
418  // Add File-Upload
419  $in_file = new ilFileInputGUI(
420  $DIC->language()
421  ->txt("bibliography_file"),
422  "bibliographic_file"
423  );
424  $in_file->setSuffixes(array("ris", "bib", "bibtex"));
425  $in_file->setRequired(false);
426  $cb_override = new ilCheckboxInputGUI(
427  $DIC->language()
428  ->txt("override_entries"),
429  "override_entries"
430  );
431  $cb_override->addSubItem($in_file);
432 
433  $form->addItem($cb_override);
434  $form->setFormAction($DIC->ctrl()->getFormAction($this, "save"));
435 
436  return $form;
437  }
438 
439 
443  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
444  {
445  global $DIC;
446 
447  $DIC->tabs()->activateTab(self::SUBTAB_SETTINGS);
448  // is_online
449  $cb = new ilCheckboxInputGUI($DIC->language()->txt("online"), "is_online");
450  $a_form->addItem($cb);
451  }
452 
453 
459  public function getEditFormCustomValues(array &$a_values)
460  {
461  $a_values["is_online"] = $this->object->getOnline();
462 
463  return $a_values;
464  }
465 
466 
467  public function render()
468  {
469  $this->showContent();
470  }
471 
472 
476  public function showContent()
477  {
478  global $DIC;
479 
480  // if user has read permission and object is online OR user has write permissions
481  $read_access = $DIC->access()->checkAccess('read', "", $this->object->getRefId());
482  $online = $this->object->getOnline();
483  $write_access = $DIC->access()->checkAccess('write', "", $this->object->getRefId());
484  if (($read_access && $online) || $write_access) {
485  $DIC->tabs()->activateTab(self::TAB_CONTENT);
486 
488  $b->setCaption('download_original_file');
489  $b->setUrl($DIC->ctrl()->getLinkTargetByClass(self::class, self::CMD_SEND_FILE));
490  $b->setPrimary(true);
491  $DIC->toolbar()->addButtonInstance($b);
492 
493  $table = new ilBiblEntryTableGUI($this, $this->facade);
494  $html = $table->getHTML();
495  $DIC->ui()->mainTemplate()->setContent($html);
496 
497  //Permanent Link
498  $DIC->ui()->mainTemplate()->setPermanentLink("bibl", $this->object->getRefId());
499  } else {
500  $object_title = ilObject::_lookupTitle(ilObject::_lookupObjId($_GET["ref_id"]));
502  sprintf(
503  $DIC->language()
504  ->txt("msg_no_perm_read_item"),
505  $object_title
506  ),
507  true
508  );
509  //redirect to repository without any parameters
510  $this->handleNonAccess();
511  }
512  }
513 
514 
515  protected function applyFilter()
516  {
517  $table = new ilBiblEntryTableGUI($this, $this->facade);
518  $table->writeFilterToSession();
519  $table->resetOffset();
520  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
521  }
522 
523 
524  protected function resetFilter()
525  {
526  $table = new ilBiblEntryTableGUI($this, $this->facade);
527  $table->resetFilter();
528  $table->resetOffset();
529  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
530  }
531 
532 
536  public function sendFile()
537  {
538  global $DIC;
539 
540  if ($DIC['ilAccess']->checkAccess('read', "", $this->object->getRefId())) {
541  $file_path = $this->object->getLegacyAbsolutePath();
542  if ($file_path) {
543  if (is_file($file_path)) {
544  ilFileDelivery::deliverFileAttached($file_path, $this->object->getFilename(), 'application/octet-stream');
545  } else {
546  ilUtil::sendFailure($DIC['lng']->txt("file_not_found"));
547  $this->showContent();
548  }
549  }
550  } else {
551  $this->handleNonAccess();
552  }
553  }
554 
555 
556  public function showDetails()
557  {
558  global $DIC;
559 
560  if ($DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
561  $id = $DIC->http()->request()->getQueryParams()[self::P_ENTRY_ID];
562  $entry = $this->facade->entryFactory()
563  ->findByIdAndTypeString($id, $this->object->getFileTypeAsString());
564  $bibGUI = new ilBiblEntryDetailPresentationGUI($entry, $this->facade);
565 
566  $DIC->ui()->mainTemplate()->setContent($bibGUI->getHTML());
567  } else {
568  $this->handleNonAccess();
569  }
570  }
571 
572 
573  public function view()
574  {
575  $this->showContent();
576  }
577 
578 
582  public function updateCustom(ilPropertyFormGUI $a_form)
583  {
584  global $DIC;
585 
586  if ($DIC->access()->checkAccess('write', "", $this->object->getRefId())) {
587  if ($this->object->getOnline() != $a_form->getInput("is_online")) {
588  $this->object->setOnline($a_form->getInput("is_online"));
589  }
590 
591  if (!empty($_FILES['bibliographic_file']['name'])) {
592  $this->addNews($this->object->getId(), 'updated');
593  }
594  } else {
595  $this->handleNonAccess();
596  }
597  }
598 
599 
600  public function toggleNotification()
601  {
602  global $DIC;
603 
604  switch ($_GET["ntf"]) {
605  case 1:
608  $DIC->user()
609  ->getId(),
611  false
612  );
613  break;
614  case 2:
617  $DIC->user()
618  ->getId(),
620  true
621  );
622  break;
623  }
624  $DIC->ctrl()->redirect($this, "");
625  }
626 
627 
631  public function addNews($obj_id, $change = 'created')
632  {
633  global $DIC;
634 
635  $ilNewsItem = new ilNewsItem();
636  $ilNewsItem->setTitle($DIC->language()->txt('news_title_' . $change));
637  $ilNewsItem->setPriority(NEWS_NOTICE);
638  $ilNewsItem->setContext($obj_id, $this->getType());
639  $ilNewsItem->setUserId($DIC->user()->getId());
640  $ilNewsItem->setVisibility(NEWS_USERS);
641  $ilNewsItem->setContentTextIsLangVar(false);
642  $ilNewsItem->create();
643  }
644 
645 
651  public function addToDeskObject()
652  {
653  global $DIC;
654 
656  ilUtil::sendSuccess($DIC->language()->txt("added_to_desktop"), true);
657  $this->ctrl->redirect($this, self::CMD_VIEW);
658  }
659 
660 
666  public function removeFromDeskObject()
667  {
668  global $DIC;
669 
671  ilUtil::sendSuccess($DIC->language()->txt("removed_from_desktop"), true);
672  $this->ctrl->redirect($this, self::CMD_VIEW);
673  }
674 
675 
681  public function addToDesk()
682  {
683  $this->addToDeskObject();
684  }
685 
686 
692  public function removeFromDesk()
693  {
694  $this->removeFromDeskObject();
695  }
696 
697 
701  protected function afterImport(ilObject $a_new_object)
702  {
706  $a_new_object->parseFileToDatabase();
707 
708  parent::afterImport($a_new_object);
709  }
710 
711 
712  private function handleNonAccess()
713  {
714  global $DIC;
715 
716  unset($_GET);
717  ilUtil::sendFailure($DIC->language()->txt("no_permission"), true);
719  }
720 }
infoScreenForward()
show information screen
removeFromDeskObject()
Remove from desktop.
Class ilObjBibliographicGUI.
Class ilInfoScreenGUI.
removeFromDesk()
Remove from desktop.
This class represents a property form user interface.
New implementation of ilObjectGUI.
GUI class for the workflow of copying objects.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
This class represents a file property in a property form.
updateCustom(ilPropertyFormGUI $a_form)
updateSettings
if(!array_key_exists('StateId', $_REQUEST)) $id
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.
static addToDesktop()
Add desktop item public.
sendFile()
provide file as a download
Export User Interface Class.
static deliverFileAttached($path_to_file, $download_file_name='', $mime_type='', $delete_file=false)
void
if(isset($_POST['submit'])) $form
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.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setTabs()
create tabs (repository/workspace switch)
addNews($obj_id, $change='created')
static removeFromDesktop()
Remove item from personal desktop public.
initEditCustomForm(ilPropertyFormGUI $a_form)
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
showContent()
shows the overview page with all entries in a table
prepareOutput($a_show_subobjects=true)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
const NEWS_USERS
Class ilObjBibliographic.
if(empty($password)) $table
Definition: pwgen.php:24
Class ilBiblEntryDetailPresentationGUI.
Class ilBiblFactoryFacade.
$info
Definition: index.php:5
addHeaderAction()
Add header action menu.
setSuffixes($a_suffixes)
Set Accepted Suffixes.
$html
Definition: example_001.php:87
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...