ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPageContent.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 
37 abstract class ilPageContent
38 {
39  //var $type; // type
40  var $hier_id; // hierarchical editing id
41  var $node; // node in page xml
42  var $dom; // dom object
43 
50  final function __construct($a_dom)
51  {
52  $this->dom = $a_dom;
53  $this->init();
54  if ($this->getType() == "")
55  {
56  die ("Error: ilPageContent::init() did not set type");
57  }
58  }
59 
64  abstract function init();
65 
71  final protected function setType($a_type)
72  {
73  $this->type = $a_type;
74  }
75 
81  function getType()
82  {
83  return $this->type;
84  }
85 
91  function setNode(&$a_node)
92  {
93  $this->node =& $a_node;
94  }
95 
96 
102  function &getNode()
103  {
104  return $this->node;
105  }
106 
107 
113  function setHierId($a_hier_id)
114  {
115  $this->hier_id = $a_hier_id;
116  }
117 
121  function getHierId()
122  {
123  return $this->hier_id;
124  }
125 
131  function readHierId()
132  {
133  if (is_object($this->node))
134  {
135  return $this->node->get_attribute("HierId");
136  }
137  }
138 
144  function setPcId($a_pcid)
145  {
146  $this->pcid = $a_pcid;
147  }
148 
154  function getPCId()
155  {
156  return $this->pcid;
157  }
158 
159 
165  function readPCId()
166  {
167  if (is_object($this->node))
168  {
169  return $this->node->get_attribute("PCID");
170  }
171  }
172 
180  final static function incEdId($ed_id)
181  {
182  $id = explode("_", $ed_id);
183  $id[count($id) - 1]++;
184 
185  return implode($id, "_");
186  }
187 
195  final static function decEdId($ed_id)
196  {
197  $id = explode("_", $ed_id);
198  $id[count($id) - 1]--;
199 
200  return implode($id, "_");
201  }
202 
211  final static function haveSameContainer($ed_id1, $ed_id2)
212  {
213  $id1 = explode("_", $ed_id1);
214  $id2 = explode("_", $ed_id1);
215  if(count($id1) == count($id2))
216  {
217  array_pop($id1);
218  array_pop($id2);
219  foreach ($id1 as $key => $id)
220  {
221  if($id != $id2[$key])
222  {
223  return false;
224  }
225  }
226  return true;
227  }
228  return false;
229  }
230 
237  function setEnabled($value)
238  {
239  if (is_object($this->node))
240  {
241  $this->node->set_attribute("Enabled", $value);
242  }
243  }
244 
248  function enable()
249  {
250  $this->setEnabled("True");
251  }
252 
256  function disable()
257  {
258  $this->setEnabled("False");
259  }
260 
266  final function isEnabled()
267  {
268  if (is_object($this->node) && $this->node->has_attribute("Enabled"))
269  {
270  $compare = $this->node->get_attribute("Enabled");
271  }
272  else
273  {
274  $compare = "True";
275  }
276 
277  return strcasecmp($compare,"true") == 0;
278  }
279 
283  function createPageContentNode($a_set_this_node = true)
284  {
285  $node = $this->dom->create_element("PageContent");
286  if ($a_set_this_node)
287  {
288  $this->node = $node;
289  }
290  return $node;
291  }
292 }
293 ?>