/**
  * Get skill presentation HTML
  *
  * @return
  */
 function getSkillHTML($a_top_skill_id, $a_user_id = 0, $a_edit = false, $a_tref_id = 0)
 {
     global $ilUser, $lng, $ilCtrl, $ilSetting;
     $this->tooltips = array();
     if ($a_user_id == 0) {
         $user = $ilUser;
     } else {
         $user = new ilObjUser($a_user_id);
     }
     $tpl = new ilTemplate("tpl.skill_pres.html", true, true, "Services/Skill");
     include_once "./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
     include_once "./Services/Skill/classes/class.ilSkillTree.php";
     $stree = new ilSkillTree();
     include_once "./Services/Skill/classes/class.ilSkillTreeNode.php";
     include_once "./Services/Skill/classes/class.ilSkillTreeNodeFactory.php";
     // general settings for the action drop down
     include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
     $act_list = new ilAdvancedSelectionListGUI();
     $act_list->setListTitle($lng->txt("actions"));
     $act_list->setSelectionHeaderClass("small");
     //		$act_list->setLinksMode("il_ContainerItemCommand2");
     $act_list->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
     $act_list->setUseImages(false);
     $b_skills = ilSkillTreeNode::getSkillTreeNodes($a_top_skill_id, true, $a_tref_id);
     foreach ($b_skills as $bs) {
         $path = $stree->getSkillTreePath($bs["id"], $bs["tref"]);
         // check draft
         foreach ($path as $p) {
             if ($p["draft"]) {
                 continue 2;
             }
         }
         reset($path);
         $skill = ilSkillTreeNodeFactory::getInstance($bs["id"]);
         $level_data = $skill->getLevelData();
         if ($this->mode == "gap") {
             if ($this->getProfileId() > 0) {
                 $this->renderProfileTargetRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
             }
             $this->renderActualLevelsRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
             $this->renderGapSelfEvalRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
             $this->renderSuggestedResources($tpl, $level_data, $bs["id"], $bs["tref"]);
         } else {
             if ($this->getProfileId() > 0) {
                 $this->renderProfileTargetRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
             }
             $this->renderMaterialsRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
             // get date of self evaluation
             $se_date = ilPersonalSkill::getSelfEvaluationDate($user->getId(), $a_top_skill_id, $bs["tref"], $bs["id"]);
             $se_rendered = $se_date == "" ? true : false;
             // get all object triggered entries and render them
             foreach ($skill->getAllLevelEntriesOfUser($bs["tref"], $user->getId()) as $level_entry) {
                 // render the self evaluation at the correct position within the list of object triggered entries
                 if ($se_date > $level_entry["status_date"] && !$se_rendered) {
                     $this->renderSelfEvaluationRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
                     $se_rendered = true;
                 }
                 $this->renderObjectEvalRow($tpl, $level_data, $level_entry);
             }
             // if not rendered yet, render self evaluation now
             if (!$se_rendered) {
                 $this->renderSelfEvaluationRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
             }
         }
         $too_low = true;
         $current_target_level = 0;
         foreach ($level_data as $k => $v) {
             // level
             $tpl->setCurrentBlock("level_td");
             $tpl->setVariable("VAL_LEVEL", $v["title"]);
             $tt_id = "skmg_skl_tt_" . self::$skill_tt_cnt;
             self::$skill_tt_cnt++;
             $tpl->setVariable("TT_ID", $tt_id);
             if ($v["description"] != "") {
                 ilTooltipGUI::addTooltip($tt_id, $v["description"]);
             }
             $tpl->parseCurrentBlock();
             // profile targel level
             /*
             				foreach ($this->profile_levels as $pl)
             				{
             					if ($pl["level_id"] == $v["id"] &&
             						$pl["base_skill_id"] == $v["skill_id"])
             					{
             						$too_low = true;
             						$current_target_level = $v["id"];
             					}
             				}
             				else
             				{
             					$tpl->setVariable("VAL_SELF_EVAL", " ");
             				}
             				$tpl->parseCurrentBlock();
             				if ($v["id"] == $se_level)
             				{
             					$found = true;
             				}
             
             				// assigned materials
             				if ($this->use_materials)
             				{
             
             					$mat_cnt = ilPersonalSkill::countAssignedMaterial($user->getId(),
             						$bs["tref"], $v["id"]);
             					if ($mat_cnt == 0)
             					{
             						$tpl->setCurrentBlock("material_td");
             						$tpl->setVariable("VAL_MATERIAL", " ");
             						$tpl->parseCurrentBlock();
             					}
             					else
             					{					
             						// links to material files
             						$tpl->setCurrentBlock("material_links");
             											
             						$mat_tt = array();
             						$cnt = 1;
             						foreach(ilPersonalSkill::getAssignedMaterial($user->getId(),
             							$bs["tref"], $v["id"]) as $item)
             						{												
             							$mat_data = $this->getMaterialInfo($item["wsp_id"]);
             							$tpl->setVariable("URL_MATERIAL", $mat_data[1]);
             							$tpl->setVariable("TXT_MATERIAL", $cnt);
             							
             							// tooltip
             							$mat_tt_id = "skmg_skl_tt_mat_".self::$skill_tt_cnt;
             							self::$skill_tt_cnt++;
             							$tpl->setVariable("TOOLTIP_MATERIAL_ID", $mat_tt_id);
             							
             							if(!$this->offline_mode)
             							{
             								ilTooltipGUI::addTooltip($mat_tt_id, $mat_data[0]);
             							}
             							else
             							{							
             								$this->tooltips[] = ilTooltipGUI::getTooltip($mat_tt_id, $mat_data[0]);
             							}
             							
             							$tpl->parseCurrentBlock();
             							$cnt++;
             						}																	
             						
             						$tpl->setCurrentBlock("material_td");
             						$tpl->setVariable("CLASS_MAT", "ilSkillMat");
             						$tpl->parseCurrentBlock();
             					}
             				}
             */
         }
         $title = $sep = "";
         $found = false;
         foreach ($path as $p) {
             if ($found) {
                 $title .= $sep . $p["title"];
                 $sep = " > ";
             }
             if ($a_top_skill_id == $p["child"]) {
                 $found = true;
             }
         }
         $tpl->setCurrentBlock("skill");
         $tpl->setVariable("BSKILL_TITLE", $title);
         /*			$tpl->setVariable("TXT_LEVEL", $lng->txt("skmg_level"));
         			$tpl->setVariable("TXT_SELF_EVAL", $lng->txt("skmg_self_evaluation"));
         			if ($this->use_materials)
         			{
         				$tpl->setVariable("TXT_MATERIAL", $lng->txt("skmg_material"));
         			}*/
         $tpl->setVariable("TXT_TARGET", $lng->txt("skmg_target_level"));
         $tpl->setVariable("TXT_360_SURVEY", $lng->txt("skmg_360_survey"));
         if ($a_edit) {
             $act_list->flush();
             $act_list->setId("act_" . $a_top_skill_id . "_" . $bs["id"]);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "tref_id", $bs["tref"]);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "basic_skill_id", $bs["id"]);
             if ($this->use_materials) {
                 $act_list->addItem($lng->txt('skmg_assign_materials'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials"));
             }
             $act_list->addItem($lng->txt('skmg_self_evaluation'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "selfEvaluation"));
             $tpl->setVariable("ACTIONS2", $act_list->getHTML());
         }
         $tpl->parseCurrentBlock();
     }
     $tpl->setVariable("SKILL_TITLE", ilSkillTreeNode::_lookupTitle($a_top_skill_id));
     if ($a_edit) {
         $act_list->flush();
         $act_list->setId("act_" . $a_top_skill_id);
         $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
         //			$act_list->addItem($lng->txt('skmg_assign_materials'), "",
         //				$ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials"));
         $act_list->addItem($lng->txt('skmg_remove_skill'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "confirmSkillRemove"));
         $tpl->setVariable("ACTIONS1", $act_list->getHTML());
     }
     return $tpl->get();
 }
 /**
  * Get skill presentation HTML
  *
  * @return
  */
 function getSkillHTML($a_top_skill_id, $a_user_id = 0, $a_edit = false)
 {
     global $ilUser, $lng, $ilCtrl, $ilSetting;
     $this->tooltips = array();
     if ($a_user_id == 0) {
         $user = $ilUser;
     } else {
         $user = new ilObjUser($a_user_id);
     }
     $tpl = new ilTemplate("tpl.skill_pres.html", true, true, "Services/Skill");
     include_once "./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
     include_once "./Services/Skill/classes/class.ilSkillTree.php";
     $stree = new ilSkillTree();
     include_once "./Services/Skill/classes/class.ilSkillTreeNode.php";
     include_once "./Services/Skill/classes/class.ilSkillTreeNodeFactory.php";
     // general settings for the action drop down
     include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
     $act_list = new ilAdvancedSelectionListGUI();
     $act_list->setListTitle($lng->txt("actions"));
     $act_list->setSelectionHeaderClass("small");
     //		$act_list->setLinksMode("il_ContainerItemCommand2");
     $act_list->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
     $act_list->setUseImages(false);
     $b_skills = ilSkillTreeNode::getSkillTreeNodes($a_top_skill_id, true);
     foreach ($b_skills as $bs) {
         $path = $stree->getSkillTreePath($bs["id"], $bs["tref"]);
         // check draft
         foreach ($path as $p) {
             if ($p["draft"]) {
                 continue 2;
             }
         }
         reset($path);
         $se_level = ilPersonalSkill::getSelfEvaluation($user->getId(), $a_top_skill_id, $bs["tref"], $bs["id"]);
         $skill = ilSkillTreeNodeFactory::getInstance($bs["id"]);
         $level_data = $skill->getLevelData();
         // check, if current self eval level is in current level data
         $valid_sel_level = false;
         if ($se_level > 0) {
             foreach ($level_data as $k => $v) {
                 if ($v["id"] == $se_level) {
                     $valid_sel_level = true;
                 }
             }
         }
         reset($level_data);
         $found = false;
         foreach ($level_data as $k => $v) {
             // level
             $tpl->setCurrentBlock("level_td");
             $tpl->setVariable("VAL_LEVEL", $v["title"]);
             $tt_id = "skmg_skl_tt_" . self::$skill_tt_cnt;
             self::$skill_tt_cnt++;
             $tpl->setVariable("TT_ID", $tt_id);
             if ($v["description"] != "") {
                 ilTooltipGUI::addTooltip($tt_id, $v["description"]);
             }
             $tpl->parseCurrentBlock();
             // self evaluation
             $tpl->setCurrentBlock("self_eval_td");
             if ($valid_sel_level && !$found) {
                 $tpl->setVariable("VAL_SELF_EVAL", "x");
                 $tpl->setVariable("CLASS_SELF_EVAL", "ilSkillSelf");
             } else {
                 $tpl->setVariable("VAL_SELF_EVAL", " ");
             }
             $tpl->parseCurrentBlock();
             if ($v["id"] == $se_level) {
                 $found = true;
             }
             // assigned materials
             if ($this->use_materials) {
                 $mat_cnt = ilPersonalSkill::countAssignedMaterial($user->getId(), $bs["tref"], $v["id"]);
                 if ($mat_cnt == 0) {
                     $tpl->setCurrentBlock("material_td");
                     $tpl->setVariable("VAL_MATERIAL", " ");
                     $tpl->parseCurrentBlock();
                 } else {
                     // links to material files
                     $tpl->setCurrentBlock("material_links");
                     $mat_tt = array();
                     $cnt = 1;
                     foreach (ilPersonalSkill::getAssignedMaterial($user->getId(), $bs["tref"], $v["id"]) as $item) {
                         $mat_data = $this->getMaterialInfo($item["wsp_id"]);
                         $tpl->setVariable("URL_MATERIAL", $mat_data[1]);
                         $tpl->setVariable("TXT_MATERIAL", $cnt);
                         // tooltip
                         $mat_tt_id = "skmg_skl_tt_mat_" . self::$skill_tt_cnt;
                         self::$skill_tt_cnt++;
                         $tpl->setVariable("TOOLTIP_MATERIAL_ID", $mat_tt_id);
                         if (!$this->offline_mode) {
                             ilTooltipGUI::addTooltip($mat_tt_id, $mat_data[0]);
                         } else {
                             $this->tooltips[] = ilTooltipGUI::getTooltip($mat_tt_id, $mat_data[0]);
                         }
                         $tpl->parseCurrentBlock();
                         $cnt++;
                     }
                     $tpl->setCurrentBlock("material_td");
                     $tpl->setVariable("CLASS_MAT", "ilSkillMat");
                     $tpl->parseCurrentBlock();
                 }
             }
         }
         $title = $sep = "";
         $found = false;
         foreach ($path as $p) {
             if ($found) {
                 $title .= $sep . $p["title"];
                 $sep = " > ";
             }
             if ($a_top_skill_id == $p["child"]) {
                 $found = true;
             }
         }
         $tpl->setCurrentBlock("skill");
         $tpl->setVariable("BSKILL_TITLE", $title);
         $tpl->setVariable("TXT_LEVEL", $lng->txt("skmg_level"));
         $tpl->setVariable("TXT_SELF_EVAL", $lng->txt("skmg_self_evaluation"));
         if ($this->use_materials) {
             $tpl->setVariable("TXT_MATERIAL", $lng->txt("skmg_material"));
         }
         if ($a_edit) {
             $act_list->flush();
             $act_list->setId("act_" . $a_top_skill_id . "_" . $bs["id"]);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "tref_id", $bs["tref"]);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "basic_skill_id", $bs["id"]);
             if ($this->use_materials) {
                 $act_list->addItem($lng->txt('skmg_assign_materials'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials"));
             }
             $act_list->addItem($lng->txt('skmg_self_evaluation'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "selfEvaluation"));
             $tpl->setVariable("ACTIONS2", $act_list->getHTML());
         }
         $tpl->parseCurrentBlock();
     }
     $tpl->setVariable("SKILL_TITLE", ilSkillTreeNode::_lookupTitle($a_top_skill_id));
     if ($a_edit) {
         $act_list->flush();
         $act_list->setId("act_" . $a_top_skill_id);
         $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
         //			$act_list->addItem($lng->txt('skmg_assign_materials'), "",
         //				$ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials"));
         $act_list->addItem($lng->txt('skmg_remove_skill'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "confirmSkillRemove"));
         $tpl->setVariable("ACTIONS1", $act_list->getHTML());
     }
     return $tpl->get();
 }