19declare(strict_types=1);
41 $this->
user = $DIC->user();
54 $parent_id = ($parent_node_id <= 0)
61 "skrt" => array(
"skll",
"scat",
"sktr",
"sktp",
"sctp"),
62 "scat" => array(
"skll",
"scat",
"sktr"),
63 "sctp" => array(
"sktp",
"sctp"));
65 if (!is_array($allowed[$par_type]) ||
66 !in_array($node->
getType(), $allowed[$par_type])) {
71 if ($a_target_node_id != 0) {
72 $target = $a_target_node_id;
77 if (count($childs) == 0) {
80 $target = $childs[count($childs) - 1][
"obj_id"];
91 $path = $this->tree->getSkillTreePath($node_id, $tref_id);
94 foreach (
$path as $p) {
95 if ($p[
"type"] !=
"skrt") {
96 $path_items[] = $p[
"title"];
99 return implode(
" > ", $path_items);
104 return $this->tree->readRootId();
117 if (!is_array($a_ids)) {
121 foreach ($a_ids as
$id) {
124 foreach (
$path as $path_id) {
125 if ($path_id !=
$id && in_array($path_id, $a_ids)) {
140 foreach ($cut_ids as
$id) {
161 $time = date(
"Y-m-d H:i:s", time());
163 foreach ($a_ids as
$id) {
168 foreach ($subnodes as $subnode) {
169 if ($subnode[
"child"] !=
$id) {
170 $ilUser->addObjectToClipboard(
181 $order = ($curnode[
"lft"] > 0)
183 : (
int) ($order + 1);
184 $ilUser->addObjectToClipboard(
204 $parent_id = $a_obj_id;
208 $skills = $ilUser->getClipboardObjects($a_type);
210 foreach ($skills as $skill) {
212 if (!in_array($skill[
"id"], array_keys($copied_nodes))) {
217 $skill[
"insert_time"],
231 in_array($a_type, array(
"sktp",
"sctp"))
234 return $copied_nodes;
244 $ilUser =
$DIC->user();
246 $ilUser->clipboardDeleteObjectsOfType(
"skll");
247 $ilUser->clipboardDeleteObjectsOfType(
"scat");
248 $ilUser->clipboardDeleteObjectsOfType(
"sktr");
249 $ilUser->clipboardDeleteObjectsOfType(
"sktp");
250 $ilUser->clipboardDeleteObjectsOfType(
"sctp");
262 string $a_insert_time,
263 array &$a_copied_nodes,
264 bool $a_as_copy =
false,
265 bool $a_add_suffix =
false
270 $ilLog =
$DIC[
"ilLog"];
276 if ($item_type ==
"scat") {
277 $item = new \ilSkillCategory($a_item_id);
278 } elseif ($item_type ==
"skll") {
279 $item = new \ilBasicSkill($a_item_id);
280 } elseif ($item_type ==
"sktr") {
281 $item = new \ilSkillTemplateReference($a_item_id);
282 } elseif ($item_type ==
"sktp") {
283 $item = new \ilBasicSkillTemplate($a_item_id);
284 } elseif ($item_type ==
"sctp") {
285 $item = new \ilSkillTemplateCategory($a_item_id);
288 $ilLog->write(
"Getting from clipboard type " . $item_type .
", " .
289 "Item ID: " . $a_item_id);
292 $target_item = $item->copy();
294 $target_item->setTitle($target_item->getTitle() .
" " .
$lng->txt(
"copy_of_suffix"));
295 $target_item->update();
297 $a_copied_nodes[$item->getId()] = $target_item->getId();
299 $target_item = $item;
302 $ilLog->write(
"Putting into skill tree type " . $target_item->getType() .
303 "Item ID: " . $target_item->getId() .
", Parent: " . $a_parent_id .
", " .
304 "Target: " . $a_target);
306 $this->
putIntoTree($target_item, $a_parent_id, $a_target);
308 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
310 foreach ($childs as $child) {
313 $target_item->getId(),
321 return $target_item->getId();
324 public function saveChildsOrder(
int $a_par_id, array $a_childs_order,
bool $a_templates =
false): void
326 $skill_tree = $this->tree;
328 if ($a_par_id != $skill_tree->readRootId()) {
329 $childs = $skill_tree->getChilds($a_par_id);
332 $childs = $skill_tree->getChildsByTypeFilter(
334 array(
"skrt",
"sktp",
"sctp")
337 $childs = $skill_tree->getChildsByTypeFilter(
339 array(
"skrt",
"skll",
"scat",
"sktr")
344 foreach ($childs as $k =>
$c) {
345 if (isset($a_childs_order[
$c[
"child"]])) {
346 $childs[$k][
"order_nr"] = (
int) $a_childs_order[
$c[
"child"]];
353 foreach ($childs as
$c) {
364 return $this->tree->getChildsByTypeFilter(
365 $this->tree->readRootId(),
366 array(
"sktp",
"sctp")
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
putIntoTree(\ilSkillTreeNode $node, int $parent_node_id, int $a_target_node_id=0)
insertItemsFromClip(string $a_type, int $a_obj_id)
Insert basic skills from clipboard.
getTopTemplates()
Get top skill templates and template categories.
clipboardCopy(array $a_ids)
Copy a set of skills/skill categories into the clipboard.
static clearClipboard()
Remove all skill items from clipboard.
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.
getWrittenPath(int $node_id, int $tref_id=0)
saveChildsOrder(int $a_par_id, array $a_childs_order, bool $a_templates=false)
clipboardCut(array $a_ids)
Cut and copy a set of skills/skill categories into the clipboard.
__construct(int $skill_tree_id, Tree\SkillTreeFactory $tree_factory)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static setAction(string $a_action)
A node in the skill tree.
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
static _writeOrderNr(int $a_obj_id, int $a_nr)
static _lookupType(int $a_obj_id)
getMaxOrderNr(int $a_par_id, bool $a_templates=false)
isInTree(?int $a_node_id)
get all information of a node.
insertNode(int $a_node_id, int $a_parent_id, int $a_pos=self::POS_LAST_NODE, bool $a_reset_deletion_date=false)
insert new node with node_id under parent node with parent_id
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
getSubTree(array $a_node, bool $a_with_data=true, array $a_type=[])
get all nodes in the subtree under specified node
deleteTree(array $a_node)
delete node and the whole subtree under this node
getPathId(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...