ILIAS  release_8 Revision v8.24
class.ilSearchRootSelector.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4/*
5 +-----------------------------------------------------------------------------+
6 | ILIAS open source |
7 +-----------------------------------------------------------------------------+
8 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
9 | |
10 | This program is free software; you can redistribute it and/or |
11 | modify it under the terms of the GNU General Public License |
12 | as published by the Free Software Foundation; either version 2 |
13 | of the License, or (at your option) any later version. |
14 | |
15 | This program is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | GNU General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU General Public License |
21 | along with this program; if not, write to the Free Software |
22 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 +-----------------------------------------------------------------------------+
24*/
25
35{
36 protected ilCtrl $ctrl;
38
39 private string $selectable_type = '';
40 private int $ref_id = 0;
41 private string $target_class = '';
42 private array $clickable_types = [];
43 private string $cmd = '';
50 public function __construct($a_target)
51 {
52 global $DIC;
53
54 $this->ctrl = $DIC->ctrl();
55 $this->system = $DIC->rbac()->system();
56
57 parent::__construct($a_target);
58 $this->root_id = $this->tree->readRootId();
59 $this->order_column = "title";
60
61 $this->setSessionExpandVariable("search_root_expand");
62
63 // add here all container objects
64 $this->addFilter("root");
65 $this->addFilter("cat");
66 $this->addFilter("grp");
67 $this->addFilter("fold");
68 $this->addFilter("crs");
69 $this->setClickableTypes(array("root", "cat", "grp", "fold", "crs"));
70
71 $this->setFiltered(true);
73
75 }
76
77 public function setPathOpen(int $ref_id): void
78 {
79 if (count($this->expanded) <= 1) {
80 foreach ($this->tree->getPathId($ref_id) as $id) {
81 $this->setExpand($id);
82 }
83 }
84 }
85
86 public function setClickableTypes(array $a_types): void
87 {
88 $this->clickable_types = $a_types;
89 }
90
91 public function isClickable(string $type, int $ref_id = 0): bool
92 {
93 return (in_array($type, $this->clickable_types));
94 }
95
96 public function setTargetClass(string $a_class): void
97 {
98 $this->target_class = $a_class;
99 }
100 public function getTargetClass(): string
101 {
102 return $this->target_class ?: 'ilsearchgui';
103 }
104 public function setCmd(string $a_cmd): void
105 {
106 $this->cmd = $a_cmd;
107 }
108 public function getCmd(): string
109 {
110 return $this->cmd ?: 'selectRoot';
111 }
112
113 public function setSelectableType(string $a_type): void
114 {
115 $this->selectable_type = $a_type;
116 }
117 public function getSelectableType(): string
118 {
120 }
121 public function setRefId(int $a_ref_id): void
122 {
123 $this->ref_id = $a_ref_id;
124 }
125 public function getRefId(): int
126 {
127 return $this->ref_id;
128 }
129
130
131 public function buildLinkTarget($a_node_id, string $a_type): string
132 {
133 $this->ctrl->setParameterByClass($this->getTargetClass(), "root_id", $a_node_id);
134
135 return $this->ctrl->getLinkTargetByClass($this->getTargetClass(), $this->getCmd());
136 }
137
138 public function buildFrameTarget(string $a_type, $a_child = 0, $a_obj_id = 0): string
139 {
140 return '';
141 }
142
143 public function showChilds($a_parent_id): bool
144 {
145 if ($a_parent_id == 0) {
146 return true;
147 }
148
149 if ($this->system->checkAccess("read", (int) $a_parent_id)) {
150 return true;
151 } else {
152 return false;
153 }
154 }
155
156
160 public function formatHeader(ilTemplate $tpl, $a_obj_id, array $a_option): void
161 {
162
163 #$tpl = new ilTemplate("tpl.tree.html", true, true, "Services/UIComponent/Explorer");
164
165 if (in_array("root", $this->clickable_types)) {
166 $tpl->setCurrentBlock("link");
167 //$tpl->setVariable("LINK_NAME",$lng->txt('repository'));
168
169 $this->ctrl->setParameterByClass($this->getTargetClass(), 'root_id', ROOT_FOLDER_ID);
170 $tpl->setVariable("LINK_TARGET", $this->ctrl->getLinkTargetByClass($this->getTargetClass(), $this->getCmd()));
171 $tpl->setVariable("TITLE", $this->lng->txt("repository"));
172
173 $tpl->parseCurrentBlock();
174 }
175 }
176}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
const IL_FM_POSITIVE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
class for explorer view in admin frame
addFilter(string $a_item)
setExpand($a_node_id)
set the expand option this value is stored in a SESSION variable to save it different view (lo view,...
setFilterMode(int $a_mode=IL_FM_NEGATIVE)
setSessionExpandVariable(string $a_var_name="expand")
setTitleLength(int $a_length)
setFiltered(bool $a_bool)
ilGlobalTemplateInterface $tpl
const TITLE_LENGTH
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
isClickable(string $type, int $ref_id=0)
buildLinkTarget($a_node_id, string $a_type)
formatHeader(ilTemplate $tpl, $a_obj_id, array $a_option)
@inheritDoc
buildFrameTarget(string $a_type, $a_child=0, $a_obj_id=0)
__construct($a_target)
Constructor @access public.
showChilds($a_parent_id)
determines wether the childs of an object should be shown or not note: this standard implementation a...
special template class to simplify handling of ITX/PEAR
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: feed.php:28
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type