19declare(strict_types=1);
65 protected \ILIAS\Container\Block\StandardGUIRequest
$request;
67 private \ILIAS\HTTP\GlobalHttpState
$http;
70 protected \ILIAS\DI\UIServices
$ui;
71 protected array
$data = array();
76 protected array
$move = array(
"left" =>
false,
"right" =>
false,
"up" =>
false,
"down" =>
false);
100 $this->
factory = $DIC->ui()->factory();
101 $this->
renderer = $DIC->ui()->renderer();
103 $this->
http = $DIC->http();
105 $this->block_manager = $block_service->internal()
108 $this->request = $block_service->internal()
116 $this->
user = $DIC->user();
117 $this->
ctrl = $DIC->ctrl();
118 $this->
access = $DIC->access();
119 $this->
lng = $DIC->language();
120 $this->main_tpl =
$DIC[
"tpl"];
121 $this->obj_def =
$DIC[
"objDefinition"];
122 $this->
ui = $DIC->ui();
124 $this->main_tpl->addJavaScript(
"./assets/js/ilblockcallback.js");
128 $this->requested_ref_id = $this->request->getRefId();
141 return htmlspecialchars(
143 ENT_QUOTES | ENT_SUBSTITUTE,
150 $this->data = $a_data;
160 $this->presentation = $type;
170 $this->block_id = $a_block_id;
185 $this->gui_object = $a_gui_object;
195 $this->title = $a_title;
206 $this->max_count = count($this->
getData());
208 $this->offset = $a_offset;
210 throw new ilException(
"ilBlockGUI::setOffset(): Offset out of range.");
226 $this->limit = $a_limit;
236 $this->enableedit = $a_enableedit;
246 $this->repositorymode = $a_repositorymode;
256 $this->subtitle = $a_subtitle;
269 $this->refid = $a_refid;
279 $this->admincommands = $a_admincommands;
289 $this->enablenuminfo = $a_enablenuminfo;
303 $this->
property = $a_properties;
308 return $this->
property[$a_property] ??
null;
311 public function setProperty(
string $a_property,
string $a_value): void
313 $this->
property[$a_property] = $a_value;
320 string $a_rowtemplatename,
321 string $a_rowtemplatedir =
""
323 $this->rowtemplatename = $a_rowtemplatename;
324 $this->rowtemplatedir = $a_rowtemplatedir;
329 return $this->getBlockType() .
"_" . $this->getBlockId() .
"_blnav";
334 return $this->getBlockType() .
"_" . $this->getBlockId() .
"_blconf";
339 return $this->getBlockType() .
"_" . $this->getBlockId() .
"_blmove";
344 return $this->rowtemplatename;
349 return $this->rowtemplatedir;
354 $this->block_commands[] = [
357 "onclick" => $a_onclick,
364 return $this->block_commands;
378 $this->initCommands();
380 $access = $this->access;
385 if ($this->isRepositoryObject()) {
386 if (!$access->
checkAccess(
"read",
"", $this->getRefId())) {
391 $this->addRepoCommands();
393 switch ($this->getPresentation()) {
394 case self::PRES_SEC_LEG:
395 $panel = $this->
factory->panel()->secondary()->legacy(
396 $this->specialCharsAsEntities($this->
getTitle()),
397 $this->
factory->legacy()->content($this->getLegacyContent())
401 case self::PRES_MAIN_LEG:
402 $panel = $this->
factory->panel()->standard(
403 $this->specialCharsAsEntities($this->
getTitle()),
404 $this->
factory->legacy()->content($this->getLegacyContent())
408 case self::PRES_SEC_LIST:
409 $this->handleNavigation();
410 $panel = $this->
factory->panel()->secondary()->listing(
411 $this->specialCharsAsEntities($this->
getTitle()),
412 $this->getListItemGroups()
416 case self::PRES_MAIN_TILE:
417 case self::PRES_MAIN_LIST:
418 $this->handleNavigation();
419 $panel = $this->
factory->panel()->listing()->standard(
420 $this->specialCharsAsEntities($this->
getTitle()),
421 $this->getListItemGroups()
427 if (in_array($this->getPresentation(), [self::PRES_SEC_LIST, self::PRES_MAIN_LIST],
true) &&
428 ($panel->getItemGroups() === [] || (count($panel->getItemGroups()) === 1 && $panel->getItemGroups()[0]->getItems() === []))) {
429 if ($this->getPresentation() === self::PRES_SEC_LIST) {
430 $panel = $this->
factory->panel()->secondary()->legacy(
431 $this->specialCharsAsEntities($this->
getTitle()),
432 $this->
factory->legacy()->content($this->getNoItemFoundContent())
435 $panel = $this->
factory->panel()->standard(
436 $this->specialCharsAsEntities($this->
getTitle()),
437 $this->
factory->legacy()->content($this->getNoItemFoundContent())
442 $actions = $this->getActionsForPanel();
443 if ($actions !==
null) {
444 $panel = $panel->withActions($actions);
446 $viewControls = $this->getViewControlsForPanel();
447 if ($viewControls !== [] &&
449 $panel instanceof StandardPanel ||
450 $panel instanceof SecondaryListingPanel ||
451 $panel instanceof SecondaryLegacyPanel ||
452 $panel instanceof StandardListingPanel
455 $panel = $panel->withViewControls($viewControls);
459 $html = $this->
renderer->renderAsync([$panel, ...$this->modals]);
461 $html = $this->
renderer->render([$panel, ...$this->modals]);
469 $html =
'<div id="' .
'block_' . $this->getBlockType() .
'_' . $this->block_id .
'">' .
490 header(
"Content-type: text/html; charset=UTF-8");
491 return $this->tpl->get();
522 $reg_page = $this->request->getNavPage($this->getNavParameter());
523 if ($reg_page !==
"") {
524 $this->nav_value =
"::" . ($reg_page * $this->getLimit());
527 if ($this->nav_value ==
"") {
528 $this->nav_value = $this->block_manager->getNavPar($this->getNavParameter());
531 $this->block_manager->setNavPar(
532 $this->getNavParameter(),
536 $nav = explode(
":", $this->nav_value);
537 if (isset($nav[2])) {
538 $this->setOffset((
int) $nav[2]);
550 $data = $this->getData();
551 $this->max_count = count(
$data);
552 $data = array_slice(
$data, $this->getOffset(), $this->getLimit(),
true);
553 $this->preloadData(
$data);
566 $factory =
$DIC->ui()->factory();
568 $data = $this->loadData();
572 foreach (
$data as $record) {
573 $item = $this->getListItemForData($record);
574 if ($item !==
null) {
579 $item_group = $factory->item()->group(
"", $items);
581 return [$item_group];
590 $factory =
$DIC->ui()->factory();
592 $ilCtrl = $this->ctrl;
594 if ($this->max_count <= $this->getLimit()) {
603 $ilCtrl->setParameterByClass(
606 "block_" . $this->getBlockType() .
"_" . $this->block_id
608 $block_id =
"block_" . $this->getBlockType() .
"_" . $this->block_id;
609 $onclick = $ilCtrl->getLinkTargetByClass(
615 $ilCtrl->setParameterByClass(
622 $href = $ilCtrl->getLinkTargetByClass(
"ilcolumngui",
"",
"",
false,
false);
628 ->withTargetURL($href, $this->getNavParameter() .
"page")
629 ->withTotalEntries($this->max_count)
630 ->withPageSize($this->getLimit())
631 ->withMaxPaginationButtons(1)
632 ->withCurrentPage($this->getOffset() / $this->getLimit());
640 $access = $this->access;
643 $obj_def = $this->obj_def;
645 if ($this->getRepositoryMode() && $this->isRepositoryObject()) {
656 $parent_gui =
"ilObj" . $obj_def->
getClassName($parent_type) .
"GUI";
658 if ($access->
checkAccess(
"delete",
"", $this->getRefId())) {
659 $this->
ctrl->setParameterByClass($parent_gui,
'ref_id', $this->requested_ref_id);
660 $this->
ctrl->setParameterByClass($parent_gui,
'item_ref_id', $this->getRefId());
662 $this->addBlockCommand(
663 $this->
ctrl->getLinkTargetByClass($parent_gui,
'delete'),
667 $this->addBlockCommand(
668 $this->
ctrl->getLinkTargetByClass($parent_gui,
'link'),
673 $this->addBlockCommand(
674 $this->
ctrl->getLinkTargetByClass($parent_gui,
'cut'),
678 $this->
ctrl->clearParameterByClass($parent_gui,
'ref_id');
679 $this->
ctrl->clearParameterByClass($parent_gui,
'item_ref_id');
683 if ($access->
checkAccess(
"copy",
"", $this->getRefId())) {
686 array(
"ilrepositorygui", $parent_gui,
"ilobjectcopygui"),
687 "initTargetSelection"
691 $this->addBlockCommand(
705 foreach ($this->getBlockCommands() as $command) {
706 $href = ($command[
'onclick'] !==
'')
709 $button = $this->
factory->button()->shy($command[
'text'], $href);
710 if ($command[
'onclick']) {
711 $button = $button->withOnLoadCode(
function (
$id) use ($command) {
713 "$(\"#$id\").click(function() { ilBlockJSHandler('" .
"block_" . $this->getBlockType() .
"_" . $this->block_id .
714 "','" . $command[
"onclick"] .
"');});";
718 if (isset($command[
'modal']) && $command[
'modal'] instanceof
Modal) {
719 $button = $button->withOnClick($command[
'modal']->getShowSignal());
720 $this->modals[] = $command[
'modal'];
722 $actions[] = $button;
725 if (count($actions) > 0) {
726 $actions = $this->
factory->dropdown()->standard($actions)
727 ->withAriaLabel(sprintf(
728 $this->
lng->txt(
'actions_for'),
729 $this->specialCharsAsEntities($this->getTitle())
740 if (count($this->presentations) > 1) {
741 $presentation = $this->
factory->viewControl()->mode(
742 $this->presentations,
744 )->withActive($this->activePresentation);
745 $viewControls[] = $presentation;
748 if ($this->sort_options !== []) {
749 if (! array_key_exists($this->activeSortOption, $this->sort_options)) {
750 $this->activeSortOption = current(array_keys($this->sort_options));
752 $sortation = $this->
factory->viewControl()->sortation(
754 $this->activeSortOption
759 $viewControls[] = $sortation;
762 if ($this->getPresentation() === self::PRES_SEC_LIST) {
763 $pg_view_control = $this->getPaginationViewControl();
764 if ($pg_view_control !==
null) {
765 $viewControls[] = $pg_view_control;
768 return $viewControls;
773 return $this->getHTML();
776 public function addSortOption(
string $option,
string $label,
bool $active): void
779 $this->activeSortOption = $option;
781 $this->sort_options[$option] = $label;
786 $this->sort_target = $target;
791 $this->presentations[$label] = $target;
793 $this->activePresentation = $label;
801 protected function send(
string $output): void
803 $this->
http->saveResponse($this->
http->response()->withBody(
804 Streams::ofString($output)
806 $this->
http->sendResponse();
807 $this->
http->close();
812 return $this->
lng->txt(
"no_items");
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
This class represents a block method of a block.
send(string $output)
Send.
addPresentation(string $label, string $target, bool $active)
specialCharsAsEntities(string $string)
setTitle(string $a_title)
isRepositoryObject()
Returns whether block has a corresponding repository object.
getAsynch()
Use this for final get before sending asynchronous output (ajax) per echo to output.
setPresentation(int $type)
getViewControlsForPanel()
ilObjectDefinition $obj_def
setAdminCommands(bool $a_admincommands)
handleNavigation()
Handle navigation.
getProperty(string $a_property)
preloadData(array $data)
Can be overwritten in subclasses.
setProperties(array $a_properties)
This function is supposed to be used for block type specific properties, that should be inherited thr...
ilGlobalTemplateInterface $main_tpl
loadData()
Load data for current page.
getListItemGroups()
Get items.
setGuiObject(object $a_gui_object)
Set GuiObject.
ILIAS UI Renderer $renderer
addBlockCommand(string $a_href, string $a_text, string $a_onclick="", ?RoundTrip $modal=null)
addRepoCommands()
Add repo commands.
setRepositoryMode(bool $a_repositorymode)
getLegacyContent()
Get legacy content.
setBlockId(string $a_block_id="0")
getPaginationViewControl()
Fill previous/next row.
addSortOption(string $option, string $label, bool $active)
ILIAS HTTP GlobalHttpState $http
setProperty(string $a_property, string $a_value)
ILIAS Container Block StandardGUIRequest $request
getListItemForData(array $data)
Get list item for data array.
setEnableEdit(bool $a_enableedit)
string $activePresentation
setRefId(int $a_refid)
Set Ref Id (only used if isRepositoryObject() is true).
setSubtitle(string $a_subtitle)
ILIAS Container Block BlockManager $block_manager
setEnableNumInfo(bool $a_enablenuminfo)
setSortTarget(string $target)
setRowTemplate(string $a_rowtemplatename, string $a_rowtemplatedir="")
Set Row Template Name.
Class ilCtrl provides processing control methods.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
Base class for ILIAS Exception handling.
parses the objects.xml it handles the xml-description of all ilias objects
getClassName(string $obj_name)
static _lookupType(int $id, bool $reference=false)
special template class to simplify handling of ITX/PEAR
A component is the most general form of an entity in the UI.
This describes commonalities between all types of Dropdowns.
This describes a Standard Dropdown.
This describes commonalities between the different modals.
This is how the factory for UI elements looks.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
static http()
Fetches the global http state from ILIAS.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
catch(ilCmiXapiException $e) send($response)