ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
24
29
34
39
43 protected $log;
44
51 final function __construct($a_pg_obj)
52 {
53 $this->log = ilLoggerFactory::getLogger('copg');
54 $this->setPage($a_pg_obj);
55 $this->dom = $a_pg_obj->getDom();
56 $this->init();
57 if ($this->getType() == "")
58 {
59 die ("Error: ilPageContent::init() did not set type");
60 }
61 }
62
68 function setPage($a_val)
69 {
70 $this->pg_obj = $a_val;
71 }
72
78 function getPage()
79 {
80 return $this->pg_obj;
81 }
82
87 abstract function init();
88
94 final protected function setType($a_type)
95 {
96 $this->type = $a_type;
97 }
98
104 function getType()
105 {
106 return $this->type;
107 }
108
114 function setNode($a_node)
115 {
116 $this->node = $a_node;
117 }
118
119
125 function &getNode()
126 {
127 return $this->node;
128 }
129
133 function getJavascriptFiles($a_mode)
134 {
135 return array();
136 }
137
141 function getCssFiles($a_mode)
142 {
143 return array();
144 }
145
149 function getOnloadCode($a_mode)
150 {
151 return array();
152 }
153
159 function setHierId($a_hier_id)
160 {
161 $this->hier_id = $a_hier_id;
162 }
163
167 function getHierId()
168 {
169 return $this->hier_id;
170 }
171
172
176 function lookupHierId()
177 {
178 return $this->node->get_attribute("HierId");
179 }
180
186 function readHierId()
187 {
188 if (is_object($this->node))
189 {
190 return $this->node->get_attribute("HierId");
191 }
192 }
193
199 function setPcId($a_pcid)
200 {
201 $this->pcid = $a_pcid;
202 }
203
209 function getPCId()
210 {
211 return $this->pcid;
212 }
213
219 function setFileDownloadLink($a_download_link)
220 {
221 $this->file_download_link = $a_download_link;
222 }
223
230 {
232 }
233
239 function setFullscreenLink($a_fullscreen_link)
240 {
241 $this->fullscreen_link = $a_fullscreen_link;
242 }
243
250 {
252 }
253
259 function setSourcecodeDownloadScript ($script_name)
260 {
261 $this->sourcecode_download_script = $script_name;
262 }
263
270 {
272 }
273
274
280 function readPCId()
281 {
282 if (is_object($this->node))
283 {
284 return $this->node->get_attribute("PCID");
285 }
286 }
287
291 function writePCId($a_pc_id)
292 {
293 if (is_object($this->node))
294 {
295 $this->node->set_attribute("PCID", $a_pc_id);
296 }
297 }
298
306 final static function incEdId($ed_id)
307 {
308 $id = explode("_", $ed_id);
309 $id[count($id) - 1]++;
310
311 return implode($id, "_");
312 }
313
321 final static function decEdId($ed_id)
322 {
323 $id = explode("_", $ed_id);
324 $id[count($id) - 1]--;
325
326 return implode($id, "_");
327 }
328
337 final static function haveSameContainer($ed_id1, $ed_id2)
338 {
339 $id1 = explode("_", $ed_id1);
340 $id2 = explode("_", $ed_id1);
341 if(count($id1) == count($id2))
342 {
343 array_pop($id1);
344 array_pop($id2);
345 foreach ($id1 as $key => $id)
346 {
347 if($id != $id2[$key])
348 {
349 return false;
350 }
351 }
352 return true;
353 }
354 return false;
355 }
356
360 static function sortHierIds($a_array)
361 {
362 uasort($a_array, array("ilPageContent", "isGreaterHierId"));
363
364 return $a_array;
365 }
366
370 static function isGreaterHierId($a, $b)
371 {
372 $a_arr = explode("_", $a);
373 $b_arr = explode("_", $b);
374 for ($i = 0; $i < count($a_arr); $i++)
375 {
376 if ((int) $a_arr[$i] > (int) $b_arr[$i])
377 {
378 return true;
379 }
380 else if ((int) $a_arr[$i] < (int) $b_arr[$i])
381 {
382 return false;
383 }
384 }
385 return false;
386 }
387
394 function setEnabled($value)
395 {
396 if (is_object($this->node))
397 {
398 $this->node->set_attribute("Enabled", $value);
399 }
400 }
401
405 function enable()
406 {
407 $this->setEnabled("True");
408 }
409
413 function disable()
414 {
415 $this->setEnabled("False");
416 }
417
423 final function isEnabled()
424 {
425 if (is_object($this->node) && $this->node->has_attribute("Enabled"))
426 {
427 $compare = $this->node->get_attribute("Enabled");
428 }
429 else
430 {
431 $compare = "True";
432 }
433
434 return strcasecmp($compare,"true") == 0;
435 }
436
440 function createPageContentNode($a_set_this_node = true)
441 {
442 $node = $this->dom->create_element("PageContent");
443 if ($a_set_this_node)
444 {
445 $this->node = $node;
446 }
447 return $node;
448 }
449
454 static function getLangVars()
455 {
456 return array();
457 }
458
465 static function handleCopiedContent(DOMDocument $a_domdoc, $a_self_ass = true, $a_clone_mobs = false)
466 {
467 }
468
475 function modifyPageContentPostXsl($a_output, $a_mode)
476 {
477 return $a_output;
478 }
479
488 static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
489 {
490 }
491
497 static function beforePageDelete($a_page)
498 {
499 }
500
509 static function afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
510 {
511 }
512
513}
514?>
An exception for terminatinating execution or to throw for unit testing.
static getLogger($a_component_id)
Get component logger.
Class ilPageContent.
writePCId($a_pc_id)
Write pc id.
setEnabled($value)
Set Enabled value for page content component.
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.
getFileDownloadLink()
Get file download link.
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 isGreaterHierId($a, $b)
Check whether Hier ID $a is greater than Hier ID $b.
setNode($a_node)
Set xml node of page content.
setFullscreenLink($a_fullscreen_link)
Set fullscreen link.
static afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
After page history entry has been created.
getCssFiles($a_mode)
Get css files.
getType()
Get type of page content.
getFullscreenLink()
Get fullscreen link.
setHierId($a_hier_id)
Set hierarchical ID in xml structure.
static haveSameContainer($ed_id1, $ed_id2)
Check, if two ids are in same container.
setFileDownloadLink($a_download_link)
Set file download link.
disable()
Disable page content.
readHierId()
Read PC Id.
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.
isEnabled()
Check whether page content is enabled.
setSourcecodeDownloadScript($script_name)
Set sourcecode download script.
readPCId()
Read PC Id.
static afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
After page has been updated (or created)
getSourcecodeDownloadScript()
Get sourcecode download script.
lookupHierId()
Get hierarchical id from dom.
static sortHierIds($a_array)
Sort an array of Hier IDS in ascending order.
getJavascriptFiles($a_mode)
Get Javascript files.
& getNode()
Get xml node of page content.
setType($a_type)
Set Type.
static getLangVars()
Get lang vars needed for editing.
getOnloadCode($a_mode)
Get on load code.
$a_type
Definition: workflow.php:93