33 protected static $js_tree_path =
"./node_modules/jstree/dist/jstree.js";
34 protected static $js_tree_path_css =
"./node_modules/jstree/dist/themes/default/style.min.css";
36 protected static $js_expl_path =
"./Services/UIComponent/Explorer2/js/Explorer2.js";
71 public function __construct($a_expl_id, $a_parent_obj, $a_parent_cmd)
75 $this->log = $DIC[
"ilLog"];
76 $this->ctrl = $DIC->ctrl();
77 $this->tpl = $DIC[
"tpl"];
78 $this->
id = $a_expl_id;
79 $this->parent_obj = $a_parent_obj;
80 $this->parent_cmd = $a_parent_cmd;
82 include_once(
"./Services/Authentication/classes/class.ilSessionIStorage.php");
86 if (!is_array($this->open_nodes)) {
87 $this->open_nodes = array();
90 $this->requested_node_id =
$_GET[
"node_id"];
92 $this->nodeOnclickEnabled =
true;
103 $this->child_limit = $a_val;
123 $this->search_term = $a_val;
144 $this->tpl = $a_main_tpl;
153 return self::$js_expl_path;
161 return self::$js_tree_path;
169 return self::$js_tree_path_css;
221 abstract public function getNodeId($a_node);
252 foreach ($childs as $child) {
314 if ($this->select_postvar !=
"") {
388 $this->skip_root_node = $a_val;
408 $this->ajax = $a_val;
428 $this->sec_highl_nodes = $a_val;
449 if (!in_array($a_id, $this->custom_open_nodes)) {
450 $this->custom_open_nodes[] = $a_id;
462 return "$('#" . $this->
getContainerId() .
"').jstree('toggle_node' , '#" .
475 $oc =
"il.Explorer2.selectOnClick(event, '" . $dn_id .
"'); return false;";
488 $this->select_postvar = $a_postvar;
489 $this->select_multi = $a_multi;
500 if (!in_array($a_id, $this->selected_nodes)) {
501 $this->selected_nodes[] = $a_id;
512 $this->offline_mode = $a_val;
536 if (
$_GET[
"exp_cmd"] !=
"" &&
538 $cmd =
$_GET[
"exp_cmd"];
539 if (in_array($cmd, array(
"openNode",
"closeNode",
"getNodeAsync"))) {
556 return "il_expl2_jstree_cont_" . $this->
getId();
567 if (!in_array($id, $this->open_nodes)) {
568 $this->open_nodes[] = $id;
570 $this->store->set(
"on_" . $this->
id, serialize($this->open_nodes));
582 if (in_array($id, $this->open_nodes)) {
583 $k = array_search($id, $this->open_nodes);
584 unset($this->open_nodes[$k]);
586 $this->store->set(
"on_" . $this->
id, serialize($this->open_nodes));
597 $etpl =
new ilTemplate(
"tpl.explorer2.html",
true,
true,
"Services/UIComponent/Explorer2");
600 if (!in_array($root, $this->open_nodes)) {
601 $this->open_nodes[] = $root;
604 if (
$_GET[
"node_id"] !=
"") {
612 echo $etpl->get(
"tag");
632 || in_array($node_id, $this->open_nodes)
633 || in_array($node_id, $this->custom_open_nodes));
648 $container_outer_id =
"il_expl2_jstree_cont_out_" . $this->
getId();
652 foreach ($this->open_nodes as $nid) {
655 foreach ($this->custom_open_nodes as $nid) {
665 if (is_object($this->parent_obj)) {
666 $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd,
"",
true);
668 $url = $ilCtrl->getLinkTargetByClass($this->parent_obj, $this->parent_cmd,
"",
true);
674 foreach ($this->sec_highl_nodes as $sh) {
678 "container_id" => $container_id,
679 "container_outer_id" => $container_outer_id,
681 "second_hnodes" => $shn,
687 $js_tree_config = array(
691 "open_parents" =>
false,
692 "strings" => array(
"loading" =>
"Loading ...",
"new_node" =>
"New node"),
693 "themes" => array(
"dots" =>
false,
"icons" =>
false,
"theme" =>
"")
696 "html_data" => array()
699 return 'il.Explorer2.init(' . json_encode(
$config) .
', ' . json_encode($js_tree_config) .
');';
704 $plugins = array(
"html_data",
"themes",
"json_data");
715 public static function init($a_main_tpl = null)
719 if ($a_main_tpl == null) {
725 include_once(
"./Services/jQuery/classes/class.iljQueryUtil.php");
728 $tpl->addJavascript(self::getLocalExplorerJsPath());
729 $tpl->addJavascript(self::getLocalJsTreeJsPath());
730 $tpl->addCss(self::getLocalJsTreeCssPath());
743 if (!in_array($root, $this->open_nodes)) {
744 $this->open_nodes[] = $root;
751 $container_outer_id =
"il_expl2_jstree_cont_out_" . $this->
getId();
753 if (!$ilCtrl->isAsynch()) {
757 $etpl =
new ilTemplate(
"tpl.explorer2.html",
true,
true,
"Services/UIComponent/Explorer2");
772 foreach ($childs as $child_node) {
787 $etpl->setVariable(
"CONTAINER_ID", $container_id);
788 $etpl->setVariable(
"CONTAINER_OUTER_ID", $container_outer_id);
791 if ($ilCtrl->isAsynch()) {
795 $content = $etpl->get();
797 return $content . $add;
815 if ($this->select_multi) {
816 $tpl->setCurrentBlock(
"cb");
817 if (in_array($this->
getNodeId($a_node), $this->selected_nodes)) {
818 $tpl->setVariable(
"CHECKED",
'checked="checked"');
821 $tpl->setVariable(
"CB_NAME", $this->select_postvar .
"[]");
822 $tpl->parseCurrentBlock();
824 $tpl->setCurrentBlock(
"rd");
825 if (in_array($this->
getNodeId($a_node), $this->selected_nodes)) {
826 $tpl->setVariable(
"SELECTED",
'checked="checked"');
829 $tpl->setVariable(
"RD_NAME", $this->select_postvar);
830 $tpl->parseCurrentBlock();
836 $tpl->touchBlock(
"hl");
838 $tpl->setCurrentBlock(
"content");
848 $targetRelatedParams = array(
849 'target="' . $target .
'"' 852 if (
'_blank' === $target) {
853 $targetRelatedParams[] =
'rel="noopener"';
856 $tpl->setVariable(
'TARGET', implode(
' ', $targetRelatedParams));
859 $tpl->setVariable(
"ONCLICK",
'onclick="return false;"');
860 $tpl->setVariable(
"A_CLASS",
'class="disabled"');
863 if ($onclick !=
"") {
864 $tpl->setVariable(
"ONCLICK",
'onclick="' . $onclick .
'"');
867 $tpl->parseCurrentBlock();
869 $tpl->touchBlock(
"tag");
872 if (!$this->
getAjax() || in_array($this->
getNodeId($a_node), $this->open_nodes)
873 || in_array($this->
getNodeId($a_node), $this->custom_open_nodes)) {
891 $childs = $this->
sortChilds($childs, $a_node_id);
896 $visible_childs = [];
899 foreach ($childs as $child) {
906 $visible_childs[] = $child;
918 $tpl->setCurrentBlock(
"list_search");
919 $tpl->setVariable(
"SEARCH_CONTAINER_ID", $a_node_id);
923 $tpl->parseCurrentBlock();
924 $tpl->touchBlock(
"tag");
928 foreach ($visible_childs as $child) {
954 return "exp_node_" . $this->
getId() .
"_" . $a_node_id;
965 $i = strlen(
"exp_node_" . $this->
getId() .
"_");
966 return substr($a_dom_node_id,
$i);
977 $tpl->setCurrentBlock(
"list_item_start");
979 $tpl->touchBlock(
"li_closed");
982 $tpl->touchBlock(
"li_opened");
989 $tpl->parseCurrentBlock();
990 $tpl->touchBlock(
"tag");
1001 $tpl->touchBlock(
"list_item_end");
1002 $tpl->touchBlock(
"tag");
1013 $tpl->touchBlock(
"list_start");
1014 $tpl->touchBlock(
"tag");
1025 $tpl->touchBlock(
"list_end");
1026 $tpl->touchBlock(
"tag");
static makeDirParents($a_dir)
Create a new directory and all parent directories.
setOfflineMode($a_val)
Set offline mode.
getNodeOnClick($a_node)
Get node onclick attribute.
isNodeClickable($a_node)
Is node clickable?
renderChilds($a_node_id, $tpl)
Render childs.
getNodeIcon($a_node)
Get node icon path.
getNodeIconAlt($a_node)
Get node icon alt attribute.
setSkipRootNode($a_val)
Set skip root node.
setSelectMode($a_postvar, $a_multi=false)
Set select mode (to deactivate, pass an empty string as postvar)
getSearchTerm()
Get search term.
getNodeToggleOnClick($a_node)
Get onclick attribute for node toggling.
static initConnection(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
getChildLimit()
Get child limit.
__construct($a_expl_id, $a_parent_obj, $a_parent_cmd)
Constructor.
renderNode($a_node, $tpl)
Render node.
static init($a_main_tpl=null)
Init JS.
setNodeOpen($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour) ...
isNodeSelectable($a_node)
Is node selectable?
isNodeHighlighted($a_node)
Is node highlighted?
isNodeVisible($a_node)
Is node visible?
handleCommand()
Handle explorer internal command.
setSecondaryHighlightedNodes($a_val)
Set secondary (background) highlighted nodes.
static getLocalJsTreeJsPath()
Get local path of jsTree js.
sortChilds($a_childs, $a_parent_node_id)
Sort childs.
getSkipRootNode()
Get skip root node.
setNodeSelected($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour) ...
setEnableDnd($enable_dnd)
Enable Drag & Drop functionality.
getSecondaryHighlightedNodes()
Get secondary (background) highlighted nodes.
static createHTMLExportDirs($a_target_dir)
Create html export directories.
getOnLoadCode()
Get on load code.
getRootNode()
Get root node.
static getLocalExplorerJsPath()
Get local path of explorer js.
getNodeId($a_node)
Get id of a node.
beforeRendering()
Before rendering.
getNodeAsync()
Get node asynchronously.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
getOfflineMode()
Get offline mode.
getNodeContent($a_node)
Get content of a node.
setMainTemplate($a_main_tpl=null)
Set main template (that is responsible for adding js/css)
listStart($tpl)
List start.
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
getSelectOnClick($a_node)
Get onclick attribute for selecting radio/checkbox.
getNodeTarget($a_node)
Get node target (frame) attribute.
getChildsOfNode($a_parent_node_id)
Get childs of node.
Session based immediate storage.
listItemStart($tpl, $a_node)
List item start.
isNodeOpen($node_id)
Get all open nodes.
setSearchTerm($a_val)
Set search term.
getDomNodeIdForNodeId($a_node_id)
Get DOM node id for node id.
nodeHasVisibleChilds($a_node)
Node has childs?
static getLocalJsTreeCssPath()
Get local path of jsTree js.
listItemEnd($tpl)
List item end.
setNodeOnclickEnabled($nodeOnclickEnabled)
setChildLimit($a_val)
Set child limit.
getNodeIdForDomNodeId($a_dom_node_id)
Get node id for dom node id.
getNodeHref($a_node)
Get href for node.
getId()
Get id of explorer element.
getContainerId()
Get container id.