ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPasteIntoMultipleItemsExplorer.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Repository/classes/class.ilRepositoryExplorer.php';
5
6/*
7* ilPasteIntoMultipleItemsExplorer Explorer
8*
9* @author Michael Jansen <mjansen@databay.de>
10*
11*/
13{
17 protected $lng;
18
22 protected $error;
23
27 protected $access;
28
29 const SEL_TYPE_CHECK = 1;
30 const SEL_TYPE_RADIO = 2;
31
32 public $root_id = 0;
33 public $output = '';
34 public $ctrl = null;
35
36 private $checked_items = array();
37 private $post_var = '';
38 private $form_items = array();
39 private $form_item_permission = 'read';
40 private $type = 0;
41
48 public function __construct($a_type, $a_target, $a_session_variable)
49 {
50 global $DIC;
51
52 $this->lng = $DIC->language();
53 $this->error = $DIC["ilErr"];
54 $this->access = $DIC->access();
55 $tree = $DIC->repositoryTree();
56 $ilCtrl = $DIC->ctrl();
57
58 $this->setId("cont_paste_explorer");
59
60 $this->ctrl = $ilCtrl;
61 $this->type = $a_type;
62
63 parent::__construct($a_target);
64 $this->tree = $tree;
65 $this->root_id = $this->tree->readRootId();
66 $this->order_column = 'title';
67 $this->setSessionExpandVariable($a_session_variable);
68
69 // reset filter
70 $this->filter = array();
71
72 $this->addFilter('root');
73 $this->addFilter('crs');
74 $this->addFilter('grp');
75 $this->addFilter('cat');
76 $this->addFilter('fold');
77 $this->addFilter('lso');
78
79 $this->addFormItemForType('root');
80 $this->addFormItemForType('crs');
81 $this->addFormItemForType('grp');
82 $this->addFormItemForType('cat');
83 $this->addFormItemForType('fold');
84 $this->addFormItemForType('lso');
85
86 $this->setFiltered(true);
88 }
89
90 public function isClickable($a_type, $a_ref_id = 0, $a_obj_id = 0)
91 {
92 return false;
93 }
94
95 public function addFormItemForType($type)
96 {
97 $this->form_items[$type] = true;
98 }
100 {
101 $this->form_items[$type] = false;
102 }
103 public function setCheckedItems($a_checked_items = array())
104 {
105 $this->checked_items = $a_checked_items;
106 }
107 public function isItemChecked($a_id)
108 {
109 return in_array($a_id, $this->checked_items) ? true : false;
110 }
111 public function setPostVar($a_post_var)
112 {
113 $this->post_var = $a_post_var;
114 }
115 public function getPostVar()
116 {
117 return $this->post_var;
118 }
119
126 public function setRequiredFormItemPermission($a_form_item_permission)
127 {
128 $this->form_item_permission = $a_form_item_permission;
129 }
130
136 {
138 }
139
140 public function buildFormItem($a_node_id, $a_type)
141 {
143
144 // permission check
145 if (!$access->checkAccess($this->getRequiredFormItemPermission(), '', $a_node_id)) {
146 return '';
147 }
148
149 if (
150 !array_key_exists($a_type, $this->form_items) ||
151 !$this->form_items[$a_type]
152 ) {
153 return '';
154 }
155
156 $disabled = false;
157 if (is_array($_SESSION["clipboard"]["ref_ids"])) {
158 $disabled = in_array($a_node_id, $_SESSION["clipboard"]["ref_ids"]);
159 } elseif ((int) $_SESSION["clipboard"]["ref_ids"]) {
160 $disabled = $a_node_id == $_SESSION["clipboard"]["ref_ids"];
161 } elseif ($_SESSION["clipboard"]["cmd"] == 'copy' && $a_node_id == $_SESSION["clipboard"]["parent"]) {
162 $disabled = true;
163 }
164
165 switch ($this->type) {
167 return ilUtil::formCheckbox((int) $this->isItemChecked($a_node_id), $this->post_var, $a_node_id, $disabled);
168 break;
169
171 return ilUtil::formRadioButton((int) $this->isItemChecked($a_node_id), $this->post_var, $a_node_id, '', $disabled);
172 break;
173 }
174 }
175
176 public function formatObject($tpl, $a_node_id, $a_option, $a_obj_id = 0)
177 {
180
181 if (!isset($a_node_id) or !is_array($a_option)) {
182 $ilErr->raiseError(get_class($this) . "::formatObject(): Missing parameter or wrong datatype! " .
183 "node_id: " . $a_node_id . " options:" . var_dump($a_option), $ilErr->WARNING);
184 }
185
186 $pic = false;
187 foreach ($a_option["tab"] as $picture) {
188 if ($picture == 'plus') {
189 $tpl->setCurrentBlock("expander");
190 $tpl->setVariable("EXP_DESC", $lng->txt("expand"));
191 $target = $this->createTarget('+', $a_node_id);
192 $tpl->setVariable("LINK_NAME", $a_node_id);
193 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
194 $tpl->setVariable("IMGPATH", $this->getImage("browser/plus.png"));
195 $tpl->parseCurrentBlock();
196 $pic = true;
197 }
198
199 if ($picture == 'minus' && $this->show_minus) {
200 $tpl->setCurrentBlock("expander");
201 $tpl->setVariable("EXP_DESC", $lng->txt("collapse"));
202 $target = $this->createTarget('-', $a_node_id);
203 $tpl->setVariable("LINK_NAME", $a_node_id);
204 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
205 $tpl->setVariable("IMGPATH", $this->getImage("browser/minus.png"));
206 $tpl->parseCurrentBlock();
207 $pic = true;
208 }
209 }
210
211 if (!$pic) {
212 $tpl->setCurrentBlock("blank");
213 $tpl->setVariable("BLANK_PATH", $this->getImage("browser/blank.png"));
214 $tpl->parseCurrentBlock();
215 }
216
217 if ($this->output_icons) {
218 $tpl->setCurrentBlock("icon");
219
220 $path = ilObject::_getIcon($a_obj_id, "tiny", $a_option["type"]);
221 $tpl->setVariable("ICON_IMAGE", $path);
222
223 $tpl->setVariable("TARGET_ID", "iconid_" . $a_node_id);
224 $this->iconList[] = "iconid_" . $a_node_id;
225 $tpl->setVariable("TXT_ALT_IMG", $lng->txt($a_option["desc"]));
226 $tpl->parseCurrentBlock();
227 }
228
229 if (strlen($formItem = $this->buildFormItem($a_node_id, $a_option['type']))) {
230 $tpl->setCurrentBlock('check');
231 $tpl->setVariable('OBJ_CHECK', $formItem);
232 $tpl->parseCurrentBlock();
233 }
234
235 if ($this->isClickable($a_option["type"], $a_node_id, $a_obj_id)) { // output link
236 $tpl->setCurrentBlock("link");
237 //$target = (strpos($this->target, "?") === false) ?
238 // $this->target."?" : $this->target."&";
239 //$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
240 $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["type"]));
241
242 $style_class = $this->getNodeStyleClass($a_node_id, $a_option["type"]);
243
244 if ($style_class != "") {
245 $tpl->setVariable("A_CLASS", ' class="' . $style_class . '" ');
246 }
247
248 if (($onclick = $this->buildOnClick($a_node_id, $a_option["type"], $a_option["title"])) != "") {
249 $tpl->setVariable("ONCLICK", "onClick=\"$onclick\"");
250 }
251
252 $tpl->setVariable("LINK_NAME", $a_node_id);
253 $tpl->setVariable("TITLE", $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]));
254 $tpl->setVariable("DESC", ilUtil::shortenText(
255 $this->buildDescription($a_option["description"], $a_node_id, $a_option["type"]),
256 $this->textwidth,
257 true
258 ));
259 $frame_target = $this->buildFrameTarget($a_option["type"], $a_node_id, $a_option["obj_id"]);
260 if ($frame_target != "") {
261 $tpl->setVariable("TARGET", " target=\"" . $frame_target . "\"");
262 }
263 $tpl->parseCurrentBlock();
264 } else { // output text only
265 $obj_title = $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]);
266
267 // highlight current node
268 if ($a_node_id == $this->highlighted) {
269 $obj_title = "<span class=\"ilHighlighted\">" . $obj_title . "</span>";
270 }
271
272 $tpl->setCurrentBlock("text");
273 $tpl->setVariable("OBJ_TITLE", $obj_title);
274 $tpl->setVariable("OBJ_DESC", ilUtil::shortenText(
275 $this->buildDescription($a_option["desc"], $a_node_id, $a_option["type"]),
276 $this->textwidth,
277 true
278 ));
279 $tpl->parseCurrentBlock();
280 }
281
282 $tpl->setCurrentBlock("list_item");
283 $tpl->parseCurrentBlock();
284 $tpl->touchBlock("element");
285 }
286
287 /*
288 * overwritten method from base class
289 * @access public
290 * @param integer obj_id
291 * @param integer array options
292 * @return string
293 */
294 public function formatHeader($tpl, $a_obj_id, $a_option)
295 {
298
299 // custom icons
300 $path = ilObject::_getIcon($a_obj_id, "tiny", "root");
301
302
303 $tpl->setCurrentBlock("icon");
304 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
305 $title = $nd["title"];
306 if ($title == "ILIAS") {
307 $title = $lng->txt("repository");
308 }
309
310 $tpl->setVariable("ICON_IMAGE", $path);
311 $tpl->setVariable("TXT_ALT_IMG", $title);
312 $tpl->parseCurrentBlock();
313
314 if (strlen($formItem = $this->buildFormItem($a_obj_id, $a_option['type']))) {
315 $tpl->setCurrentBlock('check');
316 $tpl->setVariable('OBJ_CHECK', $formItem);
317 $tpl->parseCurrentBlock();
318 }
319
320 $tpl->setVariable('OBJ_TITLE', $title);
321 }
322
323 public function showChilds($a_ref_id, $a_obj_id = 0)
324 {
325 $ilAccess = $this->access;
326
327 if ($a_ref_id == 0) {
328 return true;
329 }
330 // #11778 - ilAccessHandler::doConditionCheck()
331 if ($ilAccess->checkAccess("read", "", $a_ref_id)) {
332 return true;
333 } else {
334 return false;
335 }
336 }
337
338 public function isVisible($a_ref_id, $a_type)
339 {
340 $ilAccess = $this->access;
341
342 if (!$ilAccess->checkAccess('visible', '', $a_ref_id)) {
343 return false;
344 }
345
346 return true;
347 }
348}
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_FM_POSITIVE
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
error($a_errmsg)
set error message @access public
getNodeStyleClass($a_id, $a_type)
get style class for node
setId($a_val)
Set id.
setSessionExpandVariable($a_var_name="expand")
set name of expand session variable
addFilter($a_item)
adds item to the filter @access public
buildOnClick($a_node_id, $a_type, $a_title)
get onclick event handling (may be overwritten by derived classes)
setFilterMode($a_mode=IL_FM_NEGATIVE)
set filter mode
setFiltered($a_bool)
active/deactivate the filter @access public
createTarget($a_type, $a_node_id, $a_highlighted_subtree=false, $a_append_anch=true)
Creates Get Parameter @access private.
buildTitle($a_title, $a_id, $a_type)
standard implementation for title, may be overwritten by derived classes
buildDescription($a_desc, $a_id, $a_type)
standard implementation for description, may be overwritten by derived classes
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
formatObject($tpl, $a_node_id, $a_option, $a_obj_id=0)
Creates output recursive method @access private.
__construct($a_type, $a_target, $a_session_variable)
Constructor @access public.
setRequiredFormItemPermission($a_form_item_permission)
Set required perission for form item visibility.
formatHeader($tpl, $a_obj_id, $a_option)
overwritten method from base class @access public
getImage($a_name, $a_type="", $a_obj_id="")
get image path
buildLinkTarget($a_node_id, $a_type)
note: most of this stuff is used by ilCourseContentInterface too
buildFrameTarget($a_type, $a_child=0, $a_obj_id=0)
STATIC, do not use $this inside!
static formRadioButton($checked, $varname, $value, $onclick=null, $disabled=false)
??? @access public
static formCheckbox($checked, $varname, $value, $disabled=false)
??? @access public
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
const ROOT_FOLDER_ID
Definition: constants.php:30
$nd
Definition: error.php:12
filter()
Definition: filter.php:2
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ilErr
Definition: raiseError.php:18