1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4/**
5* Select media pool for adding objects into pages
6*
7* @author Alex Killing <alex.killing@gmx.de>
8* @version $Id$
9*
10* @ingroup ServicesCOPage
11*/
12
13include_once "./Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php";
14
15class ilPoolSelectorGUI extends ilRepositorySelectorExplorerGUI
16{
17    protected $clickable_types = array();
18    protected $selection_subcmd = "";
19
20
21    /**
22     * Constructor
23     *
24     * @param object $a_parent_obj
25     * @param string $a_parent_cmd
26     * @param object $a_selection_gui
27     * @param string $a_selection_cmd
28     * @param string $a_selection_par
29     */
30    public function __construct(
31        $a_parent_obj,
32        $a_parent_cmd,
33        $a_selection_gui = null,
34        $a_selection_cmd = "insert",
35        $a_selection_subcmd = "selectPool",
36        $a_selection_par = "pool_ref_id"
37    ) {
38        global $DIC;
39
40        $this->ctrl = $DIC->ctrl();
41        if ($a_selection_gui == null) {
42            $a_selection_gui = $a_parent_obj;
43        }
44
45        $this->selection_subcmd = $a_selection_subcmd;
46        parent::__construct(
47            $a_parent_obj,
48            $a_parent_cmd,
49            $a_selection_gui,
50            $a_selection_cmd,
51            $a_selection_par
52        );
53
54        $this->setAjax(true);
55    }
56
57    /**
58     * Get href for node
59     *
60     * @param mixed $a_node node object/array
61     * @return string href attribute
62     */
63    public function getNodeHref($a_node)
64    {
65        $ilCtrl = $this->ctrl;
66
67        $ilCtrl->setParameterByClass($this->selection_gui, "subCmd", $this->selection_subcmd);
68        $link = parent::getNodeHref($a_node);
69        $ilCtrl->setParameterByClass($this->selection_gui, "subCmd", "");
70        return $link;
71    }
72
73    /**
74     * Is node visible
75     *
76     * @param array $a_node node data
77     * @return bool visible true/false
78     */
79    public function isNodeVisible($a_node)
80    {
81        if (parent::isNodeVisible($a_node)) {
82            //hide empty container
83            if (count($this->getChildsOfNode($a_node["child"])) > 0 || $this->isNodeClickable($a_node)) {
84                // #16523
85                if ($a_node["type"] == "qpl") {
86                    include_once "Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
87                    return ilObjQuestionPool::_lookupOnline($a_node["obj_id"]);
88                }
89
90                return true;
91            }
92        }
93
94        return false;
95    }
96}
97