1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/UIComponent/Explorer2/classes/class.ilTreeExplorerGUI.php");
5
6/**
7 * SCORM editor explorer GUI class
8 *
9 * @author	Alex Killing <alex.killing@gmx.de>
10 * @version	$Id$
11 *
12 * @ingroup ModulesScormAicc
13 */
14class ilSCORM2004EditorExplorerGUI extends ilTreeExplorerGUI
15{
16    /**
17     * @var ilObjUser
18     */
19    protected $user;
20
21    /**
22     * Constructor
23     */
24    public function __construct($a_parent_obj, $a_parent_cmd, $a_slm)
25    {
26        global $DIC;
27
28        $this->user = $DIC->user();
29        $this->lng = $DIC->language();
30        $this->ctrl = $DIC->ctrl();
31        $ilUser = $DIC->user();
32
33        $this->slm = $a_slm;
34
35        $tree = new ilTree($this->slm->getId());
36        $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
37        $tree->setTreeTablePK("slm_id");
38
39        parent::__construct("scorm_ed_exp", $a_parent_obj, $a_parent_cmd, $tree);
40
41        //$this->setTypeWhiteList(array("du", "chap", "page"));
42        $this->setSkipRootNode(false);
43        $this->setAjax(false);
44    }
45
46    /**
47     * Get node content
48     *
49     * @param array
50     * @return
51     */
52    public function getNodeContent($a_node)
53    {
54        $lng = $this->lng;
55
56        if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
57            return $this->slm->getTitle();
58        }
59
60        return $a_node["title"];
61    }
62
63    /**
64     * Get node icon
65     *
66     * @param array
67     * @return
68     */
69    public function getNodeIcon($a_node)
70    {
71        if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
72            $icon = ilUtil::getImagePath("icon_sahs.svg");
73        } else {
74            $icon = ilUtil::getImagePath("icon_" . $a_node["type"] . ".svg");
75        }
76
77        return $icon;
78    }
79
80    /**
81     * Get node icon alt text
82     *
83     * @param array node array
84     * @return string alt text
85     */
86    public function getNodeIconAlt($a_node)
87    {
88        $lng = $this->lng;
89
90        if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
91            return $this->slm->getTitle();
92        }
93
94        return parent::getNodeIconAlt($a_node);
95    }
96
97    /**
98     * Is node highlighted?
99     *
100     * @param mixed $a_node node object/array
101     * @return boolean node visible true/false
102     */
103    public function isNodeHighlighted($a_node)
104    {
105        if ($a_node["child"] == $_GET["obj_id"] ||
106            ($_GET["obj_id"] == "" && $a_node["child"] == $this->getNodeId($this->getRootNode()))) {
107            return true;
108        }
109        return false;
110    }
111
112    /**
113     * Get href for node
114     *
115     * @param mixed $a_node node object/array
116     * @return string href attribute
117     */
118    public function getNodeHref($a_node)
119    {
120        $ilCtrl = $this->ctrl;
121
122        if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
123            $ilCtrl->setParameterByClass("ilobjscorm2004learningmodulegui", "obj_id", $a_node["child"]);
124            $ret = $ilCtrl->getLinkTargetByClass(["ilSAHSEditGUI", "ilObjSCORM2004LearningModuleGUI","ilobjscorm2004learningmodulegui"], "showOrganization");
125            $ilCtrl->setParameterByClass("ilobjscorm2004learningmodulegui", "obj_id", $_GET["obj_id"]);
126            return $ret;
127        }
128
129        switch ($a_node["type"]) {
130            case "page":
131                $ilCtrl->setParameterByClass("ilScorm2004PageNodeGUI", "obj_id", $a_node["child"]);
132                $ret = $ilCtrl->getLinkTargetByClass(["ilSAHSEditGUI", "ilObjSCORM2004LearningModuleGUI", "ilScorm2004PageNodeGUI"], "edit");
133                $ilCtrl->setParameterByClass("ilScorm2004PageNodeGUI", "obj_id", $_GET["obj_id"]);
134                return $ret;
135                break;
136
137            case "chap":
138                $ilCtrl->setParameterByClass("ilScorm2004ChapterGUI", "obj_id", $a_node["child"]);
139                $ret = $ilCtrl->getLinkTargetByClass(["ilSAHSEditGUI", "ilObjSCORM2004LearningModuleGUI", "ilScorm2004ChapterGUI"], "showOrganization");
140                $ilCtrl->setParameterByClass("ilScorm2004ChapterGUI", "obj_id", $_GET["obj_id"]);
141                return $ret;
142                break;
143
144            case "sco":
145                $ilCtrl->setParameterByClass("ilScorm2004ScoGUI", "obj_id", $a_node["child"]);
146                $ret = $ilCtrl->getLinkTargetByClass(["ilSAHSEditGUI", "ilObjSCORM2004LearningModuleGUI", "ilScorm2004ScoGUI"], "showOrganization");
147                $ilCtrl->setParameterByClass("ilScorm2004ScoGUI", "obj_id", $_GET["obj_id"]);
148                return $ret;
149                break;
150
151            case "ass":
152                $ilCtrl->setParameterByClass("ilScorm2004AssetGUI", "obj_id", $a_node["child"]);
153                $ret = $ilCtrl->getLinkTargetByClass(["ilSAHSEditGUI", "ilObjSCORM2004LearningModuleGUI", "ilScorm2004AssetGUI"], "showOrganization");
154                $ilCtrl->setParameterByClass("ilScorm2004AssetGUI", "obj_id", $_GET["obj_id"]);
155                return $ret;
156                break;
157        }
158    }
159}
160