ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 62 of file class.ilDclRecordListGUI.php.

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

References $_GET, $DIC, $ilCtrl, $lng, $tableview_id, GET_MODE, GET_TABLEVIEW_ID, ilDclCache\getTableCache(), and MODE_VIEW.

+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilter()

ilDclRecordListGUI::applyFilter ( )
protected

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

329 {
330 $table = new ilDclRecordListTableGUI($this, "listRecords", $this->table_obj, $this->tableview_id);
331 $table->initFilter();
332 $table->resetOffset();
333 $table->writeFilterToSession();
334 $this->ctrl->redirect($this, self::CMD_LIST_RECORDS);
335 }
if(empty($password)) $table
Definition: pwgen.php:24

References $table.

◆ checkAccess()

ilDclRecordListGUI::checkAccess ( )
protected
Returns
bool

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

624 {
625 return ilObjDataCollectionAccess::hasAccessTo($this->parent_obj->ref_id, $this->table_id, $this->tableview_id);
626 }

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ createSwitchers()

ilDclRecordListGUI::createSwitchers ( )
protected

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

576 {
577 global $DIC;
578 $ilToolbar = $DIC['ilToolbar'];
579 $ilToolbar->setFormAction($this->ctrl->getFormActionByClass("ilDclRecordListGUI", "doTableSwitch"));
580
581 //table switcher
582 $options = $this->getAvailableTables();
583 if (count($options) > 1) {
584 include_once './Services/Form/classes/class.ilSelectInputGUI.php';
585 $table_selection = new ilSelectInputGUI('', 'table_id');
586 $table_selection->setOptions($options);
587 $table_selection->setValue($this->table_id);
588
589 $ilToolbar->addText($this->lng->txt("dcl_table"));
590 $ilToolbar->addInputItem($table_selection);
591 $button = ilSubmitButton::getInstance();
592 $button->setCaption('change');
593 $button->setCommand('doTableSwitch');
594 $ilToolbar->addButtonInstance($button);
595 $ilToolbar->addSeparator();
596 }
597
598 //tableview switcher
599 $options = array();
600 foreach ($this->table_obj->getVisibleTableViews($this->parent_obj->ref_id) as $tableview) {
601 $options[$tableview->getId()] = $tableview->getTitle();
602 }
603
604 if (count($options) > 1) {
605 $tableview_selection = new ilSelectInputGUI('', 'tableview_id');
606 $tableview_selection->setOptions($options);
607 $tableview_selection->setValue($this->tableview_id);
608 $ilToolbar->addText($this->lng->txt("dcl_tableview"));
609 $ilToolbar->addInputItem($tableview_selection);
610
611 $button = ilSubmitButton::getInstance();
612 $button->setCaption('change');
613 $button->setCommand('doTableViewSwitch');
614 $ilToolbar->addButtonInstance($button);
615 $ilToolbar->addSeparator();
616 }
617 }
This class represents a selection list property in a property form.
static getInstance()
Factory.

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

+ Here is the call graph for this function:

◆ doTableSwitch()

ilDclRecordListGUI::doTableSwitch ( )

doTableSwitch

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

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

References $_POST.

◆ doTableViewSwitch()

ilDclRecordListGUI::doTableViewSwitch ( )

doTableViewSwitch

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

319 {
320 $this->ctrl->setParameterByClass("ilObjDataCollectionGUI", "tableview_id", $_POST['tableview_id']);
321 $this->ctrl->redirect($this, self::CMD_SHOW);
322 }

References $_POST.

◆ endImport()

ilDclRecordListGUI::endImport (   $i,
  $warnings 
)

End import.

Parameters
$i
$warnings

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

281 {
282 global $DIC;
283 $tpl = $DIC['tpl'];
284 $output = new ilTemplate("tpl.dcl_import_terminated.html", true, true, "Modules/DataCollection");
285 $output->setVariable("IMPORT_TERMINATED", $this->lng->txt("dcl_import_terminated") . ": " . $i);
286 foreach ($warnings as $warning) {
287 $output->setCurrentBlock("warnings");
288 $output->setVariable("WARNING", $warning);
289 $output->parseCurrentBlock();
290 }
291 if (!count($warnings)) {
292 $output->setCurrentBlock("warnings");
293 $output->setVariable("WARNING", $this->lng->txt("dcl_no_warnings"));
294 $output->parseCurrentBlock();
295 }
296 $output->setVariable("BACK_LINK", $this->ctrl->getLinkTargetByClass("ilDclRecordListGUI", "listRecords"));
297 $output->setVariable("BACK", $this->lng->txt("back"));
298 $tpl->setContent($output->get());
299 }
$tpl
Definition: ilias.php:10
$warning
Definition: X509warning.php:13
special template class to simplify handling of ITX/PEAR
$i
Definition: disco.tpl.php:19

