33 protected static string $js_tree_path =
"./node_modules/jstree/dist/jstree.js";
34 protected static string $js_tree_path_css =
"./node_modules/jstree/dist/themes/default/style.min.css";
36 protected static string $js_expl_path =
"./Services/UIComponent/Explorer2/js/Explorer2.js";
68 string $a_node_parameter_name =
"node_id"
72 $this->log =
$DIC[
"ilLog"];
73 $this->
ctrl = $DIC->ctrl();
74 $this->tpl =
$DIC[
"tpl"];
75 $this->
id = $a_expl_id;
76 $this->parent_obj = $a_parent_obj;
77 $this->parent_cmd = $a_parent_cmd;
78 $this->node_parameter_name = $a_node_parameter_name;
82 $this->open_nodes = unserialize(
$open_nodes, [
'allowed_classes' =>
false]) ?: [];
83 if (!is_array($this->open_nodes)) {
84 $this->open_nodes = array();
87 $params =
$DIC->http()->request()->getQueryParams();
88 $this->requested_node_id = (
$params[$a_node_parameter_name] ??
"");
89 $this->requested_exp_cmd = (
$params[
"exp_cmd"] ??
"");
90 $this->requested_exp_cont = (
$params[
"exp_cont"] ??
"");
91 $this->requested_searchterm = (
$params[
"searchterm"] ??
"");
93 $this->nodeOnclickEnabled =
true;
99 $this->child_limit = $a_val;
109 $this->search_term = $a_val;
119 $this->tpl = $a_main_tpl;
205 foreach ($childs as $child) {
219 public function sortChilds(array $a_childs, $a_parent_node_id): array
261 if ($this->select_postvar !==
"") {
323 $this->skip_root_node = $a_val;
333 $this->ajax = $a_val;
346 $this->sec_highl_nodes = $a_val;
363 if (!in_array($a_id, $this->custom_open_nodes)) {
364 $this->custom_open_nodes[] = $a_id;
374 return "$('#" . $this->
getContainerId() .
"').jstree('toggle_node' , '#" .
385 $oc =
"il.Explorer2.selectOnClick(event, '" . $dn_id .
"'); return false;";
394 public function setSelectMode(
string $a_postvar,
bool $a_multi =
false): void
396 $this->select_postvar = $a_postvar;
397 $this->select_multi = $a_multi;
406 if (!in_array($a_id, $this->selected_nodes)) {
407 $this->selected_nodes[] = $a_id;
413 $this->offline_mode = $a_val;
430 if ($this->requested_exp_cmd !==
"" &&
433 if (in_array($cmd, array(
"openNode",
"closeNode",
"getNodeAsync"))) {
444 return "il_expl2_jstree_cont_" . $this->
getId();
453 if (!in_array(
$id, $this->open_nodes)) {
454 $this->open_nodes[] =
$id;
456 $this->store->set(
"on_" . $this->
id, serialize($this->open_nodes));
466 if (in_array(
$id, $this->open_nodes)) {
467 $k = array_search(
$id, $this->open_nodes);
468 unset($this->open_nodes[$k]);
470 $this->store->set(
"on_" . $this->
id, serialize($this->open_nodes));
481 $etpl =
new ilTemplate(
"tpl.explorer2.html",
true,
true,
"Services/UIComponent/Explorer2");
484 if (!in_array($root, $this->open_nodes)) {
485 $this->open_nodes[] = $root;
488 if ($this->requested_node_id !==
"") {
495 echo $etpl->get(
"tag");
513 || in_array($node_id, $this->open_nodes)
514 || in_array($node_id, $this->custom_open_nodes));
526 $container_outer_id =
"il_expl2_jstree_cont_out_" . $this->
getId();
530 foreach ($this->open_nodes as $nid) {
533 foreach ($this->custom_open_nodes as $nid) {
542 if (is_object($this->parent_obj)) {
543 $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd,
"",
true);
545 if (!is_null($this->parent_obj)) {
546 $url = $ilCtrl->getLinkTargetByClass($this->parent_obj, $this->parent_cmd,
"",
true);
553 foreach ($this->sec_highl_nodes as $sh) {
557 "container_id" => $container_id,
558 "container_outer_id" => $container_outer_id,
560 "second_hnodes" => $shn,
562 "node_par_name" => $this->node_parameter_name
567 $js_tree_config = array(
571 "open_parents" =>
false,
572 "strings" => array(
"loading" =>
"Loading ...",
"new_node" =>
"New node"),
573 "themes" => array(
"dots" =>
false,
"icons" =>
false,
"theme" =>
"")
576 "html_data" => array()
579 'il.Explorer2.init(' .
580 json_encode(
$config, JSON_THROW_ON_ERROR) .
', ' .
581 json_encode($js_tree_config, JSON_THROW_ON_ERROR) .
');'
587 $plugins = array(
"html_data",
"themes",
"json_data");
617 if (!in_array($root, $this->open_nodes)) {
618 $this->open_nodes[] = $root;
625 $container_outer_id =
"il_expl2_jstree_cont_out_" . $this->
getId();
627 if (!$ilCtrl->isAsynch()) {
631 $etpl =
new ilTemplate(
"tpl.explorer2.html",
true,
true,
"Services/UIComponent/Explorer2");
646 foreach ($childs as $child_node) {
661 $etpl->setVariable(
"CONTAINER_ID", $container_id);
662 $etpl->setVariable(
"CONTAINER_OUTER_ID", $container_outer_id);
665 if ($ilCtrl->isAsynch()) {
669 $content = $etpl->get();
671 return $content . $add;
687 if ($this->select_multi) {
689 if (in_array($this->
getNodeId($a_node), $this->selected_nodes)) {
696 if (in_array($this->
getNodeId($a_node), $this->selected_nodes)) {
718 if ($target !==
"") {
719 $targetRelatedParams = array(
720 'target="' . $target .
'"'
723 if (
'_blank' === $target) {
724 $targetRelatedParams[] =
'rel="noopener"';
734 if ($onclick !==
"") {
743 if (!$this->
getAjax() || in_array($this->
getNodeId($a_node), $this->open_nodes)
744 || in_array($this->
getNodeId($a_node), $this->custom_open_nodes)) {
760 $childs = $this->
sortChilds($childs, $a_node_id);
765 $visible_childs = [];
768 foreach ($childs as $child) {
775 $visible_childs[] = $child;
795 foreach ($visible_childs as $child) {
825 return "exp_node_" . $this->
getId() .
"_" . $a_node_id;
833 $i = strlen(
"exp_node_" . $this->
getId() .
"_");
834 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.
static init(ilGlobalTemplateInterface $a_main_tpl=null)
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
setMainTemplate(ilGlobalTemplateInterface $a_main_tpl=null)
string $node_parameter_name
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
touchBlock(string $block)
overwrites ITX::touchBlock.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc