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

Class ilPCContentInclude. More...

+ Inheritance diagram for ilPCContentInclude:
+ Collaboration diagram for ilPCContentInclude:

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 content include node in xml. More...
 
 setContentId ($a_id)
 Set content id. More...
 
 getContentId ()
 Get content id. More...
 
 setContentType ($a_type)
 Set content type. More...
 
 getContentType ()
 Get content type. More...
 
 setInstId ($a_id)
 Set installation id. More...
 
 getInstId ()
 Get installation id. More...
 
 getContentIncludeAttribute ($a_attr)
 Get content include tag attribute. More...
 
 modifyPageContentPostXsl ($a_html, $a_mode)
 
- 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 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...
 
static saveContentIncludeUsage ($a_page, $a_domdoc, $a_old_nr=0)
 save content include usages More...
 
static collectContentIncludes ($a_page, $a_domdoc)
 get all content includes that are used within the page 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
 
 $incl_node
 
- Data Fields inherited from ilPageContent
 $hier_id
 
 $node
 
 $dom
 
 $page_lang
 

Protected Member Functions

 setContentIncludeAttribute ($a_attr, $a_value)
 Set attribute of content include tag. More...
 
- Protected Member Functions inherited from ilPageContent
 setType ($a_type)
 Set Type. More...
 

Protected Attributes

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

Detailed Description

Class ilPCContentInclude.

Content include object (see ILIAS DTD). Inserts content snippets from other source (e.g. media pool)

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.ilPCContentInclude.php.

Member Function Documentation

◆ afterPageHistoryEntry()

static ilPCContentInclude::afterPageHistoryEntry (   $a_page,
DOMDocument  $a_old_domdoc,
  $a_old_xml,
  $a_old_nr 
)
static

After page history entry has been created.

Parameters
object$a_pagepage object
DOMDocument$a_old_domdocold dom document
string$a_old_xmlold xml
integer$a_old_nrhistory number

Definition at line 176 of file class.ilPCContentInclude.php.

177  {
178  self::saveContentIncludeUsage($a_page, $a_old_domdoc, $a_old_nr);
179  }

◆ afterPageUpdate()

static ilPCContentInclude::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 151 of file class.ilPCContentInclude.php.

152  {
153  // pc content include
154  self::saveContentIncludeUsage($a_page, $a_domdoc);
155  }

◆ beforePageDelete()

static ilPCContentInclude::beforePageDelete (   $a_page)
static

Before page is being deleted.

Parameters
object$a_pagepage object

Definition at line 162 of file class.ilPCContentInclude.php.

References ilPageContentUsage\deleteAllUsages().

163  {
164  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
165  ilPageContentUsage::deleteAllUsages("incl", $a_page->getParentType().":pg", $a_page->getId(), false, $a_page->getLanguage());
166  }
static deleteAllUsages($a_pc_type, $a_usage_type, $a_usage_id, $a_usage_hist_nr=0, $a_lang="-")
Delete all usages.
+ Here is the call graph for this function:

◆ collectContentIncludes()

static ilPCContentInclude::collectContentIncludes (   $a_page,
  $a_domdoc 
)
static

get all content includes that are used within the page

Definition at line 202 of file class.ilPCContentInclude.php.

References ilPageContent\$node, and array.

Referenced by ilPageObjectGUI\showPage().

