ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilPCSection Class Reference

Class ilPCSection. More...

+ Inheritance diagram for ilPCSection:
+ Collaboration diagram for ilPCSection:

Public Member Functions

 init ()
 Init page content component. More...
 
 setNode ($a_node)
 Set node. More...
 
 create (&$a_pg_obj, $a_hier_id, $a_pc_id="")
 Create section node in xml. More...
 
 setCharacteristic ($a_char)
 Set Characteristic of section. More...
 
 getCharacteristic ()
 Get characteristic of section. More...
 
 modifyPageContentPostXsl ($a_output, $a_mode)
 Modify page content after xsl. More...
 
 setActiveFrom ($a_unix_ts)
 Set activation from. More...
 
 getActiveFrom ()
 Get activation from. More...
 
 setActiveTo ($a_unix_ts)
 Set activation to. More...
 
 getActiveTo ()
 Get activation to. More...
 
 getAttribute ($a_attr)
 Get attribute. More...
 
 setPermission ($a_val)
 Set permission. More...
 
 getPermission ()
 Get permission. More...
 
 setPermissionRefId ($a_ref_id)
 Set permission ref id. More...
 
 getPermissionRefId ()
 Get permission ref id. More...
 
 setNoLink ()
 Set no link. More...
 
 setExtLink ($a_href)
 Set link of area to an external one. More...
 
 setIntLink ($a_type, $a_target, $a_target_frame)
 Set link of area to an internal one. More...
 
 getLink ()
 Get link. More...
 
 handleAccess ($a_html, $a_mode)
 
 insertTimings ($a_html)
 Insert timings (in edit mode) More...
 
- Public Member Functions inherited from ilPageContent
 __construct ($a_pg_obj)
 Constructor. More...
 
 setPage ($a_val)
 Set page. More...
 
 getPage ()
 Get page. More...
 
 init ()
 Init object. More...
 
 getType ()
 Get type of page content. More...
 
 setNode ($a_node)
 Set xml node of page content. More...
 
getNode ()
 Get xml node of page content. More...
 
 getJavascriptFiles ($a_mode)
 Get Javascript files. More...
 
 getCssFiles ($a_mode)
 Get css files. More...
 
 getOnloadCode ($a_mode)
 Get on load code. More...
 
 setHierId ($a_hier_id)
 Set hierarchical ID in xml structure. More...
 
 getHierId ()
 Get hierarchical id. More...
 
 lookupHierId ()
 Get hierarchical id from dom. More...
 
 readHierId ()
 Read PC Id. More...
 
 setPcId ($a_pcid)
 Set PC Id. More...
 
 getPCId ()
 Get PC Id. More...
 
 setFileDownloadLink ($a_download_link)
 Set file download link. More...
 
 getFileDownloadLink ()
 Get file download link. More...
 
 setFullscreenLink ($a_fullscreen_link)
 Set fullscreen link. More...
 
 getFullscreenLink ()
 Get fullscreen link. More...
 
 setSourcecodeDownloadScript ($script_name)
 Set sourcecode download script. More...
 
 getSourcecodeDownloadScript ()
 Get sourcecode download script. More...
 
 readPCId ()
 Read PC Id. More...
 
 writePCId ($a_pc_id)
 Write pc id. More...
 
 setEnabled ($value)
 Set Enabled value for page content component. More...
 
 enable ()
 Enable page content. More...
 
 disable ()
 Disable page content. More...
 
 isEnabled ()
 Check whether page content is enabled. More...
 
 createPageContentNode ($a_set_this_node=true)
 Create page content node (always use this method first when adding a new element) More...
 
 modifyPageContentPostXsl ($a_output, $a_mode)
 Modify page content after xsl. More...
 

Static Public Member Functions

static getLangVars ()
 Get lang vars needed for editing. More...
 
