ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDclRecordListGUI Class Reference
+ Collaboration diagram for ilDclRecordListGUI:

Public Member Functions

 __construct (ilObjDataCollectionGUI $a_parent_obj, $table_id)
 
 executeCommand ()
 execute command More...
 
 showImportExcel ($form=null)
 
 initImportForm ()
 Init form. More...
 
 importExcel ()
 Import Data from Excel sheet. More...
 
 endImport ($i, $warnings)
 End import. More...
 
 doTableSwitch ()
 doTableSwitch More...
 
 doTableViewSwitch ()
 doTableViewSwitch More...
 
 sendFile ()
 send File to User More...
 

Data Fields

const GET_TABLE_ID = 'table_id'
 
const GET_TABLEVIEW_ID = 'tableview_id'
 
const GET_MODE = 'mode'
 
const MODE_VIEW = 1
 
const MODE_MANAGE = 2
 
const CMD_LIST_RECORDS = 'listRecords'
 
const CMD_SHOW = 'show'
 
const CMD_CONFIRM_DELETE_RECORDS = 'confirmDeleteRecords'
 
const CMD_CANCEL_DELETE = 'cancelDelete'
 
const CMD_DELETE_RECORDS = 'deleteRecords'
 
const CMD_SHOW_IMPORT_EXCEL = 'showImportExcel'
 

Protected Member Functions

 applyFilter ()
 
 resetFilter ()
 
 getAvailableTables ()
 
 getRecordListTableGUI ($use_tableview_filter)
 
 createSwitchers ()
 
 checkAccess ()
 

Protected Attributes

 $mode = self::MODE_VIEW
 
 $table_obj
 
 $ctrl
 
 $lng
 
 $tableview_id
 

Static Protected Attributes

static $available_modes = array(self::MODE_VIEW, self::MODE_MANAGE)
 

Private Member Functions

 importRecords ($file, $simulate=false)
 Import records from Excel file. More...
 
 recordBelongsToCollection (ilDclBaseRecordModel $record)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDclRecordListGUI::__construct ( ilObjDataCollectionGUI  $a_parent_obj,
  $table_id 
)
Parameters
ilObjDataCollectionGUI$a_parent_obj
$table_id

Definition at line 59 of file class.ilDclRecordListGUI.php.

References $_GET, $DIC, $lng, $tableview_id, and ilDclCache\getTableCache().

60  {
61  global $DIC;
62  $ilCtrl = $DIC['ilCtrl'];
63  $lng = $DIC['lng'];
64  $this->ctrl = $ilCtrl;
65  $this->lng = $lng;
66 
67  $this->table_id = $table_id;
68  if ($this->table_id == null) {
69  $this->table_id = filter_input(INPUT_GET, self::GET_TABLE_ID);
70  }
71 
72  $this->obj_id = $a_parent_obj->obj_id;
73  $this->parent_obj = $a_parent_obj;
74  $this->table_obj = ilDclCache::getTableCache($table_id);
75 
76  if ($tableview_id = filter_input(INPUT_GET, self::GET_TABLEVIEW_ID)) {
77  $this->tableview_id = $tableview_id;
78  } else {
79  //get first visible tableview
80  $this->tableview_id = $this->table_obj->getFirstTableViewId($this->parent_obj->ref_id);
81  //this is for ilDclTextRecordRepresentation with link to detail page
82  $_GET[self::GET_TABLEVIEW_ID] = $this->tableview_id; //TODO: find better way
83  }
84 
85  $this->ctrl->setParameterByClass(ilDclRecordEditGUI::class, self::GET_TABLE_ID, $this->table_id);
86  $this->ctrl->setParameterByClass(ilDclRecordEditGUI::class, self::GET_TABLEVIEW_ID, $this->tableview_id);
87  $this->ctrl->setParameterByClass(ilDclDetailedViewGUI::class, self::GET_TABLEVIEW_ID, $this->tableview_id);
88  $this->mode = (isset($_GET[self::GET_MODE]) && in_array($_GET[self::GET_MODE], self::$available_modes)) ? (int) $_GET[self::GET_MODE] : self::MODE_VIEW;
89  }
$_GET["client_id"]
static getTableCache($table_id=0)
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilter()

