ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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...
 
 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 ()
 Get Javascript files. More...
 
 getCssFiles ()
 Get css files. More...
 
 getOnloadCode ()
 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...
 
 readPCId ()
 Read PC Id. More...
 
 writePCId ($a_pc_id)
 Write pc id. More...
 
 isGreaterHierId ($a, $b)
 Check whether Hier ID $a is greater than Hier ID $b. 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 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
 

Additional Inherited Members

- Protected Member Functions inherited from ilPageContent
 setType ($a_type)
 Set Type. More...
 

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

Reimplemented from ilPageContent.

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 }
static saveTimings($a_page)
Save timings.

References saveTimings().

+ Here is the call graph for this function:

◆ 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.

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)

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

+ Here is the call graph for this function:

◆ getActiveFrom()

ilPCSection::getActiveFrom ( )

Get activation from.

Returns
string unix ts activation from

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

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

◆ getActiveTo()

ilPCSection::getActiveTo ( )

Get activation to.

Returns
string unix ts activation to

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

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

◆ getCacheTriggerString()

static ilPCSection::getCacheTriggerString (   $a_page)
static

Get page cache update trigger string.

Parameters
ilPageObject$a_page
Returns
string trigger string

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

252 {
253 global $ilDB;
254
255 $set = $ilDB->query("SELECT * FROM copg_section_timings ".
256 " WHERE page_id = ".$ilDB->quote($a_page->getId(), "integer").
257 " AND parent_type = ".$ilDB->quote($a_page->getParentType(), "text")
258 );
259 $str = "";
260 $current_ts = new ilDateTime(time(),IL_CAL_UNIX);
261 $current_ts = $current_ts->get(IL_CAL_UNIX);
262 while ($rec = $ilDB->fetchAssoc($set))
263 {
264 $unix_ts = $rec["unix_ts"];
265 if ($unix_ts < $current_ts)
266 {
267 $unix_ts.= "a";
268 }
269 $str.= "-".$unix_ts;
270 }
271
272 return $str;
273 }
const IL_CAL_UNIX
@classDescription Date and time handling
global $ilDB

References $ilDB, and IL_CAL_UNIX.

Referenced by ilPageObjectGUI\showPage().

+ 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

Reimplemented from ilPageContent.

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

97 {
98 return array("ed_insert_section");
99 }

◆ init()

ilPCSection::init ( )

Init page content component.

Reimplemented from ilPageContent.

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

26 {
27 $this->setType("sec");
28 }
setType($a_type)
Set Type.

References ilPageContent\setType().

+ 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 281 of file class.ilPCSection.php.

282 {
283 global $ilCtrl, $lng;
284
285 $c_pos = 0;
286 $start = strpos($a_html, "{{{{{Section;ActiveFrom");
287 if (is_int($start))
288 {
289 $end = strpos($a_html, "}}}}}", $start);
290 }
291 $i = 1;
292 while ($end > 0)
293 {
294 $param = substr($a_html, $start + 13, $end - $start - 13);
295 $param = explode(";", $param);
296 $from = $param[1];
297 $to = $param[3];
298 $html = "";
299 if ($from != "")
300 {
302 $from = new ilDateTime($from, IL_CAL_UNIX);
303 $html.= $lng->txt("cont_active_from").": ".ilDatePresentation::formatDate($from);
304 }
305 if ($to != "")
306 {
307 $to = new ilDateTime($to, IL_CAL_UNIX);
308 $html.= " ".$lng->txt("cont_active_to").": ".ilDatePresentation::formatDate($to);
309 }
310
311 $h2 = substr($a_html, 0, $start).
312 $html.
313 substr($a_html, $end + 5);
314 $a_html = $h2;
315 $i++;
316
317 $start = strpos($a_html, "{{{{{Section;ActiveFrom;", $start + 5);
318 $end = 0;
319 if (is_int($start))
320 {
321 $end = strpos($a_html, "}}}}}", $start);
322 }
323 }
324 return $a_html;
325 }
static setUseRelativeDates($a_status)
set use relative dates
static formatDate(ilDateTime $date)
Format a date @access public.
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40

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

Referenced by modifyPageContentPostXsl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modifyPageContentPostXsl()

ilPCSection::modifyPageContentPostXsl (   $a_output,
  $a_mode 
)

Modify page content after xsl.

Parameters
string$a_output
Returns
string

Reimplemented from ilPageContent.

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

122 {
123 $a_output = self::insertTimings($a_output);
124
125 return $a_output;
126 }
insertTimings($a_html)
Insert timings (in edit mode)

References insertTimings().

+ 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 203 of file class.ilPCSection.php.

204 {
205 global $ilDB;
206
207 $ilDB->manipulate("DELETE FROM copg_section_timings WHERE ".
208 " page_id = ".$ilDB->quote($a_page->getId(), "integer").
209 " AND parent_type = ".$ilDB->quote($a_page->getParentType(), "text")
210 );
211
212 $xml = $a_page->getXMLFromDom();
213
214 $doc = domxml_open_mem($xml);
215
216 // media aliases
217 $xpc = xpath_new_context($doc);
218 $path = "//Section";
219 $res = xpath_eval($xpc, $path);
220 for ($i=0; $i < count($res->nodeset); $i++)
221 {
222 $from = $res->nodeset[$i]->get_attribute("ActiveFrom");
223 if ($from != "")
224 {
225 $ilDB->manipulate("INSERT INTO copg_section_timings ".
226 "(page_id, parent_type, unix_ts) VALUES (".
227 $ilDB->quote($a_page->getId(), "integer").",".
228 $ilDB->quote($a_page->getParentType(), "text").",".
229 $ilDB->quote($from, "text").
230 ")");
231 }
232 $to = $res->nodeset[$i]->get_attribute("ActiveTo");
233 if ($to != "")
234 {
235 $ilDB->manipulate("INSERT INTO copg_section_timings ".
236 "(page_id, parent_type, unix_ts) VALUES (".
237 $ilDB->quote($a_page->getId(), "integer").",".
238 $ilDB->quote($a_page->getParentType(), "text").",".
239 $ilDB->quote($to, "text").
240 ")");
241 }
242 }
243 }
domxml_open_mem($str, $mode=DOMXML_LOAD_PARSING, &$error=NULL)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
xpath_new_context($dom_document)
$path
Definition: index.php:22

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

Referenced by afterPageUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setActiveFrom()

ilPCSection::setActiveFrom (   $a_unix_ts)

Set activation from.

Parameters
string$a_unix_tsunix ts activation from

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

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

◆ setActiveTo()

ilPCSection::setActiveTo (   $a_unix_ts)

Set activation to.

Parameters
string$a_unix_tsunix ts activation to

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

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

◆ 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 }

◆ setNode()

ilPCSection::setNode ( $a_node)

Set node.

Reimplemented from ilPageContent.

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 }

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: