39 $this->
user = $DIC->user();
42 $this->tree = $tree_factory->
getTreeById($skill_tree_id);
48 $node->
setOrderNr($tree->getMaxOrderNr($parent_node_id) + 10);
52 $parent_id = ($parent_node_id <= 0)
59 "skrt" => array(
"skll",
"scat",
"sktr",
"sktp",
"sctp"),
60 "scat" => array(
"skll",
"scat",
"sktr"),
61 "sctp" => array(
"sktp",
"sctp"));
63 if (!is_array($allowed[$par_type]) ||
64 !in_array($node->
getType(), $allowed[$par_type])) {
69 if ($a_target_node_id != 0) {
70 $target = $a_target_node_id;
73 $childs = $tree->getChilds($parent_id);
75 if (count($childs) == 0) {
78 $target = $childs[count($childs) - 1][
"obj_id"];
82 if ($tree->isInTree($parent_id) && !$tree->isInTree($node->
getId())) {
83 $tree->insertNode($node->
getId(), $parent_id, $target);
89 $path = $this->tree->getSkillTreePath($node_id, $tref_id);
92 foreach (
$path as $p) {
93 if ($p[
"type"] !=
"skrt") {
94 $path_items[] = $p[
"title"];
97 return implode(
" > ", $path_items);
102 return $this->tree->readRootId();
115 if (!is_array($a_ids)) {
119 foreach ($a_ids as
$id) {
120 $path = $tree->getPathId($id);
122 foreach (
$path as $path_id) {
123 if ($path_id != $id && in_array($path_id, $a_ids)) {
138 foreach ($cut_ids as
$id) {
139 $curnode = $tree->getNodeData($id);
140 if ($tree->isInTree($id)) {
141 $tree->deleteTree($curnode);
159 $time = date(
"Y-m-d H:i:s", time());
161 foreach ($a_ids as
$id) {
163 if ($tree->isInTree($id)) {
164 $curnode = $tree->getNodeData($id);
165 $subnodes = $tree->getSubTree($curnode);
166 foreach ($subnodes as $subnode) {
167 if ($subnode[
"child"] != $id) {
179 $order = ($curnode[
"lft"] > 0)
181 : (
int) ($order + 1);
202 $parent_id = $a_obj_id;
206 $skills =
$ilUser->getClipboardObjects($a_type);
208 foreach ($skills as $skill) {
210 if (!in_array($skill[
"id"], array_keys($copied_nodes))) {
215 $skill[
"insert_time"],
229 in_array($a_type, array(
"sktp",
"sctp"))
232 return $copied_nodes;
244 $ilUser->clipboardDeleteObjectsOfType(
"skll");
245 $ilUser->clipboardDeleteObjectsOfType(
"scat");
246 $ilUser->clipboardDeleteObjectsOfType(
"sktr");
247 $ilUser->clipboardDeleteObjectsOfType(
"sktp");
248 $ilUser->clipboardDeleteObjectsOfType(
"sctp");
260 string $a_insert_time,
261 array &$a_copied_nodes,
262 bool $a_as_copy =
false,
263 bool $a_add_suffix =
false 268 $ilLog = $DIC[
"ilLog"];
269 $lng = $DIC->language();
274 if ($item_type ==
"scat") {
275 $item = new \ilSkillCategory($a_item_id);
276 } elseif ($item_type ==
"skll") {
277 $item = new \ilBasicSkill($a_item_id);
278 } elseif ($item_type ==
"sktr") {
279 $item = new \ilSkillTemplateReference($a_item_id);
280 } elseif ($item_type ==
"sktp") {
281 $item = new \ilBasicSkillTemplate($a_item_id);
282 } elseif ($item_type ==
"sctp") {
283 $item = new \ilSkillTemplateCategory($a_item_id);
286 $ilLog->write(
"Getting from clipboard type " . $item_type .
", " .
287 "Item ID: " . $a_item_id);
290 $target_item = $item->copy();
292 $target_item->setTitle($target_item->getTitle() .
" " .
$lng->txt(
"copy_of_suffix"));
293 $target_item->update();
295 $a_copied_nodes[$item->getId()] = $target_item->getId();
297 $target_item = $item;
300 $ilLog->write(
"Putting into skill tree type " . $target_item->getType() .
301 "Item ID: " . $target_item->getId() .
", Parent: " . $a_parent_id .
", " .
302 "Target: " . $a_target);
304 $this->
putIntoTree($target_item, $a_parent_id, $a_target);
306 $childs =
$ilUser->getClipboardChilds($item->getId(), $a_insert_time);
308 foreach ($childs as $child) {
311 $target_item->getId(),
319 return $target_item->getId();
322 public function saveChildsOrder(
int $a_par_id, array $a_childs_order,
bool $a_templates =
false): void
326 if ($a_par_id != $skill_tree->readRootId()) {
327 $childs = $skill_tree->
getChilds($a_par_id);
330 $childs = $skill_tree->getChildsByTypeFilter(
332 array(
"skrt",
"sktp",
"sctp")
335 $childs = $skill_tree->getChildsByTypeFilter(
337 array(
"skrt",
"skll",
"scat",
"sktr")
342 foreach ($childs as $k =>
$c) {
343 if (isset($a_childs_order[
$c[
"child"]])) {
344 $childs[$k][
"order_nr"] = (
int) $a_childs_order[$c[
"child"]];
351 foreach ($childs as
$c) {
362 return $this->tree->getChildsByTypeFilter(
363 $this->tree->readRootId(),
364 array(
"sktp",
"sctp")
static setAction(string $a_action)
static _writeOrderNr(int $a_obj_id, int $a_nr)
getTopTemplates()
Get top skill templates and template categories.
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
saveChildsOrder(int $a_par_id, array $a_childs_order, bool $a_templates=false)
static _lookupType(int $a_obj_id)
getWrittenPath(int $node_id, int $tref_id=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
insertItemsFromClip(string $a_type, int $a_obj_id)
Insert basic skills from clipboard.
putIntoTree(\ilSkillTreeNode $node, int $parent_node_id, int $a_target_node_id=0)
__construct(int $skill_tree_id, SkillTreeFactory $tree_factory)
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...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
clipboardCopy(array $a_ids)
Copy a set of skills/skill categories into the 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.
static clearClipboard()
Remove all skill items from clipboard.
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)