ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCPlugged.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Services/COPage/classes/class.ilPageContent.php");
25 
36 {
37  var $dom;
39 
43  function init()
44  {
45  $this->setType("plug");
46  }
47 
51  function setNode(&$a_node)
52  {
53  parent::setNode($a_node); // this is the PageContent node
54  $this->plug_node =& $a_node->first_child(); // this is the Plugged node
55  }
56 
63  function create(&$a_pg_obj, $a_hier_id, $a_plugin_name,
64  $a_plugin_version)
65  {
66  $this->node = $this->createPageContentNode();
67  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER);
68  $this->plug_node =& $this->dom->create_element("Plugged");
69  $this->plug_node =& $this->node->append_child($this->plug_node);
70  $this->plug_node->set_attribute("PluginName", $a_plugin_name);
71  $this->plug_node->set_attribute("PluginVersion", $a_plugin_version);
72  }
73 
79  function setProperties($a_properties)
80  {
81  if (!is_object($this->plug_node))
82  {
83  return;
84  }
85 
86  // delete properties
87  $children = $this->plug_node->child_nodes();
88  for($i=0; $i<count($children); $i++)
89  {
90  $this->plug_node->remove_child($children[$i]);
91  }
92 
93  // set properties
94  foreach($a_properties as $key => $value)
95  {
96  $prop_node = $this->dom->create_element("PluggedProperty");
97  $prop_node =& $this->node->append_child($this->plug_node);
98  $prop_node->set_attribute("Name", $key);
99  $prop_node->set_content($value);
100  }
101  }
102 
108  function getProperties()
109  {
110  $properties = array();
111 
112  if (is_object($this->plug_node))
113  {
114  // delete properties
115  $children = $this->plug_node->child_nodes();
116  for($i=0; $i<count($children); $i++)
117  {
118  if ($children[$i]->node_name() == "PluggedProperty")
119  {
120  $properties[$children[$i]->get_attribute("Name")] =
121  $children[$i]->get_content();
122  }
123  }
124  }
125 
126  return $properties;
127  }
128 
134  function setPluginVersion($a_version)
135  {
136  if (!empty($a_version))
137  {
138  $this->plug_node->set_attribute("PluginVersion", $a_version);
139  }
140  else
141  {
142  if ($this->plug_node->has_attribute("PluginVersion"))
143  {
144  $this->plug_node->remove_attribute("PluginVersion");
145  }
146  }
147  }
148 
154  function getPluginVersion()
155  {
156  if (is_object($this->plug_node))
157  {
158  return $this->plug_node->get_attribute("PluginVersion");
159  }
160  }
161 
167  function setPluginName($a_name)
168  {
169  if (!empty($a_name))
170  {
171  $this->plug_node->set_attribute("PluginName", $a_name);
172  }
173  else
174  {
175  if ($this->plug_node->has_attribute("PluginName"))
176  {
177  $this->plug_node->remove_attribute("PluginName");
178  }
179  }
180  }
181 
187  function getPluginName()
188  {
189  if (is_object($this->plug_node))
190  {
191  return $this->plug_node->get_attribute("PluginName");
192  }
193  }
194 
195 }
196 
197 ?>