static afterPageUpdate ($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
 After page has been updated (or created) More...
 
static saveTimings ($a_page)
 Save timings. More...
 
static getCacheTriggerString ($a_page)
 Get page cache update trigger string. More...
 
- Static Public Member Functions inherited from ilPageContent
static incEdId ($ed_id)
 Increases an hierarchical editing id at lowest level (last number) More...
 
static decEdId ($ed_id)
 Decreases an hierarchical editing id at lowest level (last number) More...
 
static haveSameContainer ($ed_id1, $ed_id2)
 Check, if two ids are in same container. More...
 
static sortHierIds ($a_array)
 Sort an array of Hier IDS in ascending order. More...
 
static isGreaterHierId ($a, $b)
 Check whether Hier ID $a is greater than Hier ID $b. More...
 
static getLangVars ()
 Get lang vars needed for editing. More...
 
static handleCopiedContent (DOMDocument $a_domdoc, $a_self_ass=true, $a_clone_mobs=false)
 Handle copied content. More...
 
static afterPageUpdate ($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete ($a_page)
 Before page is being deleted. More...
 
static afterPageHistoryEntry ($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
 After page history entry has been created. More...
 

Data Fields

 $dom
 
 $sec_node
 
- Data Fields inherited from ilPageContent
 $hier_id
 
 $node
 
 $dom
 
 $page_lang
 

Protected Member Functions

 setAttribute ($a_attr, $a_val)
 Set attribute. More...
 
- Protected Member Functions inherited from ilPageContent
 setType ($a_type)
 Set Type. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilPageContent
 $file_download_link
 
 $fullscreen_link
 
 $sourcecode_download_script
 
 $log
 

Detailed Description

Class ilPCSection.

Section content object (see ILIAS DTD)

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 17 of file class.ilPCSection.php.

Member Function Documentation

◆ afterPageUpdate()

static ilPCSection::afterPageUpdate (   $a_page,
DOMDocument  $a_domdoc,
  $a_xml,
  $a_creation 
)
static

After page has been updated (or created)

Parameters
object$a_pagepage object
DOMDocument$a_domdocdom document
string$a_xmlxml
bool$a_creationtrue on creation, otherwise false

Definition at line 109 of file class.ilPCSection.php.

110  {
111  include_once("./Services/COPage/classes/class.ilPCSection.php");
112  self::saveTimings($a_page);
113  }

◆ create()

ilPCSection::create ( $a_pg_obj,
  $a_hier_id,
  $a_pc_id = "" 
)

Create section node in xml.

Parameters
object$a_pg_objPage Object
string$a_hier_idHierarchical ID

Definition at line 45 of file class.ilPCSection.php.

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

46  {
47  $this->node = $this->createPageContentNode();
48  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
49  $this->sec_node = $this->dom->create_element("Section");
50  $this->sec_node = $this->node->append_child($this->sec_node);
51  $this->sec_node->set_attribute("Characteristic", "Block");
52  }
const IL_INSERT_AFTER
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
+ Here is the call graph for this function:

◆ getActiveFrom()

ilPCSection::getActiveFrom ( )

Get activation from.

Returns
string unix ts activation from

Definition at line 154 of file class.ilPCSection.php.

155  {
156  if (is_object($this->sec_node))
157  {
158  return $this->sec_node->get_attribute("ActiveFrom");
159  }
160 
161  return "";
162  }

◆ getActiveTo()

ilPCSection::getActiveTo ( )

Get activation to.

Returns
string unix ts activation to

Definition at line 189 of file class.ilPCSection.php.

190  {
191  if (is_object($this->sec_node))
192  {
193  return $this->sec_node->get_attribute("ActiveTo");
194  }
195 
196  return "";
197  }

◆ getAttribute()

ilPCSection::getAttribute (   $a_attr)

Get attribute.

Parameters
string$a_attrattribute
Returns
string attribute value

Definition at line 226 of file class.ilPCSection.php.

Referenced by getPermission(), and getPermissionRefId().

227  {
228  if (is_object($this->sec_node))
229  {
230  return $this->sec_node->get_attribute($a_attr);
231  }
232  return "";
233  }
+ Here is the caller graph for this function:

◆ getCacheTriggerString()

static ilPCSection::getCacheTriggerString (   $a_page)
static

Get page cache update trigger string.

Parameters
ilPageObject$a_page
Returns
string trigger string

Definition at line 436 of file class.ilPCSection.php.

References $ilDB, IL_CAL_UNIX, and time.

Referenced by ilPageObjectGUI\showPage().

437  {
438  global $ilDB;
439 
440  $set = $ilDB->query("SELECT * FROM copg_section_timings ".
441  " WHERE page_id = ".$ilDB->quote($a_page->getId(), "integer").
442  " AND parent_type = ".$ilDB->quote($a_page->getParentType(), "text")
443  );
444  $str = "";
445  $current_ts = new ilDateTime(time(),IL_CAL_UNIX);
446  $current_ts = $current_ts->get(IL_CAL_UNIX);
447  while ($rec = $ilDB->fetchAssoc($set))
448  {
449  $unix_ts = $rec["unix_ts"];
450  if ($unix_ts < $current_ts)
451  {
452  $unix_ts.= "a";
453  }
454  $str.= "-".$unix_ts;
455  }
456 
457  return $str;
458  }
const IL_CAL_UNIX
Date and time handling
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ getCharacteristic()

ilPCSection::getCharacteristic ( )

Get characteristic of section.

Returns
string characteristic

Definition at line 79 of file class.ilPCSection.php.

80  {
81  if (is_object($this->sec_node))
82  {
83  $char = $this->sec_node->get_attribute("Characteristic");
84  if (substr($char, 0, 4) == "ilc_")
85  {
86  $char = substr($char, 4);
87  }
88  return $char;
89  }
90  }

◆ getLangVars()

static ilPCSection::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

Definition at line 96 of file class.ilPCSection.php.

References array.

97  {
98  return array("ed_insert_section");
99  }
Create styles array
The data for the language used.

◆ getLink()

ilPCSection::getLink ( )

Get link.

Parameters

Definition at line 322 of file class.ilPCSection.php.

References array.

323  {
324  $childs = $this->sec_node->child_nodes();
325  foreach($childs as $child)
326  {
327  if ($child->node_name() == "ExtLink")
328  {
329  return array("LinkType" => "ExtLink",
330  "Href" => $child->get_attribute("Href"));
331  }
332  if ($child->node_name() == "IntLink")
333  {
334  return array("LinkType" => "IntLink",
335  "Target" => $child->get_attribute("Target"),
336  "Type" => $child->get_attribute("Type"),
337  "TargetFrame" => $child->get_attribute("TargetFrame"));
338  }
339  }
340  return array("LinkType" => "NoLink");
341  }
Create styles array
The data for the language used.

◆ getPermission()

ilPCSection::getPermission ( )

Get permission.

Returns
string

Definition at line 250 of file class.ilPCSection.php.

References getAttribute().

251  {
252  return $this->getAttribute("Permission");
253  }
getAttribute($a_attr)
Get attribute.
+ Here is the call graph for this function:

◆ getPermissionRefId()

ilPCSection::getPermissionRefId ( )

Get permission ref id.

Returns
int ref id

Definition at line 271 of file class.ilPCSection.php.

References array, and getAttribute().

272  {
273  $id = explode("_", $this->getAttribute("PermissionRefId"));
274  if (in_array($id[1], array("", 0, IL_INST_ID)))
275  {
276  return $id[3];
277  }
278  return "";
279  }
getAttribute($a_attr)
Get attribute.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ handleAccess()

ilPCSection::handleAccess (   $a_html,
  $a_mode 
)
Parameters
$a_html
$a_mode
Returns
mixed|string

Definition at line 349 of file class.ilPCSection.php.

References $start, and array.

Referenced by modifyPageContentPostXsl().

350  {
351  global $ilAccess;
352 
353  while (($start = strpos($a_html, "{{{{{Section;Access;")) > 0)
354  {
355  $end = strpos($a_html, "}}}}}", $start);
356  $access_attr = explode(";", substr($a_html, $start, $end - $start));
357  $id = explode("_", $access_attr[3]);
358  $access = true;
359  if (in_array($id[1], array("", 0, IL_INST_ID)) && $id[3] > 0)
360  {
361  $access = $ilAccess->checkAccess($access_attr[5], "", $id[3]);
362  }
363  if ($access)
364  {
365  $a_html = substr($a_html, 0, $start).substr($a_html, $end + 5);
366  }
367  else
368  {
369  $end = strpos($a_html, "{{{{{Section;Access}}}}}", $start);
370  $a_html = substr($a_html, 0, $start).substr($a_html, $end + 24);
371  }
372  }
373 
374  $a_html = str_replace("{{{{{Section;Access}}}}}", "", $a_html);
375 
376  return $a_html;
377  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ init()

ilPCSection::init ( )

Init page content component.

Definition at line 25 of file class.ilPCSection.php.

References ilPageContent\setType().

26  {
27  $this->setType("sec");
28  }
setType($a_type)
Set Type.
+ Here is the call graph for this function:

◆ insertTimings()

ilPCSection::insertTimings (   $a_html)

Insert timings (in edit mode)

Parameters
string$a_htmlhtml
Returns
string htmls

Definition at line 466 of file class.ilPCSection.php.

References $html, $ilCtrl, $lng, $start, ilDatePresentation\formatDate(), IL_CAL_UNIX, and ilDatePresentation\setUseRelativeDates().

467  {
468  global $ilCtrl, $lng;
469 
470  $c_pos = 0;
471  $start = strpos($a_html, "{{{{{Section;ActiveFrom");
472  if (is_int($start))
473  {
474  $end = strpos($a_html, "}}}}}", $start);
475  }
476  $i = 1;
477  while ($end > 0)
478  {
479  $param = substr($a_html, $start + 13, $end - $start - 13);
480  $param = explode(";", $param);
481  $from = $param[1];
482  $to = $param[3];
483  $html = "";
484  if ($from != "")
485  {
487  $from = new ilDateTime($from, IL_CAL_UNIX);
488  $html.= $lng->txt("cont_active_from").": ".ilDatePresentation::formatDate($from);
489  }
490  if ($to != "")
491  {
492  $to = new ilDateTime($to, IL_CAL_UNIX);
493  $html.= " ".$lng->txt("cont_active_to").": ".ilDatePresentation::formatDate($to);
494  }
495 
496  $h2 = substr($a_html, 0, $start).
497  $html.
498  substr($a_html, $end + 5);
499  $a_html = $h2;
500  $i++;
501 
502  $start = strpos($a_html, "{{{{{Section;ActiveFrom;", $start + 5);
503  $end = 0;
504  if (is_int($start))
505  {
506  $end = strpos($a_html, "}}}}}", $start);
507  }
508  }
509  return $a_html;
510  }
static setUseRelativeDates($a_status)
set use relative dates
const IL_CAL_UNIX
global $ilCtrl
Definition: ilias.php:18
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
global $lng
Definition: privfeed.php:17
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ modifyPageContentPostXsl()

ilPCSection::modifyPageContentPostXsl (   $a_output,
  $a_mode 
)

Modify page content after xsl.

Parameters
string$a_output
Returns
string

Definition at line 121 of file class.ilPCSection.php.

References handleAccess().

122  {
123  $a_output = self::insertTimings($a_output);
124  $a_output = $this->handleAccess($a_output, $a_mode);
125 
126  return $a_output;
127  }
handleAccess($a_html, $a_mode)
+ Here is the call graph for this function:

◆ saveTimings()

static ilPCSection::saveTimings (   $a_page)
static

Save timings.

Parameters
ilPageObject$a_pagepage object

Definition at line 384 of file class.ilPCSection.php.

References $ilDB, $path, $res, array, domxml_open_mem(), xpath_eval(), and xpath_new_context().

385  {
386  global $ilDB;
387 
388  $ilDB->manipulate("DELETE FROM copg_section_timings WHERE ".
389  " page_id = ".$ilDB->quote($a_page->getId(), "integer").
390  " AND parent_type = ".$ilDB->quote($a_page->getParentType(), "text")
391  );
392 
393  $xml = $a_page->getXMLFromDom();
394 
395  $doc = domxml_open_mem($xml);
396 
397  // media aliases
398  $xpc = xpath_new_context($doc);
399  $path = "//Section";
400  $res = xpath_eval($xpc, $path);
401  for ($i=0; $i < count($res->nodeset); $i++)
402  {
403  $from = $res->nodeset[$i]->get_attribute("ActiveFrom");
404  if ($from != "")
405  {
406  $ilDB->replace("copg_section_timings",
407  array(
408  "page_id" => array("integer", $a_page->getId()),
409  "parent_type" => array("text", $a_page->getParentType()),
410  "unix_ts" => array("integer", $from)
411  ),
412  array()
413  );
414  }
415  $to = $res->nodeset[$i]->get_attribute("ActiveTo");
416  if ($to != "")
417  {
418  $ilDB->replace("copg_section_timings",
419  array(
420  "page_id" => array("integer", $a_page->getId()),
421  "parent_type" => array("text", $a_page->getParentType()),
422  "unix_ts" => array("integer", $to)
423  ),
424  array()
425  );
426  }
427  }
428  }
$path
Definition: aliased.php:25
xpath_new_context($dom_document)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
Create styles array
The data for the language used.
global $ilDB
domxml_open_mem($str, $mode=0, &$error=NULL)
+ Here is the call graph for this function:

◆ setActiveFrom()

ilPCSection::setActiveFrom (   $a_unix_ts)

Set activation from.

Parameters
string$a_unix_tsunix ts activation from

Definition at line 134 of file class.ilPCSection.php.

135  {
136  if ($a_unix_ts > 0)
137  {
138  $this->sec_node->set_attribute("ActiveFrom", $a_unix_ts);
139  }
140  else
141  {
142  if ($this->sec_node->has_attribute("ActiveFrom"))
143  {
144  $this->sec_node->remove_attribute("ActiveFrom");
145  }
146  }
147  }

◆ setActiveTo()

ilPCSection::setActiveTo (   $a_unix_ts)

Set activation to.

Parameters
string$a_unix_tsunix ts activation to

Definition at line 169 of file class.ilPCSection.php.

170  {
171  if ($a_unix_ts > 0)
172  {
173  $this->sec_node->set_attribute("ActiveTo", $a_unix_ts);
174  }
175  else
176  {
177  if ($this->sec_node->has_attribute("ActiveTo"))
178  {
179  $this->sec_node->remove_attribute("ActiveTo");
180  }
181  }
182  }

◆ setAttribute()

ilPCSection::setAttribute (   $a_attr,
  $a_val 
)
protected

Set attribute.

Parameters
string$a_attrattribute
string$a_valattribute value

Definition at line 205 of file class.ilPCSection.php.

Referenced by setPermission(), and setPermissionRefId().

206  {
207  if (!empty($a_val))
208  {
209  $this->sec_node->set_attribute($a_attr, $a_val);
210  }
211  else
212  {
213  if ($this->sec_node->has_attribute($a_attr))
214  {
215  $this->sec_node->remove_attribute($a_attr);
216  }
217  }
218  }
+ Here is the caller graph for this function:

◆ setCharacteristic()

ilPCSection::setCharacteristic (   $a_char)

Set Characteristic of section.

Parameters
string$a_charCharacteristic

Definition at line 59 of file class.ilPCSection.php.

60  {
61  if (!empty($a_char))
62  {
63  $this->sec_node->set_attribute("Characteristic", $a_char);
64  }
65  else
66  {
67  if ($this->sec_node->has_attribute("Characteristic"))
68  {
69  $this->sec_node->remove_attribute("Characteristic");
70  }
71  }
72  }

◆ setExtLink()

ilPCSection::setExtLink (   $a_href)

Set link of area to an external one.

Parameters
string$a_href

Definition at line 293 of file class.ilPCSection.php.

References array, ilDOMUtil\setFirstOptionalElement(), and setNoLink().

294  {
295  $this->setNoLink();
296  if (trim($a_href) != "")
297  {
298  $attributes = array("Href" => trim($a_href));
299  ilDOMUtil::setFirstOptionalElement($this->dom, $this->sec_node, "ExtLink",
300  array(""), "", $attributes);
301  }
302  }
setNoLink()
Set no link.
static setFirstOptionalElement($doc, $parent_node, $a_node_name, $a_successors, $a_content, $a_attributes, $a_remove_childs=true)
searches for an element $a_node_name within the childs of $parent_node if no node is found...
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ setIntLink()

ilPCSection::setIntLink (   $a_type,
  $a_target,
  $a_target_frame 
)

Set link of area to an internal one.

Definition at line 307 of file class.ilPCSection.php.

References $a_type, array, ilDOMUtil\setFirstOptionalElement(), and setNoLink().

308  {
309  $this->setNoLink();
310  $attributes = array("Type" => $a_type, "Target" => $a_target,
311  "TargetFrame" => $a_target_frame);
312  ilDOMUtil::setFirstOptionalElement($this->dom, $this->sec_node, "IntLink",
313  array(""), "", $attributes);
314  }
setNoLink()
Set no link.
$a_type
Definition: workflow.php:93
static setFirstOptionalElement($doc, $parent_node, $a_node_name, $a_successors, $a_content, $a_attributes, $a_remove_childs=true)
searches for an element $a_node_name within the childs of $parent_node if no node is found...
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ setNode()

ilPCSection::setNode (   $a_node)

Set node.

Definition at line 33 of file class.ilPCSection.php.

34  {
35  parent::setNode($a_node); // this is the PageContent node
36  $this->sec_node = $a_node->first_child(); // this is the Section node
37  }

◆ setNoLink()

ilPCSection::setNoLink ( )

Set no link.

Definition at line 284 of file class.ilPCSection.php.

References array, and ilDOMUtil\deleteAllChildsByName().

Referenced by setExtLink(), and setIntLink().

285  {
286  ilDOMUtil::deleteAllChildsByName($this->sec_node, array("IntLink", "ExtLink"));
287  }
static deleteAllChildsByName($a_parent, $a_node_names)
delete all childs of a node by names in $a_node_names
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPermission()

ilPCSection::setPermission (   $a_val)

Set permission.

Parameters
string$a_val"read"|"write"|"visible"

Definition at line 240 of file class.ilPCSection.php.

References setAttribute().

241  {
242  $this->setAttribute("Permission", $a_val);
243  }
setAttribute($a_attr, $a_val)
Set attribute.
+ Here is the call graph for this function:

◆ setPermissionRefId()

ilPCSection::setPermissionRefId (   $a_ref_id)

Set permission ref id.

Parameters
integer$a_ref_idref id

Definition at line 261 of file class.ilPCSection.php.

References setAttribute().

262  {
263  $this->setAttribute("PermissionRefId", "il__ref_".$a_ref_id);
264  }
setAttribute($a_attr, $a_val)
Set attribute.
+ Here is the call graph for this function:

Field Documentation

◆ $dom

ilPCSection::$dom

Definition at line 19 of file class.ilPCSection.php.

◆ $sec_node

ilPCSection::$sec_node

Definition at line 20 of file class.ilPCSection.php.


The documentation for this class was generated from the following file: