ILIAS  release_8 Revision v8.24
class.ilRepositorySelector2InputGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
28{
29 protected ?Closure $title_modifier = null;
30
35 public function __construct(
36 string $a_title,
37 string $a_postvar,
38 bool $a_multi = false,
39 ?object $forwarder = null
40 ) {
41 global $DIC;
42
43 $this->ctrl = $DIC->ctrl();
44 $this->multi_nodes = $a_multi;
45 $this->postvar = $a_postvar;
46 $forwarder_class = (is_null($forwarder))
47 ? ilPropertyFormGUI::class
48 : get_class($forwarder);
49 $this->explorer_gui = new ilRepositorySelectorExplorerGUI(
50 [$forwarder_class, ilFormPropertyDispatchGUI::class, ilRepositorySelector2InputGUI::class],
51 $this->getExplHandleCmd(),
52 $this,
53 "selectRepositoryItem",
54 "root_id",
55 "rep_exp_sel_" . $a_postvar
56 );
57 $this->explorer_gui->setSelectMode($a_postvar . "_sel", $this->multi_nodes);
58
59 parent::__construct($a_title, $a_postvar, $this->explorer_gui, $this->multi_nodes);
60 $this->setType("rep_select");
61 }
62
63 public function setTitleModifier(?Closure $a_val): void
64 {
65 $this->title_modifier = $a_val;
66 if ($a_val != null) {
67 $this->explorer_gui->setNodeContentModifier(function ($a_node) use ($a_val) {
68 return $a_val($a_node["child"]);
69 });
70 } else {
71 $this->explorer_gui->setNodeContentModifier(null);
72 }
73 }
74
75 public function getTitleModifier(): ?Closure
76 {
78 }
79
80 public function getTitleForNodeId($a_id): string
81 {
82 $c = $this->getTitleModifier();
83 if (is_callable($c)) {
84 return $c($a_id);
85 }
87 }
88
90 {
92 }
93
94 public function setExplorerGUI(\ilRepositorySelectorExplorerGUI $explorer): void
95 {
96 $this->explorer_gui = $explorer;
97 }
98
99 public function getOnloadCode(): array
100 {
101 return [
102 "il.Explorer2.initSelect('" . $this->getFieldId() . "');"
103 ];
104 }
105
106 public function getHTML(): string
107 {
108 $ilCtrl = $this->ctrl;
109 $ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", $this->postvar);
110 $html = parent::render();
111 $ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", $this->str("postvar"));
112 return $html;
113 }
114
115 public function render(string $a_mode = "property_form"): string
116 {
117 $ilCtrl = $this->ctrl;
118 $ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", $this->postvar);
119 $ret = parent::render($a_mode);
120 $ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", $this->str("postvar"));
121 return $ret;
122 }
123}
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getExplHandleCmd()
Get explorer handle command function.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(string $a_title, string $a_postvar, bool $a_multi=false, ?object $forwarder=null)
getTitleForNodeId($a_id)
Get title for node id (needs to be overwritten, if explorer is not a tree eplorer.
render(string $a_mode="property_form")
Render item.
setExplorerGUI(\ilRepositorySelectorExplorerGUI $explorer)
Explorer for selecting repository items.
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc