ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilBlockGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12abstract class ilBlockGUI
13{
14 const PRES_MAIN_LEG = 0; // main legacy panel
15 const PRES_SEC_LEG = 1; // secondary legacy panel
16 const PRES_SEC_LIST = 2; // secondary list panel
17 const PRES_MAIN_LIST = 3; // main standard list panel
18
22 protected $ui;
23
27 abstract public function getBlockType() : string;
28
34 abstract protected function isRepositoryObject() : bool;
35
36 protected $data = array();
37 protected $enablenuminfo = true;
38 protected $footer_links = array();
39 protected $block_id = 0;
40 protected $allow_moving = true;
41 protected $move = array("left" => false, "right" => false, "up" => false, "down" => false);
42 protected $block_commands = array();
43 protected $max_count = false;
44 protected $close_command = false;
45 protected $image = false;
46 protected $property = false;
47 protected $nav_value = "";
48 protected $css_row = "";
49
53 protected $title = "";
54
55
59 protected $admincommands = false;
60
61 protected $dropdown;
62
66 protected $tpl;
67
71 protected $main_tpl;
72
76 protected $user;
77
81 protected $ctrl;
82
86 protected $access;
87
91 protected $lng;
92
96 protected $obj_def;
97
101 protected $presentation;
102
108 public function __construct()
109 {
110 global $DIC;
111
112 // default presentation
113 $this->presentation = self::PRES_SEC_LEG;
114
115 $this->user = $DIC->user();
116 $this->ctrl = $DIC->ctrl();
117 $this->access = $DIC->access();
118 $this->lng = $DIC->language();
119 $this->main_tpl = $DIC["tpl"];
120 $this->obj_def = $DIC["objDefinition"];
121 $this->ui = $DIC->ui();
122
123 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
125 $this->main_tpl->addJavaScript("./Services/Block/js/ilblockcallback.js");
126
127 $this->setLimit($this->user->getPref("hits_per_page"));
128 }
129
130
136 public function setData($a_data)
137 {
138 $this->data = $a_data;
139 }
140
146 public function getData()
147 {
148 return $this->data;
149 }
150
156 public function setPresentation(int $type)
157 {
158 $this->presentation = $type;
159 }
160
166 public function getPresentation() : int
167 {
168 return $this->presentation;
169 }
170
176 public function setBlockId($a_block_id = 0)
177 {
178 $this->block_id = $a_block_id;
179 }
180
186 public function getBlockId()
187 {
188 return $this->block_id;
189 }
190
191
199 public function setGuiObject(&$a_gui_object)
200 {
201 $this->gui_object = $a_gui_object;
202 }
203
209 public function getGuiObject()
210 {
211 return $this->gui_object;
212 }
213
214
220 public function setTitle($a_title)
221 {
222 $this->title = $a_title;
223 }
224
230 public function getTitle()
231 {
232 return (string) $this->title;
233 }
234
240 public function setOffset($a_offset)
241 {
242 $this->offset = $a_offset;
243 }
244
250 public function getOffset()
251 {
252 return $this->offset;
253 }
254
255 public function correctOffset()
256 {
257 if (!($this->offset < $this->max_count)) {
258 $this->setOffset(0);
259 }
260 }
261
267 public function setLimit($a_limit)
268 {
269 $this->limit = $a_limit;
270 }
271
277 public function getLimit()
278 {
279 return $this->limit;
280 }
281
287 public function setEnableEdit($a_enableedit)
288 {
289 $this->enableedit = $a_enableedit;
290 }
291
297 public function getEnableEdit()
298 {
299 return $this->enableedit;
300 }
301
307 public function setRepositoryMode($a_repositorymode)
308 {
309 $this->repositorymode = $a_repositorymode;
310 }
311
317 public function getRepositoryMode()
318 {
319 return $this->repositorymode;
320 }
321
322
328 public function setSubtitle($a_subtitle)
329 {
330 $this->subtitle = $a_subtitle;
331 }
332
338 public function getSubtitle()
339 {
340 return $this->subtitle;
341 }
342
348 public function setRefId($a_refid)
349 {
350 $this->refid = $a_refid;
351 }
352
358 public function getRefId()
359 {
360 return $this->refid;
361 }
362
368 public function setAdminCommands(bool $a_admincommands)
369 {
370 $this->admincommands = $a_admincommands;
371 }
372
378 public function getAdminCommands() : bool
379 {
381 }
382
388 public function setEnableNumInfo($a_enablenuminfo)
389 {
390 $this->enablenuminfo = $a_enablenuminfo;
391 }
392
398 public function getEnableNumInfo()
399 {
401 }
402
409 public function setProperties($a_properties)
410 {
411 $this->property = $a_properties;
412 }
413
414 public function getProperty($a_property)
415 {
416 return $this->property[$a_property];
417 }
418
419 public function setProperty($a_property, $a_value)
420 {
421 $this->property[$a_property] = $a_value;
422 }
423
429 public function setRowTemplate($a_rowtemplatename, $a_rowtemplatedir = "")
430 {
431 $this->rowtemplatename = $a_rowtemplatename;
432 $this->rowtemplatedir = $a_rowtemplatedir;
433 }
434
435 final public function getNavParameter()
436 {
437 return $this->getBlockType() . "_" . $this->getBlockId() . "_blnav";
438 }
439
440 final public function getConfigParameter()
441 {
442 return $this->getBlockType() . "_" . $this->getBlockId() . "_blconf";
443 }
444
445 final public function getMoveParameter()
446 {
447 return $this->getBlockType() . "_" . $this->getBlockId() . "_blmove";
448 }
449
455 public function getRowTemplateName()
456 {
457 return $this->rowtemplatename;
458 }
459
465 public function getRowTemplateDir()
466 {
467 return $this->rowtemplatedir;
468 }
469
477 public function addBlockCommand(string $a_href, string $a_text, string $a_onclick = "") : void
478 {
479 $this->block_commands[] = [
480 "href" => $a_href,
481 "text" => $a_text,
482 "onclick" => $a_onclick
483 ];
484 }
485
491 public function getBlockCommands() : array
492 {
494 }
495
496
497
501 public static function getScreenMode()
502 {
503 return IL_SCREEN_SIDE;
504 }
505
509 protected function initCommands()
510 {
511 }
512
513
517 public function getHTML()
518 {
519 $this->initCommands();
520
521 if ($this->new_rendering) {
522 return $this->getHTMLNew();
523 }
524
527 $ilAccess = $this->access;
529 $objDefinition = $this->obj_def;
530
531 if ($this->isRepositoryObject()) {
532 if (!$ilAccess->checkAccess("read", "", $this->getRefId())) {
533 return "";
534 }
535 }
536
537 $this->tpl = new ilTemplate("tpl.block.html", true, true, "Services/Block");
538
539 // $this->handleConfigStatus();
540
541 $this->fillDataSection();
542 if ($this->getRepositoryMode() && $this->isRepositoryObject()) {
543 // #10993
544 // @todo: fix this in new presentation somehow
545 if ($this->getAdminCommands()) {
546 $this->tpl->setCurrentBlock("block_check");
547 $this->tpl->setVariable("BL_REF_ID", $this->getRefId());
548 $this->tpl->parseCurrentBlock();
549 }
550
551 if ($ilAccess->checkAccess("delete", "", $this->getRefId())) {
552 $this->addBlockCommand(
553 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $_GET["ref_id"] . "&cmd=delete" .
554 "&item_ref_id=" . $this->getRefId(),
555 $lng->txt("delete")
556 );
557
558 // see ilObjectListGUI::insertCutCommand();
559 $this->addBlockCommand(
560 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $_GET["ref_id"] . "&cmd=cut" .
561 "&item_ref_id=" . $this->getRefId(),
562 $lng->txt("move")
563 );
564 }
565
566 // #14595 - see ilObjectListGUI::insertCopyCommand()
567 if ($ilAccess->checkAccess("copy", "", $this->getRefId())) {
568 $parent_type = ilObject::_lookupType($_GET["ref_id"], true);
569 $parent_gui = "ilObj" . $objDefinition->getClassName($parent_type) . "GUI";
570
571 $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $this->getRefId());
572 $copy_cmd = $ilCtrl->getLinkTargetByClass(
573 array("ilrepositorygui", $parent_gui, "ilobjectcopygui"),
574 "initTargetSelection"
575 );
576
577 // see ilObjectListGUI::insertCopyCommand();
578 $this->addBlockCommand(
579 $copy_cmd,
580 $lng->txt("copy")
581 );
582 }
583 }
584
585 $this->dropdown = array();
586
587 // commands
588 if (count($this->getBlockCommands()) > 0) {
589 foreach ($this->getBlockCommands() as $command) {
590 if ($command["onclick"]) {
591 $command["onclick"] = "ilBlockJSHandler('" . "block_" . $this->getBlockType() . "_" . $this->block_id .
592 "','" . $command["onclick"] . "')";
593 }
594 $this->dropdown[] = $command;
595 }
596 }
597
598 // fill previous next
599 $this->fillPreviousNext();
600
601 // fill footer
602 $this->fillFooter();
603
604
605 // for screen readers we first output the title and the commands
606 // (e.g. close icon afterwards), otherwise we first output the
607 // header commands, since we want to have the close icon top right
608 // and not floated after the title
609 if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) {
610 $this->fillHeaderTitleBlock();
611 $this->fillHeaderCommands();
612 } else {
613 $this->fillHeaderCommands();
614 $this->fillHeaderTitleBlock();
615 }
616
617 if ($this->getPresentation() === self::PRES_MAIN_LEG) {
618 $this->tpl->touchBlock("hclassb");
619 } else {
620 $this->tpl->touchBlock("hclass");
621 }
622
623 if ($ilCtrl->isAsynch()) {
624 // return without div wrapper
625 echo $this->tpl->get();
626 //echo $this->tpl->getAsynch();
627 } else {
628 // return incl. wrapping div with id
629 return '<div id="' . "block_" . $this->getBlockType() . "_" . $this->block_id . '">' .
630 $this->tpl->get() . '</div>';
631 }
632 }
633
637 public function fillHeaderCommands()
638 {
639 // adv selection gui
640 include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
642 $dropdown->setUseImages(true);
645 $dropdown->setId("block_dd_" . $this->getBlockType() . "_" . $this->block_id);
646 foreach ($this->dropdown as $item) {
647 if ($item["href"] || $item["onclick"]) {
648 if ($item["checked"]) {
649 $item["image"] = ilUtil::getImagePath("icon_checked.svg");
650 }
651 $dropdown->addItem(
652 $item["text"],
653 "",
654 $item["href"],
655 $item["image"],
656 $item["text"],
657 "",
658 "",
659 false,
660 $item["onclick"]
661 );
662 }
663 }
664 $dropdown = $dropdown->getHTML();
665 $this->tpl->setCurrentBlock("header_dropdown");
666 $this->tpl->setVariable("ADV_DROPDOWN", $dropdown);
667 $this->tpl->parseCurrentBlock();
668
669 $this->tpl->setCurrentBlock("hitem");
670 $this->tpl->parseCurrentBlock();
671 }
672
673
677 public function fillHeaderTitleBlock()
678 {
680
681
682 // header title
683 $this->tpl->setCurrentBlock("header_title");
684 $this->tpl->setVariable(
685 "BTID",
686 "block_" . $this->getBlockType() . "_" . $this->block_id
687 );
688 $this->tpl->setVariable(
689 "BLOCK_TITLE",
690 $this->getTitle()
691 );
692 $this->tpl->setVariable(
693 "TXT_BLOCK",
694 $lng->txt("block")
695 );
696 $this->tpl->parseCurrentBlock();
697
698 $this->tpl->setCurrentBlock("hitem");
699 $this->tpl->parseCurrentBlock();
700 }
701
702
706 public function setDataSection($a_content)
707 {
708 $this->tpl->setCurrentBlock("data_section");
709 $this->tpl->setVariable("DATA", $a_content);
710 $this->tpl->parseCurrentBlock();
711 $this->tpl->setVariable("BLOCK_ROW", "");
712 }
713
718 public function fillDataSection()
719 {
720 $this->nav_value = (isset($_POST[$this->getNavParameter()]) && $_POST[$this->getNavParameter()] != "")
721 ? $_POST[$this->getNavParameter()]
722 : (isset($_GET[$this->getNavParameter()]) ? $_GET[$this->getNavParameter()] : $this->nav_value);
723 $this->nav_value = ($this->nav_value == "" && isset($_SESSION[$this->getNavParameter()]))
724 ? $_SESSION[$this->getNavParameter()]
726
728
729 $nav = explode(":", $this->nav_value);
730 if (isset($nav[2])) {
731 $this->setOffset($nav[2]);
732 } else {
733 $this->setOffset(0);
734 }
735
736 // data
737 $this->tpl->addBlockFile(
738 "BLOCK_ROW",
739 "block_row",
740 $this->getRowTemplateName(),
741 $this->getRowTemplateDir()
742 );
743
744 $data = $this->getData();
745 $this->max_count = count($data);
746 $this->correctOffset();
747 $data = array_slice($data, $this->getOffset(), $this->getLimit());
748
749 $this->preloadData($data);
750
751 foreach ($data as $record) {
752 $this->tpl->setCurrentBlock("block_row");
753 $this->fillRowColor();
754 $this->fillRow($record);
755 $this->tpl->setCurrentBlock("block_row");
756 $this->tpl->parseCurrentBlock();
757 }
758 }
759
760 public function fillRow($a_set)
761 {
762 foreach ($a_set as $key => $value) {
763 $this->tpl->setVariable("VAL_" . strtoupper($key), $value);
764 }
765 }
766
767 public function fillFooter()
768 {
769 }
770
771 final protected function fillRowColor($a_placeholder = "CSS_ROW")
772 {
773 $this->css_row = ($this->css_row != "ilBlockRow1")
774 ? "ilBlockRow1"
775 : "ilBlockRow2";
776 $this->tpl->setVariable($a_placeholder, $this->css_row);
777 }
778
782 public function fillPreviousNext()
783 {
785
786 // table pn numinfo
787 $numinfo = "";
788 if ($this->getEnableNumInfo() && $this->max_count > 0) {
789 $start = $this->getOffset() + 1; // compute num info
790 $end = $this->getOffset() + $this->getLimit();
791
792 if ($end > $this->max_count or $this->getLimit() == 0) {
793 $end = $this->max_count;
794 }
795
796 $numinfo = "(" . $start . "-" . $end . " " . strtolower($lng->txt("of")) . " " . $this->max_count . ")";
797 }
798
799 $this->setPreviousNextLinks();
800 $this->tpl->setVariable("NUMINFO", $numinfo);
801 }
802
810 public function setPreviousNextLinks()
811 {
812 // @todo: fix this
813 return false;
814
815
818
819 // if more entries then entries per page -> show link bar
820 if ($this->max_count > $this->getLimit() && ($this->getLimit() != 0)) {
821 // previous link
822 if ($this->getOffset() >= 1) {
823 $prevoffset = $this->getOffset() - $this->getLimit();
824
825 $ilCtrl->setParameterByClass(
826 "ilcolumngui",
827 $this->getNavParameter(),
828 "::" . $prevoffset
829 );
830
831 // ajax link
832 $ilCtrl->setParameterByClass(
833 "ilcolumngui",
834 "block_id",
835 "block_" . $this->getBlockType() . "_" . $this->block_id
836 );
837 $block_id = "block_" . $this->getBlockType() . "_" . $this->block_id;
838 $onclick = $ilCtrl->getLinkTargetByClass(
839 "ilcolumngui",
840 "updateBlock",
841 "",
842 true
843 );
844 $ilCtrl->setParameterByClass(
845 "ilcolumngui",
846 "block_id",
847 ""
848 );
849
850 // normal link
851 $href = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
852 $text = $lng->txt("previous");
853
854 // $this->addFooterLink($text, $href, $onclick, $block_id, true);
855 }
856
857 // calculate number of pages
858 $pages = intval($this->max_count / $this->getLimit());
859
860 // add a page if a rest remains
861 if (($this->max_count % $this->getLimit())) {
862 $pages++;
863 }
864
865 // show next link (if not last page)
866 if (!(($this->getOffset() / $this->getLimit()) == ($pages - 1)) && ($pages != 1)) {
867 $newoffset = $this->getOffset() + $this->getLimit();
868
869 $ilCtrl->setParameterByClass(
870 "ilcolumngui",
871 $this->getNavParameter(),
872 "::" . $newoffset
873 );
874
875 // ajax link
876 $ilCtrl->setParameterByClass(
877 "ilcolumngui",
878 "block_id",
879 "block_" . $this->getBlockType() . "_" . $this->block_id
880 );
881 //$this->tpl->setCurrentBlock("pnonclick");
882 $block_id = "block_" . $this->getBlockType() . "_" . $this->block_id;
883 $onclick = $ilCtrl->getLinkTargetByClass(
884 "ilcolumngui",
885 "updateBlock",
886 "",
887 true
888 );
889 //echo "-".$onclick."-";
890 //$this->tpl->parseCurrentBlock();
891 $ilCtrl->setParameterByClass(
892 "ilcolumngui",
893 "block_id",
894 ""
895 );
896
897 // normal link
898 $href = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
899 $text = $lng->txt("next");
900
901 // $this->addFooterLink($text, $href, $onclick, $block_id, true);
902 }
903 $ilCtrl->setParameterByClass(
904 "ilcolumngui",
905 $this->getNavParameter(),
906 ""
907 );
908 return true;
909 } else {
910 return false;
911 }
912 }
913
918 protected function preloadData(array $data)
919 {
920 }
921
926 public function getAsynch()
927 {
928 header("Content-type: text/html; charset=UTF-8");
929 return $this->tpl->get();
930 }
931
932 //
933 // New rendering
934 //
935
936 // temporary flag
937 protected $new_rendering = false;
938
939
945 protected function getLegacyContent() : string
946 {
947 return "";
948 }
949
955 protected function getViewControls() : array
956 {
957 if ($this->getPresentation() == self::PRES_SEC_LIST) {
958 $pg_view_control = $this->getPaginationViewControl();
959 if (!is_null($pg_view_control)) {
960 return [$pg_view_control];
961 }
962 }
963 return [];
964 }
965
972 protected function getListItemForData(array $data) : \ILIAS\UI\Component\Item\Item
973 {
974 return null;
975 }
976
977
981 protected function handleNavigation()
982 {
983 $reg_page = $_REQUEST[$this->getNavParameter() . "page"];
984 if ($reg_page !== "") {
985 $this->nav_value = "::" . ($reg_page * $this->getLimit());
986 }
987
988 if ($this->nav_value == "" && isset($_SESSION[$this->getNavParameter()])) {
989 $this->nav_value = $_SESSION[$this->getNavParameter()];
990 }
991
993
994 $nav = explode(":", $this->nav_value);
995 if (isset($nav[2])) {
996 $this->setOffset($nav[2]);
997 } else {
998 $this->setOffset(0);
999 }
1000 }
1001
1007 protected function loadData()
1008 {
1009 $data = $this->getData();
1010 $this->max_count = count($data);
1011 $this->correctOffset();
1012 $data = array_slice($data, $this->getOffset(), $this->getLimit());
1013 $this->preloadData($data);
1014 return $data;
1015 }
1016
1017
1023 protected function getListItemGroups() : array
1024 {
1025 global $DIC;
1026 $factory = $DIC->ui()->factory();
1027
1028 $data = $this->loadData();
1029
1030 $items = [];
1031
1032 foreach ($data as $record) {
1033 $item = $this->getListItemForData($record);
1034 if ($item !== null) {
1035 $items[] = $item;
1036 }
1037 }
1038
1039 $item_group = $factory->item()->group("", $items);
1040
1041 return [$item_group];
1042 }
1043
1048 {
1049 global $DIC;
1050 $factory = $DIC->ui()->factory();
1051
1053
1054
1055 // $ilCtrl->setParameterByClass("ilcolumngui",
1056 // $this->getNavParameter(), "::" . $prevoffset);
1057
1058 // ajax link
1059 $ilCtrl->setParameterByClass(
1060 "ilcolumngui",
1061 "block_id",
1062 "block_" . $this->getBlockType() . "_" . $this->block_id
1063 );
1064 $block_id = "block_" . $this->getBlockType() . "_" . $this->block_id;
1065 $onclick = $ilCtrl->getLinkTargetByClass(
1066 "ilcolumngui",
1067 "updateBlock",
1068 "",
1069 true
1070 );
1071 $ilCtrl->setParameterByClass(
1072 "ilcolumngui",
1073 "block_id",
1074 ""
1075 );
1076
1077 // normal link
1078 $href = $ilCtrl->getLinkTargetByClass("ilcolumngui", "", "", false, false);
1079
1080 //$ilCtrl->setParameterByClass("ilcolumngui",
1081 // $this->getNavParameter(), "");
1082
1083 if ($this->max_count <= $this->getLimit()) {
1084 return null;
1085 }
1086
1087 return $factory->viewControl()->pagination()
1088 ->withTargetURL($href, $this->getNavParameter() . "page")
1089 ->withTotalEntries($this->max_count)
1090 ->withPageSize($this->getLimit())
1091 ->withMaxPaginationButtons(5)
1092 ->withCurrentPage((int) $this->getOffset() / $this->getLimit());
1093 }
1094
1098 protected function addRepoCommands()
1099 {
1101 $lng = $this->lng;
1104
1105 if ($this->getRepositoryMode() && $this->isRepositoryObject()) {
1106 // #10993
1107 // @todo: fix this in new presentation somehow
1108 /*
1109 if ($this->getAdminCommands()) {
1110 $this->tpl->setCurrentBlock("block_check");
1111 $this->tpl->setVariable("BL_REF_ID", $this->getRefId());
1112 $this->tpl->parseCurrentBlock();
1113 }*/
1114
1115 if ($access->checkAccess("delete", "", $this->getRefId())) {
1116 $this->addBlockCommand(
1117 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $_GET["ref_id"] . "&cmd=delete" .
1118 "&item_ref_id=" . $this->getRefId(),
1119 $lng->txt("delete")
1120 );
1121
1122 // see ilObjectListGUI::insertCutCommand();
1123 $this->addBlockCommand(
1124 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $_GET["ref_id"] . "&cmd=cut" .
1125 "&item_ref_id=" . $this->getRefId(),
1126 $lng->txt("move")
1127 );
1128 }
1129
1130 // #14595 - see ilObjectListGUI::insertCopyCommand()
1131 if ($access->checkAccess("copy", "", $this->getRefId())) {
1132 $parent_type = ilObject::_lookupType($_GET["ref_id"], true);
1133 $parent_gui = "ilObj" . $obj_def->getClassName($parent_type) . "GUI";
1134
1135 $ctrl->setParameterByClass("ilobjectcopygui", "source_id", $this->getRefId());
1136 $copy_cmd = $ctrl->getLinkTargetByClass(
1137 array("ilrepositorygui", $parent_gui, "ilobjectcopygui"),
1138 "initTargetSelection"
1139 );
1140
1141 // see ilObjectListGUI::insertCopyCommand();
1142 $this->addBlockCommand(
1143 $copy_cmd,
1144 $lng->txt("copy")
1145 );
1146 }
1147 }
1148 }
1149
1153 public function getHTMLNew()
1154 {
1155 global $DIC;
1156 $factory = $DIC->ui()->factory();
1157 $renderer = $DIC->ui()->renderer();
1159
1161
1162 if ($this->isRepositoryObject()) {
1163 if (!$access->checkAccess("read", "", $this->getRefId())) {
1164 return "";
1165 }
1166 }
1167
1168 $this->addRepoCommands();
1169
1170 switch ($this->getPresentation()) {
1171 case self::PRES_SEC_LEG:
1172 $panel = $factory->panel()->secondary()->legacy(
1173 $this->getTitle(),
1174 $factory->legacy($this->getLegacyContent())
1175 );
1176 break;
1177
1179 $panel = $factory->panel()->standard(
1180 $this->getTitle(),
1181 $factory->legacy($this->getLegacyContent())
1182 );
1183 break;
1184
1186 $this->handleNavigation();
1187 $panel = $factory->panel()->secondary()->listing(
1188 $this->getTitle(),
1189 $this->getListItemGroups()
1190 );
1191 break;
1192
1194 $this->handleNavigation();
1195 $panel = $factory->panel()->listing()->standard(
1196 $this->getTitle(),
1197 $this->getListItemGroups()
1198 );
1199 break;
1200
1201 case self::PRES_MAIN_TILE:
1202 $this->handleNavigation();
1203 $panel = $factory->panel()->listing()->standard(
1204 $this->getTitle(),
1205 $this->getListItemGroups()
1206 );
1207 break;
1208 }
1209
1210 // actions
1211 $actions = [];
1212
1213 foreach ($this->getBlockCommands() as $command) {
1214 $href = ($command["onclick"] != "")
1215 ? ""
1216 : $command["href"];
1217 $button = $factory->button()->shy($command["text"], $href);
1218 if ($command["onclick"]) {
1219 $button = $button->withOnLoadCode(function ($id) use ($command) {
1220 return
1221 "$(\"#$id\").click(function() { ilBlockJSHandler('" . "block_" . $this->getBlockType() . "_" . $this->block_id .
1222 "','" . $command["onclick"] . "');});";
1223 });
1224 }
1225 $actions[] = $button;
1226 }
1227
1228 // check for empty list panel
1229 if (in_array($this->getPresentation(), [self::PRES_SEC_LIST, self::PRES_MAIN_LIST]) &&
1230 (count($panel->getItemGroups()) == 0 || (count($panel->getItemGroups()) == 1 && count($panel->getItemGroups()[0]->getItems()) == 0))) {
1231 if ($this->getPresentation() == self::PRES_SEC_LIST) {
1232 $panel = $factory->panel()->secondary()->legacy(
1233 $this->getTitle(),
1234 $factory->legacy($this->getNoItemFoundContent())
1235 );
1236 } else {
1237 $panel = $factory->panel()->standard(
1238 $this->getTitle(),
1239 $factory->legacy($this->getNoItemFoundContent())
1240 );
1241 }
1242 }
1243
1244
1245 if (count($actions) > 0) {
1246 $actions = $factory->dropdown()->standard($actions)
1247 ->withAriaLabel(sprintf(
1248 $this->lng->txt('actions_for'),
1249 $this->getTitle()
1250 ));
1251 $panel = $panel->withActions($actions);
1252 }
1253
1254 // view controls
1255 if (count($this->getViewControls()) > 0) {
1256 $panel = $panel->withViewControls($this->getViewControls());
1257 }
1258
1259 if ($ctrl->isAsynch()) {
1260 $html = $renderer->renderAsync($panel);
1261 } else {
1262 $html = $renderer->render($panel);
1263 }
1264
1265
1266 if ($ctrl->isAsynch()) {
1267 echo $html;
1268 exit;
1269 } else {
1270 // return incl. wrapping div with id
1271 $html = '<div id="' . "block_" . $this->getBlockType() . "_" . $this->block_id . '">' .
1272 $html . '</div>';
1273 }
1274
1275 //$this->new_rendering = false;
1276 //$html.= $this->getHTML();
1277
1278 return $html;
1279 }
1280
1286 protected function getNoItemFoundContent() : string
1287 {
1288 return $this->lng->txt("no_items");
1289 }
1290}
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_SCREEN_SIDE
User interface class for advanced drop-down selection lists.
This class represents a block method of a block.
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
initCommands()
Init commands.
setLimit($a_limit)
Set Limit.
getBlockCommands()
Get Block commands.
fillHeaderCommands()
Fill header commands block.
getOffset()
Get Offset.
getNoItemFoundContent()
No item entry.
getHTMLNew()
Get HTML.
getBlockId()
Get Block Id.
setSubtitle($a_subtitle)
Set Subtitle.
isRepositoryObject()
Returns whether block has a corresponding repository object.
setData($a_data)
Set Data.
setRefId($a_refid)
Set Ref Id (only used if isRepositoryObject() is true).
getAsynch()
Use this for final get before sending asynchronous output (ajax) per echo to output.
getRepositoryMode()
Get RepositoryMode.
setPresentation(int $type)
Set presentation.
__construct()
Constructor.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
getAdminCommands()
Get Administration Commmands.
setAdminCommands(bool $a_admincommands)
Set Administration Commmands.
handleNavigation()
Handle navigation.
getTitle()
Get Title.
preloadData(array $data)
Can be overwritten in subclasses.
fillHeaderTitleBlock()
Fill header title block (title and.
fillDataSection()
Standard implementation for row based data.
static getScreenMode()
Get Screen Mode for current command.
setOffset($a_offset)
Set Offset.
addBlockCommand(string $a_href, string $a_text, string $a_onclick="")
Add Block Command.
const PRES_MAIN_LIST
getProperty($a_property)
getRowTemplateDir()
Get Row Template Directory.
getGuiObject()
Get GuiObject.
fillRowColor($a_placeholder="CSS_ROW")
getRowTemplateName()
Get Row Template Name.
loadData()
Load data for current page.
getEnableEdit()
Get EnableEdit.
setEnableEdit($a_enableedit)
Set EnableEdit.
getListItemGroups()
Get items.
setTitle($a_title)
Set Title.
addRepoCommands()
Add repo commands.
getPresentation()
Get presentation type.
setBlockId($a_block_id=0)
Set Block Id.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
getLegacyContent()
Get legacy content.
getEnableNumInfo()
Get Enable Item Number Info.
getViewControls()
Get view controls.
getLimit()
Get Limit.
getRefId()
Get Ref Id (only used if isRepositoryObject() is true).
getPaginationViewControl()
Fill previous/next row.
fillPreviousNext()
Fill previous/next row.
setGuiObject(&$a_gui_object)
Set GuiObject.
setProperties($a_properties)
This function is supposed to be used for block type specific properties, that should be inherited thr...
getData()
Get Data.
getListItemForData(array $data)
Get list item for data array.
setRepositoryMode($a_repositorymode)
Set RepositoryMode.
getHTML()
Get HTML.
setPreviousNextLinks()
Get previous/next linkbar.
setProperty($a_property, $a_value)
getSubtitle()
Get Subtitle.
static _lookupType($a_id, $a_reference=false)
lookup object type
special template class to simplify handling of ITX/PEAR
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static initConnection(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:29
$factory
Definition: metadata.php:58
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$type
$ilUser
Definition: imgupload.php:18
ui()
Definition: ui.php:5
$a_content
Definition: workflow.php:93
$DIC
Definition: xapitoken.php:46