ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
14 const SEL_TYPE_CHECK = 1;
15 const SEL_TYPE_RADIO = 2;
16
17 public $root_id = 0;
18 public $output = '';
19 public $ctrl = null;
20
21 private $checked_items = array();
22 private $post_var = '';
23 private $form_items = array();
24 private $form_item_permission = 'read';
25 private $type = 0;
26
33 public function __construct($a_type, $a_target, $a_session_variable)
34 {
35 global $tree, $ilCtrl;
36
37 $this->setId("cont_paste_explorer");
38
39 $this->ctrl = $ilCtrl;
40 $this->type = $a_type;
41
42 parent::__construct($a_target);
43 $this->tree = $tree;
44 $this->root_id = $this->tree->readRootId();
45 $this->order_column = 'title';
46 $this->setSessionExpandVariable($a_session_variable);
47
48 // reset filter
49 $this->filter = array();
50
51 $this->addFilter('root');
52 $this->addFilter('crs');
53 $this->addFilter('grp');
54 $this->addFilter('cat');
55 $this->addFilter('fold');
56
57 $this->addFormItemForType('root');
58 $this->addFormItemForType('crs');
59 $this->addFormItemForType('grp');
60 $this->addFormItemForType('cat');
61 $this->addFormItemForType('fold');
62
63 $this->setFiltered(true);
65 }
66
67 public function isClickable($a_type, $a_ref_id, $a_obj_id = 0)
68 {
69 return false;
70 }
71
72 public function addFormItemForType($type)
73 {
74 $this->form_items[$type] = true;
75 }
77 {
78 $this->form_items[$type] = false;
79 }
80 public function setCheckedItems($a_checked_items = array())
81 {
82 $this->checked_items = $a_checked_items;
83 }
84 public function isItemChecked($a_id)
85 {
86 return in_array($a_id, $this->checked_items) ? true : false;
87 }
88 public function setPostVar($a_post_var)
89 {
90 $this->post_var = $a_post_var;
91 }
92 public function getPostVar()
93 {
94 return $this->post_var;
95 }
96
103 public function setRequiredFormItemPermission($a_form_item_permission)
104 {
105 $this->form_item_permission = $a_form_item_permission;
106 }
107
113 {
115 }
116
117 public function buildFormItem($a_node_id, $a_type)
118 {
119 // permission check
120 if(!$GLOBALS['ilAccess']->checkAccess($this->getRequiredFormItemPermission(),'',$a_node_id))
121 {
122 return '';
123 }
124
125 if(
126 !array_key_exists($a_type, $this->form_items) ||
127 !$this->form_items[$a_type]
128 )
129 {
130 return '';
131 }
132
133 $disabled = false;
134 if(is_array($_SESSION["clipboard"]["ref_ids"]))
135 {
136 $disabled = in_array($a_node_id, $_SESSION["clipboard"]["ref_ids"]);
137 }
138 else if((int)$_SESSION["clipboard"]["ref_ids"])
139 {
140 $disabled = $a_node_id == $_SESSION["clipboard"]["ref_ids"];
141 }
142 else if($_SESSION["clipboard"]["cmd"] == 'copy' && $a_node_id == $_SESSION["clipboard"]["parent"])
143 {
144 $disabled = true;
145 }
146
147 switch($this->type)
148 {
150 return ilUtil::formCheckbox((int)$this->isItemChecked($a_node_id), $this->post_var, $a_node_id, $disabled);
151 break;
152
154 return ilUtil::formRadioButton((int)$this->isItemChecked($a_node_id), $this->post_var, $a_node_id, '', $disabled);
155 break;
156 }
157 }
158
159 function formatObject(&$tpl, $a_node_id, $a_option, $a_obj_id = 0)
160 {
161 global $lng;
162
163 if (!isset($a_node_id) or !is_array($a_option))
164 {
165 $this->ilias->raiseError(get_class($this)."::formatObject(): Missing parameter or wrong datatype! ".
166 "node_id: ".$a_node_id." options:".var_dump($a_option),$this->ilias->error_obj->WARNING);
167 }
168
169 $pic = false;
170 foreach ($a_option["tab"] as $picture)
171 {
172 if ($picture == 'plus')
173 {
174 $tpl->setCurrentBlock("expander");
175 $tpl->setVariable("EXP_DESC", $lng->txt("expand"));
176 $target = $this->createTarget('+',$a_node_id);
177 $tpl->setVariable("LINK_NAME", $a_node_id);
178 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
179 $tpl->setVariable("IMGPATH", $this->getImage("browser/plus.png"));
180 $tpl->parseCurrentBlock();
181 $pic = true;
182 }
183
184 if ($picture == 'minus' && $this->show_minus)
185 {
186 $tpl->setCurrentBlock("expander");
187 $tpl->setVariable("EXP_DESC", $lng->txt("collapse"));
188 $target = $this->createTarget('-',$a_node_id);
189 $tpl->setVariable("LINK_NAME", $a_node_id);
190 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
191 $tpl->setVariable("IMGPATH", $this->getImage("browser/minus.png"));
192 $tpl->parseCurrentBlock();
193 $pic = true;
194 }
195 }
196
197 if (!$pic)
198 {
199 $tpl->setCurrentBlock("blank");
200 $tpl->setVariable("BLANK_PATH", $this->getImage("browser/blank.png"));
201 $tpl->parseCurrentBlock();
202 }
203
204 if ($this->output_icons)
205 {
206 $tpl->setCurrentBlock("icon");
207
208 $path = ilObject::_getIcon($a_obj_id, "tiny", $a_option["type"]);
209 $tpl->setVariable("ICON_IMAGE", $path);
210
211 $tpl->setVariable("TARGET_ID" , "iconid_".$a_node_id);
212 $this->iconList[] = "iconid_".$a_node_id;
213 $tpl->setVariable("TXT_ALT_IMG", $lng->txt($a_option["desc"]));
214 $tpl->parseCurrentBlock();
215 }
216
217 if(strlen($formItem = $this->buildFormItem($a_node_id, $a_option['type'])))
218 {
219 $tpl->setCurrentBlock('check');
220 $tpl->setVariable('OBJ_CHECK', $formItem);
221 $tpl->parseCurrentBlock();
222 }
223
224 if ($this->isClickable($a_option["type"], $a_node_id,$a_obj_id)) // output link
225 {
226 $tpl->setCurrentBlock("link");
227 //$target = (strpos($this->target, "?") === false) ?
228 // $this->target."?" : $this->target."&";
229 //$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
230 $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["type"]));
231
232 $style_class = $this->getNodeStyleClass($a_node_id, $a_option["type"]);
233
234 if ($style_class != "")
235 {
236 $tpl->setVariable("A_CLASS", ' class="'.$style_class.'" ' );
237 }
238
239 if (($onclick = $this->buildOnClick($a_node_id, $a_option["type"], $a_option["title"])) != "")
240 {
241 $tpl->setVariable("ONCLICK", "onClick=\"$onclick\"");
242 }
243
244 $tpl->setVariable("LINK_NAME", $a_node_id);
245 $tpl->setVariable("TITLE", $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]));
246 $tpl->setVariable("DESC", ilUtil::shortenText(
247 $this->buildDescription($a_option["description"], $a_node_id, $a_option["type"]), $this->textwidth, true));
248 $frame_target = $this->buildFrameTarget($a_option["type"], $a_node_id, $a_option["obj_id"]);
249 if ($frame_target != "")
250 {
251 $tpl->setVariable("TARGET", " target=\"".$frame_target."\"");
252 }
253 $tpl->parseCurrentBlock();
254 }
255 else // output text only
256 {
257 $obj_title = $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]);
258
259 // highlight current node
260 if($a_node_id == $this->highlighted)
261 {
262 $obj_title = "<span class=\"ilHighlighted\">".$obj_title."</span>";
263 }
264
265 $tpl->setCurrentBlock("text");
266 $tpl->setVariable("OBJ_TITLE", $obj_title);
267 $tpl->setVariable("OBJ_DESC", ilUtil::shortenText(
268 $this->buildDescription($a_option["desc"], $a_node_id, $a_option["type"]), $this->textwidth, true));
269 $tpl->parseCurrentBlock();
270 }
271
272 $tpl->setCurrentBlock("list_item");
273 $tpl->parseCurrentBlock();
274 $tpl->touchBlock("element");
275 }
276
277 /*
278 * overwritten method from base class
279 * @access public
280 * @param integer obj_id
281 * @param integer array options
282 * @return string
283 */
284 function formatHeader(&$tpl, $a_obj_id,$a_option)
285 {
286 global $lng, $ilias, $tree;
287
288 // custom icons
289 $path = ilObject::_getIcon($a_obj_id, "tiny", "root");
290
291
292 $tpl->setCurrentBlock("icon");
293 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
294 $title = $nd["title"];
295 if ($title == "ILIAS")
296 {
297 $title = $lng->txt("repository");
298 }
299
300 $tpl->setVariable("ICON_IMAGE", $path);
301 $tpl->setVariable("TXT_ALT_IMG", $title);
302 $tpl->parseCurrentBlock();
303
304 if(strlen($formItem = $this->buildFormItem($a_obj_id, $a_option['type'])))
305 {
306 $tpl->setCurrentBlock('check');
307 $tpl->setVariable('OBJ_CHECK', $formItem);
308 $tpl->parseCurrentBlock();
309 }
310
311 $tpl->setVariable('OBJ_TITLE', $title);
312 }
313
314 function showChilds($a_ref_id,$a_obj_id = 0)
315 {
316 global $ilAccess;
317
318 if ($a_ref_id == 0)
319 {
320 return true;
321 }
322 // #11778 - ilAccessHandler::doConditionCheck()
323 if ($ilAccess->checkAccess("read", "", $a_ref_id))
324 {
325 return true;
326 }
327 else
328 {
329 return false;
330 }
331 }
332}
333
334?>
global $tpl
Definition: ilias.php:8
$_SESSION["AccountId"]
const IL_FM_POSITIVE
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.
$nd
Definition: error.php:11
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22