ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilRepositorySelector2InputGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
29 {
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  {
78  return $this->title_modifier;
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  {
92  return $this->explorer_gui;
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 }
__construct(string $a_title, string $a_postvar, bool $a_multi=false, ?object $forwarder=null)
setParameterByClass(string $a_class, string $a_parameter, $a_value)
$c
Definition: deliver.php:25
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setExplorerGUI(\ilRepositorySelectorExplorerGUI $explorer)
static _lookupTitle(int $obj_id)
getExplHandleCmd()
Get explorer handle command function.
global $DIC
Definition: shib_login.php:26
__construct(Container $dic, ilPlugin $plugin)
Select explorer tree nodes input GUI.