203  {
204  $xpath = new DOMXPath($a_domdoc);
205  $nodes = $xpath->query('//ContentInclude');
206 
207  $ci_ids = array();
208  foreach ($nodes as $node)
209  {
210  $type = $node->getAttribute("ContentType");
211  $id = $node->getAttribute("ContentId");
212  $inst_id = $node->getAttribute("InstId");
213  $ci_ids[$type.":".$id.":".$inst_id] = array(
214  "type" => $type, "id" => $id, "inst_id" => $inst_id);
215  }
216 
217  return $ci_ids;
218  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ create()

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

Create content include node in xml.

Parameters
object$a_pg_objPage Object
string$a_hier_idHierarchical ID

Definition at line 53 of file class.ilPCContentInclude.php.

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

54  {
55  $this->node = $this->createPageContentNode();
56  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
57  $this->incl_node = $this->dom->create_element("ContentInclude");
58  $this->incl_node = $this->node->append_child($this->incl_node);
59  }
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:

◆ getContentId()

ilPCContentInclude::getContentId ( )

Get content id.

Definition at line 72 of file class.ilPCContentInclude.php.

References getContentIncludeAttribute().

73  {
74  return $this->getContentIncludeAttribute("ContentId");
75  }
getContentIncludeAttribute($a_attr)
Get content include tag attribute.
+ Here is the call graph for this function:

◆ getContentIncludeAttribute()

ilPCContentInclude::getContentIncludeAttribute (   $a_attr)

Get content include tag attribute.

Returns
string attribute name

Definition at line 135 of file class.ilPCContentInclude.php.

Referenced by getContentId(), getContentType(), and getInstId().

136  {
137  if (is_object($this->incl_node))
138  {
139  return $this->incl_node->get_attribute($a_attr);
140  }
141  }
+ Here is the caller graph for this function:

◆ getContentType()

ilPCContentInclude::getContentType ( )

Get content type.

Definition at line 88 of file class.ilPCContentInclude.php.

References getContentIncludeAttribute().

89  {
90  return $this->getContentIncludeAttribute("ContentType");
91  }
getContentIncludeAttribute($a_attr)
Get content include tag attribute.
+ Here is the call graph for this function:

◆ getInstId()

ilPCContentInclude::getInstId ( )

Get installation id.

Definition at line 104 of file class.ilPCContentInclude.php.

References getContentIncludeAttribute().

105  {
106  return $this->getContentIncludeAttribute("InstId");
107  }
getContentIncludeAttribute($a_attr)
Get content include tag attribute.
+ Here is the call graph for this function:

◆ init()

ilPCContentInclude::init ( )

Init page content component.

Definition at line 30 of file class.ilPCContentInclude.php.

References $DIC, and ilPageContent\setType().

31  {
32  global $DIC;
33 
34  $this->setType("incl");
35  $this->access = $DIC->access();
36  }
setType($a_type)
Set Type.
global $DIC
+ Here is the call graph for this function:

◆ modifyPageContentPostXsl()

ilPCContentInclude::modifyPageContentPostXsl (   $a_html,
  $a_mode 
)

Definition at line 223 of file class.ilPCContentInclude.php.

References $html, $info, $lng, $ref_id, $start, ilPageObject\_exists(), ilObject\_getAllReferences(), ilLink\_getLink(), ilObject\_lookupTitle(), ilPageContent\getFileDownloadLink(), ilPageContent\getFullscreenLink(), ilPageContent\getPage(), ilPageContent\getSourcecodeDownloadScript(), IL_PAGE_OFFLINE, and ilMediaPoolItem\lookupTitle().

224  {
225  global $lng;
226 
227  $end = 0;
228  $start = strpos($a_html, "{{{{{ContentInclude;");
229  if (is_int($start))
230  {
231  $end = strpos($a_html, "}}}}}", $start);
232  }
233  $i = 1;
234  while ($end > 0)
235  {
236  $param = substr($a_html, $start + 20, $end - $start - 20);
237  $param = explode(";", $param);
238 
239  if ($param[0] == "mep" && is_numeric($param[1]))
240  {
241  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
242  $html = "";
243  $snippet_lang = $this->getPage()->getLanguage();
244  if (!ilPageObject::_exists("mep", $param[1], $snippet_lang))
245  {
246  $snippet_lang = "-";
247  }
248  if (($param[2] <= 0 || $param[2] == IL_INST_ID) && ilPageObject::_exists("mep", $param[1]))
249  {
250  $page_gui = new ilMediaPoolPageGUI($param[1], 0, true, $snippet_lang);
251  if ($a_mode != "offline")
252  {
253  $page_gui->setFileDownloadLink($this->getFileDownloadLink());
254  $page_gui->setFullscreenLink($this->getFullscreenLink());
255  $page_gui->setSourcecodeDownloadScript($this->getSourcecodeDownloadScript());
256  }
257  else
258  {
259  $page_gui->setOutputMode(IL_PAGE_OFFLINE);
260  }
261 
262  $html = $page_gui->getRawContent();
263  if ($a_mode == "edit")
264  {
265  include_once("./Services/Link/classes/class.ilLink.php");
266  $par_id = $page_gui->getPageObject()->getParentId();
267  $info = "";
268  foreach (ilObject::_getAllReferences($par_id) as $ref_id)
269  {
270  if ($this->access->checkAccess("write", "", $ref_id))
271  {
272  $info = " ".$lng->txt("title").": ".ilMediaPoolItem::lookupTitle($page_gui->getPageObject()->getId()).
273  ", ".$lng->txt("obj_mep").": <a href='".ilLink::_getLink($ref_id)."'>".ilObject::_lookupTitle($par_id)."</a>";
274  }
275  }
276  $html = '<p class="small light">'.$lng->txt("copg_snippet_cannot_be_edited").$info.'</p>'.$html;
277  }
278  }
279  else
280  {
281  if ($a_mode == "edit")
282  {
283  if ($param[2] <= 0)
284  {
285  $html = "// ".$lng->txt("cont_missing_snippet")." //";
286  }
287  else
288  {
289  $html = "// ".$lng->txt("cont_snippet_from_another_installation")." //";
290  }
291  }
292  }
293  $h2 = substr($a_html, 0, $start).
294  $html.
295  substr($a_html, $end + 5);
296  $a_html = $h2;
297  $i++;
298  }
299 
300  $start = strpos($a_html, "{{{{{ContentInclude;", $start + 5);
301  $end = 0;
302  if (is_int($start))
303  {
304  $end = strpos($a_html, "}}}}}", $start);
305  }
306  }
307  return $a_html;
308  }
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
getSourcecodeDownloadScript()
Get sourcecode download script.
const IL_PAGE_OFFLINE
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
$info
Definition: example_052.php:80
getFullscreenLink()
Get fullscreen link.
static lookupTitle($a_id)
Lookup title.
$ref_id
Definition: sahs_server.php:39
global $lng
Definition: privfeed.php:17
getFileDownloadLink()
Get file download link.
$html
Definition: example_001.php:87
Class ilMediaPoolPage GUI class.
+ Here is the call graph for this function:

◆ saveContentIncludeUsage()

static ilPCContentInclude::saveContentIncludeUsage (   $a_page,
  $a_domdoc,
  $a_old_nr = 0 
)
static

save content include usages

Definition at line 184 of file class.ilPCContentInclude.php.

References ilPageContentUsage\deleteAllUsages(), and ilPageContentUsage\saveUsage().

185  {
186  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
187  $ci_ids = self::collectContentIncludes($a_page, $a_domdoc);
188  ilPageContentUsage::deleteAllUsages("incl", $a_page->getParentType().":pg", $a_page->getId(), $a_old_nr, $a_page->getLanguage());
189  foreach($ci_ids as $ci_id)
190  {
191  if ((int) $ci_id["inst_id"] <= 0 || $ci_id["inst_id"] == IL_INST_ID)
192  {
193  ilPageContentUsage::saveUsage("incl", $ci_id["id"], $a_page->getParentType().":pg", $a_page->getId(), $a_old_nr,
194  $a_page->getLanguage());
195  }
196  }
197  }
static deleteAllUsages($a_pc_type, $a_usage_type, $a_usage_id, $a_usage_hist_nr=0, $a_lang="-")
Delete all usages.
static saveUsage($a_pc_type, $a_pc_id, $a_usage_type, $a_usage_id, $a_usage_hist_nr=0, $a_lang="-")
Save usages.
+ Here is the call graph for this function:

◆ setContentId()

ilPCContentInclude::setContentId (   $a_id)

Set content id.

Definition at line 64 of file class.ilPCContentInclude.php.

References setContentIncludeAttribute().

65  {
66  $this->setContentIncludeAttribute("ContentId", $a_id);
67  }
setContentIncludeAttribute($a_attr, $a_value)
Set attribute of content include tag.
+ Here is the call graph for this function:

◆ setContentIncludeAttribute()

ilPCContentInclude::setContentIncludeAttribute (   $a_attr,
  $a_value 
)
protected

Set attribute of content include tag.

Parameters
stringattribute name
stringattribute value

Definition at line 115 of file class.ilPCContentInclude.php.

Referenced by setContentId(), setContentType(), and setInstId().

116  {
117  if (!empty($a_value))
118  {
119  $this->incl_node->set_attribute($a_attr, $a_value);
120  }
121  else
122  {
123  if ($this->incl_node->has_attribute($a_attr))
124  {
125  $this->incl_node->remove_attribute($a_attr);
126  }
127  }
128  }
+ Here is the caller graph for this function:

◆ setContentType()

ilPCContentInclude::setContentType (   $a_type)

Set content type.

Definition at line 80 of file class.ilPCContentInclude.php.

References $a_type, and setContentIncludeAttribute().

81  {
82  $this->setContentIncludeAttribute("ContentType", $a_type);
83  }
$a_type
Definition: workflow.php:93
setContentIncludeAttribute($a_attr, $a_value)
Set attribute of content include tag.
+ Here is the call graph for this function:

◆ setInstId()

ilPCContentInclude::setInstId (   $a_id)

Set installation id.

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

References setContentIncludeAttribute().

97  {
98  $this->setContentIncludeAttribute("InstId", $a_id);
99  }
setContentIncludeAttribute($a_attr, $a_value)
Set attribute of content include tag.
+ Here is the call graph for this function:

◆ setNode()

ilPCContentInclude::setNode (   $a_node)

Set node.

Definition at line 41 of file class.ilPCContentInclude.php.

42  {
43  parent::setNode($a_node); // this is the PageContent node
44  $this->incl_node = $a_node->first_child(); // this is the snippet node
45  }

Field Documentation

◆ $access

ilPCContentInclude::$access
protected

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

◆ $dom

ilPCContentInclude::$dom

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

◆ $incl_node

ilPCContentInclude::$incl_node

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


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