ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
23 {
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 CMD_VIEW = "view";
29  const TAB_EXPORT = "export";
30  const TAB_ID_RECORDS = "id_records";
31  const TAB_ID_PERMISSIONS = "id_permissions";
32  const TAB_ID_INFO = "id_info";
33  const CMD_SHOW_DETAILS = "showDetails";
34  const CMD_EDIT = "edit";
38  protected $bibl_obj;
42  protected $cmd = self::CMD_SHOW_CONTENT;
43 
44 
50  public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
51  {
52  global $DIC;
53  $this->lng = $DIC['lng'];
54  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
55  $this->lng->loadLanguageModule('bibl');
56  if ($a_id > 0) {
57  $this->bibl_obj = $this->object;
58  }
59  }
60 
61 
67  public function getStandardCmd()
68  {
69  return self::CMD_VIEW;
70  }
71 
72 
78  public function getType()
79  {
80  return "bibl";
81  }
82 
83 
87  public function executeCommand()
88  {
89  global $DIC;
90  $ilCtrl = $DIC['ilCtrl'];
91  $ilTabs = $DIC['ilTabs'];
92  $ilNavigationHistory = $DIC['ilNavigationHistory'];
93  $tpl = $DIC['tpl'];
94 
95  // Navigation History
96  $link = $ilCtrl->getLinkTarget($this, $this->getStandardCmd());
97  if ($this->object != null) {
98  $ilNavigationHistory->addItem($this->object->getRefId(), $link, "bibl");
99  $this->addHeaderAction();
100  }
101 
102  // general Access Check, especially for single entries not matching the object
103  if ($this->object instanceof ilObjBibliographic && !$DIC->access()->checkAccess('visible', "", $this->object->getRefId())) {
104  $this->handleNonAccess();
105  }
106 
107  $next_class = $ilCtrl->getNextClass($this);
108  $this->cmd = $ilCtrl->getCmd();
109  switch ($next_class) {
110  case "ilinfoscreengui":
111  $this->prepareOutput();
112  $ilTabs->activateTab(self::TAB_ID_INFO);
113  $this->infoScreenForward();
114  break;
115  case "ilcommonactiondispatchergui":
116  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
118  $this->ctrl->forwardCommand($gui);
119  break;
120  case "ilpermissiongui":
121  $this->prepareOutput();
122  $ilTabs->activateTab(self::TAB_ID_PERMISSIONS);
123  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
124  $perm_gui = new ilPermissionGUI($this);
125  $this->ctrl->forwardCommand($perm_gui);
126  break;
127  case "ilobjectcopygui":
128  include_once "./Services/Object/classes/class.ilObjectCopyGUI.php";
129  $cp = new ilObjectCopyGUI($this);
130  $cp->setType('bibl');
131  $tpl->getStandardTemplate();
132  $this->ctrl->forwardCommand($cp);
133  break;
134  case "ilobjfilegui":
135  $this->prepareOutput();
136  $ilTabs->setTabActive(self::TAB_ID_RECORDS);
137  include_once("./Modules/File/classes/class.ilObjFile.php");
138  $file_gui = new ilObjFile($this);
139  $this->ctrl->forwardCommand($file_gui);
140  break;
141  case "ilexportgui":
142  $this->prepareOutput();
143  $ilTabs->setTabActive(self::TAB_EXPORT);
144  $exp_gui = new ilExportGUI($this);
145  $exp_gui->addFormat("xml");
146  $this->ctrl->forwardCommand($exp_gui);
147  break;
148  default:
149  return parent::executeCommand();
150  }
151 
152  return true;
153  }
154 
155 
161  public function infoScreen()
162  {
163  $this->ctrl->setCmd("showSummary");
164  $this->ctrl->setCmdClass("ilinfoscreengui");
165  $this->infoScreenForward();
166  }
167 
168 
172  public function infoScreenForward()
173  {
174  global $DIC;
175 
176  if (!$this->checkPermissionBool("visible") && !$this->checkPermissionBool('read')) {
177  ilUtil::sendFailure($DIC['lng']->txt("msg_no_perm_read"), true);
178  $this->ctrl->redirectByClass('ilPersonalDesktopGUI', '');
179  }
180  $DIC['ilTabs']->activateTab(self::TAB_ID_INFO);
181  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
182  $info = new ilInfoScreenGUI($this);
183  $info->enablePrivateNotes();
184  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
185  $this->ctrl->forwardCommand($info);
186  }
187 
188 
189  /*
190  * addLocatorItems
191  */
192  public function addLocatorItems()
193  {
194  global $DIC;
195  $ilLocator = $DIC['ilLocator'];
196  if (is_object($this->object)) {
197  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
198  }
199  }
200 
201 
208  public static function _goto($a_target)
209  {
210  global $DIC;
211 
212  $id = explode("_", $a_target);
213  $DIC['ilCtrl']->setTargetScript("ilias.php");
214  $DIC['ilCtrl']->initBaseClass("ilRepositoryGUI");
215  $DIC['ilCtrl']->setParameterByClass("ilobjbibliographicgui", "ref_id", $id[0]);
216  // Detail-View
217  if ($id[1]) {
218  $DIC->ctrl()
219  ->setParameterByClass(ilObjBibliographicGUI::class, ilObjBibliographicGUI::P_ENTRY_ID, $id[1]);
220  $DIC->ctrl()->redirectByClass(
221  array(
222  ilRepositoryGUI::class,
223  ilObjBibliographicGUI::class,
224  ),
225  self::CMD_SHOW_DETAILS
226  );
227  } else {
228  $DIC->ctrl()->redirectByClass(
229  array(
230  ilRepositoryGUI::class,
231  ilObjBibliographicGUI::class,
232  ),
233  self::CMD_VIEW
234  );
235  }
236  }
237 
238 
244  protected function initCreationForms($a_new_type)
245  {
246  global $DIC;
247  $forms = parent::initCreationForms($a_new_type);
248  // Add File-Upload
249  $in_file = new ilFileInputGUI($DIC->language()->txt("bibliography file"), "bibliographic_file");
250  $in_file->setSuffixes(array("ris", "bib", "bibtex"));
251  $in_file->setRequired(true);
252  $forms[self::CFORM_NEW]->addItem($in_file);
253  $this->ctrl->saveParameterByClass('ilobjrootfoldergui', 'new_type');
254  $forms[self::CFORM_NEW]->setFormAction($this->ctrl->getFormActionByClass('ilobjrootfoldergui', "save"));
255 
256  return $forms;
257  }
258 
259 
260  public function save()
261  {
262  global $DIC;
263  $tpl = $DIC['tpl'];
264  $form = $this->initCreationForms($this->getType());
265  if ($form[self::CFORM_NEW]->checkInput()) {
266  parent::save();
267  } else {
268  $form = $form[self::CFORM_NEW];
269  $form->setValuesByPost();
270  $tpl->setContent($form->getHtml());
271  }
272  }
273 
274 
278  protected function afterSave(ilObject $a_new_object)
279  {
283  assert($a_new_object instanceof ilObjBibliographic);
284  $a_new_object->doUpdate();
285  $this->addNews($a_new_object->getId(), 'created');
286  $this->ctrl->redirect($this, self::CMD_EDIT);
287  }
288 
289 
296  public function setTabs()
297  {
298  global $DIC;
299  $ilAccess = $DIC['ilAccess'];
300  $ilTabs = $DIC['ilTabs'];
301  $lng = $DIC['lng'];
302  $ilHelp = $DIC['ilHelp'];
309  $ilHelp->setScreenIdComponent('bibl');
310  // info screen
311  if ($ilAccess->checkAccess('read', "", $this->object->getRefId())) {
312  $ilTabs->addTab(self::TAB_CONTENT, $lng->txt(self::TAB_CONTENT), $this->ctrl->getLinkTarget($this, self::CMD_SHOW_CONTENT));
313  }
314  // info screen
315  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()) || $ilAccess->checkAccess('read', "", $this->object->getRefId())) {
316  $ilTabs->addTab(self::TAB_ID_INFO, $lng->txt("info_short"), $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
317  }
318  // settings
319  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
320  $ilTabs->addTab("settings", $lng->txt("settings"), $this->ctrl->getLinkTarget($this, "editObject"));
321  }
322  // export
323  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
324  $ilTabs->addTab(self::TAB_EXPORT, $lng->txt(self::TAB_EXPORT), $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
325  }
326  // edit permissions
327  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
328  $ilTabs->addTab(self::TAB_ID_PERMISSIONS, $lng->txt("perm_settings"), $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"));
329  }
330  }
331 
332 
333  public function initEditForm()
334  {
335  global $DIC;
336  $lng = $DIC['lng'];
337  $form = parent::initEditForm();
338  // Add File-Upload
339  $in_file = new ilFileInputGUI($lng->txt("bibliography file"), "bibliographic_file");
340  $in_file->setSuffixes(array("ris", "bib", "bibtex"));
341  $in_file->setRequired(false);
342  $cb_override = new ilCheckboxInputGUI($this->lng->txt("override_entries"), "override_entries");
343  $cb_override->addSubItem($in_file);
344 
345  $form->addItem($cb_override);
346  $form->setFormAction($this->ctrl->getFormAction($this, "save"));
347 
348  return $form;
349  }
350 
351 
355  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
356  {
357  global $DIC;
358  $ilTabs = $DIC['ilTabs'];
359  $ilTabs->activateTab("settings");
360  // is_online
361  $cb = new ilCheckboxInputGUI($this->lng->txt("online"), "is_online");
362  $a_form->addItem($cb);
363  }
364 
365 
371  public function getEditFormCustomValues(array &$a_values)
372  {
373  $a_values["is_online"] = $this->object->getOnline();
374 
375  return $a_values;
376  }
377 
378 
379  public function render()
380  {
381  $this->showContent();
382  }
383 
384 
388  public function showContent()
389  {
390  global $DIC;
391  $ilAccess = $DIC['ilAccess'];
392  $ilCtrl = $DIC['ilCtrl'];
393  $ilTabs = $DIC['ilTabs'];
394  // if user has read permission and object is online OR user has write permissions
395  if (($ilAccess->checkAccess('read', "", $this->object->getRefId())
396  && $this->object->getOnline())
397  || $ilAccess->checkAccess('write', "", $this->object->getRefId())
398  ) {
399  $ilTabs->setTabActive(self::TAB_CONTENT);
400 
401  // With new UI service, currently not supported by ilToolbar
402  // $f = $DIC->ui()->factory()->button()
403  // ->primary($lng->txt("download_original_file"), $ilCtrl->getLinkTargetByClass("ilBibliographicDetailsGUI", "sendFile"));
404  // $ilToolbar->addText($DIC->ui()->renderer()->render($f));
405 
407  $b->setCaption('download_original_file');
408  $b->setUrl($ilCtrl->getLinkTargetByClass("ilBibliographicDetailsGUI", self::CMD_SEND_FILE));
409  $b->setPrimary(true);
410  $DIC['ilToolbar']->addButtonInstance($b);
411 
412  include_once "./Modules/Bibliographic/classes/class.ilBibliographicRecordListTableGUI.php";
413  $table = new ilBibliographicRecordListTableGUI($this, self::CMD_SHOW_CONTENT);
414  $html = $table->getHTML();
415  $DIC['tpl']->setContent($html);
416 
417  //Permanent Link
418  $DIC['tpl']->setPermanentLink("bibl", $this->object->getRefId());
419  } else {
420  //redirect to repository without any parameters
421  $this->handleNonAccess();
422  }
423  }
424 
425 
429  public function sendFile()
430  {
431  global $DIC;
432 
433  if ($DIC['ilAccess']->checkAccess('read', "", $this->object->getRefId())) {
434  $file_path = $this->bibl_obj->getLegacyAbsolutePath();
435  if ($file_path) {
436  if (is_file($file_path)) {
437  ilFileDelivery::deliverFileAttached($file_path, $this->bibl_obj->getFilename(), 'application/octet-stream');
438  } else {
439  ilUtil::sendFailure($DIC['lng']->txt("file_not_found"));
440  $this->showContent();
441  }
442  }
443  } else {
444  $this->handleNonAccess();
445  }
446  }
447 
448 
449  public function showDetails()
450  {
451  global $DIC;
452 
453  if ($DIC['ilAccess']->checkAccess('read', "", $this->object->getRefId())) {
454  $bibGUI = ilBibliographicDetailsGUI::getInstance($this->bibl_obj, $_GET[self::P_ENTRY_ID]);
455  $this->tpl->setContent($bibGUI->getHTML());
456  } else {
457  $this->handleNonAccess();
458  }
459  }
460 
461 
462  public function view()
463  {
464  $this->showContent();
465  }
466 
467 
471  public function updateCustom(ilPropertyFormGUI $a_form)
472  {
473  global $DIC;
474  $ilAccess = $DIC['ilAccess'];
475  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
476  if ($this->object->getOnline() != $a_form->getInput("is_online")) {
477  $this->object->setOnline($a_form->getInput("is_online"));
478  }
479 
480  if (!empty($_FILES['bibliographic_file']['name'])) {
481  $this->addNews($this->bibl_obj->getId(), 'updated');
482  }
483  } else {
484  $this->handleNonAccess();
485  }
486  }
487 
488 
489  public function toggleNotification()
490  {
491  global $DIC;
492  $ilCtrl = $DIC['ilCtrl'];
493  $ilUser = $DIC['ilUser'];
494  include_once "./Services/Notification/classes/class.ilNotification.php";
495  switch ($_GET["ntf"]) {
496  case 1:
498  break;
499  case 2:
501  break;
502  }
503  $ilCtrl->redirect($this, "");
504  }
505 
506 
510  public function addNews($obj_id, $change = 'created')
511  {
512  global $DIC;
513  $lng = $DIC['lng'];
514  $ilUser = $DIC['ilUser'];
515 
516  $ilNewsItem = new ilNewsItem();
517  $ilNewsItem->setTitle($lng->txt('news_title_' . $change));
518  $ilNewsItem->setPriority(NEWS_NOTICE);
519  $ilNewsItem->setContext($obj_id, $this->getType());
520  $ilNewsItem->setUserId($ilUser->getId());
521  $ilNewsItem->setVisibility(NEWS_USERS);
522  $ilNewsItem->setContentTextIsLangVar(false);
523  $ilNewsItem->create();
524  }
525 
526 
532  public function addToDeskObject()
533  {
534  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
536  ilUtil::sendSuccess($this->lng->txt("added_to_desktop"), true);
537  $this->ctrl->redirect($this, self::CMD_VIEW);
538  }
539 
540 
546  public function removeFromDeskObject()
547  {
548  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
550  ilUtil::sendSuccess($this->lng->txt("removed_from_desktop"), true);
551  $this->ctrl->redirect($this, self::CMD_VIEW);
552  }
553 
554 
560  public function addToDesk()
561  {
562  $this->addToDeskObject();
563  }
564 
565 
571  public function removeFromDesk()
572  {
573  $this->removeFromDeskObject();
574  }
575 
576 
580  protected function afterImport(ilObject $a_new_object)
581  {
585  $a_new_object->writeSourcefileEntriesToDb();
586  parent::afterImport($a_new_object);
587  }
588 
589 
590  private function handleNonAccess()
591  {
592  global $DIC;
593 
594  unset($_GET);
595  ilUtil::sendFailure($DIC->language()->txt("no_permission"), true);
597  }
598 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
infoScreenForward()
show information screen
removeFromDeskObject()
Remove from desktop.
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.
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.
addItem($a_item)
Add Item (Property, SectionHeader).
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
static getInstance(ilObjBibliographic $bibl_obj, $entry_id)
static addToDesktop()
Add desktop item public.
sendFile()
provide file as a download
global $ilCtrl
Definition: ilias.php:18
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
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)
$ilUser
Definition: imgupload.php:18
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
Create styles array
The data for the language used.
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.
Create new PHPExcel object
obj_idprivate
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
$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...