ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilVirtualSkillTree Class Reference

Virtual skill tree. More...

+ Collaboration diagram for ilVirtualSkillTree:

Public Member Functions

 __construct ()
 Constructor.
 getRootNode ()
 Get root node.
 setIncludeDrafts ($a_val)
 Set include drafts.
 getIncludeDrafts ()
 Get include drafts.
 setIncludeOutdated ($a_val)
 Set include outdated.
 getIncludeOutdated ()
 Get include outdated.
 getNode ($a_id)
 Get node.
 getChildsOfNode ($a_parent_id)
 Get childs of node.
 getChildsOfNodeForCSkillId ($a_cskill_id)
 Get childs of node for cskill id.
 getCSkillIdForVTreeId ($a_vtree_id)
 Get common skill id for tree id.
 getNodeTitle ($a_node)
 Get node content.
 getSubTreeForCSkillId ($a_cskill_id, $a_only_basic=false)
 Get sub tree.
 isDraft ($a_node_id)
 Is draft.
 isOutdated ($a_node_id)
 Is outdated.

Protected Attributes

 $include_drafts = false
 $drafts = array()
 $include_outdated = false
 $outdated = array()

Private Member Functions

 __getSubTreeRec ($id, &$result, $a_only_basic)
 Get subtree, internal.

Detailed Description

Virtual skill tree.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilVirtualSkillTree.php.

Constructor & Destructor Documentation

ilVirtualSkillTree::__construct ( )

Constructor.

Definition at line 23 of file class.ilVirtualSkillTree.php.

{
include_once("./Services/Skill/classes/class.ilSkillTree.php");
$this->tree = new ilSkillTree();
}

Member Function Documentation

ilVirtualSkillTree::__getSubTreeRec (   $id,
$result,
  $a_only_basic 
)
private

Get subtree, internal.

Parameters
string$idvtree id
array$resultnode array (called by reference)
bool$a_only_basicreturn only basic skills (and basic skill templates)

Definition at line 336 of file class.ilVirtualSkillTree.php.

References $result, ilSkillTreeNode\_lookupType(), and getChildsOfNode().

Referenced by getSubTreeForCSkillId().