ilDclRecordListGUI::applyFilter ( )
protected

Definition at line 324 of file class.ilDclRecordListGUI.php.

325  {
326  $table = new ilDclRecordListTableGUI($this, "listRecords", $this->table_obj, $this->tableview_id);
327  $table->initFilter();
328  $table->resetOffset();
329  $table->writeFilterToSession();
330  $this->ctrl->redirect($this, self::CMD_LIST_RECORDS);
331  }

◆ checkAccess()

ilDclRecordListGUI::checkAccess ( )
protected
Returns
bool

Definition at line 619 of file class.ilDclRecordListGUI.php.

Referenced by executeCommand().

620  {
621  return ilObjDataCollectionAccess::hasAccessTo($this->parent_obj->ref_id, $this->table_id, $this->tableview_id);
622  }
+ Here is the caller graph for this function:

◆ createSwitchers()

ilDclRecordListGUI::createSwitchers ( )
protected

Definition at line 572 of file class.ilDclRecordListGUI.php.

References $DIC, getAvailableTables(), and ilSubmitButton\getInstance().

Referenced by executeCommand().

573  {
574  global $DIC;
575  $ilToolbar = $DIC['ilToolbar'];
576  $ilToolbar->setFormAction($this->ctrl->getFormActionByClass("ilDclRecordListGUI", "doTableSwitch"));
577 
578  //table switcher
579  $options = $this->getAvailableTables();
580  if (count($options) > 1) {
581  $table_selection = new ilSelectInputGUI('', 'table_id');
582  $table_selection->setOptions($options);
583  $table_selection->setValue($this->table_id);
584 
585  $ilToolbar->addText($this->lng->txt("dcl_table"));
586  $ilToolbar->addInputItem($table_selection);
587  $button = ilSubmitButton::getInstance();
588  $button->setCaption('change');
589  $button->setCommand('doTableSwitch');
590  $ilToolbar->addButtonInstance($button);
591  $ilToolbar->addSeparator();
592  }
593 
594  //tableview switcher
595  $options = array();
596  foreach ($this->table_obj->getVisibleTableViews($this->parent_obj->ref_id) as $tableview) {
597  $options[$tableview->getId()] = $tableview->getTitle();
598  }
599 
600  if (count($options) > 1) {
601  $tableview_selection = new ilSelectInputGUI('', 'tableview_id');
602  $tableview_selection->setOptions($options);
603  $tableview_selection->setValue($this->tableview_id);
604  $ilToolbar->addText($this->lng->txt("dcl_tableview"));
605  $ilToolbar->addInputItem($tableview_selection);
606 
607  $button = ilSubmitButton::getInstance();
608  $button->setCaption('change');
609  $button->setCommand('doTableViewSwitch');
610  $ilToolbar->addButtonInstance($button);
611  $ilToolbar->addSeparator();
612  }
613  }
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doTableSwitch()

ilDclRecordListGUI::doTableSwitch ( )

doTableSwitch

Definition at line 301 of file class.ilDclRecordListGUI.php.

References $_POST.

302  {
303  $this->ctrl->clearParameters($this);
304  $this->ctrl->setParameterByClass(ilObjDataCollectionGUI::class, "table_id", $_POST['table_id']);
305  $this->ctrl->setParameter($this, "table_id", $_POST['table_id']);
306  $this->ctrl->clearParametersByClass(ilObjDataCollectionGUI::class, 'tableview_id');
307  $this->ctrl->redirect($this, self::CMD_SHOW);
308  }
$_POST["username"]

◆ doTableViewSwitch()

ilDclRecordListGUI::doTableViewSwitch ( )

doTableViewSwitch

Definition at line 314 of file class.ilDclRecordListGUI.php.

References $_POST.

315  {
316  $this->ctrl->setParameterByClass("ilObjDataCollectionGUI", "tableview_id", $_POST['tableview_id']);
317  $this->ctrl->redirect($this, self::CMD_SHOW);
318  }
$_POST["username"]

◆ endImport()

ilDclRecordListGUI::endImport (   $i,
  $warnings 
)

End import.

Parameters
$i
$warnings

Definition at line 276 of file class.ilDclRecordListGUI.php.

References $DIC, $i, and $tpl.

Referenced by importRecords().

277  {
278  global $DIC;
279  $tpl = $DIC['tpl'];
280  $output = new ilTemplate("tpl.dcl_import_terminated.html", true, true, "Modules/DataCollection");
281  $output->setVariable("IMPORT_TERMINATED", $this->lng->txt("dcl_import_terminated") . ": " . $i);
282  foreach ($warnings as $warning) {
283  $output->setCurrentBlock("warnings");
284  $output->setVariable("WARNING", $warning);
285  $output->parseCurrentBlock();
286  }
287  if (!count($warnings)) {
288  $output->setCurrentBlock("warnings");
289  $output->setVariable("WARNING", $this->lng->txt("dcl_no_warnings"));
290  $output->parseCurrentBlock();
291  }
292  $output->setVariable("BACK_LINK", $this->ctrl->getLinkTargetByClass("ilDclRecordListGUI", "listRecords"));
293  $output->setVariable("BACK", $this->lng->txt("back"));
294  $tpl->setContent($output->get());
295  }
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$i
Definition: metadata.php:24
+ Here is the caller graph for this function:

◆ executeCommand()

ilDclRecordListGUI::executeCommand ( )

execute command

Definition at line 95 of file class.ilDclRecordListGUI.php.

References $DIC, $ilSetting, $tpl, checkAccess(), createSwitchers(), ilLinkButton\getInstance(), getRecordListTableGUI(), ilObjDataCollectionAccess\hasAccessToFields(), ilObjDataCollectionAccess\hasPermissionToAddRecord(), ilUtil\sendFailure(), ilUtil\sendInfo(), and ilUtil\stripSlashes().

96  {
97  global $DIC;
98  $ilTabs = $DIC['ilTabs'];
99 
100  if (!$this->checkAccess()) {
101  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
102 
103  return;
104  }
105 
106  $this->ctrl->saveParameter($this, self::GET_MODE);
107  $cmd = $this->ctrl->getCmd(self::CMD_SHOW);
108 
109  // 'show' fills all filters with the predefined values from the tableview,
110  // whereas 'listRecords' handels the filters "normally", filling them from the POST-variable
111  switch ($cmd) {
112  case self::CMD_SHOW:
113  $this->setSubTabs();
114  $this->listRecords(true);
115  break;
116  case self::CMD_LIST_RECORDS:
117  $this->setSubTabs();
118  $this->listRecords();
119  break;
120  case self::CMD_CONFIRM_DELETE_RECORDS:
121  $this->confirmDeleteRecords();
122  break;
123  case self::CMD_CANCEL_DELETE:
124  $this->setSubTabs();
125  $this->listRecords();
126  break;
127  case self::CMD_DELETE_RECORDS:
128  $this->deleteRecords();
129  break;
130  case self::CMD_SHOW_IMPORT_EXCEL:
131  $ilTabs->setBack2Target($this->lng->txt('back'), $this->ctrl->getLinkTarget($this));
132  $this->$cmd();
133  break;
134 
135  default:
136  $this->$cmd();
137  break;
138  }
139  }
global $DIC
Definition: goto.php:24
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setSubTabs($a_tab)
set sub tabs
+ Here is the call graph for this function:

◆ getAvailableTables()

ilDclRecordListGUI::getAvailableTables ( )
protected
Returns
array

Definition at line 504 of file class.ilDclRecordListGUI.php.

