35 protected static string $js_tree_path =
"./node_modules/jstree/dist/jstree.js";
36 protected static string $js_tree_path_css =
"./node_modules/jstree/dist/themes/default/style.min.css";
70 string $a_node_parameter_name =
"node_id"
74 $this->log =
$DIC[
"ilLog"];
75 $this->
ctrl = $DIC->ctrl();
76 $this->tpl =
$DIC[
"tpl"];
77 $this->
id = $a_expl_id;
78 $this->parent_obj = $a_parent_obj;
79 $this->parent_cmd = $a_parent_cmd;
80 $this->node_parameter_name = $a_node_parameter_name;
84 $this->open_nodes = unserialize(
$open_nodes, [
'allowed_classes' =>
false]) ?: [];
85 if (!is_array($this->open_nodes)) {
86 $this->open_nodes = array();
89 $params =
$DIC->http()->request()->getQueryParams();
90 $this->requested_node_id = (
$params[$a_node_parameter_name] ??
"");
91 $this->requested_exp_cmd = (
$params[
"exp_cmd"] ??
"");
92 $this->requested_exp_cont = (
$params[
"exp_cont"] ??
"");
93 $this->requested_searchterm = (
$params[
"searchterm"] ??
"");
95 $this->nodeOnclickEnabled =
true;
101 $this->child_limit = $a_val;
111 $this->search_term = $a_val;
121 $this->tpl = $a_main_tpl;
207 foreach ($childs as $child) {
221 public function sortChilds(array $a_childs, $a_parent_node_id): array
263 if ($this->select_postvar !==
"") {
325 $this->skip_root_node = $a_val;
335 $this->ajax = $a_val;
348 $this->sec_highl_nodes = $a_val;
365 if (!in_array($a_id, $this->custom_open_nodes)) {
366 $this->custom_open_nodes[] = $a_id;
376 return "$('#" . $this->
getContainerId() .
"').jstree('toggle_node' , '#" .
387 $oc =
"il.Explorer2.selectOnClick(event, '" . $dn_id .
"'); return false;";
396 public function setSelectMode(
string $a_postvar,
bool $a_multi =
false): void
398 $this->select_postvar = $a_postvar;
399 $this->select_multi = $a_multi;
408 if (!in_array($a_id, $this->selected_nodes)) {
409 $this->selected_nodes[] = $a_id;
415 $this->offline_mode = $a_val;
432 if ($this->requested_exp_cmd !==
"" &&
435 if (in_array($cmd, array(
"openNode",
"closeNode",
"getNodeAsync"))) {
446 return "il_expl2_jstree_cont_" . $this->
getId();
455 if (!in_array(
$id, $this->open_nodes)) {
456 $this->open_nodes[] =
$id;
458 $this->store->set(
"on_" . $this->
id, serialize($this->open_nodes));
468 if (in_array(
$id, $this->open_nodes)) {
469 $k = array_search(
$id, $this->open_nodes);
470 unset($this->open_nodes[$k]);
472 $this->store->set(
"on_" . $this->
id, serialize($this->open_nodes));
483 $etpl =
new ilTemplate(
"tpl.explorer2.html",
true,
true,
"components/ILIAS/UIComponent/Explorer2");
486 if (!in_array($root, $this->open_nodes)) {
487 $this->open_nodes[] = $root;
490 if ($this->requested_node_id !==
"") {
497 echo $etpl->get(
"tag");
515 || in_array($node_id, $this->open_nodes)
516 || in_array($node_id, $this->custom_open_nodes));
528 $container_outer_id =
"il_expl2_jstree_cont_out_" . $this->
getId();
532 foreach ($this->open_nodes as $nid) {
535 foreach ($this->custom_open_nodes as $nid) {
544 if (is_object($this->parent_obj)) {
545 $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd,
"",
true);
547 if (!is_null($this->parent_obj)) {
548 $url = $ilCtrl->getLinkTargetByClass($this->parent_obj, $this->parent_cmd,
"",
true);
555 foreach ($this->sec_highl_nodes as $sh) {
559 "container_id" => $container_id,
560 "container_outer_id" => $container_outer_id,
562 "second_hnodes" => $shn,
564 "node_par_name" => $this->node_parameter_name
569 $js_tree_config = array(
573 "open_parents" =>
false,
574 "strings" => array(
"loading" =>
"Loading ...",
"new_node" =>
"New node"),
575 "themes" => array(
"dots" =>
false,
"icons" =>
false,
"theme" =>
"")
578 "html_data" => array()
581 'il.Explorer2.init(' .
582 json_encode($config, JSON_THROW_ON_ERROR) .
', ' .
583 json_encode($js_tree_config, JSON_THROW_ON_ERROR) .
');'
589 $plugins = array(
"html_data",
"themes",
"json_data");
619 if (!in_array($root, $this->open_nodes)) {
620 $this->open_nodes[] = $root;
627 $container_outer_id =
"il_expl2_jstree_cont_out_" . $this->
getId();
629 if (!$ilCtrl->isAsynch()) {
633 $etpl =
new ilTemplate(
"tpl.explorer2.html",
true,
true,
"components/ILIAS/UIComponent/Explorer2");
648 foreach ($childs as $child_node) {
663 $etpl->setVariable(
"CONTAINER_ID", $container_id);
664 $etpl->setVariable(
"CONTAINER_OUTER_ID", $container_outer_id);
667 if ($ilCtrl->isAsynch()) {
671 $content = $etpl->get();
673 return $content . $add;
689 if ($this->select_multi) {
691 if (in_array($this->
getNodeId($a_node), $this->selected_nodes)) {
698 if (in_array($this->
getNodeId($a_node), $this->selected_nodes)) {
720 if ($target !==
"") {
721 $targetRelatedParams = array(
722 'target="' . $target .
'"'
725 if (
'_blank' === $target) {
726 $targetRelatedParams[] =
'rel="noopener"';
736 if ($onclick !==
"") {
745 if (!$this->
getAjax() || in_array($this->
getNodeId($a_node), $this->open_nodes)
746 || in_array($this->
getNodeId($a_node), $this->custom_open_nodes)) {
762 $childs = $this->
sortChilds($childs, $a_node_id);
767 $visible_childs = [];
770 foreach ($childs as $child) {
777 $visible_childs[] = $child;
797 foreach ($visible_childs as $child) {
827 return "exp_node_" . $this->
getId() .
"_" . $a_node_id;
835 $i = strlen(
"exp_node_" . $this->
getId() .
"_");
836 return substr($a_dom_node_id, $i);
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setChildLimit(int $a_val)
setNodeSelected($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour)
sortChilds(array $a_childs, $a_parent_node_id)
Sort childs.
getNodeIcon($a_node)
Get node icon path.
getNodeContent($a_node)
Get content of a node.
listStart(ilTemplate $tpl)
getId()
Get id of explorer element.
isNodeSelectable($a_node)
Is node selectable?
string $requested_searchterm
getNodeIconAlt($a_node)
Get node icon alt attribute.
getNodeAsync()
Get node asynchronously.
setSelectMode(string $a_postvar, bool $a_multi=false)
Set select mode (to deactivate, pass an empty string as postvar)
static string $js_tree_path
string $requested_node_id
getNodeOnClick($a_node)
Get node onclick attribute.
static getLocalJsTreeCssPath()
renderNode($a_node, ilTemplate $tpl)
Render node.
beforeRendering()
Before rendering.
getOnLoadCode()
Get on load code.
setOfflineMode(bool $a_val)
static getLocalExplorerJsPath()
getNodeIdForDomNodeId(string $a_dom_node_id)
Get node id for dom node id.
getChildsOfNode($a_parent_node_id)
Get children of node.
isNodeClickable($a_node)
Is node clickable?
getDomNodeIdForNodeId($a_node_id)
Get DOM node id for node id.
getNodeTarget($a_node)
Get node target (frame) attribute.
setSearchTerm(string $a_val)
listItemStart(ilTemplate $tpl, $a_node)
List item start.
static getLocalJsTreeJsPath()
setSecondaryHighlightedNodes(array $a_val)
Set secondary (background) highlighted nodes.
handleCommand()
Handle explorer internal command.
nodeHasVisibleChilds($a_node)
Node has children Please note that this standard method may not be optimal depending on what a derive...
getSecondaryHighlightedNodes()
Get secondary (background) highlighted nodes.
getNodeId($a_node)
Get id of a node.
string $requested_exp_cmd
static string $js_tree_path_css
getNodeToggleOnClick($a_node)
Get onclick attribute for node toggling.
setNodeOpen($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour)
getNodeHref($a_node)
Get href for node.
static string $js_expl_path
isNodeHighlighted($a_node)
Is node highlighted?
setNodeOnclickEnabled(bool $nodeOnclickEnabled)
static createHTMLExportDirs(string $a_target_dir)
setSkipRootNode(bool $a_val)
isNodeOpen($node_id)
Get all open nodes.
isNodeRequested(string $a_node_id)
renderChilds($a_node_id, ilTemplate $tpl)
Render childs.
getRootNode()
Get root node.
isNodeVisible($a_node)
Is node visible?
ilGlobalTemplateInterface $tpl
listItemEnd(ilTemplate $tpl)
setEnableDnd(bool $enable_dnd)
getSelectOnClick($a_node)
Get onclick attribute for selecting radio/checkbox.
string $requested_exp_cont
string $node_parameter_name
setMainTemplate(?ilGlobalTemplateInterface $a_main_tpl=null)
static init(?ilGlobalTemplateInterface $a_main_tpl=null)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
Component logger with individual log levels by component id.
Session based immediate storage.
special template class to simplify handling of ITX/PEAR
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
setVariable(string $variable, $value='')
Sets the given variable to the given value.
touchBlock(string $block)
overwrites ITX::touchBlock.
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc