ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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.

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 $ilCtrl
Definition: ilias.php:18
$DIC
Definition: xapitoken.php:46

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

619 {
620 return ilObjDataCollectionAccess::hasAccessTo($this->parent_obj->ref_id, $this->table_id, $this->tableview_id);
621 }

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ createSwitchers()

ilDclRecordListGUI::createSwitchers ( )
protected

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

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

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

+ Here is the call graph for this function:

◆ doTableSwitch()

ilDclRecordListGUI::doTableSwitch ( )

doTableSwitch

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

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"]

References $_POST.

◆ doTableViewSwitch()

ilDclRecordListGUI::doTableViewSwitch ( )

doTableViewSwitch

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

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

References $_POST.

◆ endImport()

ilDclRecordListGUI::endImport (   $i,
  $warnings 
)

End import.

Parameters
$i
$warnings

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

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 }
special template class to simplify handling of ITX/PEAR
$i
Definition: metadata.php:24
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl

References $DIC, $i, and $tpl.

Referenced by importRecords().

+ Here is the caller graph for this function:

◆ executeCommand()

ilDclRecordListGUI::executeCommand ( )

execute command

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

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;
117 $this->setSubTabs();
118 $this->listRecords();
119 break;
121 $this->confirmDeleteRecords();
122 break;
124 $this->setSubTabs();
125 $this->listRecords();
126 break;
128 $this->deleteRecords();
129 break;
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 }
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 504 of file class.ilDclRecordListGUI.php.

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 }

References 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 525 of file class.ilDclRecordListGUI.php.

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->resetFilter();
533 $list->initFilterFromTableView();
534 } else {
535 $list->initFilter();
536 }
537
538 $list->setExternalSegmentation(true);
539 $list->setExternalSorting(true);
540 $list->determineOffsetAndOrder();
541
542 $limit = $list->getLimit();
543 $offset = $list->getOffset();
544
545 $num_records = count($table_obj->getPartialRecords($list->getOrderField(), $list->getOrderDirection(), $limit, $offset, $list->getFilter()));
546
547 // Fix no data found on new filter application when on a site other than the first
548 if ($num_records === 0) {
549 $list->resetOffset();
550 $offset = 0;
551 }
552
553 $data = $table_obj->getPartialRecords($list->getOrderField(), $list->getOrderDirection(), $limit, $offset, $list->getFilter());
554 $records = $data['records'];
555 $total = $data['total'];
556
557 $list->setMaxCount($total);
558 $list->setRecordData($records);
559
560 $list->determineOffsetAndOrder();
561 $list->determineLimit();
562
563 return $list;
564 }
$total
Definition: Utf8Test.php:87
$data
Definition: storeScorm.php:23

References $data, $table_obj, and $total.

◆ importExcel()

ilDclRecordListGUI::importExcel ( )

Import Data from Excel sheet.

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

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 }
Class ilDclException.
importRecords($file, $simulate=false)
Import records from Excel file.
static hasPermissionToAddRecord($ref_id, $table_id)

References 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 261 of file class.ilDclRecordListGUI.php.

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 }
$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 212 of file class.ilDclRecordListGUI.php.

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

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

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 }

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

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 }
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 196 of file class.ilDclRecordListGUI.php.

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

References $DIC, $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 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.

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

Referenced by executeCommand().

◆ CMD_CONFIRM_DELETE_RECORDS

const ilDclRecordListGUI::CMD_CONFIRM_DELETE_RECORDS = 'confirmDeleteRecords'

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

Referenced by executeCommand().

◆ CMD_DELETE_RECORDS

const ilDclRecordListGUI::CMD_DELETE_RECORDS = 'deleteRecords'

Definition at line 25 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 22 of file class.ilDclRecordListGUI.php.

Referenced by executeCommand().

◆ CMD_SHOW_IMPORT_EXCEL

const ilDclRecordListGUI::CMD_SHOW_IMPORT_EXCEL = 'showImportExcel'

Definition at line 26 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 20 of file class.ilDclRecordListGUI.php.

◆ MODE_VIEW

const ilDclRecordListGUI::MODE_VIEW = 1

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

Referenced by __construct().


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