References ilObjDataCollectionAccess\hasWriteAccess().

Referenced by createSwitchers().

505  {
506  if (ilObjDataCollectionAccess::hasWriteAccess($this->parent_obj->ref_id)) {
507  $tables = $this->parent_obj->object->getTables();
508  } else {
509  $tables = $this->parent_obj->object->getVisibleTables();
510  }
511  $options = array();
512  foreach ($tables as $table) {
513  $options[$table->getId()] = $table->getTitle();
514  }
515 
516  return $options;
517  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRecordListTableGUI()

ilDclRecordListGUI::getRecordListTableGUI (   $use_tableview_filter)
protected
Parameters
$use_tableview_filter
Returns
array

Definition at line 525 of file class.ilDclRecordListGUI.php.

References $data, $table_obj, and $total.

Referenced by executeCommand().

526  {
528 
529  $list = new ilDclRecordListTableGUI($this, "listRecords", $table_obj, $this->tableview_id, $this->mode);
530  if ($use_tableview_filter) {
531  $list->initFilter();
532  $list->resetOffset();
533  $list->resetFilter();
534  $list->initFilterFromTableView();
535  } else {
536  $list->initFilter();
537  }
538 
539  $list->setExternalSegmentation(true);
540  $list->setExternalSorting(true);
541  $list->determineOffsetAndOrder();
542 
543  $limit = $list->getLimit();
544  $offset = $list->getOffset();
545 
546  $num_records = count($table_obj->getPartialRecords($list->getOrderField(), $list->getOrderDirection(), $limit, $offset, $list->getFilter()));
547 
548  // Fix no data found on new filter application when on a site other than the first
549  if ($num_records === 0) {
550  $list->resetOffset();
551  $offset = 0;
552  }
553 
554  $data = $table_obj->getPartialRecords($list->getOrderField(), $list->getOrderDirection(), $limit, $offset, $list->getFilter());
555  $records = $data['records'];
556  $total = $data['total'];
557 
558  $list->setMaxCount($total);
559  $list->setRecordData($records);
560 
561  $list->determineOffsetAndOrder();
562  $list->determineLimit();
563 
564  return $list;
565  }
$data
Definition: storeScorm.php:23
$total
Definition: Utf8Test.php:87
+ Here is the caller graph for this function:

◆ importExcel()

ilDclRecordListGUI::importExcel ( )

Import Data from Excel sheet.

Definition at line 238 of file class.ilDclRecordListGUI.php.

References ilObjDataCollectionAccess\hasPermissionToAddRecord(), importRecords(), initImportForm(), and showImportExcel().

239  {
240  if (!(ilObjDataCollectionAccess::hasPermissionToAddRecord($this->parent_obj->ref_id, $this->table_id)) || !$this->table_obj->getImportEnabled()) {
241  throw new ilDclException($this->lng->txt("access_denied"));
242  }
243  $form = $this->initImportForm();
244  if ($form->checkInput()) {
245  $file = $form->getInput("import_file");
246  $file_location = $file["tmp_name"];
247  $simulate = $form->getInput("simulate");
248  $this->importRecords($file_location, $simulate);
249  } else {
250  $this->showImportExcel($form);
251  }
252  }
static hasPermissionToAddRecord($ref_id, $table_id)
importRecords($file, $simulate=false)
Import records from Excel file.
Class ilDclException.
+ Here is the call graph for this function:

◆ importRecords()

ilDclRecordListGUI::importRecords (   $file,
  $simulate = false 
)
private

Import records from Excel file.

Parameters
$file
bool$simulate

Definition at line 261 of file class.ilDclRecordListGUI.php.

References $result, and endImport().

Referenced by importExcel().

262  {
263  $importer = new ilDclContentImporter($this->parent_obj->object->getRefId(), $this->table_id);
264  $result = $importer->import($file, $simulate);
265 
266  $this->endImport($result['line'], $result['warnings']);
267  }
endImport($i, $warnings)
End import.
$result
Hook-Class for exporting data-collections (used in SOAP-Class) This Class avoids duplicated code by r...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initImportForm()

ilDclRecordListGUI::initImportForm ( )

Init form.

Returns
ilPropertyFormGUI

Definition at line 212 of file class.ilDclRecordListGUI.php.

References ilFormPropertyGUI\setInfo(), and ilFormPropertyGUI\setRequired().

Referenced by importExcel(), and showImportExcel().

213  {
214  $form = new ilPropertyFormGUI();
215 
216  $item = new ilCustomInputGUI();
217  $item->setHtml($this->lng->txt('dcl_file_format_description'));
218  $item->setTitle("Info");
219  $form->addItem($item);
220 
221  $file = new ilFileInputGUI($this->lng->txt("import_file"), "import_file");
222  $file->setRequired(true);
223  $form->addItem($file);
224 
225  $cb = new ilCheckboxInputGUI($this->lng->txt("dcl_simulate_import"), "simulate");
226  $cb->setInfo($this->lng->txt("dcl_simulate_info"));
227  $form->addItem($cb);
228 
229  $form->addCommandButton("importExcel", $this->lng->txt("import"));
230 
231  return $form;
232  }
This class represents a property form user interface.
This class represents a file property in a property form.
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Information Text.
This class represents a custom property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recordBelongsToCollection()

ilDclRecordListGUI::recordBelongsToCollection ( ilDclBaseRecordModel  $record)
private
Parameters
ilDclBaseRecordModel$record
Returns
bool

Definition at line 463 of file class.ilDclRecordListGUI.php.

References $_GET, $DIC, $mode, and ilDclBaseRecordModel\getTable().

Referenced by sendFile().

464  {
465  $table = $record->getTable();
466  $obj_id = $this->parent_obj->object->getId();
467  $obj_id_rec = $table->getCollectionObject()->getId();
468 
469  return $obj_id == $obj_id_rec;
470  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetFilter()

ilDclRecordListGUI::resetFilter ( )
protected

Definition at line 337 of file class.ilDclRecordListGUI.php.

338  {
339  $table = new ilDclRecordListTableGUI($this, "show", $this->table_obj, $this->tableview_id);
340  $table->initFilter();
341  $table->resetOffset();
342  $table->resetFilter();
343  $this->ctrl->redirect($this, self::CMD_LIST_RECORDS);
344  }

◆ sendFile()

ilDclRecordListGUI::sendFile ( )

send File to User

Definition at line 350 of file class.ilDclRecordListGUI.php.

References $_GET, $_POST, $DIC, $ilUser, $tpl, ilUtil\deliverFile(), ilDclCache\getRecordCache(), ilDclCache\getRecordFieldCache(), ilDclCache\getRecordRepresentation(), ilDclPropertyFormGUI\rebuildTempFileByHash(), recordBelongsToCollection(), and ilUtil\sendInfo().

351  {
352  global $DIC;
353  $ilAccess = $DIC['ilAccess'];
354  $ilUser = $DIC['ilUser'];
355  //need read access to receive file
356  if ($ilAccess->checkAccess("read", "", $this->parent_obj->ref_id)) {
357 
358  // deliver temp-files
359  if (isset($_GET['ilfilehash'])) {
360  $filehash = $_GET['ilfilehash'];
361  $field_id = $_GET['field_id'];
363 
364  $filepath = $_FILES["field_" . $field_id]['tmp_name'];
365  $filetitle = $_FILES["field_" . $field_id]['name'];
366  } else {
367  $rec_id = $_GET['record_id'];
368  $record = ilDclCache::getRecordCache($rec_id);
369  $field_id = $_GET['field_id'];
370  $file_obj = new ilObjFile($record->getRecordFieldValue($field_id), false);
371  if (!$this->recordBelongsToCollection($record, $this->parent_obj->ref_id)) {
372  return;
373  }
374  $filepath = $file_obj->getFile();
375  $filetitle = $file_obj->getTitle();
376  }
377 
378  ilUtil::deliverFile($filepath, $filetitle);
379  }
380  }
$_GET["client_id"]
recordBelongsToCollection(ilDclBaseRecordModel $record)
static rebuildTempFileByHash($hash)
Return temp files.
static getRecordCache($record_id=0)
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
+ Here is the call graph for this function:

◆ showImportExcel()

ilDclRecordListGUI::showImportExcel (   $form = null)

Definition at line 196 of file class.ilDclRecordListGUI.php.

References $DIC, $tpl, and initImportForm().

Referenced by importExcel().

197  {
198  global $DIC;
199  $tpl = $DIC['tpl'];
200  if (!$form) {
201  $form = $this->initImportForm();
202  }
203  $tpl->setContent($form->getHTML());
204  }
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $available_modes

ilDclRecordListGUI::$available_modes = array(self::MODE_VIEW, self::MODE_MANAGE)
staticprotected

Definition at line 52 of file class.ilDclRecordListGUI.php.

◆ $ctrl

ilDclRecordListGUI::$ctrl
protected

Definition at line 40 of file class.ilDclRecordListGUI.php.

◆ $lng

ilDclRecordListGUI::$lng
protected

Definition at line 44 of file class.ilDclRecordListGUI.php.

Referenced by __construct().

◆ $mode

ilDclRecordListGUI::$mode = self::MODE_VIEW
protected

Definition at line 32 of file class.ilDclRecordListGUI.php.

Referenced by recordBelongsToCollection().

◆ $table_obj

ilDclRecordListGUI::$table_obj
protected

Definition at line 36 of file class.ilDclRecordListGUI.php.

Referenced by getRecordListTableGUI().

◆ $tableview_id

ilDclRecordListGUI::$tableview_id
protected

Definition at line 48 of file class.ilDclRecordListGUI.php.

Referenced by __construct().

◆ CMD_CANCEL_DELETE

const ilDclRecordListGUI::CMD_CANCEL_DELETE = 'cancelDelete'

Definition at line 24 of file class.ilDclRecordListGUI.php.

◆ CMD_CONFIRM_DELETE_RECORDS

const ilDclRecordListGUI::CMD_CONFIRM_DELETE_RECORDS = 'confirmDeleteRecords'

Definition at line 23 of file class.ilDclRecordListGUI.php.

◆ CMD_DELETE_RECORDS

const ilDclRecordListGUI::CMD_DELETE_RECORDS = 'deleteRecords'

Definition at line 25 of file class.ilDclRecordListGUI.php.

◆ CMD_LIST_RECORDS

const ilDclRecordListGUI::CMD_LIST_RECORDS = 'listRecords'

◆ CMD_SHOW

const ilDclRecordListGUI::CMD_SHOW = 'show'

Definition at line 22 of file class.ilDclRecordListGUI.php.

◆ CMD_SHOW_IMPORT_EXCEL

const ilDclRecordListGUI::CMD_SHOW_IMPORT_EXCEL = 'showImportExcel'

Definition at line 26 of file class.ilDclRecordListGUI.php.

◆ GET_MODE

const ilDclRecordListGUI::GET_MODE = 'mode'

Definition at line 18 of file class.ilDclRecordListGUI.php.

◆ GET_TABLE_ID

const ilDclRecordListGUI::GET_TABLE_ID = 'table_id'

Definition at line 16 of file class.ilDclRecordListGUI.php.

◆ GET_TABLEVIEW_ID

const ilDclRecordListGUI::GET_TABLEVIEW_ID = 'tableview_id'

Definition at line 17 of file class.ilDclRecordListGUI.php.

◆ MODE_MANAGE

const ilDclRecordListGUI::MODE_MANAGE = 2

◆ MODE_VIEW

const ilDclRecordListGUI::MODE_VIEW = 1

Definition at line 19 of file class.ilDclRecordListGUI.php.


The documentation for this class was generated from the following file: