ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 65 of file class.ilDclRecordListGUI.php.

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

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

References $table.

◆ checkAccess()

ilDclRecordListGUI::checkAccess ( )
protected
Returns
bool

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

608 {
609 return ilObjDataCollectionAccess::hasAccessTo($this->parent_obj->ref_id, $this->table_id, $this->tableview_id);
610 }

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ createSwitchers()

ilDclRecordListGUI::createSwitchers ( )
protected

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

561 {
562 global $DIC;
563 $ilToolbar = $DIC['ilToolbar'];
564 $ilToolbar->setFormAction($this->ctrl->getFormActionByClass("ilDclRecordListGUI", "doTableSwitch"));
565
566 //table switcher
567 $options = $this->getAvailableTables();
568 if (count($options) > 1) {
569 include_once './Services/Form/classes/class.ilSelectInputGUI.php';
570 $table_selection = new ilSelectInputGUI('', 'table_id');
571 $table_selection->setOptions($options);
572 $table_selection->setValue($this->table_id);
573
574 $ilToolbar->addText($this->lng->txt("dcl_table"));
575 $ilToolbar->addInputItem($table_selection);
576 $button = ilSubmitButton::getInstance();
577 $button->setCaption('change');
578 $button->setCommand('doTableSwitch');
579 $ilToolbar->addButtonInstance($button);
580 $ilToolbar->addSeparator();
581 }
582
583 //tableview switcher
584 $options = array();
585 foreach ($this->table_obj->getVisibleTableViews($this->parent_obj->ref_id) as $tableview) {
586 $options[$tableview->getId()] = $tableview->getTitle();
587 }
588
589 if (count($options) > 1) {
590 $tableview_selection = new ilSelectInputGUI('', 'tableview_id');
591 $tableview_selection->setOptions($options);
592 $tableview_selection->setValue($this->tableview_id);
593 $ilToolbar->addText($this->lng->txt("dcl_tableview"));
594 $ilToolbar->addInputItem($tableview_selection);
595
596 $button = ilSubmitButton::getInstance();
597 $button->setCaption('change');
598 $button->setCommand('doTableViewSwitch');
599 $ilToolbar->addButtonInstance($button);
600 $ilToolbar->addSeparator();
601 }
602 }
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
This class represents a selection list property in a property form.
static getInstance()
Factory.

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.

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

References $_POST.

◆ doTableViewSwitch()

ilDclRecordListGUI::doTableViewSwitch ( )

doTableViewSwitch

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

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

References $_POST.

◆ endImport()

ilDclRecordListGUI::endImport (   $i,
  $warnings 
)

End import.

Parameters
$i
$warnings

Definition at line 279 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 }
$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
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output

References $DIC, $i, $output, $tpl, $warning, and $warnings.

Referenced by importRecords().

+ Here is the caller graph for this function:

◆ executeCommand()

ilDclRecordListGUI::executeCommand ( )

execute command

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

102 {
103 global $DIC;
104 $ilTabs = $DIC['ilTabs'];
105
106 if (!$this->checkAccess()) {
107 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
108 return;
109 }
110
111 $this->ctrl->saveParameter($this, self::GET_MODE);
112 $cmd = $this->ctrl->getCmd(self::CMD_SHOW);
113
114 // 'show' fills all filters with the predefined values from the tableview,
115 // whereas 'listRecords' handels the filters "normally", filling them from the POST-variable
116 switch ($cmd) {
117 case self::CMD_SHOW:
118 $this->setSubTabs();
119 $this->listRecords(true);
120 break;
122 $this->setSubTabs();
123 $this->listRecords();
124 break;
126 $this->confirmDeleteRecords();
127 break;
129 $this->setSubTabs();
130 $this->listRecords();
131 break;
133 $this->deleteRecords();
134 break;
136 $ilTabs->setBack2Target($this->lng->txt('back'), $this->ctrl->getLinkTarget($this));
137 $this->$cmd();
138 break;
139
140 default:
141 $this->$cmd();
142 break;
143 }
144 }
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 503 of file class.ilDclRecordListGUI.php.

504 {
505 if (ilObjDataCollectionAccess::hasWriteAccess($this->parent_obj->ref_id)) {
506 $tables = $this->parent_obj->object->getTables();
507 } else {
508 $tables = $this->parent_obj->object->getVisibleTables();
509 }
510 $options = array();
511 foreach ($tables as $table) {
512 $options[$table->getId()] = $table->getTitle();
513 }
514
515 return $options;
516 }

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

524 {
526
527 $list = new ilDclRecordListTableGUI($this, "listRecords", $table_obj, $this->tableview_id, $this->mode);
528 if ($use_tableview_filter) {
529 $list->initFilter();
530 $list->resetFilter();
531 $list->initFilterFromTableView();
532 } else {
533 $list->initFilter();
534 }
535
536 $list->setExternalSegmentation(true);
537 $list->setExternalSorting(true);
538 $list->determineOffsetAndOrder();
539
540 $limit = $list->getLimit();
541 $offset = $list->getOffset();
542
543 $data = $table_obj->getPartialRecords($list->getOrderField(), $list->getOrderDirection(), $limit, $offset, $list->getFilter());
544 $records = $data['records'];
545 $total = $data['total'];
546
547 $list->setMaxCount($total);
548 $list->setRecordData($records);
549
550 $list->determineOffsetAndOrder();
551 $list->determineLimit();
552
553 return $list;
554 }
$total
Definition: Utf8Test.php:87
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
$records
Definition: simple_test.php:22

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

◆ importExcel()

ilDclRecordListGUI::importExcel ( )

Import Data from Excel sheet.

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

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

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

265 {
266 $importer = new ilDclContentImporter($this->parent_obj->object->getRefId(), $this->table_id);
267 $result = $importer->import($file, $simulate);
268
269 $this->endImport($result['line'], $result['warnings']);
270 }
$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 214 of file class.ilDclRecordListGUI.php.

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

References $table.

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

◆ $ctrl

ilDclRecordListGUI::$ctrl
protected

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

◆ $lng

ilDclRecordListGUI::$lng
protected

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

Referenced by getRecordListTableGUI().

◆ $tableview_id

ilDclRecordListGUI::$tableview_id
protected

Definition at line 53 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: