ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  public $hier_id; // hierarchical editing id
21  public $node; // node in page xml
22  public $dom; // dom object
23  public $page_lang;
24 
29 
33  protected $fullscreen_link;
34 
39 
43  protected $log;
44 
51  final public 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  die("Error: ilPageContent::init() did not set type");
59  }
60  }
61 
67  public function setPage($a_val)
68  {
69  $this->pg_obj = $a_val;
70  }
71 
77  public function getPage()
78  {
79  return $this->pg_obj;
80  }
81 
86  abstract public function init();
87 
93  final protected function setType($a_type)
94  {
95  $this->type = $a_type;
96  }
97 
103  public function getType()
104  {
105  return $this->type;
106  }
107 
113  public function setNode($a_node)
114  {
115  $this->node = $a_node;
116  }
117 
118 
124  public function &getNode()
125  {
126  return $this->node;
127  }
128 
132  public function getJavascriptFiles($a_mode)
133  {
134  return array();
135  }
136 
140  public function getCssFiles($a_mode)
141  {
142  return array();
143  }
144 
148  public function getOnloadCode($a_mode)
149  {
150  return array();
151  }
152 
158  public function setHierId($a_hier_id)
159  {
160  $this->hier_id = $a_hier_id;
161  }
162 
166  public function getHierId()
167  {
168  return $this->hier_id;
169  }
170 
171 
175  public function lookupHierId()
176  {
177  return $this->node->get_attribute("HierId");
178  }
179 
185  public function readHierId()
186  {
187  if (is_object($this->node)) {
188  return $this->node->get_attribute("HierId");
189  }
190  }
191 
197  public function setPcId($a_pcid)
198  {
199  $this->pcid = $a_pcid;
200  }
201 
207  public function getPCId()
208  {
209  return $this->pcid;
210  }
211 
217  public function setFileDownloadLink($a_download_link)
218  {
219  $this->file_download_link = $a_download_link;
220  }
221 
227  public function getFileDownloadLink()
228  {
230  }
231 
237  public function setFullscreenLink($a_fullscreen_link)
238  {
239  $this->fullscreen_link = $a_fullscreen_link;
240  }
241 
247  public function getFullscreenLink()
248  {
249  return $this->fullscreen_link;
250  }
251 
257  public function setSourcecodeDownloadScript($script_name)
258  {
259  $this->sourcecode_download_script = $script_name;
260  }
261 
267  public function getSourcecodeDownloadScript()
268  {
270  }
271 
272 
278  public function readPCId()
279  {
280  if (is_object($this->node)) {
281  return $this->node->get_attribute("PCID");
282  }
283  }
284 
288  public function writePCId($a_pc_id)
289  {
290  if (is_object($this->node)) {
291  $this->node->set_attribute("PCID", $a_pc_id);
292  }
293  }
294 
302  final public static function incEdId($ed_id)
303  {
304  $id = explode("_", $ed_id);
305  $id[count($id) - 1]++;
306 
307  return implode($id, "_");
308  }
309 
317  final public static function decEdId($ed_id)
318  {
319  $id = explode("_", $ed_id);
320  $id[count($id) - 1]--;
321 
322  return implode($id, "_");
323  }
324 
333  final public static function haveSameContainer($ed_id1, $ed_id2)
334  {
335  $id1 = explode("_", $ed_id1);
336  $id2 = explode("_", $ed_id1);
337  if (count($id1) == count($id2)) {
338  array_pop($id1);
339  array_pop($id2);
340  foreach ($id1 as $key => $id) {
341  if ($id != $id2[$key]) {
342  return false;
343  }
344  }
345  return true;
346  }
347  return false;
348  }
349 
353  public static function sortHierIds($a_array)
354  {
355  uasort($a_array, array("ilPageContent", "isGreaterHierId"));
356 
357  return $a_array;
358  }
359 
363  public static function isGreaterHierId($a, $b)
364  {
365  $a_arr = explode("_", $a);
366  $b_arr = explode("_", $b);
367  for ($i = 0; $i < count($a_arr); $i++) {
368  if ((int) $a_arr[$i] > (int) $b_arr[$i]) {
369  return true;
370  } elseif ((int) $a_arr[$i] < (int) $b_arr[$i]) {
371  return false;
372  }
373  }
374  return false;
375  }
376 
383  public function setEnabled($value)
384  {
385  if (is_object($this->node)) {
386  $this->node->set_attribute("Enabled", $value);
387  }
388  }
389 
393  public function enable()
394  {
395  $this->setEnabled("True");
396  }
397 
401  public function disable()
402  {
403  $this->setEnabled("False");
404  }
405 
411  final public function isEnabled()
412  {
413  if (is_object($this->node) && $this->node->has_attribute("Enabled")) {
414  $compare = $this->node->get_attribute("Enabled");
415  } else {
416  $compare = "True";
417  }
418 
419  return strcasecmp($compare, "true") == 0;
420  }
421 
425  public function createPageContentNode($a_set_this_node = true)
426  {
427  $node = $this->dom->create_element("PageContent");
428  if ($a_set_this_node) {
429  $this->node = $node;
430  }
431  return $node;
432  }
433 
438  public static function getLangVars()
439  {
440  return array();
441  }
442 
449  public static function handleCopiedContent(DOMDocument $a_domdoc, $a_self_ass = true, $a_clone_mobs = false)
450  {
451  }
452 
459  public function modifyPageContentPostXsl($a_output, $a_mode)
460  {
461  return $a_output;
462  }
463 
472  public static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
473  {
474  }
475 
481  public static function beforePageDelete($a_page)
482  {
483  }
484 
493  public static function afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
494  {
495  }
496 }
setPcId($a_pcid)
Set PC Id.
getSourcecodeDownloadScript()
Get sourcecode download script.
setNode($a_node)
Set xml node of page content.
static incEdId($ed_id)
Increases an hierarchical editing id at lowest level (last number)
init()
Init object.
lookupHierId()
Get hierarchical id from dom.
getOnloadCode($a_mode)
Get on load code.
disable()
Disable page content.
getType()
Get type of page content.
$type
static sortHierIds($a_array)
Sort an array of Hier IDS in ascending order.
getPCId()
Get PC Id.
& getNode()
Get xml node of page content.
setEnabled($value)
Set Enabled value for page content component.
static getLangVars()
Get lang vars needed for editing.
if(!array_key_exists('StateId', $_REQUEST)) $id
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.
setFullscreenLink($a_fullscreen_link)
Set fullscreen link.
__construct($a_pg_obj)
Constructor.
Class ilPageContent.
enable()
Enable 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)
$a_type
Definition: workflow.php:92
isEnabled()
Check whether page content is enabled.
readPCId()
Read PC Id.
getJavascriptFiles($a_mode)
Get Javascript files.
setSourcecodeDownloadScript($script_name)
Set sourcecode download script.
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.
getFullscreenLink()
Get fullscreen link.
getHierId()
Get hierarchical id.
setFileDownloadLink($a_download_link)
Set file download link.
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)
$i
Definition: disco.tpl.php:19
getCssFiles($a_mode)
Get css files.
static getLogger($a_component_id)
Get component logger.
getFileDownloadLink()
Get file download link.
static isGreaterHierId($a, $b)
Check whether Hier ID $a is greater than Hier ID $b.
$key
Definition: croninfo.php:18
readHierId()
Read PC Id.
setHierId($a_hier_id)
Set hierarchical ID in xml structure.