ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilPCResources.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once("./Services/COPage/classes/class.ilPageContent.php");
5
18{
19 var $dom;
21
25 function init()
26 {
27 $this->setType("repobj");
28 }
29
33 function setNode(&$a_node)
34 {
35 parent::setNode($a_node); // this is the PageContent node
36 $this->res_node =& $a_node->first_child(); // this is the Resources 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->res_node =& $this->dom->create_element("Resources");
50 $this->res_node =& $this->node->append_child($this->res_node);
51 }
52
58 function setResourceListType($a_type)
59 {
60 if (!empty($a_type))
61 {
62 $children = $this->res_node->child_nodes();
63 for ($i=0; $i<count($children); $i++)
64 {
65 $this->res_node->remove_child($children[$i]);
66 }
67 $list_node =& $this->dom->create_element("ResourceList");
68 $list_node =& $this->res_node->append_child($list_node);
69 $list_node->set_attribute("Type", $a_type);
70 }
71 }
72
78 function setItemGroupRefId($a_ref_id)
79 {
80 if (!empty($a_ref_id))
81 {
82 $children = $this->res_node->child_nodes();
83 for ($i=0; $i<count($children); $i++)
84 {
85 $this->res_node->remove_child($children[$i]);
86 }
87 $list_node =& $this->dom->create_element("ItemGroup");
88 $list_node =& $this->res_node->append_child($list_node);
89 $list_node->set_attribute("RefId", $a_ref_id);
90 }
91 }
92
99 {
100 if (is_object($this->res_node))
101 {
102 $children = $this->res_node->child_nodes();
103 if (is_object($children[0]) && $children[0]->node_name() == "ResourceList")
104 {
105 return $children[0]->get_attribute("Type");
106 }
107 }
108 return false;
109 }
110
117 {
118 if (is_object($this->res_node))
119 {
120 $children = $this->res_node->child_nodes();
121 if (is_object($children[0]) && $children[0]->node_name() == "ItemGroup")
122 {
123 return (int) $children[0]->get_attribute("RefId");
124 }
125 }
126 return false;
127 }
128
134 function getMainType()
135 {
136 if (is_object($this->res_node))
137 {
138 $children = $this->res_node->child_nodes();
139 if (is_object($children[0]))
140 {
141 return $children[0]->node_name();
142 }
143 }
144 return false;
145 }
146
153 static function modifyItemGroupRefIdsByMapping($a_page, $mappings)
154 {
155 $dom = $a_page->getDom();
156
157 if ($dom instanceof php4DOMDocument)
158 {
159 $dom = $dom->myDOMDocument;
160 }
161
162 $xpath_temp = new DOMXPath($dom);
163 $igs = $xpath_temp->query("//Resources/ItemGroup");
164
165 foreach ($igs as $ig_node)
166 {
167 $ref_id = $ig_node->getAttribute("RefId");
168 if ($mappings[$ref_id] > 0)
169 {
170 $ig_node->setAttribute("RefId", $mappings[$ref_id]);
171 }
172 }
173
174 }
175
180 static function getLangVars()
181 {
182 return array("pc_res");
183 }
184
185
186}
187
188?>
const IL_INSERT_AFTER
Class ilPCResources.
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create resources node in xml.
setResourceListType($a_type)
Set Type of Resource List (currently only one)
getResourceListType()
Get Resource Lis Type.
static modifyItemGroupRefIdsByMapping($a_page, $mappings)
Modify ref ids by mapping.
getMainType()
Get main type.
init()
Init page content component.
getItemGroupRefId()
Get item group ref id.
setNode(&$a_node)
Set node.
static getLangVars()
Get lang vars needed for editing.
setItemGroupRefId($a_ref_id)
Set Item Group Ref Id.
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.
$ref_id
Definition: sahs_server.php:39