ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilRepositorySelector2InputGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29{
30 protected ?Closure $title_modifier = null;
31
36 public function __construct(
37 string $a_title,
38 string $a_postvar,
39 bool $a_multi = false,
40 ?object $forwarder = null
41 ) {
42 global $DIC;
43
44 $this->ctrl = $DIC->ctrl();
45 $this->multi_nodes = $a_multi;
46 $this->postvar = $a_postvar;
47 $forwarder_class = (is_null($forwarder))
48 ? ilPropertyFormGUI::class
49 : get_class($forwarder);
50 $this->explorer_gui = new ilRepositorySelectorExplorerGUI(
51 [$forwarder_class, ilFormPropertyDispatchGUI::class, ilRepositorySelector2InputGUI::class],
52 $this->getExplHandleCmd(),
53 $this,
54 "selectRepositoryItem",
55 "root_id",
56 "rep_exp_sel_" . $a_postvar
57 );
58 $this->explorer_gui->setSelectMode($a_postvar . "_sel", $this->multi_nodes);
59
60 parent::__construct($a_title, $a_postvar, $this->explorer_gui, $this->multi_nodes);
61 $this->setType("rep_select");
62 }
63
64 public function setTitleModifier(?Closure $a_val): void
65 {
66 $this->title_modifier = $a_val;
67 if ($a_val != null) {
68 $this->explorer_gui->setNodeContentModifier(function ($a_node) use ($a_val) {
69 return $a_val($a_node["child"]);
70 });
71 } else {
72 $this->explorer_gui->setNodeContentModifier(null);
73 }
74 }
75
76 public function getTitleModifier(): ?Closure
77 {
79 }
80
81 public function getTitleForNodeId($a_id): string
82 {
83 $c = $this->getTitleModifier();
84 if (is_callable($c)) {
85 return $c($a_id);
86 }
88 }
89
91 {
93 }
94
95 public function setExplorerGUI(\ilRepositorySelectorExplorerGUI $explorer): void
96 {
97 $this->explorer_gui = $explorer;
98 }
99
100 public function getOnloadCode(): array
101 {
102 return [
104 ];
105 }
106
107 public function getHTML(): string
108 {
109 $ilCtrl = $this->ctrl;
110 $ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", $this->postvar);
111 $html = parent::render();
112 $ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", $this->str("postvar"));
113 return $html;
114 }
115
116 public function render(string $a_mode = "property_form"): string
117 {
118 $ilCtrl = $this->ctrl;
119 $ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", $this->postvar);
120 $ret = parent::render($a_mode);
121 $ilCtrl->setParameterByClass("ilformpropertydispatchgui", "postvar", $this->str("postvar"));
122 return $ret;
123 }
124}
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
Select explorer tree nodes input GUI.
getExplHandleCmd()
Get explorer handle command function.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
__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: deliver.php:25
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26