3 declare(strict_types=1);
42 $this->
user = $DIC->user();
45 $this->tree = $tree_factory->getTreeById($skill_tree_id);
51 $node->
setOrderNr($tree->getMaxOrderNr($parent_node_id) + 10);
55 $parent_id = ($parent_node_id <= 0)
62 "skrt" => array(
"skll",
"scat",
"sktr",
"sktp",
"sctp"),
63 "scat" => array(
"skll",
"scat",
"sktr"),
64 "sctp" => array(
"sktp",
"sctp"));
66 if (!is_array($allowed[$par_type]) ||
67 !in_array($node->
getType(), $allowed[$par_type])) {
72 if ($a_target_node_id != 0) {
73 $target = $a_target_node_id;
76 $childs = $tree->getChilds($parent_id);
78 if (count($childs) == 0) {
81 $target = $childs[count($childs) - 1][
"obj_id"];
85 if ($tree->isInTree($parent_id) && !$tree->isInTree($node->
getId())) {
86 $tree->insertNode($node->
getId(), $parent_id, $target);
92 $path = $this->tree->getSkillTreePath($node_id, $tref_id);
95 foreach (
$path as $p) {
96 if ($p[
"type"] !=
"skrt") {
97 $path_items[] = $p[
"title"];
100 return implode(
" > ", $path_items);
105 return $this->tree->readRootId();
118 if (!is_array($a_ids)) {
122 foreach ($a_ids as
$id) {
123 $path = $tree->getPathId($id);
125 foreach (
$path as $path_id) {
126 if ($path_id != $id && in_array($path_id, $a_ids)) {
141 foreach ($cut_ids as
$id) {
142 $curnode = $tree->getNodeData($id);
143 if ($tree->isInTree($id)) {
144 $tree->deleteTree($curnode);
162 $time = date(
"Y-m-d H:i:s", time());
164 foreach ($a_ids as
$id) {
166 if ($tree->isInTree($id)) {
167 $curnode = $tree->getNodeData($id);
168 $subnodes = $tree->getSubTree($curnode);
169 foreach ($subnodes as $subnode) {
170 if ($subnode[
"child"] != $id) {
171 $ilUser->addObjectToClipboard(
182 $order = ($curnode[
"lft"] > 0)
184 : (
int) ($order + 1);
185 $ilUser->addObjectToClipboard(
205 $parent_id = $a_obj_id;
209 $skills = $ilUser->getClipboardObjects($a_type);
211 foreach ($skills as $skill) {
213 if (!in_array($skill[
"id"], array_keys($copied_nodes))) {
218 $skill[
"insert_time"],
232 in_array($a_type, array(
"sktp",
"sctp"))
235 return $copied_nodes;
245 $ilUser = $DIC->user();
247 $ilUser->clipboardDeleteObjectsOfType(
"skll");
248 $ilUser->clipboardDeleteObjectsOfType(
"scat");
249 $ilUser->clipboardDeleteObjectsOfType(
"sktr");
250 $ilUser->clipboardDeleteObjectsOfType(
"sktp");
251 $ilUser->clipboardDeleteObjectsOfType(
"sctp");
263 string $a_insert_time,
264 array &$a_copied_nodes,
265 bool $a_as_copy =
false,
266 bool $a_add_suffix =
false 271 $ilLog = $DIC[
"ilLog"];
272 $lng = $DIC->language();
277 if ($item_type ==
"scat") {
278 $item = new \ilSkillCategory($a_item_id);
279 } elseif ($item_type ==
"skll") {
280 $item = new \ilBasicSkill($a_item_id);
281 } elseif ($item_type ==
"sktr") {
282 $item = new \ilSkillTemplateReference($a_item_id);
283 } elseif ($item_type ==
"sktp") {
284 $item = new \ilBasicSkillTemplate($a_item_id);
285 } elseif ($item_type ==
"sctp") {
286 $item = new \ilSkillTemplateCategory($a_item_id);
289 $ilLog->write(
"Getting from clipboard type " . $item_type .
", " .
290 "Item ID: " . $a_item_id);
293 $target_item = $item->copy();
295 $target_item->setTitle($target_item->getTitle() .
" " .
$lng->txt(
"copy_of_suffix"));
296 $target_item->update();
298 $a_copied_nodes[$item->getId()] = $target_item->getId();
300 $target_item = $item;
303 $ilLog->write(
"Putting into skill tree type " . $target_item->getType() .
304 "Item ID: " . $target_item->getId() .
", Parent: " . $a_parent_id .
", " .
305 "Target: " . $a_target);
307 $this->
putIntoTree($target_item, $a_parent_id, $a_target);
309 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
311 foreach ($childs as $child) {
314 $target_item->getId(),
322 return $target_item->getId();
325 public function saveChildsOrder(
int $a_par_id, array $a_childs_order,
bool $a_templates =
false): void
329 if ($a_par_id != $skill_tree->readRootId()) {
330 $childs = $skill_tree->
getChilds($a_par_id);
333 $childs = $skill_tree->getChildsByTypeFilter(
335 array(
"skrt",
"sktp",
"sctp")
338 $childs = $skill_tree->getChildsByTypeFilter(
340 array(
"skrt",
"skll",
"scat",
"sktr")
345 foreach ($childs as $k =>
$c) {
346 if (isset($a_childs_order[
$c[
"child"]])) {
347 $childs[$k][
"order_nr"] = (
int) $a_childs_order[$c[
"child"]];
354 foreach ($childs as
$c) {
365 return $this->tree->getChildsByTypeFilter(
366 $this->tree->readRootId(),
367 array(
"sktp",
"sctp")
static setAction(string $a_action)
static _writeOrderNr(int $a_obj_id, int $a_nr)
__construct(int $skill_tree_id, Tree\SkillTreeFactory $tree_factory)
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
insertItemsFromClip(string $a_type, int $a_obj_id)
Insert basic skills from clipboard.
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
pasteTree(int $a_item_id, int $a_parent_id, int $a_target, string $a_insert_time, array &$a_copied_nodes, bool $a_as_copy=false, bool $a_add_suffix=false)
Paste item (tree) from clipboard to skill tree.
saveChildsOrder(int $a_par_id, array $a_childs_order, bool $a_templates=false)
static _lookupType(int $a_obj_id)
clipboardCut(array $a_ids)
Cut and copy a set of skills/skill categories into the clipboard.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getTopTemplates()
Get top skill templates and template categories.
static clearClipboard()
Remove all skill items from clipboard.
clipboardCopy(array $a_ids)
Copy a set of skills/skill categories into the clipboard.
getWrittenPath(int $node_id, int $tref_id=0)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
putIntoTree(\ilSkillTreeNode $node, int $parent_node_id, int $a_target_node_id=0)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)