5 require_once(
"./Services/COPage/classes/class.ilPageContent.php");
38 $this->lng = $DIC->language();
39 $this->plugin_admin = $DIC[
"ilPluginAdmin"];
48 parent::setNode($a_node);
49 $this->plug_node = $a_node->first_child();
67 $this->plug_node = $this->dom->create_element(
"Plugged");
68 $this->plug_node = $this->node->append_child($this->plug_node);
69 $this->plug_node->set_attribute(
"PluginName", $a_plugin_name);
70 $this->plug_node->set_attribute(
"PluginVersion", $a_plugin_version);
80 if (!is_object($this->plug_node)) {
85 $children = $this->plug_node->child_nodes();
86 for (
$i = 0;
$i < count($children);
$i++) {
87 $this->plug_node->remove_child($children[
$i]);
90 foreach ($a_properties as $key => $value) {
91 $prop_node = $this->dom->create_element(
"PluggedProperty");
92 $prop_node = $this->plug_node->append_child($prop_node);
93 $prop_node->set_attribute(
"Name", $key);
95 $prop_node->set_content($value);
107 $properties = array();
109 if (is_object($this->plug_node)) {
111 $children = $this->plug_node->child_nodes();
112 for (
$i = 0;
$i < count($children);
$i++) {
113 if ($children[
$i]->node_name() ==
"PluggedProperty") {
114 $properties[$children[
$i]->get_attribute(
"Name")] =
115 $children[
$i]->get_content();
130 if (!empty($a_version)) {
131 $this->plug_node->set_attribute(
"PluginVersion", $a_version);
133 if ($this->plug_node->has_attribute(
"PluginVersion")) {
134 $this->plug_node->remove_attribute(
"PluginVersion");
146 if (is_object($this->plug_node)) {
147 return $this->plug_node->get_attribute(
"PluginVersion");
158 if (!empty($a_name)) {
159 $this->plug_node->set_attribute(
"PluginName", $a_name);
161 if ($this->plug_node->has_attribute(
"PluginName")) {
162 $this->plug_node->remove_attribute(
"PluginName");
174 if (is_object($this->plug_node)) {
175 return $this->plug_node->get_attribute(
"PluginName");
186 public static function handleCopiedPluggedContent(
ilPageObject $a_page, DOMDocument $a_domdoc)
189 $ilPluginAdmin = $DIC[
'ilPluginAdmin'];
191 $xpath =
new DOMXPath($a_domdoc);
192 $nodes = $xpath->query(
"//Plugged");
195 foreach ($nodes as
$node) {
196 $plugin_name = $node->getAttribute(
'PluginName');
197 $plugin_version = $node->getAttribute(
'PluginVersion');
199 if ($ilPluginAdmin->isActive(
IL_COMP_SERVICE,
"COPage",
"pgcp", $plugin_name)) {
201 $plugin_obj = $ilPluginAdmin->getPluginObject(
IL_COMP_SERVICE,
"COPage",
"pgcp", $plugin_name);
202 $plugin_obj->setPageObj($a_page);
204 $properties = array();
206 foreach ($node->childNodes as $child) {
207 $properties[$child->getAttribute(
'Name')] = $child->nodeValue;
212 $plugin_obj->onClone($properties, $plugin_version);
214 foreach ($node->childNodes as $child) {
215 $node->removeChild($child);
217 foreach ($properties as
$name => $value) {
218 $child =
new DOMElement(
'PluggedProperty', $value);
219 $node->appendChild($child);
220 $child->setAttribute(
'Name',
$name);
233 public static function handleDeletedPluggedNode(
ilPageObject $a_page, DOMNode $a_node)
236 $ilPluginAdmin = $DIC[
'ilPluginAdmin'];
238 $plugin_name = $a_node->getAttribute(
'PluginName');
239 $plugin_version = $a_node->getAttribute(
'PluginVersion');
241 if ($ilPluginAdmin->isActive(
IL_COMP_SERVICE,
"COPage",
"pgcp", $plugin_name)) {
243 $plugin_obj = $ilPluginAdmin->getPluginObject(
IL_COMP_SERVICE,
"COPage",
"pgcp", $plugin_name);
244 $plugin_obj->setPageObj($a_page);
246 $properties = array();
248 foreach ($a_node->childNodes as $child) {
249 $properties[$child->getAttribute(
'Name')] = $child->nodeValue;
253 $plugin_obj->onDelete($properties, $plugin_version);
267 $start = strpos($a_html,
"{{{{{Plugged<pl");
269 if (is_int($start)) {
270 $end = strpos($a_html,
"}}}}}", $start);
275 $param = substr($a_html, $start + 5, $end - $start - 5);
276 $param = str_replace(
' xmlns:xhtml="http://www.w3.org/1999/xhtml"',
"",
$param);
280 $plugin_version =
$param[2];
281 $properties = array();
288 if ($a_mode ==
"edit") {
289 $plugin_html =
'<div class="ilBox">' .
$lng->txt(
"content_plugin_not_activated") .
" (" . $plugin_name .
")</div>";
291 if ($ilPluginAdmin->isActive(
IL_COMP_SERVICE,
"COPage",
"pgcp", $plugin_name)) {
292 $plugin_obj = $ilPluginAdmin->getPluginObject(
298 $plugin_obj->setPageObj($this->
getPage());
299 $gui_obj = $plugin_obj->getUIClassInstance();
300 $plugin_html = $gui_obj->getElementHTML($a_mode, $properties, $plugin_version);
303 $a_html = substr($a_html, 0, $start) .
305 substr($a_html, $end + 5);
307 if (strlen($a_html) > $start + 5) {
308 $start = strpos($a_html,
"{{{{{Plugged<pl", $start + 5);
313 if (is_int($start)) {
314 $end = strpos($a_html,
"}}}}}", $start);
330 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
335 foreach ($pl_names as $pl_name) {
336 $plugin = $ilPluginAdmin->getPluginObject(
343 $pl_dir =
$plugin->getDirectory();
345 $pl_js_files =
$plugin->getJavascriptFiles($a_mode);
346 foreach ($pl_js_files as $pl_js_file) {
347 if (!is_int(strpos($pl_js_file,
"//"))) {
348 $pl_js_file = $pl_dir .
"/" . $pl_js_file;
350 if (!in_array($pl_js_file, $js_files)) {
351 $js_files[] = $pl_js_file;
366 $css_files = array();
368 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
373 foreach ($pl_names as $pl_name) {
374 $plugin = $ilPluginAdmin->getPluginObject(
381 $pl_dir =
$plugin->getDirectory();
383 $pl_css_files =
$plugin->getCssFiles($a_mode);
384 foreach ($pl_css_files as $pl_css_file) {
385 if (!is_int(strpos($pl_css_file,
"//"))) {
386 $pl_css_file = $pl_dir .
"/" . $pl_css_file;
388 if (!in_array($pl_css_file, $css_files)) {
389 $css_files[] = $pl_css_file;
setProperties($a_properties)
Set properties of plugged component.
getCssFiles($a_mode)
Get css files.
create( $a_pg_obj, $a_hier_id, $a_pc_id, $a_plugin_name, $a_plugin_version)
Create plugged node in xml.
init()
Init page content component.
getProperties()
Get properties of plugged component.
Class ilPCPlugged Plugged content object (see ILIAS DTD)
setType($a_type)
Set Type.
getPluginVersion()
Get version of plugged component.
setPluginVersion($a_version)
Set version of plugged component.
getPluginName()
Get name of plugged component.
setPluginName($a_name)
Set name of plugged component.
modifyPageContentPostXsl($a_html, $a_mode, $a_abstract_only=false)
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
getJavascriptFiles($a_mode)
Get javascript files.
setNode($a_node)
Set node.