References $DIC, $i, Sabre\VObject\$output, $tpl, $warning, and $warnings.

Referenced by importRecords().

+ Here is the caller graph for this function:

◆ executeCommand()

ilDclRecordListGUI::executeCommand ( )

execute command

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

99 {
100 global $DIC;
101 $ilTabs = $DIC['ilTabs'];
102
103 if (!$this->checkAccess()) {
104 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
105
106 return;
107 }
108
109 $this->ctrl->saveParameter($this, self::GET_MODE);
110 $cmd = $this->ctrl->getCmd(self::CMD_SHOW);
111
112 // 'show' fills all filters with the predefined values from the tableview,
113 // whereas 'listRecords' handels the filters "normally", filling them from the POST-variable
114 switch ($cmd) {
115 case self::CMD_SHOW:
116 $this->setSubTabs();
117 $this->listRecords(true);
118 break;
120 $this->setSubTabs();
121 $this->listRecords();
122 break;
124 $this->confirmDeleteRecords();
125 break;
127 $this->setSubTabs();
128 $this->listRecords();
129 break;
131 $this->deleteRecords();
132 break;
134 $ilTabs->setBack2Target($this->lng->txt('back'), $this->ctrl->getLinkTarget($this));
135 $this->$cmd();
136 break;
137
138 default:
139 $this->$cmd();
140 break;
141 }
142 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $DIC, checkAccess(), CMD_CANCEL_DELETE, CMD_CONFIRM_DELETE_RECORDS, CMD_DELETE_RECORDS, CMD_LIST_RECORDS, CMD_SHOW, CMD_SHOW_IMPORT_EXCEL, and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ getAvailableTables()

ilDclRecordListGUI::getAvailableTables ( )
protected
Returns
array

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

509 {
510 if (ilObjDataCollectionAccess::hasWriteAccess($this->parent_obj->ref_id)) {
511 $tables = $this->parent_obj->object->getTables();
512 } else {
513 $tables = $this->parent_obj->object->getVisibleTables();
514 }
515 $options = array();
516 foreach ($tables as $table) {
517 $options[$table->getId()] = $table->getTitle();
518 }
519
520 return $options;
521 }

References PHPMailer\PHPMailer\$options, $table, and ilObjDataCollectionAccess\hasWriteAccess().

Referenced by createSwitchers().

+ 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 529 of file class.ilDclRecordListGUI.php.

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

References $data, $list, $records, $table_obj, and $total.

◆ importExcel()

ilDclRecordListGUI::importExcel ( )

Import Data from Excel sheet.

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

243 {
244 if (!(ilObjDataCollectionAccess::hasPermissionToAddRecord($this->parent_obj->ref_id, $this->table_id)) || !$this->table_obj->getImportEnabled()) {
245 throw new ilDclException($this->lng->txt("access_denied"));
246 }
247 $form = $this->initImportForm();
248 if ($form->checkInput()) {
249 $file = $form->getInput("import_file");
250 $file_location = $file["tmp_name"];
251 $simulate = $form->getInput("simulate");
252 $this->importRecords($file_location, $simulate);
253 } else {
254 $this->showImportExcel($form);
255 }
256 }
Class ilDclException.
importRecords($file, $simulate=false)
Import records from Excel file.
static hasPermissionToAddRecord($ref_id, $table_id)
if(isset($_POST['submit'])) $form

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

+ 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 265 of file class.ilDclRecordListGUI.php.

266 {
267 $importer = new ilDclContentImporter($this->parent_obj->object->getRefId(), $this->table_id);
268 $result = $importer->import($file, $simulate);
269
270 $this->endImport($result['line'], $result['warnings']);
271 }
$result
Hook-Class for exporting data-collections (used in SOAP-Class) This Class avoids duplicated code by r...
endImport($i, $warnings)
End import.

References $result, and endImport().

Referenced by importExcel().

+ 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 215 of file class.ilDclRecordListGUI.php.

216 {
217 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
218 $form = new ilPropertyFormGUI();
219
220 $item = new ilCustomInputGUI();
221 $item->setHtml($this->lng->txt('dcl_file_format_description'));
222 $item->setTitle("Info");
223 $form->addItem($item);
224
225 $file = new ilFileInputGUI($this->lng->txt("import_file"), "import_file");
226 $file->setRequired(true);
227 $form->addItem($file);
228
229 $cb = new ilCheckboxInputGUI($this->lng->txt("dcl_simulate_import"), "simulate");
230 $cb->setInfo($this->lng->txt("dcl_simulate_info"));
231 $form->addItem($cb);
232
233 $form->addCommandButton("importExcel", $this->lng->txt("import"));
234
235 return $form;
236 }
This class represents a checkbox property in a property form.
This class represents a custom property in a property form.
This class represents a file property in a property form.
This class represents a property form user interface.

References $form.

Referenced by importExcel(), and showImportExcel().

+ Here is the caller graph for this function:

◆ recordBelongsToCollection()

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

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

468 {
469 $table = $record->getTable();
470 $obj_id = $this->parent_obj->object->getId();
471 $obj_id_rec = $table->getCollectionObject()->getId();
472
473 return $obj_id == $obj_id_rec;
474 }

References $table, and ilDclBaseRecordModel\getTable().

Referenced by sendFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetFilter()

ilDclRecordListGUI::resetFilter ( )
protected

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

342 {
343 $table = new ilDclRecordListTableGUI($this, "show", $this->table_obj, $this->tableview_id);
344 $table->initFilter();
345 $table->resetOffset();
346 $table->resetFilter();
347 $this->ctrl->redirect($this, self::CMD_LIST_RECORDS);
348 }

References $table.

◆ sendFile()

ilDclRecordListGUI::sendFile ( )

send File to User

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

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

References $_GET, $DIC, $ilUser, ilUtil\deliverFile(), ilDclCache\getRecordCache(), ilDclPropertyFormGUI\rebuildTempFileByHash(), and recordBelongsToCollection().

+ Here is the call graph for this function:

◆ showImportExcel()

ilDclRecordListGUI::showImportExcel (   $form = null)

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

200 {
201 global $DIC;
202 $tpl = $DIC['tpl'];
203 if (!$form) {
204 $form = $this->initImportForm();
205 }
206 $tpl->setContent($form->getHTML());
207 }

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

Referenced by importExcel().

+ 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 55 of file class.ilDclRecordListGUI.php.

◆ $ctrl

ilDclRecordListGUI::$ctrl
protected

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

◆ $lng

ilDclRecordListGUI::$lng
protected

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

Referenced by __construct().

◆ $mode

ilDclRecordListGUI::$mode = self::MODE_VIEW
protected

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

◆ $table_obj

ilDclRecordListGUI::$table_obj
protected

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

Referenced by getRecordListTableGUI().

◆ $tableview_id

ilDclRecordListGUI::$tableview_id
protected

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

Referenced by __construct().

◆ CMD_CANCEL_DELETE

const ilDclRecordListGUI::CMD_CANCEL_DELETE = 'cancelDelete'

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

Referenced by executeCommand().

◆ CMD_CONFIRM_DELETE_RECORDS

const ilDclRecordListGUI::CMD_CONFIRM_DELETE_RECORDS = 'confirmDeleteRecords'

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

Referenced by executeCommand().

◆ CMD_DELETE_RECORDS

const ilDclRecordListGUI::CMD_DELETE_RECORDS = 'deleteRecords'

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

Referenced by executeCommand().

◆ CMD_LIST_RECORDS

const ilDclRecordListGUI::CMD_LIST_RECORDS = 'listRecords'

◆ CMD_SHOW

const ilDclRecordListGUI::CMD_SHOW = 'show'

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

Referenced by executeCommand().

◆ CMD_SHOW_IMPORT_EXCEL

const ilDclRecordListGUI::CMD_SHOW_IMPORT_EXCEL = 'showImportExcel'

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

Referenced by executeCommand().

◆ GET_MODE

const ilDclRecordListGUI::GET_MODE = 'mode'

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

Referenced by __construct().

◆ 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.

Referenced by __construct().

◆ MODE_MANAGE

const ilDclRecordListGUI::MODE_MANAGE = 2

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

◆ MODE_VIEW

const ilDclRecordListGUI::MODE_VIEW = 1

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

Referenced by __construct().


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