ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilPCSkills.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
6 require_once("./Services/COPage/classes/class.ilPageContent.php");
7 
19 {
20  var $dom;
21 
25  function init()
26  {
27  $this->setType("skills");
28  }
29 
33  function setNode($a_node)
34  {
35  parent::setNode($a_node); // this is the PageContent node
36  $this->skill_node = $a_node->first_child(); // this is the skill node
37  }
38 
45  function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
46  {
47  $this->node = $this->createPageContentNode();
48  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
49  $this->skill_node = $this->dom->create_element("Skills");
50  $this->skill_node = $this->node->append_child($this->skill_node);
51  }
52 
58  function setData($a_skill_id)
59  {
60  global $ilUser;
61 
62  $this->skill_node->set_attribute("Id", $a_skill_id);
63  $this->skill_node->set_attribute("User", $ilUser->getId());
64  }
65 
71  function getSkillId()
72  {
73  if (is_object($this->skill_node))
74  {
75  return $this->skill_node->get_attribute("Id");
76  }
77  }
78 
87  static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
88  {
89  // pc skill
90  self::saveSkillUsage($a_page, $a_domdoc);
91  }
92 
98  static function beforePageDelete($a_page)
99  {
100  require_once('Services/COPage/classes/class.ilPageContentUsage.php'); // Mantis #18636
101  ilPageContentUsage::deleteAllUsages("skmg", $a_page->getParentType().":pg", $a_page->getId(), false,
102  $a_page->getLanguage());
103  }
104 
113  static function afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
114  {
115  self::saveSkillUsage($a_page, $a_old_domdoc, $a_old_nr);
116  }
117 
121  static function saveSkillUsage($a_page, $a_domdoc, $a_old_nr = 0)
122  {
123  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
124  $skl_ids = self::collectSkills($a_page, $a_domdoc);
125  ilPageContentUsage::deleteAllUsages("skmg", $a_page->getParentType().":pg", $a_page->getId(), $a_old_nr,
126  $a_page->getLanguage());
127  foreach($skl_ids as $skl_id)
128  {
129  if ((int) $skl_id["inst_id"] <= 0)
130  {
131  ilPageContentUsage::saveUsage("skmg", $skl_id["id"], $a_page->getParentType().":pg", $a_page->getId(), $a_old_nr,
132  $a_page->getLanguage());
133  }
134  }
135  }
136 
140  static function collectSkills($a_page, $a_domdoc)
141  {
142  $xpath = new DOMXPath($a_domdoc);
143  $nodes = $xpath->query('//Skills');
144 
145  $skl_ids = array();
146  foreach($nodes as $node)
147  {
148  $user = $node->getAttribute("User");
149  $id = $node->getAttribute("Id");
150  $inst_id = $node->getAttribute("InstId");
151  $skl_ids[$user.":".$id.":".$inst_id] = array(
152  "user" => $user, "id" => $id, "inst_id" => $inst_id);
153  }
154 
155  return $skl_ids;
156  }
157 
158 
159 }
160 ?>
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create skill node in xml.
static afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
After page has been updated (or created)
static afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
After page history entry has been created.
static collectSkills($a_page, $a_domdoc)
get all content includes that are used within the page
setType($a_type)
Set Type.
Class ilPageContent.
static beforePageDelete($a_page)
Before page is being deleted.
Class ilPCSkills.
static saveSkillUsage($a_page, $a_domdoc, $a_old_nr=0)
save content include usages
$ilUser
Definition: imgupload.php:18
const IL_INSERT_AFTER
Create styles array
The data for the language used.
static deleteAllUsages($a_pc_type, $a_usage_type, $a_usage_id, $a_usage_hist_nr=0, $a_lang="-")
Delete all usages.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
setData($a_skill_id)
Set skill settings.
init()
Init page content component.
static saveUsage($a_pc_type, $a_pc_id, $a_usage_type, $a_usage_id, $a_usage_hist_nr=0, $a_lang="-")
Save usages.
setNode($a_node)
Set node.
getSkillId()
Get skill mode.