ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilBlockGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
29 abstract class ilBlockGUI
30 {
31  public const PRES_MAIN_LEG = 0; // main legacy panel
32  public const PRES_SEC_LEG = 1; // secondary legacy panel
33  public const PRES_SEC_LIST = 2; // secondary list panel
34  public const PRES_MAIN_LIST = 3; // main standard list panel
35  public const PRES_MAIN_TILE = 4; // main standard list panel
36  private int $offset;
37  private int $limit;
38  private bool $enableedit;
39  private string $subtitle;
40  private int $refid;
41  private string $rowtemplatename;
42  private string $rowtemplatedir;
43  protected object $gui_object;
44  protected \ILIAS\Block\StandardGUIRequest $request;
45  protected \ILIAS\Block\BlockManager $block_manager;
46  private \ILIAS\HTTP\GlobalHttpState $http;
47 
48  protected bool $repositorymode = false;
49  protected \ILIAS\DI\UIServices $ui;
50  protected array $data = array();
51  protected bool $enablenuminfo = true;
52  protected array $footer_links = array();
53  protected string $block_id = "0";
54  protected bool $allow_moving = true;
55  protected array $move = array("left" => false, "right" => false, "up" => false, "down" => false);
56  protected array $block_commands = array();
57  protected int $max_count = 0;
58  protected bool $close_command = false;
59  protected bool $image = false;
60  protected array $property = [];
61  protected string $nav_value = "";
62  protected string $css_row = "";
63  protected string $title = "";
64  protected bool $admincommands = false;
65  protected array $dropdown;
66  protected ?ilTemplate $tpl;
68  protected ilObjUser $user;
69  protected ilCtrl $ctrl;
71  protected ilLanguage $lng;
73  protected int $presentation;
74  protected ?int $requested_ref_id;
75 
76  public function __construct()
77  {
78  global $DIC;
79 
80 
81  $this->http = $DIC->http();
82  $block_service = new ILIAS\Block\Service($DIC);
83  $this->block_manager = $block_service->internal()
84  ->domain()
85  ->block();
86  $this->request = $block_service->internal()
87  ->gui()
88  ->standardRequest();
89 
90 
91  // default presentation
92  $this->presentation = self::PRES_SEC_LEG;
93 
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();
101 
103  $this->main_tpl->addJavaScript("./Services/Block/js/ilblockcallback.js");
104 
105  $this->setLimit((int) $this->user->getPref("hits_per_page"));
106 
107  $this->requested_ref_id = $this->request->getRefId();
108  }
109 
110  abstract public function getBlockType(): string;
111 
115  abstract protected function isRepositoryObject(): bool;
116 
117  protected function specialCharsAsEntities(string $string): string
118  {
119  // Should be replaced by a proper refinery transformation once https://github.com/ILIAS-eLearning/ILIAS/pull/6314 is merged
120  return htmlspecialchars(
121  $string,
122  ENT_QUOTES | ENT_SUBSTITUTE,
123  'utf-8'
124  );
125  }
126 
127  public function setData(array $a_data): void
128  {
129  $this->data = $a_data;
130  }
131 
132  public function getData(): array
133  {
134  return $this->data;
135  }
136 
137  public function setPresentation(int $type): void
138  {
139  $this->presentation = $type;
140  }
141 
142  public function getPresentation(): int
143  {
144  return $this->presentation;
145  }
146 
147  public function setBlockId(string $a_block_id = "0"): void
148  {
149  $this->block_id = $a_block_id;
150  }
151 
152  public function getBlockId(): string
153  {
154  return $this->block_id;
155  }
156 
162  public function setGuiObject(object $a_gui_object): void
163  {
164  $this->gui_object = $a_gui_object;
165  }
166 
167  public function getGuiObject(): object
168  {
169  return $this->gui_object;
170  }
171 
172  public function setTitle(string $a_title): void
173  {
174  $this->title = $a_title;
175  }
176 
177  public function getTitle(): string
178  {
179  return $this->title;
180  }
181 
182  public function setOffset(int $a_offset): void
183  {
184  $this->offset = $a_offset;
185  }
186 
187  public function getOffset(): int
188  {
189  return $this->offset;
190  }
191 
192  public function correctOffset(): void
193  {
194  if (!($this->offset < $this->max_count)) {
195  $this->setOffset(0);
196  }
197  }
198 
199  public function setLimit(int $a_limit): void
200  {
201  $this->limit = $a_limit;
202  }
203 
204  public function getLimit(): int
205  {
206  return $this->limit;
207  }
208 
209  public function setEnableEdit(bool $a_enableedit): void
210  {
211  $this->enableedit = $a_enableedit;
212  }
213 
214  public function getEnableEdit(): bool
215  {
216  return $this->enableedit;
217  }
218 
219  public function setRepositoryMode(bool $a_repositorymode): void
220  {
221  $this->repositorymode = $a_repositorymode;
222  }
223 
224  public function getRepositoryMode(): bool
225  {
226  return $this->repositorymode;
227  }
228 
229  public function setSubtitle(string $a_subtitle): void
230  {
231  $this->subtitle = $a_subtitle;
232  }
233 
234  public function getSubtitle(): string
235  {
236  return $this->subtitle;
237  }
238 
242  public function setRefId(int $a_refid): void
243  {
244  $this->refid = $a_refid;
245  }
246 
247  public function getRefId(): int
248  {
249  return $this->refid;
250  }
251 
252  public function setAdminCommands(bool $a_admincommands): void
253  {
254  $this->admincommands = $a_admincommands;
255  }
256 
257  public function getAdminCommands(): bool
258  {
259  return $this->admincommands;
260  }
261 
262  public function setEnableNumInfo(bool $a_enablenuminfo): void
263  {
264  $this->enablenuminfo = $a_enablenuminfo;
265  }
266 
267  public function getEnableNumInfo(): bool
268  {
269  return $this->enablenuminfo;
270  }
271 
276  public function setProperties(array $a_properties): void
277  {
278  $this->property = $a_properties;
279  }
280 
281  public function getProperty(string $a_property): ?string
282  {
283  return $this->property[$a_property] ?? null;
284  }
285 
286  public function setProperty(string $a_property, string $a_value): void
287  {
288  $this->property[$a_property] = $a_value;
289  }
290 
294  public function setRowTemplate(
295  string $a_rowtemplatename,
296  string $a_rowtemplatedir = ""
297  ): void {
298  $this->rowtemplatename = $a_rowtemplatename;
299  $this->rowtemplatedir = $a_rowtemplatedir;
300  }
301 
302  final public function getNavParameter(): string
303  {
304  return $this->getBlockType() . "_" . $this->getBlockId() . "_blnav";
305  }
306 
307  final public function getConfigParameter(): string
308  {
309  return $this->getBlockType() . "_" . $this->getBlockId() . "_blconf";
310  }
311 
312  final public function getMoveParameter(): string
313  {
314  return $this->getBlockType() . "_" . $this->getBlockId() . "_blmove";
315  }
316 
317  public function getRowTemplateName(): string
318  {
319  return $this->rowtemplatename;
320  }
321 
322  public function getRowTemplateDir(): string
323  {
324  return $this->rowtemplatedir;
325  }
326 
327  public function addBlockCommand(string $a_href, string $a_text, string $a_onclick = ""): void
328  {
329  $this->block_commands[] = [
330  "href" => $a_href,
331  "text" => $a_text,
332  "onclick" => $a_onclick
333  ];
334  }
335 
336  public function getBlockCommands(): array
337  {
338  return $this->block_commands;
339  }
340 
341  public static function getScreenMode(): string
342  {
343  return IL_SCREEN_SIDE;
344  }
345 
346  protected function initCommands(): void
347  {
348  }
349 
350  public function getHTML(): string
351  {
352  $this->initCommands();
353 
354  if ($this->new_rendering) {
355  return $this->getHTMLNew();
356  }
357 
358  $ilCtrl = $this->ctrl;
359  $lng = $this->lng;
360  $ilAccess = $this->access;
362  $objDefinition = $this->obj_def;
363 
364  if ($this->isRepositoryObject()) {
365  if (!$ilAccess->checkAccess("read", "", $this->getRefId())) {
366  return "";
367  }
368  }
369 
370  $this->tpl = new ilTemplate("tpl.block.html", true, true, "Services/Block");
371 
372  // $this->handleConfigStatus();
373 
374  $this->fillDataSection();
375  if ($this->getRepositoryMode() && $this->isRepositoryObject()) {
376  // #10993
377  // @todo: fix this in new presentation somehow
378  if ($this->getAdminCommands()) {
379  $this->tpl->setCurrentBlock("block_check");
380  $this->tpl->setVariable("BL_REF_ID", $this->getRefId());
381  $this->tpl->parseCurrentBlock();
382  }
383 
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(),
388  $lng->txt("delete")
389  );
390 
391  // see ilObjectListGUI::insertCutCommand();
392  $this->addBlockCommand(
393  "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->requested_ref_id . "&cmd=cut" .
394  "&item_ref_id=" . $this->getRefId(),
395  $lng->txt("move")
396  );
397  }
398 
399  // #14595 - see ilObjectListGUI::insertCopyCommand()
400  if ($ilAccess->checkAccess("copy", "", $this->getRefId())) {
401  $parent_type = ilObject::_lookupType($this->requested_ref_id, true);
402  $parent_gui = "ilObj" . $objDefinition->getClassName($parent_type) . "GUI";
403 
404  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $this->getRefId());
405  $copy_cmd = $ilCtrl->getLinkTargetByClass(
406  array("ilrepositorygui", $parent_gui, "ilobjectcopygui"),
407  "initTargetSelection"
408  );
409 
410  // see ilObjectListGUI::insertCopyCommand();
411  $this->addBlockCommand(
412  $copy_cmd,
413  $lng->txt("copy")
414  );
415  }
416  }
417 
418  $this->dropdown = array();
419 
420  // commands
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"] . "')";
426  }
427  $this->dropdown[] = $command;
428  }
429  }
430 
431  // fill previous next
432  $this->fillPreviousNext();
433 
434  // fill footer
435  $this->fillFooter();
436 
437 
438  $this->fillHeaderCommands();
439  $this->fillHeaderTitleBlock();
440 
441  if ($this->getPresentation() === self::PRES_MAIN_LEG) {
442  $this->tpl->touchBlock("hclassb");
443  } else {
444  $this->tpl->touchBlock("hclass");
445  }
446 
447  if ($ilCtrl->isAsynch()) {
448  // return without div wrapper
449  echo $this->tpl->get();
450  //echo $this->tpl->getAsynch();
451  } else {
452  // return incl. wrapping div with id
453  return '<div id="' . "block_" . $this->getBlockType() . "_" . $this->block_id . '">' .
454  $this->tpl->get() . '</div>';
455  }
456  return "";
457  }
458 
459  public function fillHeaderCommands(): void
460  {
461  // adv selection gui
462  $dropdown = new ilAdvancedSelectionListGUI();
463  $dropdown->setUseImages(true);
465  $dropdown->setHeaderIcon(ilAdvancedSelectionListGUI::ICON_CONFIG);
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"]) {
470  $item["image"] = ilUtil::getImagePath("icon_checked.svg");
471  }
472  $dropdown->addItem(
473  $item["text"],
474  "",
475  $item["href"],
476  $item["image"] ?? "",
477  $item["text"],
478  "",
479  "",
480  false,
481  $item["onclick"]
482  );
483  }
484  }
485  $dropdown = $dropdown->getHTML();
486  $this->tpl->setCurrentBlock("header_dropdown");
487  $this->tpl->setVariable("ADV_DROPDOWN", $dropdown);
488  $this->tpl->parseCurrentBlock();
489 
490  $this->tpl->setCurrentBlock("hitem");
491  $this->tpl->parseCurrentBlock();
492  }
493 
494  public function fillHeaderTitleBlock(): void
495  {
496  $lng = $this->lng;
497 
498 
499  // header title
500  $this->tpl->setCurrentBlock("header_title");
501  $this->tpl->setVariable(
502  "BTID",
503  "block_" . $this->getBlockType() . "_" . $this->block_id
504  );
505  $this->tpl->setVariable(
506  "BLOCK_TITLE",
507  $this->getTitle()
508  );
509  $this->tpl->setVariable(
510  "TXT_BLOCK",
511  $lng->txt("block")
512  );
513  $this->tpl->parseCurrentBlock();
514 
515  $this->tpl->setCurrentBlock("hitem");
516  $this->tpl->parseCurrentBlock();
517  }
518 
522  public function setDataSection(string $a_content): void
523  {
524  $this->tpl->setCurrentBlock("data_section");
525  $this->tpl->setVariable("DATA", $a_content);
526  $this->tpl->parseCurrentBlock();
527  $this->tpl->setVariable("BLOCK_ROW", "");
528  }
529 
534  public function fillDataSection(): void
535  {
536  $req_nav_par = $this->request->getNavPar($this->getNavParameter());
537  if ($req_nav_par != "") {
538  $this->nav_value = $req_nav_par;
539  }
540  $this->nav_value = ($this->nav_value != "")
541  ? $this->nav_value
542  : $this->block_manager->getNavPar($this->getNavParameter());
543 
544  $this->block_manager->setNavPar(
545  $this->getNavParameter(),
546  $this->nav_value
547  );
548 
549  $nav = explode(":", $this->nav_value);
550  if (isset($nav[2])) {
551  $this->setOffset((int) $nav[2]);
552  } else {
553  $this->setOffset(0);
554  }
555 
556  // data
557  $this->tpl->addBlockFile(
558  "BLOCK_ROW",
559  "block_row",
560  $this->getRowTemplateName(),
561  $this->getRowTemplateDir()
562  );
563 
564  $data = $this->getData();
565  $this->max_count = count($data);
566  $this->correctOffset();
567  $data = array_slice($data, $this->getOffset(), $this->getLimit());
568 
569  $this->preloadData($data);
570 
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();
577  }
578  }
579 
580  public function fillRow(array $a_set): void
581  {
582  foreach ($a_set as $key => $value) {
583  $this->tpl->setVariable("VAL_" . strtoupper($key), $value);
584  }
585  }
586 
587  public function fillFooter(): void
588  {
589  }
590 
591  final protected function fillRowColor(string $a_placeholder = "CSS_ROW"): void
592  {
593  $this->css_row = ($this->css_row != "ilBlockRow1")
594  ? "ilBlockRow1"
595  : "ilBlockRow2";
596  $this->tpl->setVariable($a_placeholder, $this->css_row);
597  }
598 
599  public function fillPreviousNext(): void
600  {
601  $lng = $this->lng;
602 
603  // table pn numinfo
604  $numinfo = "";
605  if ($this->getEnableNumInfo() && $this->max_count > 0) {
606  $start = $this->getOffset() + 1; // compute num info
607  $end = $this->getOffset() + $this->getLimit();
608 
609  if ($end > $this->max_count or $this->getLimit() == 0) {
610  $end = $this->max_count;
611  }
612 
613  $numinfo = "(" . $start . "-" . $end . " " . strtolower($lng->txt("of")) . " " . $this->max_count . ")";
614  }
615 
616  $this->setPreviousNextLinks();
617  $this->tpl->setVariable("NUMINFO", $numinfo);
618  }
619 
620  public function setPreviousNextLinks(): void
621  {
622  }
623 
628  protected function preloadData(array $data): void
629  {
630  }
631 
636  public function getAsynch(): string
637  {
638  header("Content-type: text/html; charset=UTF-8");
639  return $this->tpl->get();
640  }
641 
642  //
643  // New rendering
644  //
645 
646  // temporary flag
647  protected bool $new_rendering = false;
648 
649 
655  protected function getLegacyContent(): string
656  {
657  return "";
658  }
659 
665  protected function getViewControls(): array
666  {
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];
671  }
672  }
673  return [];
674  }
675 
682  protected function getListItemForData(array $data): ?\ILIAS\UI\Component\Item\Item
683  {
684  return null;
685  }
686 
687 
691  protected function handleNavigation(): void
692  {
693  $reg_page = $this->request->getNavPage($this->getNavParameter());
694  if ($reg_page !== "") {
695  $this->nav_value = "::" . ($reg_page * $this->getLimit());
696  }
697 
698  if ($this->nav_value == "") {
699  $this->nav_value = $this->block_manager->getNavPar($this->getNavParameter());
700  }
701 
702  $this->block_manager->setNavPar(
703  $this->getNavParameter(),
704  $this->nav_value
705  );
706 
707  $nav = explode(":", $this->nav_value);
708  if (isset($nav[2])) {
709  $this->setOffset((int) $nav[2]);
710  } else {
711  $this->setOffset(0);
712  }
713  }
714 
719  protected function loadData(): array
720  {
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);
726  return $data;
727  }
728 
729 
735  protected function getListItemGroups(): array
736  {
737  global $DIC;
738  $factory = $DIC->ui()->factory();
739 
740  $data = $this->loadData();
741 
742  $items = [];
743 
744  foreach ($data as $record) {
745  $item = $this->getListItemForData($record);
746  if ($item !== null) {
747  $items[] = $item;
748  }
749  }
750 
751  $item_group = $factory->item()->group("", $items);
752 
753  return [$item_group];
754  }
755 
759  public function getPaginationViewControl(): ?\ILIAS\UI\Component\ViewControl\Pagination
760  {
761  global $DIC;
762  $factory = $DIC->ui()->factory();
763 
764  $ilCtrl = $this->ctrl;
765 
766 
767  // $ilCtrl->setParameterByClass("ilcolumngui",
768  // $this->getNavParameter(), "::" . $prevoffset);
769 
770  // ajax link
771  $ilCtrl->setParameterByClass(
772  "ilcolumngui",
773  "block_id",
774  "block_" . $this->getBlockType() . "_" . $this->block_id
775  );
776  $block_id = "block_" . $this->getBlockType() . "_" . $this->block_id;
777  $onclick = $ilCtrl->getLinkTargetByClass(
778  "ilcolumngui",
779  "updateBlock",
780  "",
781  true
782  );
783  $ilCtrl->setParameterByClass(
784  "ilcolumngui",
785  "block_id",
786  ""
787  );
788 
789  // normal link
790  $href = $ilCtrl->getLinkTargetByClass("ilcolumngui", "", "", false, false);
791 
792  //$ilCtrl->setParameterByClass("ilcolumngui",
793  // $this->getNavParameter(), "");
794 
795  if ($this->max_count <= $this->getLimit()) {
796  return null;
797  }
798 
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());
805  }
806 
810  protected function addRepoCommands(): void
811  {
812  $access = $this->access;
813  $lng = $this->lng;
814  $ctrl = $this->ctrl;
815  $obj_def = $this->obj_def;
816 
817  if ($this->getRepositoryMode() && $this->isRepositoryObject()) {
818  // #10993
819  // @todo: fix this in new presentation somehow
820  /*
821  if ($this->getAdminCommands()) {
822  $this->tpl->setCurrentBlock("block_check");
823  $this->tpl->setVariable("BL_REF_ID", $this->getRefId());
824  $this->tpl->parseCurrentBlock();
825  }*/
826 
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(),
831  $lng->txt("delete")
832  );
833 
834  $this->addBlockCommand(
835  "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->requested_ref_id . "&cmd=link" .
836  "&item_ref_id=" . $this->getRefId(),
837  $lng->txt("link")
838  );
839 
840  // see ilObjectListGUI::insertCutCommand();
841  $this->addBlockCommand(
842  "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->requested_ref_id . "&cmd=cut" .
843  "&item_ref_id=" . $this->getRefId(),
844  $lng->txt("move")
845  );
846  }
847 
848  // #14595 - see ilObjectListGUI::insertCopyCommand()
849  if ($access->checkAccess("copy", "", $this->getRefId())) {
850  $parent_type = ilObject::_lookupType($this->requested_ref_id, true);
851  $parent_gui = "ilObj" . $obj_def->getClassName($parent_type) . "GUI";
852 
853  $ctrl->setParameterByClass("ilobjectcopygui", "source_id", $this->getRefId());
854  $copy_cmd = $ctrl->getLinkTargetByClass(
855  array("ilrepositorygui", $parent_gui, "ilobjectcopygui"),
856  "initTargetSelection"
857  );
858 
859  // see ilObjectListGUI::insertCopyCommand();
860  $this->addBlockCommand(
861  $copy_cmd,
862  $lng->txt("copy")
863  );
864  }
865  }
866  }
867 
868  public function getHTMLNew(): string
869  {
870  global $DIC;
871  $factory = $DIC->ui()->factory();
872  $renderer = $DIC->ui()->renderer();
873  $access = $this->access;
874  $panel = null;
875 
876  $ctrl = $this->ctrl;
877 
878  if ($this->isRepositoryObject()) {
879  if (!$access->checkAccess("read", "", $this->getRefId())) {
880  return "";
881  }
882  }
883 
884  $this->addRepoCommands();
885 
886  switch ($this->getPresentation()) {
887  case self::PRES_SEC_LEG:
888  $panel = $factory->panel()->secondary()->legacy(
889  $this->specialCharsAsEntities($this->getTitle()),
890  $factory->legacy($this->getLegacyContent())
891  );
892  break;
893 
894  case self::PRES_MAIN_LEG:
895  $panel = $factory->panel()->standard(
896  $this->specialCharsAsEntities($this->getTitle()),
897  $factory->legacy($this->getLegacyContent())
898  );
899  break;
900 
901  case self::PRES_SEC_LIST:
902  $this->handleNavigation();
903  $panel = $factory->panel()->secondary()->listing(
904  $this->specialCharsAsEntities($this->getTitle()),
905  $this->getListItemGroups()
906  );
907  break;
908 
909  case self::PRES_MAIN_TILE:
910  case self::PRES_MAIN_LIST:
911  $this->handleNavigation();
912  $panel = $factory->panel()->listing()->standard(
913  $this->specialCharsAsEntities($this->getTitle()),
914  $this->getListItemGroups()
915  );
916  break;
917 
918  }
919 
920  // actions
921  $actions = [];
922 
923  foreach ($this->getBlockCommands() as $command) {
924  $href = ($command["onclick"] != "")
925  ? ""
926  : $command["href"];
927  $button = $factory->button()->shy($command["text"], $href);
928  if ($command["onclick"]) {
929  $button = $button->withOnLoadCode(function ($id) use ($command) {
930  return
931  "$(\"#$id\").click(function() { ilBlockJSHandler('" . "block_" . $this->getBlockType() . "_" . $this->block_id .
932  "','" . $command["onclick"] . "');});";
933  });
934  }
935  $actions[] = $button;
936  }
937 
938  // check for empty list panel
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) {
942  $panel = $factory->panel()->secondary()->legacy(
943  $this->specialCharsAsEntities($this->getTitle()),
944  $factory->legacy($this->getNoItemFoundContent())
945  );
946  } else {
947  $panel = $factory->panel()->standard(
948  $this->specialCharsAsEntities($this->getTitle()),
949  $factory->legacy($this->getNoItemFoundContent())
950  );
951  }
952  }
953 
954 
955  if (count($actions) > 0) {
956  $actions = $factory->dropdown()->standard($actions)
957  ->withAriaLabel(sprintf(
958  $this->lng->txt('actions_for'),
959  htmlspecialchars($this->getTitle())
960  ));
961  $panel = $panel->withActions($actions);
962  }
963 
964  // view controls
965  if (count($this->getViewControls()) > 0) {
966  $panel = $panel->withViewControls($this->getViewControls());
967  }
968 
969  if ($ctrl->isAsynch()) {
970  $html = $renderer->renderAsync($panel);
971  } else {
972  $html = $renderer->render($panel);
973  }
974 
975 
976  if ($ctrl->isAsynch()) {
977  $this->send($html);
978  } else {
979  // return incl. wrapping div with id
980  $html = '<div id="' . "block_" . $this->getBlockType() . "_" . $this->block_id . '">' .
981  $html . '</div>';
982  }
983 
984  return $html;
985  }
986 
991  protected function send(string $output): void
992  {
993  $this->http->saveResponse($this->http->response()->withBody(
994  Streams::ofString($output)
995  ));
996  $this->http->sendResponse();
997  $this->http->close();
998  }
999 
1000  public function getNoItemFoundContent(): string
1001  {
1002  return $this->lng->txt("no_items");
1003  }
1004 }
ILIAS Block BlockManager $block_manager
ilObjUser $user
fillRow(array $a_set)
ILIAS DI UIServices $ui
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
Class Factory.
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...
array $block_commands
$type
ilLanguage $lng
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:198
setLimit(int $a_limit)
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.
string $rowtemplatename
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...
const PRES_MAIN_LIST
const PRES_MAIN_TILE
setParameterByClass(string $a_class, string $a_parameter, $a_value)
specialCharsAsEntities(string $string)
getLegacyContent()
Get legacy content.
setProperty(string $a_property, string $a_value)
global $DIC
Definition: feed.php:28
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
object $gui_object
ilGlobalTemplateInterface $main_tpl
static http()
Fetches the global http state from ILIAS.
string $rowtemplatedir
setOffset(int $a_offset)
ilTemplate $tpl
preloadData(array $data)
Can be overwritten in subclasses.
static getScreenMode()
getListItemForData(array $data)
Get list item for data array.
setAdminCommands(bool $a_admincommands)
getListItemGroups()
Get items.
getPaginationViewControl()
Fill previous/next row.
string $key
Consumer key/client ID value.
Definition: System.php:193
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.
$ilUser
Definition: imgupload.php:34
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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.
setData(array $a_data)
ilAccessHandler $access
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.
const IL_SCREEN_SIDE
getProperty(string $a_property)
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
setPresentation(int $type)
$factory
Definition: metadata.php:75