19declare(strict_types=1);
26use Psr\Http\Message\ServerRequestInterface;
72 protected ?ServerRequestInterface
$request =
null;
82 protected ?
string $id =
null;
104 $this->checkArgListElements(
'columns',
$columns, [Column::class]);
106 throw new \InvalidArgumentException(
'cannot construct a table without columns.');
131 $ret[
$id] =
$col->withIndex($idx++);
139 $sortable_visible_cols = array_filter(
141 static fn (
$c):
bool =>
$c->isSortable()
143 if ($sortable_visible_cols === []) {
144 return array_key_first($visible_cols);
146 return array_key_first($sortable_visible_cols);
167 $this->checkArgListElements(
'actions',
$actions, [
T\
Action\Action::class]);
231 return $this->
range ?? $this->data_factory->range(0, $this->number_of_rows);
288 return array_merge($this->actions_multi, $this->actions_std);
296 return array_merge($this->actions_single, $this->actions_std);
304 return array_merge($this->actions_single, $this->actions_multi, $this->actions_std);
309 return count($this->columns);
327 if (is_null($this->selected_optional_column_ids)) {
340 static fn (
$c):
bool =>
$c->isOptional()
351 static fn (
$c):
bool =>
$c->isInitiallyVisible()
364 ARRAY_FILTER_USE_BOTH
370 return $this->data_row_builder
396 $view_controls = $view_controls
397 ->withStoredInput($stored_values)
399 $this->
setStorageData($view_controls->getComponentInternalValues());
400 return $view_controls;
408 ?array $additional_parameters = []
411 $total_count = $this->getDataRetrieval()->getTotalRowCount($filter_data, $additional_parameters);
414 if ($request = $this->getRequest()) {
415 # This retrieves container data from the request
416 $data = $this->applyValuesToViewcontrols($view_controls, $request)->getData();
417 $range =
$data[self::VIEWCONTROL_KEY_PAGINATION];
418 $range = ($range instanceof
Range) ? $range->
croppedTo($total_count ?? PHP_INT_MAX) :
null;
421 ->withOrder(
$data[self::VIEWCONTROL_KEY_ORDERING] ??
null)
422 ->withSelectedOptionalColumns(
$data[self::VIEWCONTROL_KEY_FIELDSELECTION] ??
null);
424 # This retrieves the view controls that should be displayed
425 $view_controls = $table->applyValuesToViewcontrols($table->getViewControls($total_count), $request);
429 $table->withFilter($filter_data),
437 self::VIEWCONTROL_KEY_PAGINATION => $this->getViewControlPagination($total_count),
438 self::VIEWCONTROL_KEY_ORDERING => $this->getViewControlOrdering(),
439 self::VIEWCONTROL_KEY_FIELDSELECTION => $this->getViewControlFieldSelection(),
441 $view_controls = array_filter($view_controls);
442 return $this->view_control_container_factory->standard($view_controls);
447 $smallest_option = current(Pagination::DEFAULT_LIMITS);
448 if (is_null($total_count) || $total_count >= $smallest_option) {
449 $range = $this->getRange();
451 $this->view_control_factory->pagination()
452 ->withTotalCount($total_count)
454 Pagination::FNAME_OFFSET => $range->
getStart(),
455 Pagination::FNAME_LIMIT => $range->
getLength()
458 return $this->view_control_factory->group([
459 $this->view_control_factory->nullControl(),
460 $this->view_control_factory->nullControl()
466 $sortable_visible_cols = array_filter(
467 $this->getVisibleColumns(),
468 static fn (
$c):
bool =>
$c->isSortable()
471 if ($sortable_visible_cols === []) {
476 foreach ($sortable_visible_cols as $col_id => $col) {
478 $order_asc = $this->data_factory->order($col_id, Order::ASC);
479 $order_desc = $this->data_factory->order($col_id, Order::DESC);
481 $labels = $col->getOrderingLabels();
482 $sort_options[$labels[0]] = $order_asc;
483 $sort_options[$labels[1]] = $order_desc;
485 return $this->view_control_factory->sortation($sort_options);
490 $optional_cols = $this->getOptionalColumns();
491 if ($optional_cols === []) {
495 return $this->view_control_factory
496 ->fieldSelection(array_map(
497 static fn (
$c):
string =>
$c->getTitle(),
500 ->withValue($this->getSelectedOptionalColumns());
505 $clone = clone $this;
512 if (
null !== (
$id = $this->
getId())) {
513 return self::STORAGE_ID_PREFIX .
$id;
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
InternalDataService $data
range(CardinalDimension $cardinal_dimension)
order(string $subject, string $direction)
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a range of whole positive numbers.
croppedTo(int $max)
This will create a range that is guaranteed to not exceed $max.
int()
Contains constraints and transformations on numbers.
string()
Contains constraints for string.
bool()
Get a kind transformation to a bool.
SignalGeneratorInterface $signal_generator
withMultiActionsPresent(bool $flag)
T DataRetrieval $data_retrieval
withSelectedOptionalColumns(?array $selected_optional_column_ids)
Signal $multi_action_signal
getAdditionalParameters()
array $selected_optional_column_ids
getSelectedOptionalColumns()
setStorageData(array $data)
ViewControl Factory $view_control_factory
enumerateColumns(array $columns)
array $additional_parameters
DataRowBuilder $data_row_builder
withNumberOfRows(int $number_of_rows)
getViewControls(?int $total_count=null)
applyViewControls(array $filter_data, ?array $additional_parameters=[])
applyValuesToViewcontrols(ViewControlContainer\ViewControl $view_controls, ServerRequestInterface $request)
const VIEWCONTROL_KEY_FIELDSELECTION
withRequest(ServerRequestInterface $request)
DataFactory $data_factory
ViewControlContainer Factory $view_control_container_factory
getInitiallyVisibleColumns()
getViewControlFieldSelection()
const VIEWCONTROL_KEY_PAGINATION
withActions(array $actions)
withFilter(?array $filter)
getViewControlPagination(?int $total_count=null)
const VIEWCONTROL_KEY_ORDERING
Signal $async_action_signal
withAdditionalParameters(?array $additional_parameters)
__construct(SignalGeneratorInterface $signal_generator, ViewControl\Factory $view_control_factory, ViewControlContainer\Factory $view_control_container_factory, DataFactory $data_factory, DataRowBuilder $data_row_builder, string $title, array $columns, T\DataRetrieval $data_retrieval, \ArrayAccess $storage)
ViewControlContainerFactory $view_control_container_factory
DataRowBuilder $data_row_builder
ilBiblDataFactory $data_factory
Psr Http Message ServerRequestInterface $request
clone(ilDclStandardField $original_record)
array $visible_optional_columns
storage()
Fetches the storage filesystem.
Interface to be extended by components that have the possibility to bind to Javascript.
A Column describes the form of presentation for a certain aspect of data, i.e.
create(string $class='')
Create a signal, each created signal MUST have a unique ID.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getViewControls()
@inheritDoc
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.