ILIAS  release_7 Revision v7.30-3-g800a261c036
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  protected $profile_back_url;
21  public $hier_id; // hierarchical editing id
22  public $node; // node in page xml
23  public $dom; // dom object
24  public $page_lang;
25 
30 
34  protected $fullscreen_link;
35 
40 
44  protected $log;
45 
52  final public function __construct($a_pg_obj)
53  {
54  $this->log = ilLoggerFactory::getLogger('copg');
55  $this->setPage($a_pg_obj);
56  $this->dom = $a_pg_obj->getDom();
57  $this->init();
58  if ($this->getType() == "") {
59  die("Error: ilPageContent::init() did not set type");
60  }
61  }
62 
68  public function setPage($a_val)
69  {
70  $this->pg_obj = $a_val;
71  }
72 
78  public function getPage()
79  {
80  return $this->pg_obj;
81  }
82 
87  abstract public function init();
88 
94  final protected function setType($a_type)
95  {
96  $this->type = $a_type;
97  }
98 
104  public function getType()
105  {
106  return $this->type;
107  }
108 
114  public function setNode($a_node)
115  {
116  $this->node = $a_node;
117  }
118 
119 
125  public function &getNode()
126  {
127  return $this->node;
128  }
129 
133  public function getJavascriptFiles($a_mode)
134  {
135  return array();
136  }
137 
141  public function getCssFiles($a_mode)
142  {
143  return [];
144  }
145 
149  public function getOnloadCode($a_mode)
150  {
151  return array();
152  }
153 
159  public function setHierId($a_hier_id)
160  {
161  $this->hier_id = $a_hier_id;
162  }
163 
167  public function getHierId()
168  {
169  return $this->hier_id;
170  }
171 
172 
176  public function lookupHierId()
177  {
178  return $this->node->get_attribute("HierId");
179  }
180 
186  public function readHierId()
187  {
188  if (is_object($this->node)) {
189  return $this->node->get_attribute("HierId");
190  }
191  }
192 
198  public function setPcId($a_pcid)
199  {
200  $this->pcid = $a_pcid;
201  }
202 
208  public function getPCId()
209  {
210  return $this->pcid;
211  }
212 
218  public function setFileDownloadLink($a_download_link)
219  {
220  $this->file_download_link = $a_download_link;
221  }
222 
228  public function getFileDownloadLink()
229  {
231  }
232 
233  public function setProfileBackUrl($url)
234  {
235  $this->profile_back_url = $url;
236  }
237 
238  public function getProfileBackUrl()
239  {
241  }
242 
248  public function setFullscreenLink($a_fullscreen_link)
249  {
250  $this->fullscreen_link = $a_fullscreen_link;
251  }
252 
258  public function getFullscreenLink()
259  {
260  return $this->fullscreen_link;
261  }
262 
268  public function setSourcecodeDownloadScript($script_name)
269  {
270  $this->sourcecode_download_script = $script_name;
271  }
272 
278  public function getSourcecodeDownloadScript()
279  {
281  }
282 
283 
289  public function readPCId()
290  {
291  if (is_object($this->node)) {
292  return $this->node->get_attribute("PCID");
293  }
294  }
295 
299  public function writePCId($a_pc_id)
300  {
301  if (is_object($this->node)) {
302  $this->node->set_attribute("PCID", $a_pc_id);
303  }
304  }
305 
313  final public static function incEdId($ed_id)
314  {
315  $id = explode("_", $ed_id);
316  $id[count($id) - 1]++;
317 
318  return implode("_", $id);
319  }
320 
328  final public static function decEdId($ed_id)
329  {
330  $id = explode("_", $ed_id);
331  $id[count($id) - 1]--;
332 
333  return implode("_", $id);
334  }
335 
344  final public static function haveSameContainer($ed_id1, $ed_id2)
345  {
346  $id1 = explode("_", $ed_id1);
347  $id2 = explode("_", $ed_id1);
348  if (count($id1) == count($id2)) {
349  array_pop($id1);
350  array_pop($id2);
351  foreach ($id1 as $key => $id) {
352  if ($id != $id2[$key]) {
353  return false;
354  }
355  }
356  return true;
357  }
358  return false;
359  }
360 
364  public static function sortHierIds($a_array)
365  {
366  uasort($a_array, array("ilPageContent", "isGreaterHierId"));
367 
368  return $a_array;
369  }
370 
374  public static function isGreaterHierId($a, $b)
375  {
376  $a_arr = explode("_", $a);
377  $b_arr = explode("_", $b);
378  for ($i = 0; $i < count($a_arr); $i++) {
379  if ((int) $a_arr[$i] > (int) $b_arr[$i]) {
380  return true;
381  } elseif ((int) $a_arr[$i] < (int) $b_arr[$i]) {
382  return false;
383  }
384  }
385  return false;
386  }
387 
394  public function setEnabled($value)
395  {
396  if (is_object($this->node)) {
397  $this->node->set_attribute("Enabled", $value);
398  }
399  }
400 
404  public function enable()
405  {
406  $this->setEnabled("True");
407  }
408 
412  public function disable()
413  {
414  $this->setEnabled("False");
415  }
416 
422  final public function isEnabled()
423  {
424  if (is_object($this->node) && $this->node->has_attribute("Enabled")) {
425  $compare = $this->node->get_attribute("Enabled");
426  } else {
427  $compare = "True";
428  }
429 
430  return strcasecmp($compare, "true") == 0;
431  }
432 
436  public function createPageContentNode($a_set_this_node = true)
437  {
438  $node = $this->dom->create_element("PageContent");
439  if ($a_set_this_node) {
440  $this->node = $node;
441  }
442  return $node;
443  }
444 
449  public static function getLangVars()
450  {
451  return array();
452  }
453 
460  public static function handleCopiedContent(DOMDocument $a_domdoc, $a_self_ass = true, $a_clone_mobs = false)
461  {
462  }
463 
472  public function modifyPageContentPostXsl($a_output, $a_mode, $a_abstract_only = false)
473  {
474  return $a_output;
475  }
476 
485  public static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
486  {
487  }
488 
494  public static function beforePageDelete($a_page)
495  {
496  }
497 
506  public static function afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
507  {
508  }
509 
514  public function getModel()
515  {
516  return null;
517  }
518 }
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.
getModel()
Get model.
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.
static beforePageDelete($a_page)
Before page is being deleted.
setType($a_type)
Set Type.
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)
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.
modifyPageContentPostXsl($a_output, $a_mode, $a_abstract_only=false)
Modify page content after xsl.
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)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
getCssFiles($a_mode)
Get css files.
static getLogger($a_component_id)
Get component logger.
$url
getFileDownloadLink()
Get file download link.
static isGreaterHierId($a, $b)
Check whether Hier ID $a is greater than Hier ID $b.
readHierId()
Read PC Id.
$i
Definition: metadata.php:24
setHierId($a_hier_id)
Set hierarchical ID in xml structure.