ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

 $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

 $lng
 
 $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 206 of file class.ilPCContentInclude.php.

References $id, ilPageContent\$node, $type, and array.

Referenced by ilPageObjectGUI\showPage().

207  {
208  $xpath = new DOMXPath($a_domdoc);
209  $nodes = $xpath->query('//ContentInclude');
210 
211  $ci_ids = array();
212  foreach ($nodes as $node) {
213  $type = $node->getAttribute("ContentType");
214  $id = $node->getAttribute("ContentId");
215  $inst_id = $node->getAttribute("InstId");
216  $ci_ids[$type . ":" . $id . ":" . $inst_id] = array(
217  "type" => $type, "id" => $id, "inst_id" => $inst_id);
218  }
219 
220  return $ci_ids;
221  }
$type
if(!array_key_exists('StateId', $_REQUEST)) $id
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 58 of file class.ilPCContentInclude.php.

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

59  {
60  $this->node = $this->createPageContentNode();
61  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
62  $this->incl_node = $this->dom->create_element("ContentInclude");
63  $this->incl_node = $this->node->append_child($this->incl_node);
64  }
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 77 of file class.ilPCContentInclude.php.

References getContentIncludeAttribute().

78  {
79  return $this->getContentIncludeAttribute("ContentId");
80  }
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 136 of file class.ilPCContentInclude.php.

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

137  {
138  if (is_object($this->incl_node)) {
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 93 of file class.ilPCContentInclude.php.

References getContentIncludeAttribute().

94  {
95  return $this->getContentIncludeAttribute("ContentType");
96  }
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 109 of file class.ilPCContentInclude.php.

References getContentIncludeAttribute().

110  {
111  return $this->getContentIncludeAttribute("InstId");
112  }
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 34 of file class.ilPCContentInclude.php.

References $DIC, and ilPageContent\setType().

35  {
36  global $DIC;
37 
38  $this->lng = $DIC->language();
39  $this->setType("incl");
40  $this->access = $DIC->access();
41  }
global $DIC
Definition: saml.php:7
setType($a_type)
Set Type.
+ Here is the call graph for this function:

◆ modifyPageContentPostXsl()

ilPCContentInclude::modifyPageContentPostXsl (   $a_html,
  $a_mode 
)

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

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

227  {
228  $lng = $this->lng;
229 
230  $end = 0;
231  $start = strpos($a_html, "{{{{{ContentInclude;");
232  if (is_int($start)) {
233  $end = strpos($a_html, "}}}}}", $start);
234  }
235  $i = 1;
236  while ($end > 0) {
237  $param = substr($a_html, $start + 20, $end - $start - 20);
238  $param = explode(";", $param);
239 
240  if ($param[0] == "mep" && is_numeric($param[1])) {
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  $snippet_lang = "-";
246  }
247  if (($param[2] <= 0 || $param[2] == IL_INST_ID) && ilPageObject::_exists("mep", $param[1])) {
248  $page_gui = new ilMediaPoolPageGUI($param[1], 0, true, $snippet_lang);
249  if ($a_mode != "offline") {
250  $page_gui->setFileDownloadLink($this->getFileDownloadLink());
251  $page_gui->setFullscreenLink($this->getFullscreenLink());
252  $page_gui->setSourcecodeDownloadScript($this->getSourcecodeDownloadScript());
253  } else {
254  $page_gui->setOutputMode(IL_PAGE_OFFLINE);
255  }
256 
257  $html = $page_gui->getRawContent();
258  if ($a_mode == "edit") {
259  include_once("./Services/Link/classes/class.ilLink.php");
260  $par_id = $page_gui->getPageObject()->getParentId();
261  $info = "";
262  foreach (ilObject::_getAllReferences($par_id) as $ref_id) {
263  if ($this->access->checkAccess("write", "", $ref_id)) {
264  $info = " " . $lng->txt("title") . ": " . ilMediaPoolItem::lookupTitle($page_gui->getPageObject()->getId()) .
265  ", " . $lng->txt("obj_mep") . ": <a href='" . ilLink::_getLink($ref_id) . "'>" . ilObject::_lookupTitle($par_id) . "</a>";
266  }
267  }
268  $html = '<p class="small light">' . $lng->txt("copg_snippet_cannot_be_edited") . $info . '</p>' . $html;
269  }
270  } else {
271  if ($a_mode == "edit") {
272  if ($param[2] <= 0) {
273  $html = "// " . $lng->txt("cont_missing_snippet") . " //";
274  } else {
275  $html = "// " . $lng->txt("cont_snippet_from_another_installation") . " //";
276  }
277  }
278  }
279  $h2 = substr($a_html, 0, $start) .
280  $html .
281  substr($a_html, $end + 5);
282  $a_html = $h2;
283  $i++;
284  }
285 
286  $start = strpos($a_html, "{{{{{ContentInclude;", $start + 5);
287  $end = 0;
288  if (is_int($start)) {
289  $end = strpos($a_html, "}}}}}", $start);
290  }
291  }
292  return $a_html;
293  }
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
$end
Definition: saml1-acs.php:18
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
getFullscreenLink()
Get fullscreen link.
static lookupTitle($a_id)
Lookup title.
$i
Definition: disco.tpl.php:19
getFileDownloadLink()
Get file download link.
$info
Definition: index.php:5
$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  if ((int) $ci_id["inst_id"] <= 0 || $ci_id["inst_id"] == IL_INST_ID) {
192  "incl",
193  $ci_id["id"],
194  $a_page->getParentType() . ":pg",
195  $a_page->getId(),
196  $a_old_nr,
197  $a_page->getLanguage()
198  );
199  }
200  }
201  }
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 69 of file class.ilPCContentInclude.php.

References setContentIncludeAttribute().

70  {
71  $this->setContentIncludeAttribute("ContentId", $a_id);
72  }
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 120 of file class.ilPCContentInclude.php.

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

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

◆ setContentType()

ilPCContentInclude::setContentType (   $a_type)

Set content type.

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

References $a_type, and setContentIncludeAttribute().

86  {
87  $this->setContentIncludeAttribute("ContentType", $a_type);
88  }
$a_type
Definition: workflow.php:92
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 101 of file class.ilPCContentInclude.php.

References setContentIncludeAttribute().

102  {
103  $this->setContentIncludeAttribute("InstId", $a_id);
104  }
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 46 of file class.ilPCContentInclude.php.

47  {
48  parent::setNode($a_node); // this is the PageContent node
49  $this->incl_node = $a_node->first_child(); // this is the snippet node
50  }

Field Documentation

◆ $access

ilPCContentInclude::$access
protected

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

◆ $incl_node

ilPCContentInclude::$incl_node

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

◆ $lng

ilPCContentInclude::$lng
protected

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

Referenced by modifyPageContentPostXsl().


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