ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPageContent.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
17 abstract class ilPageContent
18 {
19  //var $type; // type
20  var $hier_id; // hierarchical editing id
21  var $node; // node in page xml
22  var $dom; // dom object
23 
30  final function __construct($a_pg_obj)
31  {
32  $this->setPage($a_pg_obj);
33  $this->dom = $a_pg_obj->getDom();
34  $this->init();
35  if ($this->getType() == "")
36  {
37  die ("Error: ilPageContent::init() did not set type");
38  }
39  }
40 
46  function setPage($a_val)
47  {
48  $this->pg_obj = $a_val;
49  }
50 
56  function getPage()
57  {
58  return $this->pg_obj;
59  }
60 
65  abstract function init();
66 
72  final protected function setType($a_type)
73  {
74  $this->type = $a_type;
75  }
76 
82  function getType()
83  {
84  return $this->type;
85  }
86 
92  function setNode(&$a_node)
93  {
94  $this->node =& $a_node;
95  }
96 
97 
103  function &getNode()
104  {
105  return $this->node;
106  }
107 
112  {
113  return array();
114  }
115 
119  function getCssFiles()
120  {
121  return array();
122  }
123 
129  function setHierId($a_hier_id)
130  {
131  $this->hier_id = $a_hier_id;
132  }
133 
137  function getHierId()
138  {
139  return $this->hier_id;
140  }
141 
142 
146  function lookupHierId()
147  {
148  return $this->node->get_attribute("HierId");
149  }
150 
156  function readHierId()
157  {
158  if (is_object($this->node))
159  {
160  return $this->node->get_attribute("HierId");
161  }
162  }
163 
169  function setPcId($a_pcid)
170  {
171  $this->pcid = $a_pcid;
172  }
173 
179  function getPCId()
180  {
181  return $this->pcid;
182  }
183 
184 
190  function readPCId()
191  {
192  if (is_object($this->node))
193  {
194  return $this->node->get_attribute("PCID");
195  }
196  }
197 
201  function writePCId($a_pc_id)
202  {
203  if (is_object($this->node))
204  {
205  $this->node->set_attribute("PCID", $a_pc_id);
206  }
207  }
208 
216  final static function incEdId($ed_id)
217  {
218  $id = explode("_", $ed_id);
219  $id[count($id) - 1]++;
220 
221  return implode($id, "_");
222  }
223 
231  final static function decEdId($ed_id)
232  {
233  $id = explode("_", $ed_id);
234  $id[count($id) - 1]--;
235 
236  return implode($id, "_");
237  }
238 
247  final static function haveSameContainer($ed_id1, $ed_id2)
248  {
249  $id1 = explode("_", $ed_id1);
250  $id2 = explode("_", $ed_id1);
251  if(count($id1) == count($id2))
252  {
253  array_pop($id1);
254  array_pop($id2);
255  foreach ($id1 as $key => $id)
256  {
257  if($id != $id2[$key])
258  {
259  return false;
260  }
261  }
262  return true;
263  }
264  return false;
265  }
266 
270  static function sortHierIds($a_array)
271  {
272  uasort($a_array, array("ilPageContent", "isGreaterHierId"));
273 
274  return $a_array;
275  }
276 
280  function isGreaterHierId($a, $b)
281  {
282  $a_arr = explode("_", $a);
283  $b_arr = explode("_", $b);
284  for ($i = 0; $i < count($a_arr); $i++)
285  {
286  if ((int) $a_arr[$i] > (int) $b_arr[$i])
287  {
288  return true;
289  }
290  else if ((int) $a_arr[$i] < (int) $b_arr[$i])
291  {
292  return false;
293  }
294  }
295  return false;
296  }
297 
304  function setEnabled($value)
305  {
306  if (is_object($this->node))
307  {
308  $this->node->set_attribute("Enabled", $value);
309  }
310  }
311 
315  function enable()
316  {
317  $this->setEnabled("True");
318  }
319 
323  function disable()
324  {
325  $this->setEnabled("False");
326  }
327 
333  final function isEnabled()
334  {
335  if (is_object($this->node) && $this->node->has_attribute("Enabled"))
336  {
337  $compare = $this->node->get_attribute("Enabled");
338  }
339  else
340  {
341  $compare = "True";
342  }
343 
344  return strcasecmp($compare,"true") == 0;
345  }
346 
350  function createPageContentNode($a_set_this_node = true)
351  {
352  $node = $this->dom->create_element("PageContent");
353  if ($a_set_this_node)
354  {
355  $this->node = $node;
356  }
357  return $node;
358  }
359 
364  static function getLangVars()
365  {
366  return array();
367  }
368 
375  static function handleCopiedContent(DOMDocument $a_domdoc, $a_self_ass = true, $a_clone_mobs = false)
376  {
377  }
378 
385  function modifyPageContentPostXsl($a_output, $a_mode)
386  {
387  return $a_output;
388  }
389 
398  static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
399  {
400  }
401 
407  static function beforePageDelete($a_page)
408  {
409  }
410 
419  static function afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
420  {
421  }
422 
423 }
424 ?>
setPcId($a_pcid)
Set PC Id.
static incEdId($ed_id)
Increases an hierarchical editing id at lowest level (last number)
getCssFiles()
Get css files.
init()
Init object.
lookupHierId()
Get hierarchical id from dom.
getJavascriptFiles()
Get Javascript files.
disable()
Disable page content.
getType()
Get type of page content.
static sortHierIds($a_array)
Sort an array of Hier IDS in ascending order.
getPCId()
Get PC Id.
isGreaterHierId($a, $b)
Check whether Hier ID $a is greater than Hier ID $b.
& getNode()
Get xml node of page content.
setEnabled($value)
Set Enabled value for page content component.
static getLangVars()
Get lang vars needed for editing.
static beforePageDelete($a_page)
Before page is being deleted.
setType($a_type)
Set Type.
modifyPageContentPostXsl($a_output, $a_mode)
Modify page content after xsl.
setPage($a_val)
Set page.
static haveSameContainer($ed_id1, $ed_id2)
Check, if two ids are in same container.
__construct($a_pg_obj)
Constructor.
Class ilPageContent.
enable()
Enable page content.
setNode(&$a_node)
Set xml node of page content.
static handleCopiedContent(DOMDocument $a_domdoc, $a_self_ass=true, $a_clone_mobs=false)
Handle copied content.
static afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
After page has been updated (or created)
isEnabled()
Check whether page content is enabled.
readPCId()
Read PC Id.
static afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
After page history entry has been created.
writePCId($a_pc_id)
Write pc id.
getHierId()
Get hierarchical id.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
static decEdId($ed_id)
Decreases an hierarchical editing id at lowest level (last number)
readHierId()
Read PC Id.
setHierId($a_hier_id)
Set hierarchical ID in xml structure.