33 protected static $js_tree_path =
"./libs/bower/bower_components/jstree/jquery.jstree.js";
34 protected static $js_expl_path =
"./Services/UIComponent/Explorer2/js/Explorer2.js";
49 public function __construct($a_expl_id, $a_parent_obj, $a_parent_cmd)
53 $this->log = $DIC[
"ilLog"];
54 $this->ctrl = $DIC->ctrl();
55 $this->tpl = $DIC[
"tpl"];
56 $this->
id = $a_expl_id;
57 $this->parent_obj = $a_parent_obj;
58 $this->parent_cmd = $a_parent_cmd;
61 include_once(
"./Services/Authentication/classes/class.ilSessionIStorage.php");
63 $open_nodes = $this->store->get(
"on_" . $this->
id);
64 $this->open_nodes = unserialize($open_nodes);
65 if (!is_array($this->open_nodes)) {
66 $this->open_nodes =
array();
69 $this->nodeOnclickEnabled =
true;
79 $this->tpl = $a_main_tpl;
88 return self::$js_expl_path;
96 return self::$js_tree_path;
148 abstract public function getNodeId($a_node);
179 foreach ($childs as $child) {
241 if ($this->select_postvar !=
"") {
315 $this->skip_root_node = $a_val;
335 $this->ajax = $a_val;
355 $this->sec_highl_nodes = $a_val;
376 if (!in_array($a_id, $this->custom_open_nodes)) {
377 $this->custom_open_nodes[] = $a_id;
389 return "$('#" . $this->
getContainerId() .
"').jstree('toggle_node' , '#" .
402 $oc =
"il.Explorer2.selectOnClick('" . $dn_id .
"'); return false;";
415 $this->select_postvar = $a_postvar;
416 $this->select_multi = $a_multi;
427 if (!in_array($a_id, $this->selected_nodes)) {
428 $this->selected_nodes[] = $a_id;
439 $this->offline_mode = $a_val;
463 if (
$_GET[
"exp_cmd"] !=
"" &&
465 $cmd =
$_GET[
"exp_cmd"];
466 if (in_array($cmd,
array(
"openNode",
"closeNode",
"getNodeAsync"))) {
483 return "il_expl2_jstree_cont_" . $this->
getId();
494 if (!in_array(
$id, $this->open_nodes)) {
495 $this->open_nodes[] =
$id;
497 $this->store->set(
"on_" . $this->
id, serialize($this->open_nodes));
509 if (in_array(
$id, $this->open_nodes)) {
510 $k = array_search(
$id, $this->open_nodes);
511 unset($this->open_nodes[$k]);
513 $this->store->set(
"on_" . $this->
id, serialize($this->open_nodes));
524 if (
$_GET[
"node_id"] !=
"") {
530 $etpl =
new ilTemplate(
"tpl.explorer2.html",
true,
true,
"Services/UIComponent/Explorer2");
532 echo $etpl->get(
"tag");
554 $container_outer_id =
"il_expl2_jstree_cont_out_" . $this->
getId();
558 foreach ($this->open_nodes as $nid) {
561 foreach ($this->custom_open_nodes as $nid) {
563 if (!in_array($dnode, $open_nodes)) {
564 $open_nodes[] = $dnode;
571 if (is_object($this->parent_obj)) {
572 $url =
$ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd,
"",
true);
574 $url =
$ilCtrl->getLinkTargetByClass($this->parent_obj, $this->parent_cmd,
"",
true);
580 foreach ($this->sec_highl_nodes as $sh) {
584 "container_id" => $container_id,
585 "container_outer_id" => $container_outer_id,
587 "second_hnodes" => $shn,
593 $js_tree_config =
array(
596 "initially_open" => $open_nodes,
597 "open_parents" =>
false,
598 "strings" =>
array(
"loading" =>
"Loading ...",
"new_node" =>
"New node")
601 "themes" =>
array(
"dots" =>
false,
"icons" =>
false,
"theme" =>
""),
602 "html_data" =>
array()
605 return 'il.Explorer2.init(' . json_encode(
$config) .
', ' . json_encode($js_tree_config) .
');';
610 $plugins =
array(
"html_data",
"themes",
"json_data");
622 public static function init($a_main_tpl = null)
626 if ($a_main_tpl == null) {
632 include_once(
"./Services/jQuery/classes/class.iljQueryUtil.php");
635 $tpl->addJavascript(self::getLocalExplorerJsPath());
636 $tpl->addJavascript(self::getLocalJsTreeJsPath());
649 if (!in_array($root, $this->open_nodes)) {
650 $this->open_nodes[] = $root;
657 $container_outer_id =
"il_expl2_jstree_cont_out_" . $this->
getId();
663 $etpl =
new ilTemplate(
"tpl.explorer2.html",
true,
true,
"Services/UIComponent/Explorer2");
677 foreach ($childs as $child_node) {
691 $etpl->setVariable(
"CONTAINER_ID", $container_id);
692 $etpl->setVariable(
"CONTAINER_OUTER_ID", $container_outer_id);
699 return $etpl->get() . $add;
714 if ($this->select_multi) {
715 $tpl->setCurrentBlock(
"cb");
716 if (in_array($this->
getNodeId($a_node), $this->selected_nodes)) {
717 $tpl->setVariable(
"CHECKED",
'checked="checked"');
720 $tpl->setVariable(
"CB_NAME", $this->select_postvar .
"[]");
721 $tpl->parseCurrentBlock();
723 $tpl->setCurrentBlock(
"rd");
724 if (in_array($this->
getNodeId($a_node), $this->selected_nodes)) {
725 $tpl->setVariable(
"SELECTED",
'checked="checked"');
728 $tpl->setVariable(
"RD_NAME", $this->select_postvar);
729 $tpl->parseCurrentBlock();
735 $tpl->touchBlock(
"hl");
737 $tpl->setCurrentBlock(
"content");
745 $targetRelatedParams =
array(
750 $targetRelatedParams[] =
'rel="noopener"';
753 $tpl->setVariable(
'TARGET', implode(
' ', $targetRelatedParams));
756 $tpl->setVariable(
"ONCLICK",
'onclick="return false;"');
757 $tpl->setVariable(
"A_CLASS",
'class="disabled"');
760 if ($onclick !=
"") {
761 $tpl->setVariable(
"ONCLICK",
'onclick="' . $onclick .
'"');
764 $tpl->parseCurrentBlock();
766 $tpl->touchBlock(
"tag");
768 if (!$this->
getAjax() || in_array($this->
getNodeId($a_node), $this->open_nodes)
769 || in_array($this->
getNodeId($a_node), $this->custom_open_nodes)) {
785 $childs = $this->
sortChilds($childs, $a_node_id);
787 if (count($childs) > 0) {
789 foreach ($childs as $child) {
812 return "exp_node_" . $this->
getId() .
"_" . $a_node_id;
823 $i = strlen(
"exp_node_" . $this->
getId() .
"_");
824 return substr($a_dom_node_id,
$i);
835 $tpl->setCurrentBlock(
"list_item_start");
837 $tpl->touchBlock(
"li_closed");
843 $tpl->parseCurrentBlock();
844 $tpl->touchBlock(
"tag");
855 $tpl->touchBlock(
"list_item_end");
856 $tpl->touchBlock(
"tag");
867 $tpl->touchBlock(
"list_start");
868 $tpl->touchBlock(
"tag");
879 $tpl->touchBlock(
"list_end");
880 $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)
if(!array_key_exists('StateId', $_REQUEST)) $id
getNodeToggleOnClick($a_node)
Get onclick attribute for node toggling.
__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.
special template class to simplify handling of ITX/PEAR
beforeRendering()
Before rendering.
getNodeAsync()
Get node asynchronously.
Create styles array
The data for the language used.
getOfflineMode()
Get offline mode.
getNodeContent($a_node)
Get content of a node.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
listStart($tpl)
List start.
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.
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
listItemStart($tpl, $a_node)
List item start.
getDomNodeIdForNodeId($a_node_id)
Get DOM node id for node id.
nodeHasVisibleChilds($a_node)
Node has childs?
listItemEnd($tpl)
List item end.
setNodeOnclickEnabled($nodeOnclickEnabled)
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.
setMainTemplate(ilTemplate $a_main_tpl=null)
Set main template (that is responsible for adding js/css)
getContainerId()
Get container id.