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;
83 $open_nodes = $this->store->get(
"on_" . $this->
id);
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;
126 return self::$js_expl_path;
131 return self::$js_tree_path;
136 return self::$js_tree_path_css;
179 abstract public function getNodeId($a_node);
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) {
537 if (!in_array($dnode, $open_nodes)) {
538 $open_nodes[] = $dnode;
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(
572 "initially_open" => $open_nodes,
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");
602 $tpl = $a_main_tpl ?? $DIC[
"tpl"];
609 $tpl->
addCss(self::getLocalJsTreeCssPath());
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)) {
695 $tpl->
setVariable(
"CB_NAME", $this->select_postvar .
"[]");
698 if (in_array($this->
getNodeId($a_node), $this->selected_nodes)) {
699 $tpl->
setVariable(
"SELECTED",
'checked="checked"');
702 $tpl->
setVariable(
"RD_NAME", $this->select_postvar);
720 if ($target !==
"") {
721 $targetRelatedParams = array(
722 'target="' . $target .
'"' 725 if (
'_blank' === $target) {
726 $targetRelatedParams[] =
'rel="noopener"';
729 $tpl->
setVariable(
'TARGET', implode(
' ', $targetRelatedParams));
732 $tpl->
setVariable(
"ONCLICK",
'onclick="return false;"');
736 if ($onclick !==
"") {
737 $tpl->
setVariable(
"ONCLICK",
'onclick="' . $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;
788 $tpl->
setVariable(
"SEARCH_CONTAINER_ID", $a_node_id);
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);
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
isNodeRequested(string $a_node_id)
setSkipRootNode(bool $a_val)
string $requested_exp_cmd
getNodeOnClick($a_node)
Get node onclick attribute.
isNodeClickable($a_node)
Is node clickable?
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
getNodeIcon($a_node)
Get node icon path.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
getNodeIconAlt($a_node)
Get node icon alt attribute.
sortChilds(array $a_childs, $a_parent_node_id)
Sort childs.
getNodeToggleOnClick($a_node)
Get onclick attribute for node toggling.
string $requested_searchterm
setNodeOpen($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour) ...
isNodeSelectable($a_node)
Is node selectable?
static string $js_expl_path
isNodeHighlighted($a_node)
Is node highlighted?
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
isNodeVisible($a_node)
Is node visible?
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
handleCommand()
Handle explorer internal command.
static getLocalJsTreeJsPath()
ilGlobalTemplateInterface $tpl
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setEnableDnd(bool $enable_dnd)
setNodeSelected($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour) ...
static createHTMLExportDirs(string $a_target_dir)
touchBlock(string $block)
getSecondaryHighlightedNodes()
Get secondary (background) highlighted nodes.
setVariable($variable, $value='')
Sets a variable value.
getOnLoadCode()
Get on load code.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
renderChilds($a_node_id, ilTemplate $tpl)
Render childs.
listStart(ilTemplate $tpl)
getRootNode()
Get root node.
listItemEnd(ilTemplate $tpl)
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static getLocalExplorerJsPath()
getNodeId($a_node)
Get id of a node.
getNodeIdForDomNodeId(string $a_dom_node_id)
Get node id for dom node id.
listItemStart(ilTemplate $tpl, $a_node)
List item start.
setSearchTerm(string $a_val)
beforeRendering()
Before rendering.
string $node_parameter_name
getNodeAsync()
Get node asynchronously.
string $requested_node_id
setSelectMode(string $a_postvar, bool $a_multi=false)
Set select mode (to deactivate, pass an empty string as postvar)
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
getNodeContent($a_node)
Get content of a node.
static string $js_tree_path_css
setOfflineMode(bool $a_val)
getSelectOnClick($a_node)
Get onclick attribute for selecting radio/checkbox.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
renderNode($a_node, ilTemplate $tpl)
Render node.
__construct(Container $dic, ilPlugin $plugin)
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.
getNodeTarget($a_node)
Get node target (frame) attribute.
getChildsOfNode($a_parent_node_id)
Get children of node.
Session based immediate storage.
setSecondaryHighlightedNodes(array $a_val)
Set secondary (background) highlighted nodes.
isNodeOpen($node_id)
Get all open nodes.
getDomNodeIdForNodeId($a_node_id)
Get DOM node id for node id.
nodeHasVisibleChilds($a_node)
Node has children Please note that this standard method may not be optimal depending on what a derive...
static getLocalJsTreeCssPath()
setChildLimit(int $a_val)
static string $js_tree_path
static init(?ilGlobalTemplateInterface $a_main_tpl=null)
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
setNodeOnclickEnabled(bool $nodeOnclickEnabled)
getNodeHref($a_node)
Get href for node.
getId()
Get id of explorer element.
setMainTemplate(?ilGlobalTemplateInterface $a_main_tpl=null)
string $requested_exp_cont