19 declare(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()
92 $this->presentation = self::PRES_SEC_LEG;
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;
327 public function addBlockCommand(
string $a_href,
string $a_text,
string $a_onclick =
""): void
329 $this->block_commands[] = [
332 "onclick" => $a_onclick
354 if ($this->new_rendering) {
365 if (!$ilAccess->checkAccess(
"read",
"", $this->getRefId())) {
370 $this->tpl =
new ilTemplate(
"tpl.block.html",
true,
true,
"Services/Block");
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())) {
386 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->requested_ref_id .
"&cmd=delete" .
387 "&item_ref_id=" . $this->
getRefId(),
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" 418 $this->dropdown = array();
423 if ($command[
"onclick"]) {
424 $command[
"onclick"] =
"ilBlockJSHandler('" .
"block_" . $this->
getBlockType() .
"_" . $this->block_id .
425 "','" . $command[
"onclick"] .
"')";
427 $this->dropdown[] = $command;
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",
"");
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(
549 $nav = explode(
":", $this->nav_value);
550 if (isset($nav[2])) {
557 $this->tpl->addBlockFile(
565 $this->max_count = count($data);
571 foreach ($data as $record) {
572 $this->tpl->setCurrentBlock(
"block_row");
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);
609 if ($end > $this->max_count or $this->
getLimit() == 0) {
613 $numinfo =
"(" . $start .
"-" . $end .
" " . strtolower($lng->
txt(
"of")) .
" " . $this->max_count .
")";
617 $this->tpl->setVariable(
"NUMINFO", $numinfo);
638 header(
"Content-type: text/html; charset=UTF-8");
639 return $this->tpl->get();
669 if (!is_null($pg_view_control)) {
670 return [$pg_view_control];
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(
707 $nav = explode(
":", $this->nav_value);
708 if (isset($nav[2])) {
722 $this->max_count = count($data);
744 foreach ($data as $record) {
746 if ($item !== null) {
751 $item_group =
$factory->item()->group(
"", $items);
753 return [$item_group];
774 "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()
801 ->withTotalEntries($this->max_count)
803 ->withMaxPaginationButtons(5)
827 if ($access->
checkAccess(
"delete",
"", $this->getRefId())) {
829 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->requested_ref_id .
"&cmd=delete" .
830 "&item_ref_id=" . $this->
getRefId(),
835 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->requested_ref_id .
"&cmd=link" .
836 "&item_ref_id=" . $this->
getRefId(),
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" 872 $renderer = $DIC->ui()->renderer();
879 if (!$access->
checkAccess(
"read",
"", $this->getRefId())) {
887 case self::PRES_SEC_LEG:
890 $factory->legacy($this->getLegacyContent())
894 case self::PRES_MAIN_LEG:
897 $factory->legacy($this->getLegacyContent())
901 case self::PRES_SEC_LIST:
909 case self::PRES_MAIN_TILE:
910 case self::PRES_MAIN_LIST:
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))) {
944 $factory->legacy($this->getNoItemFoundContent())
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'),
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");
ILIAS Block BlockManager $block_manager
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
ilObjectDefinition $obj_def
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
fillRowColor(string $a_placeholder="CSS_ROW")
setProperties(array $a_properties)
This function is supposed to be used for block type specific properties, that should be inherited thr...
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
setBlockId(string $a_block_id="0")
setDataSection(string $a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
handleNavigation()
Handle navigation.
send(string $output)
Send.
Class ChatMainBarProvider .
addRepoCommands()
Add repo commands.
setEnableNumInfo(bool $a_enablenuminfo)
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) ...
setEnableEdit(bool $a_enableedit)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setParameterByClass(string $a_class, string $a_parameter, $a_value)
specialCharsAsEntities(string $string)
getLegacyContent()
Get legacy content.
setProperty(string $a_property, string $a_value)
ILIAS Block StandardGUIRequest $request
setRowTemplate(string $a_rowtemplatename, string $a_rowtemplatedir="")
Set Row Template Name.
parses the objects.xml it handles the xml-description of all ilias objects
ilGlobalTemplateInterface $main_tpl
static http()
Fetches the global http state from ILIAS.
preloadData(array $data)
Can be overwritten in subclasses.
getListItemForData(array $data)
Get list item for data array.
setAdminCommands(bool $a_admincommands)
getListItemGroups()
Get items.
getPaginationViewControl()
Fill previous/next row.
getClassName(string $obj_name)
getAsynch()
Use this for final get before sending asynchronous output (ajax) per echo to output.
setRefId(int $a_refid)
Set Ref Id (only used if isRepositoryObject() is true).
getViewControls()
Get view controls.
setGuiObject(object $a_gui_object)
Set GuiObject.
ILIAS HTTP GlobalHttpState $http
loadData()
Load data for current page.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
setTitle(string $a_title)
setSubtitle(string $a_subtitle)
isRepositoryObject()
Returns whether block has a corresponding repository object.
This class represents a block method of a block.
addBlockCommand(string $a_href, string $a_text, string $a_onclick="")
setRepositoryMode(bool $a_repositorymode)
static _lookupType(int $id, bool $reference=false)
fillDataSection()
Standard implementation for row based data.
getProperty(string $a_property)
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
setPresentation(int $type)