19declare(strict_types=1);
44 protected \ILIAS\Block\StandardGUIRequest
$request;
46 private \ILIAS\HTTP\GlobalHttpState
$http;
49 protected \ILIAS\DI\UIServices
$ui;
50 protected array
$data = array();
55 protected array
$move = array(
"left" =>
false,
"right" =>
false,
"up" =>
false,
"down" =>
false);
81 $this->
http = $DIC->http();
83 $this->block_manager = $block_service->internal()
86 $this->request = $block_service->internal()
94 $this->
user = $DIC->user();
95 $this->
ctrl = $DIC->ctrl();
96 $this->
access = $DIC->access();
97 $this->
lng = $DIC->language();
98 $this->main_tpl =
$DIC[
"tpl"];
99 $this->obj_def =
$DIC[
"objDefinition"];
100 $this->
ui = $DIC->ui();
103 $this->main_tpl->addJavaScript(
"./Services/Block/js/ilblockcallback.js");
105 $this->
setLimit((
int) $this->
user->getPref(
"hits_per_page"));
107 $this->requested_ref_id = $this->request->getRefId();
120 return htmlspecialchars(
122 ENT_QUOTES | ENT_SUBSTITUTE,
129 $this->data = $a_data;
139 $this->presentation =
$type;
149 $this->block_id = $a_block_id;
164 $this->gui_object = $a_gui_object;
174 $this->title = $a_title;
184 $this->offset = $a_offset;
194 if (!($this->offset < $this->max_count)) {
201 $this->limit = $a_limit;
211 $this->enableedit = $a_enableedit;
221 $this->repositorymode = $a_repositorymode;
231 $this->subtitle = $a_subtitle;
244 $this->refid = $a_refid;
254 $this->admincommands = $a_admincommands;
264 $this->enablenuminfo = $a_enablenuminfo;
278 $this->
property = $a_properties;
283 return $this->
property[$a_property] ??
null;
286 public function setProperty(
string $a_property,
string $a_value): void
288 $this->
property[$a_property] = $a_value;
295 string $a_rowtemplatename,
296 string $a_rowtemplatedir =
""
298 $this->rowtemplatename = $a_rowtemplatename;
299 $this->rowtemplatedir = $a_rowtemplatedir;
304 return $this->getBlockType() .
"_" . $this->getBlockId() .
"_blnav";
309 return $this->getBlockType() .
"_" . $this->getBlockId() .
"_blconf";
314 return $this->getBlockType() .
"_" . $this->getBlockId() .
"_blmove";
319 return $this->rowtemplatename;
324 return $this->rowtemplatedir;
327 public function addBlockCommand(
string $a_href,
string $a_text,
string $a_onclick =
""): void
329 $this->block_commands[] = [
332 "onclick" => $a_onclick
338 return $this->block_commands;
352 $this->initCommands();
354 if ($this->new_rendering) {
355 return $this->getHTMLNew();
358 $ilCtrl = $this->ctrl;
360 $ilAccess = $this->access;
362 $objDefinition = $this->obj_def;
364 if ($this->isRepositoryObject()) {
365 if (!$ilAccess->checkAccess(
"read",
"", $this->getRefId())) {
370 $this->tpl =
new ilTemplate(
"tpl.block.html",
true,
true,
"Services/Block");
374 $this->fillDataSection();
375 if ($this->getRepositoryMode() && $this->isRepositoryObject()) {
378 if ($this->getAdminCommands()) {
379 $this->tpl->setCurrentBlock(
"block_check");
380 $this->tpl->setVariable(
"BL_REF_ID", $this->getRefId());
381 $this->tpl->parseCurrentBlock();
384 if ($ilAccess->checkAccess(
"delete",
"", $this->getRefId())) {
385 $this->addBlockCommand(
386 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->requested_ref_id .
"&cmd=delete" .
387 "&item_ref_id=" . $this->getRefId(),
392 $this->addBlockCommand(
393 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->requested_ref_id .
"&cmd=cut" .
394 "&item_ref_id=" . $this->getRefId(),
400 if ($ilAccess->checkAccess(
"copy",
"", $this->getRefId())) {
402 $parent_gui =
"ilObj" . $objDefinition->getClassName($parent_type) .
"GUI";
404 $ilCtrl->setParameterByClass(
"ilobjectcopygui",
"source_id", $this->getRefId());
405 $copy_cmd = $ilCtrl->getLinkTargetByClass(
406 array(
"ilrepositorygui", $parent_gui,
"ilobjectcopygui"),
407 "initTargetSelection"
411 $this->addBlockCommand(
418 $this->dropdown = array();
421 if (count($this->getBlockCommands()) > 0) {
422 foreach ($this->getBlockCommands() as $command) {
423 if ($command[
"onclick"]) {
424 $command[
"onclick"] =
"ilBlockJSHandler('" .
"block_" . $this->getBlockType() .
"_" . $this->block_id .
425 "','" . $command[
"onclick"] .
"')";
427 $this->dropdown[] = $command;
432 $this->fillPreviousNext();
438 $this->fillHeaderCommands();
439 $this->fillHeaderTitleBlock();
441 if ($this->getPresentation() === self::PRES_MAIN_LEG) {
442 $this->tpl->touchBlock(
"hclassb");
444 $this->tpl->touchBlock(
"hclass");
447 if ($ilCtrl->isAsynch()) {
449 echo $this->tpl->get();
453 return '<div id="' .
"block_" . $this->getBlockType() .
"_" . $this->block_id .
'">' .
454 $this->tpl->get() .
'</div>';
463 $dropdown->setUseImages(
true);
466 $dropdown->setId(
"block_dd_" . $this->getBlockType() .
"_" . $this->block_id);
467 foreach ($this->dropdown as $item) {
468 if ($item[
"href"] || $item[
"onclick"]) {
469 if (isset($item[
"checked"]) && $item[
"checked"]) {
476 $item[
"image"] ??
"",
485 $dropdown = $dropdown->getHTML();
486 $this->tpl->setCurrentBlock(
"header_dropdown");
487 $this->tpl->setVariable(
"ADV_DROPDOWN", $dropdown);
488 $this->tpl->parseCurrentBlock();
490 $this->tpl->setCurrentBlock(
"hitem");
491 $this->tpl->parseCurrentBlock();
500 $this->tpl->setCurrentBlock(
"header_title");
501 $this->tpl->setVariable(
503 "block_" . $this->getBlockType() .
"_" . $this->block_id
505 $this->tpl->setVariable(
509 $this->tpl->setVariable(
513 $this->tpl->parseCurrentBlock();
515 $this->tpl->setCurrentBlock(
"hitem");
516 $this->tpl->parseCurrentBlock();
524 $this->tpl->setCurrentBlock(
"data_section");
525 $this->tpl->setVariable(
"DATA", $a_content);
526 $this->tpl->parseCurrentBlock();
527 $this->tpl->setVariable(
"BLOCK_ROW",
"");
536 $req_nav_par = $this->request->getNavPar($this->getNavParameter());
537 if ($req_nav_par !=
"") {
538 $this->nav_value = $req_nav_par;
540 $this->nav_value = ($this->nav_value !=
"")
542 : $this->block_manager->getNavPar($this->getNavParameter());
544 $this->block_manager->setNavPar(
545 $this->getNavParameter(),
549 $nav = explode(
":", $this->nav_value);
550 if (isset($nav[2])) {
551 $this->setOffset((
int) $nav[2]);
557 $this->tpl->addBlockFile(
560 $this->getRowTemplateName(),
561 $this->getRowTemplateDir()
564 $data = $this->getData();
565 $this->max_count = count(
$data);
566 $this->correctOffset();
567 $data = array_slice(
$data, $this->getOffset(), $this->getLimit());
569 $this->preloadData(
$data);
571 foreach (
$data as $record) {
572 $this->tpl->setCurrentBlock(
"block_row");
573 $this->fillRowColor();
574 $this->fillRow($record);
575 $this->tpl->setCurrentBlock(
"block_row");
576 $this->tpl->parseCurrentBlock();
582 foreach ($a_set as
$key => $value) {
583 $this->tpl->setVariable(
"VAL_" . strtoupper(
$key), $value);
591 final protected function fillRowColor(
string $a_placeholder =
"CSS_ROW"): void
593 $this->css_row = ($this->css_row !=
"ilBlockRow1")
596 $this->tpl->setVariable($a_placeholder, $this->css_row);
605 if ($this->getEnableNumInfo() && $this->max_count > 0) {
606 $start = $this->getOffset() + 1;
607 $end = $this->getOffset() + $this->getLimit();
609 if ($end > $this->max_count or $this->getLimit() == 0) {
610 $end = $this->max_count;
613 $numinfo =
"(" . $start .
"-" . $end .
" " . strtolower(
$lng->txt(
"of")) .
" " . $this->max_count .
")";
616 $this->setPreviousNextLinks();
617 $this->tpl->setVariable(
"NUMINFO", $numinfo);
638 header(
"Content-type: text/html; charset=UTF-8");
639 return $this->tpl->get();
647 protected bool $new_rendering =
false;
667 if ($this->getPresentation() == self::PRES_SEC_LIST) {
668 $pg_view_control = $this->getPaginationViewControl();
669 if (!is_null($pg_view_control)) {
670 return [$pg_view_control];
693 $reg_page = $this->request->getNavPage($this->getNavParameter());
694 if ($reg_page !==
"") {
695 $this->nav_value =
"::" . ($reg_page * $this->getLimit());
698 if ($this->nav_value ==
"") {
699 $this->nav_value = $this->block_manager->getNavPar($this->getNavParameter());
702 $this->block_manager->setNavPar(
703 $this->getNavParameter(),
707 $nav = explode(
":", $this->nav_value);
708 if (isset($nav[2])) {
709 $this->setOffset((
int) $nav[2]);
721 $data = $this->getData();
722 $this->max_count = count(
$data);
723 $this->correctOffset();
724 $data = array_slice(
$data, $this->getOffset(), $this->getLimit());
725 $this->preloadData(
$data);
740 $data = $this->loadData();
744 foreach (
$data as $record) {
745 $item = $this->getListItemForData($record);
746 if ($item !==
null) {
751 $item_group =
$factory->item()->group(
"", $items);
753 return [$item_group];
764 $ilCtrl = $this->ctrl;
771 $ilCtrl->setParameterByClass(
774 "block_" . $this->getBlockType() .
"_" . $this->block_id
776 $block_id =
"block_" . $this->getBlockType() .
"_" . $this->block_id;
777 $onclick = $ilCtrl->getLinkTargetByClass(
783 $ilCtrl->setParameterByClass(
790 $href = $ilCtrl->getLinkTargetByClass(
"ilcolumngui",
"",
"",
false,
false);
795 if ($this->max_count <= $this->getLimit()) {
799 return $factory->viewControl()->pagination()
800 ->withTargetURL($href, $this->getNavParameter() .
"page")
801 ->withTotalEntries($this->max_count)
802 ->withPageSize($this->getLimit())
803 ->withMaxPaginationButtons(5)
804 ->withCurrentPage($this->getOffset() / $this->getLimit());
812 $access = $this->access;
815 $obj_def = $this->obj_def;
817 if ($this->getRepositoryMode() && $this->isRepositoryObject()) {
827 if ($access->
checkAccess(
"delete",
"", $this->getRefId())) {
828 $this->addBlockCommand(
829 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->requested_ref_id .
"&cmd=delete" .
830 "&item_ref_id=" . $this->getRefId(),
834 $this->addBlockCommand(
835 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->requested_ref_id .
"&cmd=link" .
836 "&item_ref_id=" . $this->getRefId(),
841 $this->addBlockCommand(
842 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->requested_ref_id .
"&cmd=cut" .
843 "&item_ref_id=" . $this->getRefId(),
849 if ($access->
checkAccess(
"copy",
"", $this->getRefId())) {
851 $parent_gui =
"ilObj" . $obj_def->
getClassName($parent_type) .
"GUI";
855 array(
"ilrepositorygui", $parent_gui,
"ilobjectcopygui"),
856 "initTargetSelection"
860 $this->addBlockCommand(
872 $renderer =
$DIC->ui()->renderer();
873 $access = $this->access;
878 if ($this->isRepositoryObject()) {
879 if (!$access->
checkAccess(
"read",
"", $this->getRefId())) {
884 $this->addRepoCommands();
886 switch ($this->getPresentation()) {
887 case self::PRES_SEC_LEG:
889 $this->specialCharsAsEntities($this->getTitle()),
890 $factory->legacy($this->getLegacyContent())
894 case self::PRES_MAIN_LEG:
896 $this->specialCharsAsEntities($this->getTitle()),
897 $factory->legacy($this->getLegacyContent())
901 case self::PRES_SEC_LIST:
902 $this->handleNavigation();
904 $this->specialCharsAsEntities($this->getTitle()),
905 $this->getListItemGroups()
909 case self::PRES_MAIN_TILE:
910 case self::PRES_MAIN_LIST:
911 $this->handleNavigation();
913 $this->specialCharsAsEntities($this->getTitle()),
914 $this->getListItemGroups()
923 foreach ($this->getBlockCommands() as $command) {
924 $href = ($command[
"onclick"] !=
"")
927 $button =
$factory->button()->shy($command[
"text"], $href);
928 if ($command[
"onclick"]) {
929 $button = $button->withOnLoadCode(
function (
$id) use ($command) {
931 "$(\"#$id\").click(function() { ilBlockJSHandler('" .
"block_" . $this->getBlockType() .
"_" . $this->block_id .
932 "','" . $command[
"onclick"] .
"');});";
935 $actions[] = $button;
939 if (in_array($this->getPresentation(), [self::PRES_SEC_LIST, self::PRES_MAIN_LIST]) &&
940 (count(
$panel->getItemGroups()) == 0 || (count(
$panel->getItemGroups()) == 1 && count(
$panel->getItemGroups()[0]->getItems()) == 0))) {
941 if ($this->getPresentation() == self::PRES_SEC_LIST) {
943 $this->specialCharsAsEntities($this->getTitle()),
944 $factory->legacy($this->getNoItemFoundContent())
948 $this->specialCharsAsEntities($this->getTitle()),
949 $factory->legacy($this->getNoItemFoundContent())
955 if (count($actions) > 0) {
956 $actions =
$factory->dropdown()->standard($actions)
957 ->withAriaLabel(sprintf(
958 $this->
lng->txt(
'actions_for'),
959 htmlspecialchars($this->getTitle())
970 $html = $renderer->renderAsync(
$panel);
972 $html = $renderer->render(
$panel);
980 $html =
'<div id="' .
"block_" . $this->getBlockType() .
"_" . $this->block_id .
'">' .
991 protected function send(
string $output): void
993 $this->
http->saveResponse($this->
http->response()->withBody(
994 Streams::ofString($output)
996 $this->
http->sendResponse();
997 $this->
http->close();
1002 return $this->
lng->txt(
"no_items");
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a block method of a block.
send(string $output)
Send.
setDataSection(string $a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
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)
ilObjectDefinition $obj_def
setAdminCommands(bool $a_admincommands)
handleNavigation()
Handle navigation.
getProperty(string $a_property)
preloadData(array $data)
Can be overwritten in subclasses.
fillDataSection()
Standard implementation for row based data.
addBlockCommand(string $a_href, string $a_text, string $a_onclick="")
setProperties(array $a_properties)
This function is supposed to be used for block type specific properties, that should be inherited thr...
ILIAS Block BlockManager $block_manager
ilGlobalTemplateInterface $main_tpl
loadData()
Load data for current page.
ILIAS Block StandardGUIRequest $request
fillRowColor(string $a_placeholder="CSS_ROW")
getListItemGroups()
Get items.
setGuiObject(object $a_gui_object)
Set GuiObject.
addRepoCommands()
Add repo commands.
setRepositoryMode(bool $a_repositorymode)
getLegacyContent()
Get legacy content.
setBlockId(string $a_block_id="0")
getViewControls()
Get view controls.
getPaginationViewControl()
Fill previous/next row.
ILIAS HTTP GlobalHttpState $http
setProperty(string $a_property, string $a_value)
getListItemForData(array $data)
Get list item for data array.
setEnableEdit(bool $a_enableedit)
setRefId(int $a_refid)
Set Ref Id (only used if isRepositoryObject() is true).
setSubtitle(string $a_subtitle)
setEnableNumInfo(bool $a_enablenuminfo)
setRowTemplate(string $a_rowtemplatename, string $a_rowtemplatedir="")
Set Row Template Name.
Class ilCtrl provides processing control methods.
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
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
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getViewControls()
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.
catch(ilCmiXapiException $e) send($response)