ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
17abstract 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
127 function getOnloadCode()
128 {
129 return array();
130 }
131
137 function setHierId($a_hier_id)
138 {
139 $this->hier_id = $a_hier_id;
140 }
141
145 function getHierId()
146 {
147 return $this->hier_id;
148 }
149
150
154 function lookupHierId()
155 {
156 return $this->node->get_attribute("HierId");
157 }
158
164 function readHierId()
165 {
166 if (is_object($this->node))
167 {
168 return $this->node->get_attribute("HierId");
169 }
170 }
171
177 function setPcId($a_pcid)
178 {
179 $this->pcid = $a_pcid;
180 }
181
187 function getPCId()
188 {
189 return $this->pcid;
190 }
191
192
198 function readPCId()
199 {
200 if (is_object($this->node))
201 {
202 return $this->node->get_attribute("PCID");
203 }
204 }
205
209 function writePCId($a_pc_id)
210 {
211 if (is_object($this->node))
212 {
213 $this->node->set_attribute("PCID", $a_pc_id);
214 }
215 }
216
224 final static function incEdId($ed_id)
225 {
226 $id = explode("_", $ed_id);
227 $id[count($id) - 1]++;
228
229 return implode($id, "_");
230 }
231
239 final static function decEdId($ed_id)
240 {
241 $id = explode("_", $ed_id);
242 $id[count($id) - 1]--;
243
244 return implode($id, "_");
245 }
246
255 final static function haveSameContainer($ed_id1, $ed_id2)
256 {
257 $id1 = explode("_", $ed_id1);
258 $id2 = explode("_", $ed_id1);
259 if(count($id1) == count($id2))
260 {
261 array_pop($id1);
262 array_pop($id2);
263 foreach ($id1 as $key => $id)
264 {
265 if($id != $id2[$key])
266 {
267 return false;
268 }
269 }
270 return true;
271 }
272 return false;
273 }
274
278 static function sortHierIds($a_array)
279 {
280 uasort($a_array, array("ilPageContent", "isGreaterHierId"));
281
282 return $a_array;
283 }
284
288 function isGreaterHierId($a, $b)
289 {
290 $a_arr = explode("_", $a);
291 $b_arr = explode("_", $b);
292 for ($i = 0; $i < count($a_arr); $i++)
293 {
294 if ((int) $a_arr[$i] > (int) $b_arr[$i])
295 {
296 return true;
297 }
298 else if ((int) $a_arr[$i] < (int) $b_arr[$i])
299 {
300 return false;
301 }
302 }
303 return false;
304 }
305
312 function setEnabled($value)
313 {
314 if (is_object($this->node))
315 {
316 $this->node->set_attribute("Enabled", $value);
317 }
318 }
319
323 function enable()
324 {
325 $this->setEnabled("True");
326 }
327
331 function disable()
332 {
333 $this->setEnabled("False");
334 }
335
341 final function isEnabled()
342 {
343 if (is_object($this->node) && $this->node->has_attribute("Enabled"))
344 {
345 $compare = $this->node->get_attribute("Enabled");
346 }
347 else
348 {
349 $compare = "True";
350 }
351
352 return strcasecmp($compare,"true") == 0;
353 }
354
358 function createPageContentNode($a_set_this_node = true)
359 {
360 $node = $this->dom->create_element("PageContent");
361 if ($a_set_this_node)
362 {
363 $this->node = $node;
364 }
365 return $node;
366 }
367
372 static function getLangVars()
373 {
374 return array();
375 }
376
383 static function handleCopiedContent(DOMDocument $a_domdoc, $a_self_ass = true, $a_clone_mobs = false)
384 {
385 }
386
393 function modifyPageContentPostXsl($a_output, $a_mode)
394 {
395 return $a_output;
396 }
397
406 static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
407 {
408 }
409
415 static function beforePageDelete($a_page)
416 {
417 }
418
427 static function afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
428 {
429 }
430
431}
432?>
Class ilPageContent.
writePCId($a_pc_id)
Write pc id.
setEnabled($value)
Set Enabled value for page content component.
getCssFiles()
Get css files.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
static beforePageDelete($a_page)
Before page is being deleted.
__construct($a_pg_obj)
Constructor.
static decEdId($ed_id)
Decreases an hierarchical editing id at lowest level (last number)
getHierId()
Get hierarchical id.
modifyPageContentPostXsl($a_output, $a_mode)
Modify page content after xsl.
init()
Init object.
static handleCopiedContent(DOMDocument $a_domdoc, $a_self_ass=true, $a_clone_mobs=false)
Handle copied content.
static afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
After page history entry has been created.
getType()
Get type of page content.
setHierId($a_hier_id)
Set hierarchical ID in xml structure.
static haveSameContainer($ed_id1, $ed_id2)
Check, if two ids are in same container.
getJavascriptFiles()
Get Javascript files.
disable()
Disable page content.
readHierId()
Read PC Id.
isGreaterHierId($a, $b)
Check whether Hier ID $a is greater than Hier ID $b.
getOnloadCode()
Get on load code.
static incEdId($ed_id)
Increases an hierarchical editing id at lowest level (last number)
enable()
Enable page content.
setPcId($a_pcid)
Set PC Id.
setPage($a_val)
Set page.
setNode(&$a_node)
Set xml node of page content.
isEnabled()
Check whether page content is enabled.
readPCId()
Read PC Id.
static afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
After page has been updated (or created)
lookupHierId()
Get hierarchical id from dom.
static sortHierIds($a_array)
Sort an array of Hier IDS in ascending order.
& getNode()
Get xml node of page content.
setType($a_type)
Set Type.
static getLangVars()
Get lang vars needed for editing.