ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
6require_once("./Services/COPage/classes/class.ilPageContent.php");
7
19{
23 protected $user;
24
25 public $dom;
26
30 public function init()
31 {
32 global $DIC;
33
34 $this->user = $DIC->user();
35 $this->setType("skills");
36 }
37
41 public function setNode($a_node)
42 {
43 parent::setNode($a_node); // this is the PageContent node
44 $this->skill_node = $a_node->first_child(); // this is the skill node
45 }
46
53 public function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
54 {
55 $this->node = $this->createPageContentNode();
56 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
57 $this->skill_node = $this->dom->create_element("Skills");
58 $this->skill_node = $this->node->append_child($this->skill_node);
59 }
60
66 public function setData($a_skill_id)
67 {
69
70 $this->skill_node->set_attribute("Id", $a_skill_id);
71 $this->skill_node->set_attribute("User", $ilUser->getId());
72 }
73
79 public function getSkillId()
80 {
81 if (is_object($this->skill_node)) {
82 return $this->skill_node->get_attribute("Id");
83 }
84 }
85
94 public static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
95 {
96 // pc skill
97 self::saveSkillUsage($a_page, $a_domdoc);
98 }
99
105 public static function beforePageDelete($a_page)
106 {
107 require_once('Services/COPage/classes/class.ilPageContentUsage.php'); // Mantis #18636
109 "skmg",
110 $a_page->getParentType() . ":pg",
111 $a_page->getId(),
112 false,
113 $a_page->getLanguage()
114 );
115 }
116
125 public static function afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
126 {
127 self::saveSkillUsage($a_page, $a_old_domdoc, $a_old_nr);
128 }
129
133 public static function saveSkillUsage($a_page, $a_domdoc, $a_old_nr = 0)
134 {
135 include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
136 $skl_ids = self::collectSkills($a_page, $a_domdoc);
138 "skmg",
139 $a_page->getParentType() . ":pg",
140 $a_page->getId(),
141 $a_old_nr,
142 $a_page->getLanguage()
143 );
144 foreach ($skl_ids as $skl_id) {
145 if ((int) $skl_id["inst_id"] <= 0) {
147 "skmg",
148 $skl_id["id"],
149 $a_page->getParentType() . ":pg",
150 $a_page->getId(),
151 $a_old_nr,
152 $a_page->getLanguage()
153 );
154 }
155 }
156 }
157
161 public static function collectSkills($a_page, $a_domdoc)
162 {
163 $xpath = new DOMXPath($a_domdoc);
164 $nodes = $xpath->query('//Skills');
165
166 $skl_ids = array();
167 foreach ($nodes as $node) {
168 $user = $node->getAttribute("User");
169 $id = $node->getAttribute("Id");
170 $inst_id = $node->getAttribute("InstId");
171 $skl_ids[$user . ":" . $id . ":" . $inst_id] = array(
172 "user" => $user, "id" => $id, "inst_id" => $inst_id);
173 }
174
175 return $skl_ids;
176 }
177}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
const IL_INSERT_AFTER
Class ilPCSkills.
static beforePageDelete($a_page)
Before page is being deleted.
init()
Init page content component.
setData($a_skill_id)
Set skill settings.
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.
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create skill node in xml.
static saveSkillUsage($a_page, $a_domdoc, $a_old_nr=0)
save content include usages
static collectSkills($a_page, $a_domdoc)
get all content includes that are used within the page
getSkillId()
Get skill mode.
setNode($a_node)
Set node.
static saveUsage($a_pc_type, $a_pc_id, $a_usage_type, $a_usage_id, $a_usage_hist_nr=0, $a_lang="-")
Save usages.
static deleteAllUsages($a_pc_type, $a_usage_type, $a_usage_id, $a_usage_hist_nr=0, $a_lang="-")
Delete all usages.
Class ilPageContent.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
setType($a_type)
Set Type.
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46