ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 73 of file class.ilDclRecordListGUI.php.

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

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

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

◆ checkAccess()

ilDclRecordListGUI::checkAccess ( )
protected
Returns
bool

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

598 {
599 return ilObjDataCollectionAccess::hasAccessTo($this->parent_obj->ref_id, $this->table_id, $this->tableview_id);
600 }

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ createSwitchers()

ilDclRecordListGUI::createSwitchers ( )
protected

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

549 {
550 global $DIC;
551 $ilToolbar = $DIC['ilToolbar'];
552 $ilToolbar->setFormAction($this->ctrl->getFormActionByClass("ilDclRecordListGUI", "doTableSwitch"));
553
554 //table switcher
555 $options = $this->getAvailableTables();
556 if (count($options) > 1) {
557
558 include_once './Services/Form/classes/class.ilSelectInputGUI.php';
559 $table_selection = new ilSelectInputGUI('', 'table_id');
560 $table_selection->setOptions($options);
561 $table_selection->setValue($this->table_id);
562
563 $ilToolbar->addText($this->lng->txt("dcl_table"));
564 $ilToolbar->addInputItem($table_selection);
565 $button = ilSubmitButton::getInstance();
566 $button->setCaption('change');
567 $button->setCommand('doTableSwitch');
568 $ilToolbar->addButtonInstance($button);
569 $ilToolbar->addSeparator();
570 }
571
572 //tableview switcher
573 $options = array();
574 foreach ($this->table_obj->getVisibleTableViews($this->parent_obj->ref_id) as $tableview) {
575 $options[$tableview->getId()] = $tableview->getTitle();
576 }
577
578 if (count($options) > 1) {
579
580 $tableview_selection = new ilSelectInputGUI('', 'tableview_id');
581 $tableview_selection->setOptions($options);
582 $tableview_selection->setValue($this->tableview_id);
583 $ilToolbar->addText($this->lng->txt("dcl_tableview"));
584 $ilToolbar->addInputItem($tableview_selection);
585
586 $button = ilSubmitButton::getInstance();
587 $button->setCaption('change');
588 $button->setCommand('doTableViewSwitch');
589 $ilToolbar->addButtonInstance($button);
590 $ilToolbar->addSeparator();
591 }
592 }
This class represents a selection list property in a property form.
static getInstance()
Factory.
if(!is_array($argv)) $options

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

+ Here is the call graph for this function:

◆ doTableSwitch()

ilDclRecordListGUI::doTableSwitch ( )

doTableSwitch

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

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

References $_POST.

◆ doTableViewSwitch()

ilDclRecordListGUI::doTableViewSwitch ( )

doTableViewSwitch

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

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

References $_POST.

◆ endImport()

ilDclRecordListGUI::endImport (   $i,
  $warnings 
)

End import.

Parameters
$i
$warnings

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

280 {
281 global $DIC;
282 $tpl = $DIC['tpl'];
283 $output = new ilTemplate("tpl.dcl_import_terminated.html", true, true, "Modules/DataCollection");
284 $output->setVariable("IMPORT_TERMINATED", $this->lng->txt("dcl_import_terminated") . ": " . $i);
285 foreach ($warnings as $warning) {
286 $output->setCurrentBlock("warnings");
287 $output->setVariable("WARNING", $warning);
288 $output->parseCurrentBlock();
289 }
290 if (!count($warnings)) {
291 $output->setCurrentBlock("warnings");
292 $output->setVariable("WARNING", $this->lng->txt("dcl_no_warnings"));
293 $output->parseCurrentBlock();
294 }
295 $output->setVariable("BACK_LINK", $this->ctrl->getLinkTargetByClass("ilDclRecordListGUI", "listRecords"));
296 $output->setVariable("BACK", $this->lng->txt("back"));
297 $tpl->setContent($output->get());
298 }
global $tpl
Definition: ilias.php:8
special template class to simplify handling of ITX/PEAR
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output

