ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
DataRetrieval.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use Generator;
27use ilLanguage;
28use ILIAS\UI\Factory as UIFactory;
29use ILIAS\UI\Component\Table\DataRetrieval as DataRetrievalInterface;
31use ilObject;
36
37class DataRetrieval implements DataRetrievalInterface
38{
39 public function __construct(
40 protected ilCalendarCategories $categories,
41 protected ilCalendarActions $actions,
42 protected ilLanguage $lng,
43 protected UIFactory $ui_factory
44 ) {
45 }
46
47 public function getRows(
48 DataRowBuilder $row_builder,
49 array $visible_column_ids,
51 Order $order,
52 mixed $additional_viewcontrol_data,
53 mixed $filter_data,
54 mixed $additional_parameters
55 ): Generator {
56 $data = [];
57 foreach ($this->categories->getCategoriesInfo() as $info) {
58 $datum = [];
59 $datum['title'] = $info['title'];
60 $datum['type'] = $info['type'];
61 $datum['obj_id'] = $info['obj_id'];
62 $datum['obj_type'] =
64 ilObject::_lookupType($info['obj_id']) : '';
65 $datum['type_sortable'] = ilCalendarCategory::lookupCategorySortIndex($info['type']) .
66 ($info['type'] === ilCalendarCategory::TYPE_OBJ ? $datum['obj_type'] : ''); // Append object type to make type sortable
67 $data[$info['cat_id']] = $datum;
68 }
69
70 $order_field = array_keys($order->get())[0];
71 $order_direction = $order->get()[$order_field];
72 $order_field = match($order_field) {
73 TableBuilder::TYPE_COLUMN => 'type_sortable',
74 default => 'title'
75 };
76 uasort($data, fn($a, $b) => strtolower((string) $a[$order_field]) <=> strtolower((string) $b[$order_field]));
77 if ($order_direction === Order::DESC) {
78 $data = array_reverse($data, true);
79 }
80 $data = array_slice($data, $range->getStart(), $range->getLength(), true);
81
82 $usr_icon = $this->ui_factory->symbol()->icon()->standard('usr', $this->lng->txt('obj_usr'));
83 $role_icon = $this->ui_factory->symbol()->icon()->standard('role', $this->lng->txt('obj_role'));
84
85 foreach ($data as $id => $datum) {
86 $row_datum = [TableBuilder::TITLE_COLUMN => $datum['title']];
87 if ($icon = $this->buildTypeIcon($datum['type'], $datum['obj_type'])) {
88 $row_datum[TableBuilder::TYPE_COLUMN] = $icon;
89 }
90 $row = $row_builder->buildDataRow(
91 (string) $id,
92 $row_datum
93 );
94 yield $this->disableInactiveActions($id, $row);
95 }
96 }
97
98 public function getTotalRowCount(
99 mixed $additional_viewcontrol_data,
100 mixed $filter_data,
101 mixed $additional_parameters
102 ): ?int {
103 return count($this->categories->getCategoriesInfo());
104 }
105
106 protected function buildTypeIcon(int $type, string $obj_type): ?Icon
107 {
108 $f = $this->ui_factory->symbol()->icon();
109 $size = Icon::MEDIUM;
110 return match ($type) {
112 'assets/images/standard/icon_calg.svg',
113 $this->lng->txt('cal_type_system'),
114 $size
115 ),
117 'assets/images/standard/icon_calch.svg',
118 $this->lng->txt('cal_ch_ch'),
119 $size
120 ),
121 ilCalendarCategory::TYPE_USR => $f->standard(
122 'usr',
123 $this->lng->txt('cal_type_personal'),
124 $size
125 ),
126 ilCalendarCategory::TYPE_OBJ => $f->standard(
127 $obj_type,
128 $this->lng->txt('cal_type_' . $type),
129 $size
130 ),
132 'book',
133 $this->lng->txt('cal_type_' . $type),
134 $size
135 ),
136 default => null
137 };
138 }
139
140 protected function disableInactiveActions(int $id, DataRow $row): DataRow
141 {
142 if (!$this->actions->checkSettingsCal($id)) {
143 $row = $row->withDisabledAction(TableBuilder::ACTION_EDIT);
144 }
145 if (!$this->actions->checkAddEvent($id)) {
146 $row = $row->withDisabledAction(TableBuilder::ACTION_IMPORT);
147 }
148 if (!$this->actions->checkShareCal($id)) {
149 $row = $row->withDisabledAction(TableBuilder::ACTION_SHARE);
150 }
151 if (!$this->actions->checkSynchronizeCal($id)) {
152 $row = $row->withDisabledAction(TableBuilder::ACTION_SYNCHRONIZE);
153 }
154 if (!$this->actions->checkDeleteCal($id)) {
155 $row = $row->withDisabledAction(TableBuilder::ACTION_DELETE);
156 }
157 return $row;
158 }
159}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e....
buildTypeIcon(int $type, string $obj_type)
disableInactiveActions(int $id, DataRow $row)
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
__construct(protected ilCalendarCategories $categories, protected ilCalendarActions $actions, protected ilLanguage $lng, protected UIFactory $ui_factory)
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
const DESC
Definition: Order.php:31
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
Checks if certain actions can be performed.
class for calendar categories
Stores calendar categories.
static lookupCategorySortIndex(int $a_type_id)
Lookup sort index of calendar type.
language handling
Class ilObject Basic functions for all objects.
static _lookupType(int $id, bool $reference=false)
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'vtt', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$info
Definition: entry_point.php:21
This describes how an icon could be modified during construction of UI.
Definition: Icon.php:29
buildDataRow(string $id, array $record)
withDisabledAction(string $action_id, bool $disable=true)
Refer to an Action by its id and disable it for this row/record only.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
global $lng
Definition: privfeed.php:26
$data
Definition: storeScorm.php:45