ILIAS  release_8 Revision v8.23
ilPCContentInclude Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 init ()
 Init page content component. More...
 
 setNode (php4DOMElement $a_node)
 
 create (ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
 
 setContentId (int $a_id)
 Set content id. More...
 
 getContentId ()
 Get content id. More...
 
 setContentType (string $a_type)
 Set content type. More...
 
 getContentType ()
 Get content type. More...
 
 setInstId (string $a_id)
 Set installation id. More...
 
 getInstId ()
 Get installation id. More...
 
 getContentIncludeAttribute (string $a_attr)
 Get content include tag attribute. More...
 
 modifyPageContentPostXsl (string $a_output, string $a_mode, bool $a_abstract_only=false)
 
- Public Member Functions inherited from ilPageContent
 __construct (ilPageObject $a_pg_obj)
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 init ()
 Init object. More...
 
 getType ()
 
 setNode (php4DOMElement $a_node)
 Set xml node of page content. More...
 
 getNode ()
 
 getJavascriptFiles (string $a_mode)
 
 getCssFiles (string $a_mode)
 
 getOnloadCode (string $a_mode)
 
 setHierId (string $a_hier_id)
 
 getHierId ()
 
 lookupHierId ()
 
 readHierId ()
 
 setPcId (string $a_pcid)
 
 getPCId ()
 
 setFileDownloadLink (string $a_download_link)
 
 getFileDownloadLink ()
 
 setProfileBackUrl (string $url)
 
 getProfileBackUrl ()
 
 setFullscreenLink (string $a_fullscreen_link)
 
 getFullscreenLink ()
 
 setSourcecodeDownloadScript (string $script_name)
 
 getSourcecodeDownloadScript ()
 
 readPCId ()
 
 writePCId (string $a_pc_id)
 
 setEnabled (string $value)
 Set Enabled value for page content component. More...
 
 enable ()
 
 disable ()
 
 isEnabled ()
 
 createPageContentNode (bool $a_set_this_node=true)
 Create page content node (always use this method first when adding a new element) More...
 
 modifyPageContentPostXsl (string $a_output, string $a_mode, bool $a_abstract_only=false)
 Modify page content after xsl. More...
 
 getModel ()
 Get model as needed for the front-end editor. More...
 

Static Public Member Functions

static afterPageUpdate (ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete (ilPageObject $a_page)
 Before page is being deleted. More...
 
static afterPageHistoryEntry (ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
 After page history entry has been created. More...
 
static saveContentIncludeUsage (ilPageObject $a_page, DOMDocument $a_domdoc, int $a_old_nr=0)
 save content include usages More...
 
static collectContentIncludes (ilPageObject $a_page, DOMDocument $a_domdoc)
 get all content includes that are used within the page More...
 
static deleteHistoryLowerEqualThan (string $parent_type, int $page_id, string $lang, int $delete_lower_than_nr)
 
- Static Public Member Functions inherited from ilPageContent
static incEdId (string $ed_id)
 Increases an hierarchical editing id at lowest level (last number) More...
 
static decEdId (string $ed_id)
 Decreases an hierarchical editing id at lowest level (last number) More...
 
static sortHierIds (array $a_array)
 Sort an array of Hier IDS in ascending order. More...
 
static isGreaterHierId (string $a, string $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, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
 Handle copied content. More...
 
static afterPageUpdate (ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete (ilPageObject $a_page)
 Before page is being deleted. More...
 
static afterRepositoryCopy (ilPageObject $page, array $mapping, int $source_ref_id)
 After repository (container) copy action. More...
 
static afterPageHistoryEntry (ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
 After page history entry has been created. More...
 
static deleteHistoryLowerEqualThan (string $parent_type, int $page_id, string $lang, int $delete_lower_than_nr)
 Overwrite in derived classes, if old history entries are being deleted. More...
 

Data Fields

php4DOMElement $incl_node
 
- Data Fields inherited from ilPageContent
string $hier_id = ""
 
php4DOMElement $node = null
 
php4DOMDocument $dom = null
 
string $page_lang = ""
 

Protected Member Functions

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

Protected Attributes

ilLanguage $lng
 
ilAccessHandler $access
 
- Protected Attributes inherited from ilPageContent
string $pcid
 
string $type = ""
 
ilPageObject $pg_obj
 
string $file_download_link
 
string $fullscreen_link
 
string $sourcecode_download_script
 
ilLogger $log
 
string $profile_back_url = ""
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilPCContentInclude

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

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Member Function Documentation

◆ afterPageHistoryEntry()

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

After page history entry has been created.

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

166  : void {
167  self::saveContentIncludeUsage($a_page, $a_old_domdoc, $a_old_nr);
168  }

◆ afterPageUpdate()

static ilPCContentInclude::afterPageUpdate ( ilPageObject  $a_page,
DOMDocument  $a_domdoc,
string  $a_xml,
bool  $a_creation 
)
static

After page has been updated (or created)

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

145  : void {
146  // pc content include
147  self::saveContentIncludeUsage($a_page, $a_domdoc);
148  }

◆ beforePageDelete()

static ilPCContentInclude::beforePageDelete ( ilPageObject  $a_page)
static

Before page is being deleted.

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

References ilPageContentUsage\deleteAllUsages(), ilPageObject\getId(), ilPageObject\getLanguage(), and ilPageObject\getParentType().

153  : void
154  {
155  ilPageContentUsage::deleteAllUsages("incl", $a_page->getParentType() . ":pg", $a_page->getId(), 0, $a_page->getLanguage());
156  }
static deleteAllUsages(string $a_pc_type, string $a_usage_type, int $a_usage_id, int $a_usage_hist_nr=0, string $a_lang="-")
+ Here is the call graph for this function:

◆ collectContentIncludes()

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

get all content includes that are used within the page

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

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

Referenced by ilPageObjectGUI\showPage().

200  : array {
201  $xpath = new DOMXPath($a_domdoc);
202  $nodes = $xpath->query('//ContentInclude');
203 
204  $ci_ids = array();
205  foreach ($nodes as $node) {
206  $type = $node->getAttribute("ContentType");
207  $id = $node->getAttribute("ContentId");
208  $inst_id = $node->getAttribute("InstId");
209  $ci_ids[$type . ":" . $id . ":" . $inst_id] = array(
210  "type" => $type, "id" => $id, "inst_id" => $inst_id);
211  }
212 
213  return $ci_ids;
214  }
php4DOMElement $node
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ create()

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

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

References ilPageContent\createPageContentNode(), IL_INSERT_AFTER, and ilPageObject\insertContent().

55  : void {
56  $this->node = $this->createPageContentNode();
57  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
58  $this->incl_node = $this->dom->create_element("ContentInclude");
59  $this->incl_node = $this->node->append_child($this->incl_node);
60  }
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent
const IL_INSERT_AFTER
createPageContentNode(bool $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:

◆ deleteHistoryLowerEqualThan()

static ilPCContentInclude::deleteHistoryLowerEqualThan ( string  $parent_type,
int  $page_id,
string  $lang,
int  $delete_lower_than_nr 
)
static

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

References $DIC.

296  : void {
297  global $DIC;
298 
299  $usage_repo = $DIC->copage()
300  ->internal()
301  ->repo()
302  ->usage();
303 
304  $usage_repo->deleteHistoryUsagesLowerEqualThan(
305  "incl",
306  $parent_type . ":pg",
307  $page_id,
308  $delete_lower_than_nr,
309  $lang
310  );
311  }
global $DIC
Definition: feed.php:28
$lang
Definition: xapiexit.php:26

◆ getContentId()

ilPCContentInclude::getContentId ( )

Get content id.

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

References getContentIncludeAttribute().

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

◆ getContentIncludeAttribute()

ilPCContentInclude::getContentIncludeAttribute ( string  $a_attr)

Get content include tag attribute.

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

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

129  : string
130  {
131  if (is_object($this->incl_node)) {
132  return $this->incl_node->get_attribute($a_attr);
133  }
134  return "";
135  }
+ Here is the caller graph for this function:

◆ getContentType()

ilPCContentInclude::getContentType ( )

Get content type.

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

References getContentIncludeAttribute().

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

◆ getInstId()

ilPCContentInclude::getInstId ( )

Get installation id.

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

References getContentIncludeAttribute().

105  : string
106  {
107  return $this->getContentIncludeAttribute("InstId");
108  }
getContentIncludeAttribute(string $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 36 of file class.ilPCContentInclude.php.

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\lng(), and ilPageContent\setType().

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

◆ modifyPageContentPostXsl()

ilPCContentInclude::modifyPageContentPostXsl ( string  $a_output,
string  $a_mode,
bool  $a_abstract_only = false 
)

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

References $i, $lng, $param, $ref_id, ilPageObject\_exists(), ilObject\_getAllReferences(), ilLink\_getLink(), ilObject\_lookupTitle(), ILIAS\Repository\access(), ilPageContent\getFileDownloadLink(), ilPageContent\getFullscreenLink(), ilPageContent\getPage(), ilPageContent\getProfileBackUrl(), ilPageContent\getSourcecodeDownloadScript(), IL_INST_ID, ilMediaPoolItem\lookupTitle(), ilPageObjectGUI\OFFLINE, and ilLanguage\txt().

220  : string {
221  $lng = $this->lng;
222 
223  $end = 0;
224  $start = strpos($a_output, "{{{{{ContentInclude;");
225  if (is_int($start)) {
226  $end = strpos($a_output, "}}}}}", $start);
227  }
228  $i = 1;
229  $parent_lang = $this->getPage()->getLanguage();
230  if ($parent_lang == "-" && $this->getPage()->getConcreteLang() != "") {
231  $parent_lang = $this->getPage()->getConcreteLang();
232  }
233  while ($end > 0) {
234  $param = substr($a_output, $start + 20, $end - $start - 20);
235  $param = explode(";", $param);
236 
237  if ($param[0] == "mep" && is_numeric($param[1])) {
238  $html = "";
239  $snippet_lang = $parent_lang;
240  if (!ilPageObject::_exists("mep", $param[1], $snippet_lang)) {
241  $snippet_lang = "-";
242  }
243  if (($param[2] <= 0 || $param[2] == IL_INST_ID) && ilPageObject::_exists("mep", $param[1])) {
244  $page_gui = new ilMediaPoolPageGUI($param[1], 0, true, $snippet_lang);
245  if ($a_mode != "offline") {
246  $page_gui->setFileDownloadLink($this->getFileDownloadLink());
247  $page_gui->setProfileBackUrl($this->getProfileBackUrl());
248  $page_gui->setFullscreenLink($this->getFullscreenLink() . "&pg_type=mep");
249  $page_gui->setSourcecodeDownloadScript($this->getSourcecodeDownloadScript());
250  } else {
251  $page_gui->setOutputMode(ilPageObjectGUI::OFFLINE);
252  }
253 
254  $html = $page_gui->getRawContent();
255  if ($a_mode == "edit") {
256  $par_id = $page_gui->getPageObject()->getParentId();
257  $info = "";
258  foreach (ilObject::_getAllReferences($par_id) as $ref_id) {
259  if ($this->access->checkAccess("write", "", $ref_id)) {
260  $info = " " . $lng->txt("title") . ": " . ilMediaPoolItem::lookupTitle($page_gui->getPageObject()->getId()) .
261  ", " . $lng->txt("obj_mep") . ": <a href='" . ilLink::_getLink($ref_id) . "'>" . ilObject::_lookupTitle($par_id) . "</a>";
262  }
263  }
264  $html = '<p class="small light">' . $lng->txt("copg_snippet_cannot_be_edited") . $info . '</p>' . $html;
265  }
266  } else {
267  if ($a_mode == "edit") {
268  if ($param[2] <= 0) {
269  $html = "// " . $lng->txt("cont_missing_snippet") . " //";
270  } else {
271  $html = "// " . $lng->txt("cont_snippet_from_another_installation") . " //";
272  }
273  }
274  }
275  $h2 = substr($a_output, 0, $start) .
276  $html .
277  substr($a_output, $end + 5);
278  $a_output = $h2;
279  $i++;
280  }
281 
282  $start = strpos($a_output, "{{{{{ContentInclude;", $start + 5);
283  $end = 0;
284  if (is_int($start)) {
285  $end = strpos($a_output, "}}}}}", $start);
286  }
287  }
288  return $a_output;
289  }
const IL_INST_ID
Definition: constants.php:40
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _getAllReferences(int $id)
get all reference ids for object ID
static lookupTitle(int $a_id)
$ref_id
Definition: ltiauth.php:67
static _lookupTitle(int $obj_id)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
$param
Definition: xapitoken.php:46
Class ilMediaPoolPage GUI class.
$i
Definition: metadata.php:41
+ Here is the call graph for this function:

◆ saveContentIncludeUsage()

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

save content include usages

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

References ilPageContentUsage\deleteAllUsages(), ilPageObject\getId(), ilPageObject\getLanguage(), ilPageObject\getParentType(), IL_INST_ID, and ilPageContentUsage\saveUsage().

177  : void {
178  $ci_ids = self::collectContentIncludes($a_page, $a_domdoc);
179  ilPageContentUsage::deleteAllUsages("incl", $a_page->getParentType() . ":pg", $a_page->getId(), $a_old_nr, $a_page->getLanguage());
180  foreach ($ci_ids as $ci_id) {
181  if ((int) $ci_id["inst_id"] <= 0 || $ci_id["inst_id"] == IL_INST_ID) {
183  "incl",
184  $ci_id["id"],
185  $a_page->getParentType() . ":pg",
186  $a_page->getId(),
187  $a_old_nr,
188  $a_page->getLanguage()
189  );
190  }
191  }
192  }
const IL_INST_ID
Definition: constants.php:40
static saveUsage(string $a_pc_type, int $a_pc_id, string $a_usage_type, int $a_usage_id, int $a_usage_hist_nr=0, string $a_lang="-")
static deleteAllUsages(string $a_pc_type, string $a_usage_type, int $a_usage_id, int $a_usage_hist_nr=0, string $a_lang="-")
+ Here is the call graph for this function:

◆ setContentId()

ilPCContentInclude::setContentId ( int  $a_id)

Set content id.

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

References setContentIncludeAttribute().

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

◆ setContentIncludeAttribute()

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

Set attribute of content include tag.

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

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

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

◆ setContentType()

ilPCContentInclude::setContentType ( string  $a_type)

Set content type.

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

References setContentIncludeAttribute().

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

◆ setInstId()

ilPCContentInclude::setInstId ( string  $a_id)

Set installation id.

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

References setContentIncludeAttribute().

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

◆ setNode()

ilPCContentInclude::setNode ( php4DOMElement  $a_node)

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

References php4DOMNode\first_child().

45  : void
46  {
47  parent::setNode($a_node); // this is the PageContent node
48  $this->incl_node = $a_node->first_child(); // this is the snippet node
49  }
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilPCContentInclude::$access
protected

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

◆ $incl_node

php4DOMElement ilPCContentInclude::$incl_node

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

◆ $lng

ilLanguage ilPCContentInclude::$lng
protected

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

Referenced by modifyPageContentPostXsl().


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