References $DIC, $output, and $tpl.

Referenced by importRecords().

+ Here is the caller graph for this function:

◆ executeCommand()

ilDclRecordListGUI::executeCommand ( )

execute command

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

108 {
109 global $DIC;
110 $ilTabs = $DIC['ilTabs'];
111
112 if (!$this->checkAccess()){
113 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
114 return;
115 }
116
117 $this->ctrl->saveParameter($this, self::GET_MODE);
118 $cmd = $this->ctrl->getCmd(self::CMD_SHOW);
119
120 // 'show' fills all filters with the predefined values from the tableview,
121 // whereas 'listRecords' handels the filters "normally", filling them from the POST-variable
122 switch ($cmd) {
123 case self::CMD_SHOW:
124 $this->setSubTabs();
125 $this->listRecords(true);
126 break;
128 $this->setSubTabs();
129 $this->listRecords();
130 break;
132 $this->confirmDeleteRecords();
133 break;
135 $this->setSubTabs();
136 $this->listRecords();
137 break;
139 $this->deleteRecords();
140 break;
142 $ilTabs->setBack2Target($this->lng->txt('back'), $this->ctrl->getLinkTarget($this));
143 $this->$cmd();
144 break;
145
146 default:
147 $this->$cmd();
148 break;
149 }
150 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$cmd
Definition: sahs_server.php:35

References $cmd, $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 495 of file class.ilDclRecordListGUI.php.

495 {
496 if (ilObjDataCollectionAccess::hasWriteAccess($this->parent_obj->ref_id)) {
497 $tables = $this->parent_obj->object->getTables();
498 } else {
499 $tables = $this->parent_obj->object->getVisibleTables();
500 }
501 $options = array();
502 foreach ($tables as $table) {
503 $options[$table->getId()] = $table->getTitle();
504 }
505
506 return $options;
507 }

References $options, 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 514 of file class.ilDclRecordListGUI.php.

514 {
516
517 $list = new ilDclRecordListTableGUI($this, "listRecords", $table_obj, $this->tableview_id, $this->mode);
518 if ($use_tableview_filter) {
519 $list->initFilterFromTableView();
520 } else {
521 $list->initFilter();
522 }
523
524 $list->setExternalSegmentation(true);
525 $list->setExternalSorting(true);
526 $list->determineOffsetAndOrder();
527
528 $limit = $list->getLimit();
529 $offset = $list->getOffset();
530
531 $data = $table_obj->getPartialRecords($list->getOrderField(), $list->getOrderDirection(), $limit, $offset, $list->getFilter());
532 $records = $data['records'];
533 $total = $data['total'];
534
535 $list->setMaxCount($total);
536 $list->setRecordData($records);
537
538 $list->determineOffsetAndOrder();
539 $list->determineLimit();
540
541 return $list;
542 }
$total
Definition: Utf8Test.php:87
$records
Definition: simple_test.php:22

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

◆ importExcel()

ilDclRecordListGUI::importExcel ( )

Import Data from Excel sheet.

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

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

References $file, 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 266 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 $file, $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 218 of file class.ilDclRecordListGUI.php.

218 {
219 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
220 $form = new ilPropertyFormGUI();
221
222 $item = new ilCustomInputGUI();
223 $item->setHtml($this->lng->txt('dcl_file_format_description'));
224 $item->setTitle("Info");
225 $form->addItem($item);
226
227 $file = new ilFileInputGUI($this->lng->txt("import_file"), "import_file");
228 $file->setRequired(true);
229 $form->addItem($file);
230
231 $cb = new ilCheckboxInputGUI($this->lng->txt("dcl_simulate_import"), "simulate");
232 $cb->setInfo($this->lng->txt("dcl_simulate_info"));
233 $form->addItem($cb);
234
235 $form->addCommandButton("importExcel", $this->lng->txt("import"));
236
237 return $form;
238 }
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 $file.

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

456 {
457 $table = $record->getTable();
458 $obj_id = $this->parent_obj->object->getId();
459 $obj_id_rec = $table->getCollectionObject()->getId();
460
461 return $obj_id == $obj_id_rec;
462 }

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

334 {
335 $table = new ilDclRecordListTableGUI($this, "listRecords", $this->table_obj, $this->tableview_id);
336 $table->initFilter();
337 $table->resetOffset();
338 $table->resetFilter();
339 $this->ctrl->redirect($this, self::CMD_LIST_RECORDS);
340 }

◆ sendFile()

ilDclRecordListGUI::sendFile ( )

send File to User

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

346 {
347 global $DIC;
348 $ilAccess = $DIC['ilAccess'];
349 $ilUser = $DIC['ilUser'];
350 //need read access to receive file
351 if ($ilAccess->checkAccess("read", "", $this->parent_obj->ref_id)) {
352
353 // deliver temp-files
354 if(isset($_GET['ilfilehash'])) {
355 $filehash = $_GET['ilfilehash'];
356 $field_id = $_GET['field_id'];
358
359 $filepath = $_FILES["field_" . $field_id]['tmp_name'];
360 $filetitle = $_FILES["field_" . $field_id]['name'];
361 } else {
362 $rec_id = $_GET['record_id'];
363 $record = ilDclCache::getRecordCache($rec_id);
364 $field_id = $_GET['field_id'];
365 $file_obj = new ilObjFile($record->getRecordFieldValue($field_id), false);
366 if (!$this->recordBelongsToCollection($record, $this->parent_obj->ref_id)) {
367 return;
368 }
369 $filepath = $file_obj->getFile();
370 $filetitle = $file_obj->getTitle();
371 }
372
373 ilUtil::deliverFile($filepath, $filetitle);
374 }
375 }
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 204 of file class.ilDclRecordListGUI.php.

204 {
205 global $DIC;
206 $tpl = $DIC['tpl'];
207 if (!$form) {
208 $form = $this->initImportForm();
209 }
210 $tpl->setContent($form->getHTML());
211 }

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

◆ $ctrl

ilDclRecordListGUI::$ctrl
protected

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

◆ $lng

ilDclRecordListGUI::$lng
protected

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

Referenced by __construct().

◆ $mode

ilDclRecordListGUI::$mode = self::MODE_VIEW
protected

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

◆ $table_obj

ilDclRecordListGUI::$table_obj
protected

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

Referenced by getRecordListTableGUI().

◆ $tableview_id

ilDclRecordListGUI::$tableview_id
protected

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

Referenced by __construct().

◆ CMD_CANCEL_DELETE

const ilDclRecordListGUI::CMD_CANCEL_DELETE = 'cancelDelete'

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

Referenced by executeCommand().

◆ CMD_CONFIRM_DELETE_RECORDS

const ilDclRecordListGUI::CMD_CONFIRM_DELETE_RECORDS = 'confirmDeleteRecords'

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

Referenced by executeCommand().

◆ CMD_DELETE_RECORDS

const ilDclRecordListGUI::CMD_DELETE_RECORDS = 'deleteRecords'

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

Referenced by executeCommand().

◆ CMD_SHOW_IMPORT_EXCEL

const ilDclRecordListGUI::CMD_SHOW_IMPORT_EXCEL = 'showImportExcel'

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

Referenced by executeCommand().

◆ GET_MODE

const ilDclRecordListGUI::GET_MODE = 'mode'

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

Referenced by __construct().

◆ GET_TABLE_ID

const ilDclRecordListGUI::GET_TABLE_ID = 'table_id'

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

◆ GET_TABLEVIEW_ID

const ilDclRecordListGUI::GET_TABLEVIEW_ID = 'tableview_id'

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

Referenced by __construct().

◆ MODE_MANAGE

const ilDclRecordListGUI::MODE_MANAGE = 2

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

◆ MODE_VIEW

const ilDclRecordListGUI::MODE_VIEW = 1

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

Referenced by __construct().


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