ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilExplorerSelectInputGUI Class Reference

Select explorer tree nodes input GUI. More...

+ Inheritance diagram for ilExplorerSelectInputGUI:
+ Collaboration diagram for ilExplorerSelectInputGUI:

Public Member Functions

 __construct (string $a_title, string $a_postvar, ilExplorerBaseGUI $a_explorer_gui, bool $a_multi=false)
 
 getExplHandleCmd ()
 Get explorer handle command function. More...
 
 handleExplorerCommand ()
 Handle explorer command. More...
 
 getTitleForNodeId ($a_id)
 Get title for node id (needs to be overwritten, if explorer is not a tree eplorer. More...
 
 setValue ($a_value)
 
 getValue ()
 
 setValueByArray (array $a_values)
 Set value by array. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 getInput ()
 
 render (string $a_mode="property_form")
 Render item. More...
 
 insert (ilTemplate $a_tpl)
 Insert property html. More...
 
 getTableFilterHTML ()
 Get HTML for table filter. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct (string $a_title="", string $a_postvar="")
 
 executeCommand ()
 
 getType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setPostVar (string $a_postvar)
 
 getPostVar ()
 
 getFieldId ()
 
 setInfo (string $a_info)
 
 getInfo ()
 
 setAlert (string $a_alert)
 
 getAlert ()
 
 setRequired (bool $a_required)
 
 getRequired ()
 
 setDisabled (bool $a_disabled)
 
 getDisabled ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm (ilPropertyFormGUI $a_parentform)
 
 getParentForm ()
 
 setParent (ilFormPropertyGUI $a_val)
 
 getParent ()
 
 getSubForm ()
 
 hideSubForm ()
 
 setHiddenTitle (string $a_val)
 
 getHiddenTitle ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
 serializeData ()
 
 unserializeData (string $a_data)
 
 setParentTable ($a_val)
 Set parent table. More...
 
 getParentTable ()
 Get parent table. More...
 
 writeToSession ()
 
 clearFromSession ()
 
 readFromSession ()
 
 getHiddenTag (string $a_post_var, string $a_value)
 
 setMulti (bool $a_multi, bool $a_sortable=false, bool $a_addremove=true)
 
 getMulti ()
 
 setMultiValues (array $a_values)
 
 getMultiValues ()
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback (string $a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value for filter. More...
 
 getFormLabelFor ()
 Get label "for" attribute value for form. More...
 
 setRequestParam (string $key, $val)
 This writes the request (aka post) values. More...
 
- Public Member Functions inherited from ilTableFilterItem
 getTableFilterLabelFor ()
 Get label "for" attribute value. More...
 

Protected Member Functions

 getInitializationOnLoadCode ()
 
- Protected Member Functions inherited from ilFormPropertyGUI
 symbol ()
 
 setType (string $a_type)
 
 checkParentFormTable ()
 
 getSessionKey ()
 
 getMultiIconsHTML ()
 
 int ($key)
 
 intArray ($key)
 
 str ($key)
 
 raw ($key)
 
 strArray ($key)
 
 arrayArray ($key)
 
 isRequestParamArray (string $key)
 
 getRequestParam (string $key, Refinery\Transformation $t)
 

Protected Attributes

ilGlobalTemplateInterface $global_template
 
UIServices $ui
 
 $value
 
bool $multi_nodes
 
ilExplorerBaseGUI $explorer_gui
 
bool $disabled = false
 
 $on_load_code
 The on load code sould only be added once, otherwise the select link opens two modals and stuff breaks (https://mantis.ilias.de/view.php?id=42821). More...
 
- Protected Attributes inherited from ilFormPropertyGUI
array $set_params = []
 
ilTable2GUI $parent_table = null
 
ilFormPropertyGUI $parent_gui = null
 
ilCtrl $ctrl
 
ilLanguage $lng
 
string $type = ""
 
string $title = ""
 
string $postvar = ""
 
string $info = ""
 
string $alert = ""
 
bool $required = false
 
ilPropertyFormGUI $parentform = null
 
string $hidden_title = ""
 
bool $multi = false
 
bool $multi_sortable = false
 
bool $multi_addremove = true
 
array $multi_values = []
 
RequestInterface $request
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
bool $disabled = false
 
ilGlobalTemplateInterface $global_tpl = null
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters (string $a_text)
 Remove prohibited characters see #19159. More...
 

Detailed Description

Select explorer tree nodes input GUI.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de
Deprecated:
10

Definition at line 28 of file class.ilExplorerSelectInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilExplorerSelectInputGUI::__construct ( string  $a_title,
string  $a_postvar,
ilExplorerBaseGUI  $a_explorer_gui,
bool  $a_multi = false 
)

Definition at line 50 of file class.ilExplorerSelectInputGUI.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\lng(), ilFormPropertyGUI\setType(), and ILIAS\Repository\ui().

55  {
56  global $DIC;
57 
58  $this->lng = $DIC->language();
59  $this->multi_nodes = $a_multi;
60  $this->explorer_gui = $a_explorer_gui;
61  $this->global_template = $DIC->ui()->mainTemplate();
62 
63  $this->ui = $DIC->ui();
64 
65  parent::__construct($a_title, $a_postvar);
66  $this->setType("exp_select");
67  }
global $DIC
Definition: shib_login.php:26
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilExplorerSelectInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
bool Input ok, true/false

Definition at line 136 of file class.ilExplorerSelectInputGUI.php.

References ilFormPropertyGUI\$lng, getInput(), ilFormPropertyGUI\getRequired(), ilFormPropertyGUI\setAlert(), and ilLanguage\txt().

136  : bool
137  {
138  $lng = $this->lng;
139 
140  // check required
141  if ($this->getRequired()) {
142  if ((!$this->multi_nodes && trim($this->getInput()) === "") ||
143  ($this->multi_nodes && count($this->getInput()) === 0)) {
144  $this->setAlert($lng->txt("msg_input_is_required"));
145  return false;
146  }
147  }
148  return true;
149  }
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...
+ Here is the call graph for this function:

◆ getExplHandleCmd()

ilExplorerSelectInputGUI::getExplHandleCmd ( )

Get explorer handle command function.

Definition at line 72 of file class.ilExplorerSelectInputGUI.php.

Referenced by ilTaxSelectInputGUI\__construct(), and ilRepositorySelector2InputGUI\__construct().

72  : string
73  {
74  return "handleExplorerCommand";
75  }
+ Here is the caller graph for this function:

◆ getInitializationOnLoadCode()

ilExplorerSelectInputGUI::getInitializationOnLoadCode ( )
protected

Definition at line 268 of file class.ilExplorerSelectInputGUI.php.

References $on_load_code, ilFormPropertyGUI\getFieldId(), and ILIAS\Repository\ui().

Referenced by ilRepositorySelector2InputGUI\getOnloadCode(), and render().

268  : string
269  {
270  if (isset($this->on_load_code)) {
271  return $this->on_load_code;
272  }
273 
274  $modal = $this->ui->factory()->modal()->roundtrip(
275  'placeholder',
276  $this->ui->factory()->legacy()->content('<div id="' . $this->getFieldId() . '_expl_marker"></div>')
277  );
278  $rendered_modal = str_replace(
279  ["\r\n", "\n", "\r"],
280  ' ',
281  addslashes(json_encode($this->ui->renderer()->renderAsync($modal)))
282  );
283  return $this->on_load_code = 'il.Explorer2.initSelect(\'' . $this->getFieldId() . '\',"' .
284  $rendered_modal . '",\'' .
285  $modal->getShowSignal() . '\',\'' .
286  $modal->getCloseSignal() . '\');';
287  }
$on_load_code
The on load code sould only be added once, otherwise the select link opens two modals and stuff break...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInput()

ilExplorerSelectInputGUI::getInput ( )
Returns
string|string[]

Definition at line 154 of file class.ilExplorerSelectInputGUI.php.

References ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\str(), and ilFormPropertyGUI\strArray().

Referenced by checkInput().

155  {
156  if ($this->multi_nodes) {
157  return $this->strArray($this->getPostVar());
158  } else {
159  return $this->str($this->getPostVar());
160  }
161  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilExplorerSelectInputGUI::getTableFilterHTML ( )

Get HTML for table filter.

Implements ilTableFilterItem.

Definition at line 262 of file class.ilExplorerSelectInputGUI.php.

References render().

262  : string
263  {
264  $html = $this->render("table_filter");
265  return $html;
266  }
render(string $a_mode="property_form")
Render item.
+ Here is the call graph for this function:

◆ getTitleForNodeId()

ilExplorerSelectInputGUI::getTitleForNodeId (   $a_id)
abstract

Get title for node id (needs to be overwritten, if explorer is not a tree eplorer.

Referenced by handleExplorerCommand(), and render().

+ Here is the caller graph for this function:

◆ getValue()

ilExplorerSelectInputGUI::getValue ( )
Returns
string|int|array node id or array of node ids (multi mode)

Definition at line 119 of file class.ilExplorerSelectInputGUI.php.

References $value.

Referenced by handleExplorerCommand(), and render().

+ Here is the caller graph for this function:

◆ handleExplorerCommand()

ilExplorerSelectInputGUI::handleExplorerCommand ( )

Handle explorer command.

Definition at line 80 of file class.ilExplorerSelectInputGUI.php.

References getTitleForNodeId(), and getValue().

80  : void
81  {
82  $val = $this->getValue();
83  if (is_array($val)) {
84  foreach ($val as $v) {
85  $this->explorer_gui->setNodeOpen($v);
86  $this->explorer_gui->setNodeSelected($v);
87  }
88  } elseif ($val != "") {
89  $this->explorer_gui->setNodeOpen($val);
90  $this->explorer_gui->setNodeSelected($val);
91  }
92  $this->explorer_gui->handleCommand();
93  }
+ Here is the call graph for this function:

◆ insert()

ilExplorerSelectInputGUI::insert ( ilTemplate  $a_tpl)

Insert property html.

Definition at line 252 of file class.ilExplorerSelectInputGUI.php.

References ilTemplate\parseCurrentBlock(), render(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

252  : void
253  {
254  $a_tpl->setCurrentBlock("prop_generic");
255  $a_tpl->setVariable("PROP_GENERIC", $this->render());
256  $a_tpl->parseCurrentBlock();
257  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
render(string $a_mode="property_form")
Render item.
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:

◆ render()

ilExplorerSelectInputGUI::render ( string  $a_mode = "property_form")

Render item.

Definition at line 166 of file class.ilExplorerSelectInputGUI.php.

References ilFormPropertyGUI\$lng, $on_load_code, ILIAS\UI\examples\Input\Field\Checkbox\disabled(), ilFormPropertyGUI\getFieldId(), getInitializationOnLoadCode(), ilLinkButton\getInstance(), ilFormPropertyGUI\getPostVar(), getTitleForNodeId(), getValue(), and ilLanguage\txt().

Referenced by getTableFilterHTML(), and insert().

166  : string
167  {
168  $lng = $this->lng;
169 
171 
172  $this->global_tpl->addJavascript("assets/js/Explorer2.js");
173  $this->global_tpl->addJavascript("asserts/js/LegacyModal.js");
174  $this->global_tpl->addOnLoadCode($on_load_code);
175 
176  $tpl = new ilTemplate("tpl.prop_expl_select.html", true, true, "components/ILIAS/UIComponent/Explorer2");
177 
178  if ($a_mode !== "property_form") {
179  $tpl->touchBlock("tiny_presentation");
180  }
181 
182  // set values
183  $val = $this->getValue();
184  if (is_array($val)) {
185  $val_txt = $sep = "";
186  foreach ($val as $v) {
187  $tpl->setCurrentBlock("node_hid");
188  $tpl->setVariable("HID_NAME", $this->getPostVar() . "[]");
189  $tpl->setVariable("HID_VAL", $v);
190  $tpl->parseCurrentBlock();
191  $val_txt .= $sep . $this->getTitleForNodeId($v);
192  $sep = ", ";
193  $this->explorer_gui->setNodeOpen($v);
194  $this->explorer_gui->setNodeSelected($v);
195  }
196  $tpl->setVariable("VAL_TXT", $val_txt);
197  } elseif ($val != "") {
198  $tpl->setCurrentBlock("node_hid");
199  $tpl->setVariable("HID_NAME", $this->getPostVar());
200  $tpl->setVariable("HID_VAL", $val);
201  $tpl->parseCurrentBlock();
202  $tpl->setVariable("VAL_TXT", $this->getTitleForNodeId($val));
203  $this->explorer_gui->setNodeOpen($val);
204  $this->explorer_gui->setNodeSelected($val);
205  }
206 
207  $tpl->setVariable("POST_VAR", $this->getPostVar());
208  $tpl->setVariable("ID", $this->getFieldId());
209  $this->global_template->addOnLoadCode($on_load_code);
210 
211  // $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
212 
213  //added disabled
214  if (!$this->disabled) {
215  $tpl->setCurrentBlock("txt_select");
216  $tpl->setVariable("TXT_SELECT", $lng->txt("select"));
217  $tpl->setVariable("ID_TXT_SELECT", $this->getFieldId());
218  $tpl->parseCurrentBlock();
219 
220  $tpl->setCurrentBlock("txt_reset");
221  $tpl->setVariable("TXT_RESET", $lng->txt("reset"));
222  $tpl->setVariable("ID_TXT_RESET", $this->getFieldId());
223  $tpl->parseCurrentBlock();
224  }
225 
226  $tpl->setVariable("EXPL", $this->explorer_gui->getHTML());
227 
228  $top_tb = new ilToolbarGUI();
229 
230  $button = ilLinkButton::getInstance();
231  $button->setCaption("select");
232  $button->addCSSClass("ilExplSelectInputButS");
233  $button->setOmitPreventDoubleSubmission(true);
234  $top_tb->addStickyItem($button);
235 
236  $button = ilLinkButton::getInstance();
237  $button->setCaption("cancel");
238  $button->addCSSClass("ilExplSelectInputButC");
239  $button->setOmitPreventDoubleSubmission(true);
240  $top_tb->addStickyItem($button);
241 
242  // :TODO: we should probably clone the buttons properly
243  $tpl->setVariable("TOP_TB", $top_tb->getHTML());
244  $tpl->setVariable("BOT_TB", $top_tb->getHTML());
245 
246  return $tpl->get();
247  }
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...
$on_load_code
The on load code sould only be added once, otherwise the select link opens two modals and stuff break...
getTitleForNodeId($a_id)
Get title for node id (needs to be overwritten, if explorer is not a tree eplorer.
disabled()
description: > Example showing how to plug a disabled checkbox into a form
Definition: disabled.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValue()

ilExplorerSelectInputGUI::setValue (   $a_value)
Parameters
string|int|arraynode id or array of node ids (multi mode)

Definition at line 103 of file class.ilExplorerSelectInputGUI.php.

Referenced by ilCronOerHarvester\addCustomSettingsToForm(), and setValueByArray().

103  : void
104  {
105  if ($this->multi_nodes && !is_array($a_value)) {
106  if ($a_value !== false) {
107  $this->value = array($a_value);
108  } else {
109  $this->value = array();
110  }
111  } else {
112  $this->value = $a_value;
113  }
114  }
+ Here is the caller graph for this function:

◆ setValueByArray()

ilExplorerSelectInputGUI::setValueByArray ( array  $a_values)

Set value by array.

Definition at line 127 of file class.ilExplorerSelectInputGUI.php.

References ilFormPropertyGUI\getPostVar(), and setValue().

127  : void
128  {
129  $this->setValue($a_values[$this->getPostVar()] ?? "");
130  }
+ Here is the call graph for this function:

Field Documentation

◆ $disabled

bool ilExplorerSelectInputGUI::$disabled = false
protected

Definition at line 39 of file class.ilExplorerSelectInputGUI.php.

◆ $explorer_gui

ilExplorerBaseGUI ilExplorerSelectInputGUI::$explorer_gui
protected

◆ $global_template

ilGlobalTemplateInterface ilExplorerSelectInputGUI::$global_template
protected

Definition at line 30 of file class.ilExplorerSelectInputGUI.php.

◆ $multi_nodes

bool ilExplorerSelectInputGUI::$multi_nodes
protected

Definition at line 37 of file class.ilExplorerSelectInputGUI.php.

◆ $on_load_code

ilExplorerSelectInputGUI::$on_load_code
protected

The on load code sould only be added once, otherwise the select link opens two modals and stuff breaks (https://mantis.ilias.de/view.php?id=42821).

This is only necessary if the input is rendered twice, and might lead to problems if the post var is changed in between.

Definition at line 48 of file class.ilExplorerSelectInputGUI.php.

Referenced by getInitializationOnLoadCode(), and render().

◆ $ui

UIServices ilExplorerSelectInputGUI::$ui
protected

Definition at line 31 of file class.ilExplorerSelectInputGUI.php.

◆ $value

ilExplorerSelectInputGUI::$value
protected

Definition at line 36 of file class.ilExplorerSelectInputGUI.php.

Referenced by getValue().


The documentation for this class was generated from the following file: