ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjectTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 {
30  protected array $objects = [];
31  protected bool $show_path = false;
32  protected bool $row_selection_input = false;
33  protected UIServices $ui;
34 
35  public function __construct(?object $parent_obj, string $parent_cmd, string $id)
36  {
37  global $DIC;
38  $this->ui = $DIC->ui();
39  $this->setId('obj_table_' . $id);
40  parent::__construct($parent_obj, $parent_cmd);
41  }
42 
43  public function enableObjectPath(bool $status): void
44  {
45  $this->show_path = $status;
46  }
47 
48  public function enabledObjectPath(): bool
49  {
50  return $this->show_path;
51  }
52 
54  {
55  return $path;
56  }
57 
58  public function enableRowSelectionInput(bool $stat): void
59  {
60  $this->row_selection_input = $stat;
61  }
62 
63  public function enabledRowSelectionInput(): bool
64  {
66  }
67 
68  public function fillRowSelectionInput(array $set): void
69  {
70  $this->tpl->setCurrentBlock('row_selection_input');
71  $this->tpl->setVariable('OBJ_INPUT_TYPE', 'checkbox');
72  $this->tpl->setVariable('OBJ_INPUT_NAME', 'id[]');
73  $this->tpl->setVariable('OBJ_INPUT_VALUE', $set['ref_id']);
74  }
75 
79  public function setObjects(array $ref_ids): void
80  {
81  $this->objects = $ref_ids;
82  }
83 
87  public function getObjects(): array
88  {
89  return $this->objects;
90  }
91 
92  public function init(): void
93  {
94  if ($this->enabledRowSelectionInput()) {
95  $this->addColumn('', 'id', '5px');
96  }
97 
98  $this->addColumn($this->lng->txt('type'), 'type', '30px');
99  $this->addColumn($this->lng->txt('title'), 'title');
100 
101  $this->setOrderColumn('title');
102  $this->setRowTemplate('tpl.object_table_row.html', 'Services/Object');
103  }
104 
105  protected function fillRow(array $set): void
106  {
107  if ($this->enabledRowSelectionInput()) {
108  $this->fillRowSelectionInput($set);
109  }
110 
111  $type_icon = $this->ui->factory()->symbol()->icon()->custom(
112  ilObject::_getIcon($set['obj_id'], 'big', $set['type']),
113  $this->lng->txt('obj_' . $set['type'])
114  );
115 
116  $this->tpl->setVariable('OBJ_LINK', ilLink::_getLink($set['ref_id'], $set['type']));
117  $this->tpl->setVariable('OBJ_LINKED_TITLE', $set['title']);
118  $this->tpl->setVariable('TYPE_IMG', $this->ui->renderer()->render($type_icon));
119 
120  if ($this->enabledObjectPath()) {
121  $path_gui = new ilPathGUI();
122  $path_gui = $this->customizePath($path_gui);
123 
124  $this->tpl->setCurrentBlock('path');
125  $this->tpl->setVariable('OBJ_PATH', $path_gui->getPath(ROOT_FOLDER_ID, (int) $set['ref_id']));
126  $this->tpl->parseCurrentBlock();
127  }
128  }
129 
130  public function parse(): void
131  {
132  $counter = 0;
133  $set = array();
134  foreach ($this->getObjects() as $ref_id) {
136  if ($type == 'rolf') {
137  continue;
138  }
139 
140  $set[$counter]['ref_id'] = $ref_id;
141  $set[$counter]['obj_id'] = ilObject::_lookupObjId($ref_id);
142  $set[$counter]['type'] = ilObject::_lookupType(ilObject::_lookupObjId($ref_id));
143  $set[$counter]['title'] = ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id));
144  $counter++;
145  }
146  $this->setData($set);
147  }
148 }
setData(array $a_data)
Creates a path for a start and endnode.
enableRowSelectionInput(bool $stat)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
setObjects(array $ref_ids)
set table content objects
$type
const ROOT_FOLDER_ID
Definition: constants.php:32
fillRowSelectionInput(array $set)
setId(string $a_val)
$path
Definition: ltiservices.php:32
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
Provides fluid interface to RBAC services.
Definition: UIServices.php:23
$ref_id
Definition: ltiauth.php:67
static _lookupTitle(int $obj_id)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
getObjects()
get object ref_ids
customizePath(ilPathGUI $path)
__construct(?object $parent_obj, string $parent_cmd, string $id)
__construct(Container $dic, ilPlugin $plugin)
Settings for LO courses.
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
static _lookupType(int $id, bool $reference=false)
setOrderColumn(string $a_order_column="", string $a_default_column="")
enableObjectPath(bool $status)