1<?php
2/*
3    +-----------------------------------------------------------------------------+
4    | ILIAS open source                                                           |
5    +-----------------------------------------------------------------------------+
6    | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
7    |                                                                             |
8    | This program is free software; you can redistribute it and/or               |
9    | modify it under the terms of the GNU General Public License                 |
10    | as published by the Free Software Foundation; either version 2              |
11    | of the License, or (at your option) any later version.                      |
12    |                                                                             |
13    | This program is distributed in the hope that it will be useful,             |
14    | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
15    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
16    | GNU General Public License for more details.                                |
17    |                                                                             |
18    | You should have received a copy of the GNU General Public License           |
19    | along with this program; if not, write to the Free Software                 |
20    | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
21    +-----------------------------------------------------------------------------+
22*/
23
24/*
25* Repository Explorer
26*
27* @author Stefan Meyer <meyer@leifos.com>
28* @version $Id$
29*
30* @package core
31*/
32
33require_once("./Services/UIComponent/Explorer/classes/class.ilExplorer.php");
34
35class ilSearchRootSelector extends ilExplorer
36{
37
38    /**
39     * id of root folder
40     * @var int root folder id
41     * @access private
42     */
43    public $root_id;
44    public $output;
45    public $ctrl;
46
47    public $selectable_type;
48    public $ref_id;
49    /**
50    * Constructor
51    * @access	public
52    * @param	string	scriptname
53    * @param    int user_id
54    */
55    public function __construct($a_target)
56    {
57        global $DIC;
58
59        $tree = $DIC['tree'];
60        $ilCtrl = $DIC['ilCtrl'];
61
62        $this->ctrl = $ilCtrl;
63
64        parent::__construct($a_target);
65        $this->tree = $tree;
66        $this->root_id = $this->tree->readRootId();
67        $this->order_column = "title";
68
69        $this->setSessionExpandVariable("search_root_expand");
70
71        // add here all container objects
72        $this->addFilter("root");
73        $this->addFilter("cat");
74        $this->addFilter("grp");
75        $this->addFilter("fold");
76        $this->addFilter("crs");
77        $this->setClickableTypes(array("root", "cat", "grp", "fold", "crs"));
78
79        $this->setFiltered(true);
80        $this->setFilterMode(IL_FM_POSITIVE);
81
82        $this->setTitleLength(ilObject::TITLE_LENGTH);
83    }
84
85    public function setClickableTypes($a_types)
86    {
87        $this->clickable_types = $a_types;
88    }
89
90    public function isClickable($a_type, $a_ref_id = 0)
91    {
92        if (in_array($a_type, $this->clickable_types)) {
93            return true;
94        }
95        return false;
96    }
97
98    public function setTargetClass($a_class)
99    {
100        $this->target_class = $a_class;
101    }
102    public function getTargetClass()
103    {
104        return $this->target_class ? $this->target_class : 'ilsearchgui';
105    }
106    public function setCmd($a_cmd)
107    {
108        $this->cmd = $a_cmd;
109    }
110    public function getCmd()
111    {
112        return $this->cmd ? $this->cmd : 'selectRoot';
113    }
114
115    public function setSelectableType($a_type)
116    {
117        $this->selectable_type = $a_type;
118    }
119    public function setRefId($a_ref_id)
120    {
121        $this->ref_id = $a_ref_id;
122    }
123
124
125    public function buildLinkTarget($a_node_id, $a_type)
126    {
127        $this->ctrl->setParameterByClass($this->getTargetClass(), "root_id", $a_node_id);
128
129        return $this->ctrl->getLinkTargetByClass($this->getTargetClass(), $this->getCmd());
130    }
131
132    public function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
133    {
134        return '';
135    }
136
137    public function showChilds($a_ref_id)
138    {
139        global $DIC;
140
141        $rbacsystem = $DIC['rbacsystem'];
142
143        if ($a_ref_id == 0) {
144            return true;
145        }
146
147        if ($rbacsystem->checkAccess("read", $a_ref_id)) {
148            return true;
149        } else {
150            return false;
151        }
152    }
153
154
155    /**
156    * overwritten method from base class
157    * @access	public
158    * @param	integer obj_id
159    * @param	integer array options
160    * @return	string
161    */
162    public function formatHeader($tpl, $a_obj_id, $a_option)
163    {
164        global $DIC;
165
166        $lng = $DIC['lng'];
167        $ilias = $DIC['ilias'];
168
169        #$tpl = new ilTemplate("tpl.tree.html", true, true, "Services/UIComponent/Explorer");
170
171        if (in_array("root", $this->clickable_types)) {
172            $tpl->setCurrentBlock("link");
173            //$tpl->setVariable("LINK_NAME",$lng->txt('repository'));
174
175            $this->ctrl->setParameterByClass($this->getTargetClass(), 'root_id', ROOT_FOLDER_ID);
176            $tpl->setVariable("LINK_TARGET", $this->ctrl->getLinkTargetByClass($this->getTargetClass(), $this->getCmd()));
177            $tpl->setVariable("TITLE", $lng->txt("repository"));
178
179            $tpl->parseCurrentBlock();
180        }
181
182        #$this->output[] = $tpl->get();
183
184        return true;
185    }
186} // END class ilRepositoryExplorer
187