34    protected static $js_tree_path = 
"./libs/bower/bower_components/jstree/dist/jstree.js";
 
   35    protected static $js_tree_path_css = 
"./libs/bower/bower_components/jstree/dist/themes/default/style.min.css";
 
   37    protected static $js_expl_path = 
"./Services/UIComponent/Explorer2/js/Explorer2.js";
 
   58    public function __construct($a_expl_id, $a_parent_obj, $a_parent_cmd)
 
   62        $this->log = 
$DIC[
"ilLog"];
 
   63        $this->ctrl = 
$DIC->ctrl();
 
   64        $this->tpl = 
$DIC[
"tpl"];
 
   65        $this->
id = $a_expl_id;
 
   66        $this->parent_obj = $a_parent_obj;
 
   67        $this->parent_cmd = $a_parent_cmd;
 
   69        include_once(
"./Services/Authentication/classes/class.ilSessionIStorage.php");
 
   71        $open_nodes = $this->store->get(
"on_" . $this->
id);
 
   72        $this->open_nodes = unserialize($open_nodes);
 
   73        if (!is_array($this->open_nodes)) {
 
   74            $this->open_nodes = array();
 
   77        $this->nodeOnclickEnabled = 
true;
 
   87        $this->child_limit = $a_val;
 
  107        $this->search_term = $a_val;
 
  128        $this->tpl = $a_main_tpl;
 
  236        foreach ($childs as $child) {
 
  298        if ($this->select_postvar != 
"") {
 
  372        $this->skip_root_node = $a_val;
 
  392        $this->ajax = $a_val;
 
  412        $this->sec_highl_nodes = $a_val;
 
  433        if (!in_array($a_id, $this->custom_open_nodes)) {
 
  434            $this->custom_open_nodes[] = $a_id;
 
  446        return "$('#" . $this->
getContainerId() . 
"').jstree('toggle_node' , '#" .
 
  459        $oc = 
"il.Explorer2.selectOnClick(event, '" . $dn_id . 
"'); return false;";
 
  472        $this->select_postvar = $a_postvar;
 
  473        $this->select_multi = $a_multi;
 
  484        if (!in_array($a_id, $this->selected_nodes)) {
 
  485            $this->selected_nodes[] = $a_id;
 
  496        $this->offline_mode = $a_val;
 
  520        if (
$_GET[
"exp_cmd"] != 
"" &&
 
  522            $cmd = 
$_GET[
"exp_cmd"];
 
  523            if (in_array($cmd, array(
"openNode", 
"closeNode", 
"getNodeAsync"))) {
 
  540        return "il_expl2_jstree_cont_" . $this->
getId();
 
  551        if (!in_array(
$id, $this->open_nodes)) {
 
  552            $this->open_nodes[] = 
$id;
 
  554        $this->store->set(
"on_" . $this->
id, serialize($this->open_nodes));
 
  566        if (in_array(
$id, $this->open_nodes)) {
 
  567            $k = array_search(
$id, $this->open_nodes);
 
  568            unset($this->open_nodes[$k]);
 
  570        $this->store->set(
"on_" . $this->
id, serialize($this->open_nodes));
 
  581        $etpl = 
new ilTemplate(
"tpl.explorer2.html", 
true, 
true, 
"Services/UIComponent/Explorer2");
 
  584        if (!in_array(
$root, $this->open_nodes)) {
 
  585            $this->open_nodes[] = 
$root;
 
  588        if (
$_GET[
"node_id"] != 
"") {
 
  596        echo $etpl->get(
"tag");
 
  616            || in_array($node_id, $this->open_nodes)
 
  617            || in_array($node_id, $this->custom_open_nodes));
 
  632        $container_outer_id = 
"il_expl2_jstree_cont_out_" . $this->
getId();
 
  636        foreach ($this->open_nodes as $nid) {
 
  639        foreach ($this->custom_open_nodes as $nid) {
 
  641            if (!in_array($dnode, $open_nodes)) {
 
  642                $open_nodes[] = $dnode;
 
  649            if (is_object($this->parent_obj)) {
 
  650                $url = 
$ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd, 
"", 
true);
 
  652                $url = 
$ilCtrl->getLinkTargetByClass($this->parent_obj, $this->parent_cmd, 
"", 
true);
 
  658        foreach ($this->sec_highl_nodes as $sh) {
 
  662            "container_id" => $container_id,
 
  663            "container_outer_id" => $container_outer_id,
 
  665            "second_hnodes" => $shn,
 
  671        $js_tree_config = array(
 
  674                "initially_open" => $open_nodes,
 
  675                "open_parents" => 
false,
 
  676                "strings" => array(
"loading" => 
"Loading ...", 
"new_node" => 
"New node"),
 
  677                "themes" => array(
"dots" => 
false, 
"icons" => 
false, 
"theme" => 
"")
 
  680            "html_data" => array()
 
  683        return 'il.Explorer2.init(' . json_encode(
$config) . 
', ' . json_encode($js_tree_config) . 
');';
 
  688        $plugins = array(
"html_data", 
"themes", 
"json_data");
 
  699    public static function init($a_main_tpl = 
null)
 
  703        if ($a_main_tpl == 
null) {
 
  709        include_once(
"./Services/jQuery/classes/class.iljQueryUtil.php");
 
  712        $tpl->addJavascript(self::getLocalExplorerJsPath());
 
  713        $tpl->addJavascript(self::getLocalJsTreeJsPath());
 
  714        $tpl->addCss(self::getLocalJsTreeCssPath());
 
  727        if (!in_array(
$root, $this->open_nodes)) {
 
  728            $this->open_nodes[] = 
$root;
 
  735        $container_outer_id = 
"il_expl2_jstree_cont_out_" . $this->
getId();
 
  741        $etpl = 
new ilTemplate(
"tpl.explorer2.html", 
true, 
true, 
"Services/UIComponent/Explorer2");
 
  755            foreach ($childs as $child_node) {
 
  769        $etpl->setVariable(
"CONTAINER_ID", $container_id);
 
  770        $etpl->setVariable(
"CONTAINER_OUTER_ID", $container_outer_id);
 
  777        $content = $etpl->get();
 
  779        return $content . $add;
 
  797                if ($this->select_multi) {
 
  798                    $tpl->setCurrentBlock(
"cb");
 
  799                    if (in_array($this->
getNodeId($a_node), $this->selected_nodes)) {
 
  800                        $tpl->setVariable(
"CHECKED", 
'checked="checked"');
 
  803                    $tpl->setVariable(
"CB_NAME", $this->select_postvar . 
"[]");
 
  804                    $tpl->parseCurrentBlock();
 
  806                    $tpl->setCurrentBlock(
"rd");
 
  807                    if (in_array($this->
getNodeId($a_node), $this->selected_nodes)) {
 
  808                        $tpl->setVariable(
"SELECTED", 
'checked="checked"');
 
  811                    $tpl->setVariable(
"RD_NAME", $this->select_postvar);
 
  812                    $tpl->parseCurrentBlock();
 
  818                $tpl->touchBlock(
"hl");
 
  820            $tpl->setCurrentBlock(
"content");
 
  830                $targetRelatedParams = array(
 
  835                    $targetRelatedParams[] = 
'rel="noopener"';
 
  838                $tpl->setVariable(
'TARGET', implode(
' ', $targetRelatedParams));
 
  841                $tpl->setVariable(
"ONCLICK", 
'onclick="return false;"');
 
  842                $tpl->setVariable(
"A_CLASS", 
'class="disabled"');
 
  845                if ($onclick != 
"") {
 
  846                    $tpl->setVariable(
"ONCLICK", 
'onclick="' . $onclick . 
'"');
 
  849            $tpl->parseCurrentBlock();
 
  851            $tpl->touchBlock(
"tag");
 
  854        if (!$this->
getAjax() || in_array($this->
getNodeId($a_node), $this->open_nodes)
 
  855            || in_array($this->
getNodeId($a_node), $this->custom_open_nodes)) {
 
  873        $childs = $this->
sortChilds($childs, $a_node_id);
 
  878            $visible_childs = [];
 
  881            foreach ($childs as $child) {
 
  888                    $visible_childs[] = $child;
 
  900                $tpl->setCurrentBlock(
"list_search");
 
  901                $tpl->setVariable(
"SEARCH_CONTAINER_ID", $a_node_id);
 
  903                $tpl->parseCurrentBlock();
 
  904                $tpl->touchBlock(
"tag");
 
  908            foreach ($visible_childs as $child) {
 
  934        return "exp_node_" . $this->
getId() . 
"_" . $a_node_id;
 
  945        $i = strlen(
"exp_node_" . $this->
getId() . 
"_");
 
  946        return substr($a_dom_node_id, 
$i);
 
  957        $tpl->setCurrentBlock(
"list_item_start");
 
  959            $tpl->touchBlock(
"li_closed");
 
  962            $tpl->touchBlock(
"li_opened");
 
  969        $tpl->parseCurrentBlock();
 
  970        $tpl->touchBlock(
"tag");
 
  981        $tpl->touchBlock(
"list_item_end");
 
  982        $tpl->touchBlock(
"tag");
 
  993        $tpl->touchBlock(
"list_start");
 
  994        $tpl->touchBlock(
"tag");
 
 1005        $tpl->touchBlock(
"list_end");
 
 1006        $tpl->touchBlock(
"tag");
 
An exception for terminatinating execution or to throw for unit testing.
setNodeSelected($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour)
getNodeIcon($a_node)
Get node icon path.
getNodeContent($a_node)
Get content of a node.
getId()
Get id of explorer element.
isNodeSelectable($a_node)
Is node selectable?
getContainerId()
Get container id.
setNodeOnclickEnabled($nodeOnclickEnabled)
getNodeIconAlt($a_node)
Get node icon alt attribute.
getNodeAsync()
Get node asynchronously.
getNodeOnClick($a_node)
Get node onclick attribute.
setSecondaryHighlightedNodes($a_val)
Set secondary (background) highlighted nodes.
static init($a_main_tpl=null)
Init JS.
static getLocalJsTreeCssPath()
Get local path of jsTree js.
beforeRendering()
Before rendering.
setEnableDnd($enable_dnd)
Enable Drag & Drop functionality.
setMainTemplate(ilTemplate $a_main_tpl=null)
Set main template (that is responsible for adding js/css)
getOnLoadCode()
Get on load code.
renderChilds($a_node_id, $tpl)
Render childs.
getChildLimit()
Get child limit.
static getLocalExplorerJsPath()
Get local path of explorer js.
renderNode($a_node, $tpl)
Render node.
getChildsOfNode($a_parent_node_id)
Get childs 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.
getNodeIdForDomNodeId($a_dom_node_id)
Get node id for dom node id.
static getLocalJsTreeJsPath()
Get local path of jsTree js.
handleCommand()
Handle explorer internal command.
nodeHasVisibleChilds($a_node)
Node has childs?
setChildLimit($a_val)
Set child limit.
getSecondaryHighlightedNodes()
Get secondary (background) highlighted nodes.
sortChilds($a_childs, $a_parent_node_id)
Sort childs.
getNodeId($a_node)
Get id of a node.
setSearchTerm($a_val)
Set search term.
getSkipRootNode()
Get skip root node.
getSearchTerm()
Get search term.
getNodeToggleOnClick($a_node)
Get onclick attribute for node toggling.
getOfflineMode()
Get offline mode.
setSkipRootNode($a_val)
Set skip root node.
setNodeOpen($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour)
__construct($a_expl_id, $a_parent_obj, $a_parent_cmd)
Constructor.
getNodeHref($a_node)
Get href for node.
isNodeHighlighted($a_node)
Is node highlighted?
static createHTMLExportDirs($a_target_dir)
Create html export directories.
listItemEnd($tpl)
List item end.
isNodeOpen($node_id)
Get all open nodes.
setSelectMode($a_postvar, $a_multi=false)
Set select mode (to deactivate, pass an empty string as postvar)
listStart($tpl)
List start.
getRootNode()
Get root node.
setOfflineMode($a_val)
Set offline mode.
isNodeVisible($a_node)
Is node visible?
getSelectOnClick($a_node)
Get onclick attribute for selecting radio/checkbox.
listItemStart($tpl, $a_node)
List item start.
Session based immediate storage.
special template class to simplify handling of ITX/PEAR
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
if(!array_key_exists('StateId', $_REQUEST)) $id