{
$childs = $this->getChildsOfNode($id);
foreach ($childs as $c)
{
if (!$a_only_basic || in_array($c["type"], array("skll", "sktp")) ||
($c["type"] == "sktr" && ilSkillTreeNode::_lookupType($c["skill_id"]) == "sktp"))
{
$result[] = $c;
}
$this->__getSubTreeRec($c["id"], $result, $a_only_basic);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilVirtualSkillTree::getChildsOfNode (   $a_parent_id)

Get childs of node.

Parameters
string$a_parent_idparent id
Returns
array childs

Definition at line 133 of file class.ilVirtualSkillTree.php.

References $d, $drafts, $outdated, ilSkillTreeNode\_lookupStatus(), ilSkillTemplateReference\_lookupTemplateId(), getCSkillIdForVTreeId(), getIncludeDrafts(), getIncludeOutdated(), ilSkillTreeNode\STATUS_DRAFT, and ilSkillTreeNode\STATUS_OUTDATED.

Referenced by __getSubTreeRec(), and getChildsOfNodeForCSkillId().

{
$a_parent_id_parts = explode(":", $a_parent_id);
$a_parent_skl_tree_id = $a_parent_id_parts[0];
$a_parent_skl_template_tree_id = $a_parent_id_parts[1];
if ($a_parent_skl_template_tree_id == 0)
{
$childs = $this->tree->getChildsByTypeFilter($a_parent_skl_tree_id, array("scat", "skll", "sktr"), "order_nr");
}
else
{
$childs = $this->tree->getChildsByTypeFilter($a_parent_skl_template_tree_id, array("sktp", "sctp"), "order_nr");
}
include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
$drafts = array();
$outdated = array();
foreach ($childs as $k => $c)
{
if ($a_parent_skl_template_tree_id > 0)
{
// we are in template tree only
$child_id = $a_parent_skl_tree_id.":".$c["child"];
}
else if (!in_array($c["type"], array("sktr", "sctr")))
{
// we are in main tree only
$child_id = $c["child"].":0";
}
else
{
// get template id for references
include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
$child_id = $c["child"].":".ilSkillTemplateReference::_lookupTemplateId($c["child"]);
}
unset($childs[$k]["child"]);
unset($childs[$k]["skl_tree_id"]);
unset($childs[$k]["lft"]);
unset($childs[$k]["rgt"]);
unset($childs[$k]["depth"]);
$childs[$k]["id"] = $child_id;
//echo "-".$child_id."-";
$cid = $this->getCSkillIdForVTreeId($child_id);
//echo "-".$cid."-";
$cid_parts = explode(":", $cid);
$childs[$k]["skill_id"] = $cid_parts[0];
$childs[$k]["tref_id"] = $cid_parts[1];
$childs[$k]["cskill_id"] = $cid;
$childs[$k]["parent"] = $a_parent_id;
$this->parent[$c["id"]] = $a_parent_id;
// @todo: prepare this for tref id?
in_array($a_parent_id, $this->drafts))
{
$this->drafts[] = $child_id;
$drafts[] = $k;
}
in_array($a_parent_id, $this->outdated))
{
$this->outdated[] = $child_id;
$outdated[] = $k;
}
}
if (!$this->getIncludeDrafts())
{
foreach ($drafts as $d)
{
unset($childs[$d]);
}
}
if (!$this->getIncludeOutdated())
{
foreach ($outdated as $d)
{
unset($childs[$d]);
}
}
return $childs;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilVirtualSkillTree::getChildsOfNodeForCSkillId (   $a_cskill_id)

Get childs of node for cskill id.

Parameters
string$a_cskill_idcommon skill id <skill_id>:<tref_id>
Returns
array array of childs

Definition at line 224 of file class.ilVirtualSkillTree.php.

References getChildsOfNode().

{
$id_parts = explode(":", $a_cskill_id);
if ($id_parts[1] == 0)
{
$id = $id_parts[0].":0";
}
else
{
$id = $id_parts[1].":".$id_parts[0];
}
return $this->getChildsOfNode($id);
}

+ Here is the call graph for this function:

ilVirtualSkillTree::getCSkillIdForVTreeId (   $a_vtree_id)

Get common skill id for tree id.

Parameters
string$a_vtree_idvtree id
Returns
string cskill id

Definition at line 244 of file class.ilVirtualSkillTree.php.

Referenced by getChildsOfNode(), and getNode().

{
$id_parts = explode(":", $a_vtree_id);
if ($id_parts[1] == 0)
{
// skill in main tree
$skill_id = $id_parts[0];
$tref_id = 0;
}
else
{
// skill in template
$tref_id = $id_parts[0];
$skill_id = $id_parts[1];
}
return $skill_id.":".$tref_id;
}

+ Here is the caller graph for this function:

ilVirtualSkillTree::getIncludeDrafts ( )

Get include drafts.

Returns
bool include drafts

Definition at line 60 of file class.ilVirtualSkillTree.php.

References $include_drafts.

Referenced by getChildsOfNode().

{
}

+ Here is the caller graph for this function:

ilVirtualSkillTree::getIncludeOutdated ( )

Get include outdated.

Returns
bool include outdated

Definition at line 80 of file class.ilVirtualSkillTree.php.

References $include_outdated.

Referenced by getChildsOfNode().

+ Here is the caller graph for this function:

ilVirtualSkillTree::getNode (   $a_id)

Get node.

Parameters
string$a_idvtree id
Returns
array node array

Definition at line 91 of file class.ilVirtualSkillTree.php.

References ilSkillTemplateReference\_lookupTemplateId(), and getCSkillIdForVTreeId().

Referenced by getSubTreeForCSkillId().

{
$id_parts = explode(":", $a_id);
$skl_tree_id = $id_parts[0];
$skl_template_tree_id = $id_parts[1];
if ($skl_template_tree_id == 0 || (ilSkillTemplateReference::_lookupTemplateId($skl_tree_id)
== $skl_template_tree_id))
{
$node_data = $this->tree->getNodeData($skl_tree_id);
$node_data["parent"] = $node_data["parent"].":0";
}
else
{
$node_data = $this->tree->getNodeData($skl_template_tree_id);
$node_data["parent"] = $skl_tree_id.":".$node_data["parent"];
}
unset($node_data["child"]);
unset($node_data["skl_tree_id"]);
unset($node_data["lft"]);
unset($node_data["rgt"]);
unset($node_data["depth"]);
$node_data["id"] = $a_id;
$cid = $this->getCSkillIdForVTreeId($a_id);
$cid_parts = explode(":", $cid);
$node_data["skill_id"] = $cid_parts[0];
$node_data["tref_id"] = $cid_parts[1];
$node_data["cskill_id"] = $cid;
return $node_data;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilVirtualSkillTree::getNodeTitle (   $a_node)

Get node content.

Parameters
array$a_nodenode data
Returns
string title

Definition at line 269 of file class.ilVirtualSkillTree.php.

References $lng.

{
global $lng;
$a_parent_id_parts = explode(":", $a_node["id"]);
$a_parent_skl_tree_id = $a_parent_id_parts[0];
$a_parent_skl_template_tree_id = $a_parent_id_parts[1];
// title
$title = $a_node["title"];
// root?
if ($a_node["type"] == "skrt")
{
$lng->txt("skmg_skills");
}
else
{
if ($a_node["type"] == "sktr")
{
// include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
// $title.= " (".ilSkillTreeNode::_lookupTitle($a_parent_skl_template_tree_id).")";
}
}
return $title;
}
ilVirtualSkillTree::getRootNode ( )

Get root node.

Returns
array root node array

Definition at line 34 of file class.ilVirtualSkillTree.php.

{
$root_id = $this->tree->readRootId();
$root_node = $this->tree->getNodeData($root_id);
unset($root_node["child"]);
$root_node["id"] = $root_id.":0";
$root_node["cskill_id"] = $root_id.":0";
return $root_node;
}
ilVirtualSkillTree::getSubTreeForCSkillId (   $a_cskill_id,
  $a_only_basic = false 
)

Get sub tree.

Parameters
string$a_cskill_idcskill id
bool$a_only_basicreturn only basic skills (and basic skill templates)
Returns
array node array

Definition at line 304 of file class.ilVirtualSkillTree.php.

References $result, __getSubTreeRec(), ilSkillTreeNode\_lookupType(), and getNode().

{
$id_parts = explode(":", $a_cskill_id);
if ($id_parts[1] == 0)
{
$id = $id_parts[0].":0";
}
else
{
$id = $id_parts[1].":".$id_parts[0];
}
$result = array();
$node = $this->getNode($id);
if (!$a_only_basic || in_array($node["type"], array("skll", "sktp")) ||
($node["type"] == "sktr" && ilSkillTreeNode::_lookupType($node["skill_id"]) == "sktp"))
{
$result[] = $node;
}
$this->__getSubTreeRec($id, $result, $a_only_basic);
return $result;
}

+ Here is the call graph for this function:

ilVirtualSkillTree::isDraft (   $a_node_id)

Is draft.

Parameters
int$a_node_idnode id
Returns
bool is draft true/false

Definition at line 356 of file class.ilVirtualSkillTree.php.

{
return in_array($a_node_id, $this->drafts);
}
ilVirtualSkillTree::isOutdated (   $a_node_id)

Is outdated.

Parameters
int$a_node_idnode id
Returns
bool is outdated true/false

Definition at line 367 of file class.ilVirtualSkillTree.php.

{
return in_array($a_node_id, $this->outdated);
}
ilVirtualSkillTree::setIncludeDrafts (   $a_val)

Set include drafts.

Parameters
bool$a_valinclude drafts

Definition at line 50 of file class.ilVirtualSkillTree.php.

{
$this->include_drafts = $a_val;
}
ilVirtualSkillTree::setIncludeOutdated (   $a_val)

Set include outdated.

Parameters
bool$a_valinclude outdated

Definition at line 70 of file class.ilVirtualSkillTree.php.

{
$this->include_outdated = $a_val;
}

Field Documentation

ilVirtualSkillTree::$drafts = array()
protected

Definition at line 16 of file class.ilVirtualSkillTree.php.

Referenced by getChildsOfNode().

ilVirtualSkillTree::$include_drafts = false
protected

Definition at line 15 of file class.ilVirtualSkillTree.php.

Referenced by getIncludeDrafts().

ilVirtualSkillTree::$include_outdated = false
protected

Definition at line 17 of file class.ilVirtualSkillTree.php.

Referenced by getIncludeOutdated().

ilVirtualSkillTree::$outdated = array()
protected

Definition at line 18 of file class.ilVirtualSkillTree.php.

Referenced by getChildsOfNode().


The documentation for this class was generated from the following file: