4 define(
"IL_INSERT_BEFORE", 0);
5 define(
"IL_INSERT_AFTER", 1);
6 define(
"IL_INSERT_CHILD", 2);
8 define (
"IL_CHAPTER_TITLE",
"st_title");
9 define (
"IL_PAGE_TITLE",
"pg_title");
10 define (
"IL_NO_HEADER",
"none");
52 function ilPageObject($a_parent_type, $a_id = 0, $a_old_nr = 0, $a_halt =
true)
56 require_once(
"./Services/COPage/syntax_highlight/php/Beautifier/Init.php");
57 require_once(
"./Services/COPage/syntax_highlight/php/Output/Output_css.php");
59 $this->parent_type = $a_parent_type;
63 $this->contains_int_link =
false;
64 $this->needs_parsing =
false;
65 $this->update_listeners = array();
66 $this->update_listener_cnt = 0;
67 $this->dom_builded =
false;
68 $this->halt_on_error = $a_halt;
69 $this->page_not_found =
false;
70 $this->old_nr = $a_old_nr;
71 $this->layout_mode =
false;
72 $this->encoding =
"UTF-8";
74 array(
"PageContent",
"TableRow",
"TableData",
"ListItem",
"FileItem",
87 $this->halt_on_error = $a_halt;
97 $this->rendermd5 = $a_rendermd5;
107 return $this->rendermd5;
117 $this->renderedcontent = $a_renderedcontent;
127 return $this->renderedcontent;
137 $this->renderedtime = $a_renderedtime;
147 return $this->renderedtime;
157 $this->lastchange = $a_lastchange;
167 return $this->lastchange;
177 $this->layout_mode = $a_layout_mode;
198 $ilBench->start(
"ContentPresentation",
"ilPageObject_read");
201 if ($this->old_nr == 0)
203 $query =
"SELECT * FROM page_object WHERE page_id = ".$ilDB->quote($this->
id,
"integer").
" ".
204 "AND parent_type=".$ilDB->quote($this->
getParentType(),
"text");
205 $pg_set = $this->ilias->db->query(
$query);
206 $this->page_record = $ilDB->fetchAssoc($pg_set);
207 $this->
setActive($this->page_record[
"active"]);
213 $query =
"SELECT * FROM page_history WHERE ".
214 "page_id = ".$ilDB->quote($this->
id,
"integer").
" ".
215 "AND parent_type=".$ilDB->quote($this->
getParentType(),
"text").
216 " AND nr = ".$ilDB->quote((
int) $this->old_nr,
"integer");
217 $pg_set = $ilDB->query(
$query);
218 $this->page_record = $ilDB->fetchAssoc($pg_set);
220 if (!$this->page_record)
222 if ($this->halt_on_error)
224 echo
"Error: Page ".$this->id.
" is not in database".
225 " (parent type ".$this->getParentType().
").";
exit;
229 $this->page_not_found =
true;
233 $this->xml = $this->page_record[
"content"];
234 $this->
setParentId($this->page_record[
"parent_id"]);
235 $this->last_change_user = $this->page_record[
"last_change_user"];
236 $this->create_user = $this->page_record[
"create_user"];
242 $ilBench->stop(
"ContentPresentation",
"ilPageObject_read");
251 static function _exists($a_parent_type, $a_id)
255 if (isset(self::$exists[$a_parent_type.
":".$a_id]))
258 return self::$exists[$a_parent_type.
":".$a_id];
261 $query =
"SELECT page_id FROM page_object WHERE page_id = ".$ilDB->quote($a_id,
"integer").
" ".
262 "AND parent_type= ".$ilDB->quote($a_parent_type,
"text");
264 $set = $ilDB->query(
$query);
265 if (
$row = $ilDB->fetchAssoc($set))
267 self::$exists[$a_parent_type.
":".$a_id] =
true;
272 self::$exists[$a_parent_type.
":".$a_id] =
false;
287 $query =
"SELECT page_id, is_empty FROM page_object WHERE page_id = ".$ilDB->quote($a_id,
"integer").
" ".
288 "AND parent_type= ".$ilDB->quote($a_parent_type,
"text");
290 $set = $ilDB->query(
$query);
291 if (
$row = $ilDB->fetchAssoc($set))
293 if (
$row[
"is_empty"] != 1)
305 if ($this->dom_builded && !$a_force)
312 $ilBench->start(
"ContentPresentation",
"ilPageObject_buildDom");
314 $ilBench->stop(
"ContentPresentation",
"ilPageObject_buildDom");
317 $path =
"//PageObject";
319 if (count(
$res->nodeset) == 1)
321 $this->node =&
$res->nodeset[0];
326 $this->dom_builded =
true;
361 $this->parent_id = $a_id;
371 $this->parent_type = $a_type;
382 $this->update_listeners[$cnt][
"object"] =& $a_object;
383 $this->update_listeners[$cnt][
"method"] = $a_method;
384 $this->update_listeners[$cnt][
"parameters"] = $a_parameters;
385 $this->update_listener_cnt++;
392 $object =& $this->update_listeners[$i][
"object"];
393 $method = $this->update_listeners[$i][
"method"];
394 $parameters = $this->update_listeners[$i][
"parameters"];
395 $object->$method($parameters);
406 $this->active = $a_active;
414 function getActive($a_check_scheduled_activation =
false)
416 if ($a_check_scheduled_activation && !$this->active)
418 include_once(
"./Services/Calendar/classes/class.ilDateTime.php");
427 return $this->active;
433 function _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation =
false)
437 $set = $ilDB->queryF(
"SELECT active, activation_start, activation_end FROM page_object WHERE page_id = %s".
438 " AND parent_type = %s",
439 array(
"integer",
"text"),
440 array($a_id, $a_parent_type));
441 $rec = $ilDB->fetchAssoc($set);
444 if (!$rec[
"active"] && $a_check_scheduled_activation)
446 if ($rec[
"n"] >= $rec[
"activation_start"] &&
447 $rec[
"n"] <= $rec[
"activation_end"])
453 return $rec[
"active"];
463 $set = $ilDB->queryF(
"SELECT active, activation_start, activation_end FROM page_object WHERE page_id = %s".
464 " AND parent_type = %s", array(
"integer",
"text"),
465 array($a_id, $a_parent_type));
466 $rec = $ilDB->fetchAssoc($set);
468 if (!$rec[
"active"] && $rec[
"activation_start"] !=
"")
479 function _writeActive($a_id, $a_parent_type, $a_active, $a_reset_scheduled_activation =
true)
483 if ($a_reset_scheduled_activation)
485 $st = $ilDB->manipulateF(
"UPDATE page_object SET active = %s, activation_start = %s, ".
486 " activation_end = %s WHERE page_id = %s".
487 " AND parent_type = %s", array(
"boolean",
"timestamp",
"timestamp",
"integer",
"text"),
488 array($a_active, null, null, $a_id, $a_parent_type));
492 $st = $ilDB->prepareManip(
"UPDATE page_object SET active = %s WHERE page_id = %s".
493 " AND parent_type = %s", array(
"boolean",
"integer",
"text"),
494 array($a_active, $a_id, $a_parent_type));
505 $res = $ilDB->query(
"SELECT parent_id FROM page_object WHERE page_id = ".$ilDB->quote($a_id,
"integer").
" ".
506 "AND parent_type=".$ilDB->quote($a_type,
"text"));
507 $rec = $ilDB->fetchAssoc(
$res);
508 return $rec[
"parent_id"];
519 $this->activationstart = $a_activationstart;
529 return $this->activationstart;
539 $this->activationend = $a_activationend;
549 return $this->activationend;
559 if (!is_object($cont_node))
563 switch($cont_node->node_name())
566 $child_node =& $cont_node->first_child();
568 switch($child_node->node_name())
571 require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
573 $par->setNode($cont_node);
574 $par->setHierId($a_hier_id);
575 $par->setPcId($a_pc_id);
579 if ($child_node->get_attribute(
"DataTable") ==
"y")
581 require_once(
"./Services/COPage/classes/class.ilPCDataTable.php");
583 $tab->setNode($cont_node);
584 $tab->setHierId($a_hier_id);
588 require_once(
"./Services/COPage/classes/class.ilPCTable.php");
590 $tab->setNode($cont_node);
591 $tab->setHierId($a_hier_id);
593 $tab->setPcId($a_pc_id);
597 if (
$_GET[
"pgEdMediaMode"] !=
"") {echo
"ilPageObject::error media";
exit;}
600 require_once(
"./Services/COPage/classes/class.ilPCMediaObject.php");
602 $mal_node =& $child_node->first_child();
604 $id_arr = explode(
"_", $mal_node->get_attribute(
"OriginId"));
605 $mob_id = $id_arr[count($id_arr) - 1];
615 $mob->readMediaObject($mob_id);
618 $mob->setNode($cont_node);
619 $mob->setHierId($a_hier_id);
620 $mob->setPcId($a_pc_id);
624 require_once(
"./Services/COPage/classes/class.ilPCList.php");
626 $list->setNode($cont_node);
627 $list->setHierId($a_hier_id);
628 $list->setPcId($a_pc_id);
632 require_once(
"./Services/COPage/classes/class.ilPCFileList.php");
634 $file_list->setNode($cont_node);
635 $file_list->setHierId($a_hier_id);
636 $file_list->setPcId($a_pc_id);
641 require_once(
"./Services/COPage/classes/class.ilPCQuestion.php");
643 $pc_question->setNode($cont_node);
644 $pc_question->setHierId($a_hier_id);
645 $pc_question->setPcId($a_pc_id);
649 require_once(
"./Services/COPage/classes/class.ilPCSection.php");
651 $sec->setNode($cont_node);
652 $sec->setHierId($a_hier_id);
653 $sec->setPcId($a_pc_id);
657 require_once(
"./Services/COPage/classes/class.ilPCResources.php");
659 $res->setNode($cont_node);
660 $res->setHierId($a_hier_id);
661 $res->setPcId($a_pc_id);
665 require_once(
"./Services/COPage/classes/class.ilPCMap.php");
667 $map->setNode($cont_node);
668 $map->setHierId($a_hier_id);
669 $map->setPcId($a_pc_id);
673 require_once(
"./Services/COPage/classes/class.ilPCTabs.php");
675 $map->setNode($cont_node);
676 $map->setHierId($a_hier_id);
677 $map->setPcId($a_pc_id);
681 require_once(
"./Services/COPage/classes/class.ilPCPlugged.php");
683 $plugged->setNode($cont_node);
684 $plugged->setHierId($a_hier_id);
685 $plugged->setPcId($a_pc_id);
690 require_once(
"./Services/COPage/classes/class.ilPCPlaceHolder.php");
692 $placeholder->setNode($cont_node);
693 $placeholder->setHierId($a_hier_id);
694 $placeholder->setPcId($a_pc_id);
697 case "ContentInclude":
698 require_once(
"./Services/COPage/classes/class.ilPCContentInclude.php");
700 $inc->setNode($cont_node);
701 $inc->setHierId($a_hier_id);
702 $inc->setPcId($a_pc_id);
708 require_once(
"./Services/COPage/classes/class.ilPCTableData.php");
710 $td->setNode($cont_node);
711 $td->setHierId($a_hier_id);
715 require_once(
"./Services/COPage/classes/class.ilPCListItem.php");
717 $td->setNode($cont_node);
718 $td->setHierId($a_hier_id);
722 require_once(
"./Services/COPage/classes/class.ilPCFileItem.php");
724 $file_item->setNode($cont_node);
725 $file_item->setHierId($a_hier_id);
729 require_once(
"./Services/COPage/classes/class.ilPCTab.php");
731 $tab->setNode($cont_node);
732 $tab->setHierId($a_hier_id);
741 if($a_hier_id ==
"pg")
750 $path =
"//*[@PCID = '$a_pc_id']";
752 if (count(
$res->nodeset) == 1)
754 $cont_node =&
$res->nodeset[0];
760 $path =
"//*[@HierId = '$a_hier_id']";
762 if (count(
$res->nodeset) == 1)
764 $cont_node =&
$res->nodeset[0];
774 $path =
"//*[@HierId = '$a_hier_id']";
776 if (count(
$res->nodeset) == 1)
799 $this->encoding = $a_encoding;
825 $enc_str = (!empty($this->encoding))
826 ?
"encoding=\"".$this->encoding.
"\""
828 return "<?xml version=\"1.0\" $enc_str ?>".
829 "<!DOCTYPE PageObject SYSTEM \"".ILIAS_ABSOLUTE_PATH.
"/xml/".$this->cur_dtd.
"\">".
844 $xml = $this->getXmlContent();
850 if ($a_new_question_copies)
855 $xml = $temp_dom->dump_mem(0, $this->encoding);
856 $xml = eregi_replace(
"<\?xml[^>]*>",
"",
$xml);
857 $xml = eregi_replace(
"<!DOCTYPE[^>]*>",
"",
$xml);
869 $path =
"//Question";
874 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
875 for ($i = 0; $i < count (
$res->nodeset); $i++)
877 $qref =
$res->nodeset[$i]->get_attribute(
"QRef");
886 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
891 $duplicate_id = $question->duplicate(
false);
892 $res->nodeset[$i]->set_attribute(
"QRef",
"il__qst_".$duplicate_id);
902 function getXMLFromDom($a_incl_head =
false, $a_append_mobs =
false, $a_append_bib =
false,
903 $a_append_str =
"", $a_omit_pageobject_tag =
false)
908 return $this->dom->dump_mem(0, $this->encoding);
913 if ($a_append_mobs || $a_append_bib || $a_append_link_info)
926 return "<dummy>".$this->dom->dump_node($this->node).$mobs.$bibs.$trans.$a_append_str.
"</dummy>";
930 if (is_object($this->dom))
932 if ($a_omit_pageobject_tag)
935 $childs =& $this->node->child_nodes();
936 for($i = 0; $i < count($childs); $i++)
938 $xml.= $this->dom->dump_node($childs[$i]);
944 $xml = $this->dom->dump_mem(0, $this->encoding);
945 $xml = eregi_replace(
"<\?xml[^>]*>",
"",
$xml);
946 $xml = eregi_replace(
"<!DOCTYPE[^>]*>",
"",
$xml);
970 $lang_vars = array(
"ed_insert_par",
"ed_insert_code",
971 "ed_insert_dtable",
"ed_insert_atable",
"ed_insert_media",
"ed_insert_list",
972 "ed_insert_filelist",
"ed_paste_clip",
"ed_edit",
"ed_insert_section",
973 "ed_edit_prop",
"ed_edit_files",
"ed_edit_data",
"ed_delete",
"ed_moveafter",
"ed_movebefore",
974 "ed_go",
"ed_new_row_after",
"ed_new_row_before",
975 "ed_new_col_after",
"ed_new_col_before",
"ed_delete_col",
976 "ed_delete_row",
"ed_class",
"ed_width",
"ed_align_left",
977 "ed_align_right",
"ed_align_center",
"ed_align_left_float",
978 "ed_align_right_float",
"ed_delete_item",
"ed_new_item_before",
979 "ed_new_item_after",
"ed_copy_clip",
"please_select",
"ed_split_page",
980 "ed_item_up",
"ed_item_down",
"ed_row_up",
"ed_row_down",
981 "ed_col_left",
"ed_col_right",
"ed_split_page_next",
"ed_enable",
982 "de_activate",
"ed_insert_repobj",
"ed_insert_map",
"ed_insert_tabs",
983 "ed_insert_pcqst",
"empty_question",
"ed_paste",
"question_placeh",
"media_placeh",
"text_placeh",
984 "ed_insert_plach",
"question_placehl",
"media_placehl",
"text_placehl",
985 "pc_flist",
"pc_par",
"pc_mob",
"pc_qst",
"pc_sec",
"pc_dtab",
"pc_tab",
986 "pc_code",
"pc_vacc",
"pc_hacc",
"pc_res",
"pc_map",
"pc_list",
"ed_insert_incl",
"pc_incl");
988 foreach ($lang_vars as $lang_var)
1002 $xml.=
"<LV name=\"$var\" value=\"".$lng->txt(
"cont_".$var).
"\"/>";
1007 require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
1009 $path =
"//Paragraph[1]";
1011 if (count(
$res->nodeset) > 0)
1013 $cont_node =&
$res->nodeset[0]->parent_node();
1015 $par->setNode($cont_node);
1016 return $par->getText();
1033 if (is_object(
$node))
1035 $node->set_content($a_content);
1050 $this->contains_int_link = $a_contains_link;
1065 if ($a_parse ===
true)
1067 $this->needs_parsing =
true;
1069 if ($a_parse ===
false)
1071 $this->needs_parsing =
false;
1088 $r = $ilias->db->query(
"SELECT * FROM object_reference WHERE ref_id=".
1089 $ilDB->quote(
$_GET[
"ref_id"],
'integer'));
1092 include_once(
"./classes/class.ilNestedSetXML.php");
1094 $bibs_xml = $nested->export(
$row[
"obj_id"],
"bib");
1109 $path =
"//MediaObject/MediaAlias";
1112 for($i = 0; $i < count(
$res->nodeset); $i++)
1114 $id_arr = explode(
"_",
$res->nodeset[$i]->get_attribute(
"OriginId"));
1115 $mob_id = $id_arr[count($id_arr) - 1];
1116 $mob_ids[$mob_id] = $mob_id;
1121 $path =
"//IntLink[@Type = 'MediaObject']";
1124 for($i = 0; $i < count(
$res->nodeset); $i++)
1126 if ((
$res->nodeset[$i]->get_attribute(
"TargetFrame") ==
"") ||
1129 $target =
$res->nodeset[$i]->get_attribute(
"Target");
1130 $id_arr = explode(
"_", $target);
1131 if (($id_arr[1] == IL_INST_ID) ||
1132 (substr($target, 0, 4) ==
"il__"))
1134 $mob_id = $id_arr[count($id_arr) - 1];
1137 $mob_ids[$mob_id] = $mob_id;
1154 $path =
"//IntLink";
1158 for($i = 0; $i < count(
$res->nodeset); $i++)
1160 $target =
$res->nodeset[$i]->get_attribute(
"Target");
1161 $type =
$res->nodeset[$i]->get_attribute(
"Type");
1162 $targetframe =
$res->nodeset[$i]->get_attribute(
"TargetFrame");
1163 $anchor =
$res->nodeset[$i]->get_attribute(
"Anchor");
1164 $links[$target.
":".
$type.
":".$targetframe.
":".$anchor] =
1165 array(
"Target" => $target,
"Type" =>
$type,
1166 "TargetFrame" => $targetframe,
"Anchor" => $anchor);
1169 if (
$type ==
"MediaObject" && $targetframe ==
"")
1171 if (substr($target, 0, 4) ==
"il__")
1173 $id_arr = explode(
"_", $target);
1174 $id = $id_arr[count($id_arr) - 1];
1177 foreach($med_links as
$key => $med_link)
1179 $links[
$key] = $med_link;
1190 $path =
"//MediaAlias";
1193 require_once(
"Services/MediaObjects/classes/class.ilMediaItem.php");
1194 for($i = 0; $i < count(
$res->nodeset); $i++)
1196 $oid =
$res->nodeset[$i]->get_attribute(
"OriginId");
1197 if (substr($oid, 0, 4) ==
"il__")
1199 $id_arr = explode(
"_", $oid);
1200 $id = $id_arr[count($id_arr) - 1];
1203 foreach($med_links as
$key => $med_link)
1205 $links[
$key] = $med_link;
1224 $path =
"//FileItem/Identifier";
1231 $path =
"//FileItem/Identifier";
1234 $file_ids = array();
1235 for($i = 0; $i < count(
$res->nodeset); $i++)
1237 $id_arr = explode(
"_",
$res->nodeset[$i]->get_attribute(
"Entry"));
1238 $file_id = $id_arr[count($id_arr) - 1];
1239 $file_ids[$file_id] = $file_id;
1255 require_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1256 foreach($mob_ids as $mob_id => $dummy)
1274 $path =
"//MediaObject/MediaAlias[@OriginId='il__mob_$a_mob_id']";
1276 $mal_node =&
$res->nodeset[$a_nr - 1];
1277 $mob_node =& $mal_node->parent_node();
1279 return $this->dom->dump_node($mob_node);
1290 $this->dom->validate(
$error);
1311 $this->hier_ids = array();
1312 $this->first_row_ids = array();
1313 $this->first_col_ids = array();
1314 $this->list_item_ids = array();
1315 $this->file_item_ids = array();
1322 foreach ($this->id_elements as $el)
1324 $path.= $sep.
"//".$el;
1329 for($i = 0; $i < count(
$res->nodeset); $i++)
1331 $cnode =
$res->nodeset[$i];
1332 $ctag = $cnode->node_name();
1336 while($cnode =& $cnode->previous_sibling())
1338 if (($cnode->node_type() == XML_ELEMENT_NODE)
1339 && $cnode->has_attribute(
"HierId"))
1341 $sib_hier_id = $cnode->get_attribute(
"HierId");
1347 if ($sib_hier_id !=
"")
1349 require_once(
"./Services/COPage/classes/class.ilPageContent.php");
1351 $res->nodeset[$i]->set_attribute(
"HierId", $node_hier_id);
1352 $this->hier_ids[] = $node_hier_id;
1353 if ($ctag ==
"TableData")
1355 if (substr($par_hier_id,strlen($par_hier_id)-2) ==
"_1")
1357 $this->first_row_ids[] = $node_hier_id;
1360 if ($ctag ==
"ListItem")
1362 $this->list_item_ids[] = $node_hier_id;
1364 if ($ctag ==
"FileItem")
1366 $this->file_item_ids[] = $node_hier_id;
1372 $cnode =
$res->nodeset[$i];
1374 while($cnode =& $cnode->parent_node())
1376 if (($cnode->node_type() == XML_ELEMENT_NODE)
1377 && $cnode->has_attribute(
"HierId"))
1379 $par_hier_id = $cnode->get_attribute(
"HierId");
1385 if (($par_hier_id !=
"") && ($par_hier_id !=
"pg"))
1387 $node_hier_id = $par_hier_id.
"_1";
1388 $res->nodeset[$i]->set_attribute(
"HierId", $node_hier_id);
1389 $this->hier_ids[] = $node_hier_id;
1390 if ($ctag ==
"TableData")
1392 $this->first_col_ids[] = $node_hier_id;
1393 if (substr($par_hier_id,strlen($par_hier_id)-2) ==
"_1")
1395 $this->first_row_ids[] = $node_hier_id;
1398 if ($ctag ==
"ListItem")
1400 $this->list_item_ids[] = $node_hier_id;
1402 if ($ctag ==
"FileItem")
1404 $this->file_item_ids[] = $node_hier_id;
1410 $node_hier_id =
"1";
1411 $res->nodeset[$i]->set_attribute(
"HierId", $node_hier_id);
1412 $this->hier_ids[] = $node_hier_id;
1419 $path =
"//PageObject";
1421 for($i = 0; $i < count(
$res->nodeset); $i++)
1423 $res->nodeset[$i]->set_attribute(
"HierId",
"pg");
1424 $this->hier_ids[] =
"pg";
1434 return $this->hier_ids;
1442 return $this->first_row_ids;
1450 return $this->first_col_ids;
1458 return $this->list_item_ids;
1466 return $this->file_item_ids;
1474 if(is_object($this->dom))
1477 $path =
"//*[@HierId]";
1479 for($i = 0; $i < count(
$res->nodeset); $i++)
1481 if (
$res->nodeset[$i]->has_attribute(
"HierId"))
1483 $res->nodeset[$i]->remove_attribute(
"HierId");
1496 $path =
"//FileItem";
1498 for($i = 0; $i < count(
$res->nodeset); $i++)
1500 $cnode =&
$res->nodeset[$i];
1501 $size_node =& $this->dom->create_element(
"Size");
1502 $size_node =& $cnode->append_child($size_node);
1504 $childs =& $cnode->child_nodes();
1506 for($j = 0; $j < count($childs); $j++)
1508 if ($childs[$j]->node_name() ==
"Identifier")
1510 if ($childs[$j]->has_attribute(
"Entry"))
1512 $entry = $childs[$j]->get_attribute(
"Entry");
1513 $entry_arr = explode(
"_", $entry);
1514 $id = $entry_arr[count($entry_arr) - 1];
1515 require_once(
"./Modules/File/classes/class.ilObjFile.php");
1520 $size_node->set_content(
$size);
1534 $path =
"//IntLink";
1536 for($i = 0; $i < count(
$res->nodeset); $i++)
1538 $target =
$res->nodeset[$i]->get_attribute(
"Target");
1539 $type =
$res->nodeset[$i]->get_attribute(
"Type");
1542 if ($new_target !==
false)
1544 $res->nodeset[$i]->set_attribute(
"Target", $new_target);
1549 IL_INST_ID > 0 &&
$type !=
"RepositoryItem")
1554 $res->nodeset[$i]->set_attribute(
"Target", $new_target);
1564 $path =
"//MediaAlias";
1568 for($i = 0; $i < count(
$res->nodeset); $i++)
1570 $orig_id =
$res->nodeset[$i]->get_attribute(
"OriginId");
1571 $id_arr = explode(
"_", $orig_id);
1572 $mob_id = $id_arr[count($id_arr) - 1];
1591 $path =
"//IntLink";
1593 for($i = 0; $i < count(
$res->nodeset); $i++)
1595 $target =
$res->nodeset[$i]->get_attribute(
"Target");
1596 $type =
$res->nodeset[$i]->get_attribute(
"Type");
1598 if ($a_from_to[$obj_id] > 0 && is_int(strpos($target,
"__")))
1602 $res->nodeset[$i]->set_attribute(
"Target",
"il__pg_".$a_from_to[$obj_id]);
1607 $res->nodeset[$i]->set_attribute(
"Target",
"il__st_".$a_from_to[$obj_id]);
1617 $path =
"//MediaAlias";
1620 require_once(
"Services/MediaObjects/classes/class.ilMediaItem.php");
1621 require_once(
"Services/COPage/classes/class.ilMediaAliasItem.php");
1623 for($i = 0; $i < count(
$res->nodeset); $i++)
1625 $media_object_node =
$res->nodeset[$i]->parent_node();
1626 $page_content_node = $media_object_node->parent_node();
1627 $c_hier_id = $page_content_node->get_attribute(
"HierId");
1631 $c_hier_id,
"Standard");
1632 $areas = $std_alias_item->getMapAreas();
1633 $correction_needed =
false;
1634 if (count($areas) > 0)
1637 foreach($areas as $area)
1639 if ($area[
"Type"] ==
"PageObject" ||
1640 $area[
"Type"] ==
"StructureObject")
1642 $t = $area[
"Target"];
1643 $tid = _extractObjIdOfTarget(
$t);
1644 if ($a_from_to[$tid] > 0)
1646 $correction_needed =
true;
1657 $oid =
$res->nodeset[$i]->get_attribute(
"OriginId");
1658 if (substr($oid, 0, 4) ==
"il__")
1660 $id_arr = explode(
"_", $oid);
1661 $id = $id_arr[count($id_arr) - 1];
1664 $med_item = $mob->getMediaItem(
"Standard");
1665 $med_areas = $med_item->getMapAreas();
1667 foreach($med_areas as $area)
1669 $link_type = ($area->getLinkType() ==
"int")
1674 "Nr" => $area->getNr(),
1675 "Shape" => $area->getShape(),
1676 "Coords" => $area->getCoords(),
1678 "LinkType" => $link_type,
1679 "Href" => $area->getHref(),
1680 "Title" => $area->getTitle(),
1681 "Target" => $area->getTarget(),
1682 "Type" => $area->getType(),
1683 "TargetFrame" => $area->getTargetFrame()
1687 if ($area->getType() ==
"PageObject" ||
1688 $area->getType() ==
"StructureObject")
1690 $t = $area->getTarget();
1692 if ($a_from_to[$tid] > 0)
1694 $correction_needed =
true;
1703 if ($correction_needed)
1706 $std_alias_item->deleteAllMapAreas();
1707 foreach($areas as $area)
1709 if ($area[
"Link"][
"LinkType"] ==
"IntLink")
1711 $target = $area[
"Link"][
"Target"];
1712 $type = $area[
"Link"][
"Type"];
1714 if ($a_from_to[$obj_id] > 0)
1718 $area[
"Link"][
"Target"] =
"il__pg_".$a_from_to[$obj_id];
1722 $area[
"Link"][
"Target"] =
"il__st_".$a_from_to[$obj_id];
1727 $std_alias_item->addMapArea($area[
"Shape"], $area[
"Coords"],
1728 $area[
"Link"][
"Title"],
1729 array(
"Type" => $area[
"Link"][
"Type"],
1730 "TargetFrame" => $area[
"Link"][
"TargetFrame"],
1731 "Target" => $area[
"Link"][
"Target"],
1732 "Href" => $area[
"Link"][
"Href"],
1733 "LinkType" => $area[
"Link"][
"LinkType"],
1750 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
1757 foreach($sources as $source)
1760 if ($source[
"type"] ==
"lm:pg")
1763 $page_obj =
new ilPageObject(
"lm", $source[
"id"],
false);
1764 if (!$page_obj->page_not_found)
1767 $page_obj->handleImportRepositoryLink($a_rep_import_id,
1768 $a_rep_type, $a_rep_ref_id);
1770 $page_obj->update();
1781 $path =
"//IntLink";
1784 for($i = 0; $i < count(
$res->nodeset); $i++)
1787 $target =
$res->nodeset[$i]->get_attribute(
"Target");
1788 $type =
$res->nodeset[$i]->get_attribute(
"Type");
1789 if ($target == $a_rep_import_id &&
$type ==
"RepositoryItem")
1792 $res->nodeset[$i]->set_attribute(
"Target",
1793 "il__".$a_rep_type.
"_".$a_rep_ref_id);
1828 $ilDB->insert(
"page_object", array(
1829 "page_id" => array(
"integer", $this->
getId()),
1830 "parent_id" => array(
"integer", $this->
getParentId()),
1833 "create_user" => array(
"integer", $ilUser->getId()),
1834 "last_change_user" => array(
"integer", $ilUser->getId()),
1835 "inactive_elements" => array(
"integer", $iel),
1836 "int_links" => array(
"integer", $inl),
1838 "last_change" => array(
"timestamp",
ilUtil::now())
1879 $ilDB->update(
"page_object", array(
1881 "parent_id" => array(
"integer", $this->
getParentId()),
1882 "last_change_user" => array(
"integer", $ilUser->getId()),
1883 "last_change" => array(
"timestamp",
ilUtil::now()),
1884 "active" => array(
"integer", $this->
getActive()),
1887 "inactive_elements" => array(
"integer", $iel),
1888 "int_links" => array(
"integer", $inl),
1890 "page_id" => array(
"integer", $this->
getId()),
1912 function update($a_validate =
true, $a_no_history =
false, $skip_handle_usages =
false)
1942 $old_set = $ilDB->query(
"SELECT * FROM page_object WHERE ".
1943 "page_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
1944 "parent_type = ".$ilDB->quote($this->getParentType(),
"text"));
1945 $last_nr_set = $ilDB->query(
"SELECT max(nr) as mnr FROM page_history WHERE ".
1946 "page_id = ".$ilDB->quote($this->getId(),
"integer").
" AND ".
1947 "parent_type = ".$ilDB->quote($this->getParentType(),
"text"));
1948 $last_nr = $ilDB->fetchAssoc($last_nr_set);
1949 if ($old_rec = $ilDB->fetchAssoc($old_set))
1952 if (($content != $old_rec[
"content"]) && !$a_no_history &&
1955 if ($old_rec[
"content"] !=
"<PageObject></PageObject>")
1957 $ilDB->manipulateF(
"DELETE FROM page_history WHERE ".
1958 "page_id = %s AND parent_type = %s AND hdate = %s",
1959 array(
"integer",
"text",
"timestamp"),
1960 array($old_rec[
"page_id"], $old_rec[
"parent_type"], $old_rec[
"last_change"]));
1961 $ilDB->insert(
"page_history", array(
1962 "page_id" => array(
"integer", $old_rec[
"page_id"]),
1963 "parent_type" => array(
"text", $old_rec[
"parent_type"]),
1964 "hdate" => array(
"timestamp", $old_rec[
"last_change"]),
1965 "parent_id" => array(
"integer", $old_rec[
"parent_id"]),
1966 "content" => array(
"clob", $old_rec[
"content"]),
1967 "user_id" => array(
"integer", $old_rec[
"last_change_user"]),
1969 "nr" => array(
"integer", (
int) $last_nr[
"mnr"] + 1)
1983 $this->
saveMobUsage($old_rec[
"content"], $last_nr[
"mnr"] + 1);
1985 $this->
saveFileUsage($old_rec[
"content"], $last_nr[
"mnr"] + 1);
1987 $this->history_saved =
true;
1991 $this->history_saved =
true;
1996 $em = (trim($content) ==
"<PageObject/>")
2016 $ilDB->update(
"page_object", array(
2017 "content" => array(
"clob", $content),
2018 "parent_id" => array(
"integer", $this->
getParentId()),
2019 "last_change_user" => array(
"integer", $ilUser->getId()),
2020 "last_change" => array(
"timestamp",
ilUtil::now()),
2021 "is_empty" => array(
"integer", $em),
2022 "active" => array(
"integer", $this->
getActive()),
2025 "inactive_elements" => array(
"integer", $iel),
2026 "int_links" => array(
"integer", $inl),
2028 "page_id" => array(
"integer", $this->
getId()),
2041 if (!$skip_handle_usages)
2044 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2049 foreach($mob_ids as $mob)
2054 $usages = $mob_obj->getUsages(
false);
2055 if (count($usages) == 0)
2063 include_once(
"./Modules/File/classes/class.ilObjFile.php");
2067 foreach($file_ids as
$file)
2071 $file_obj =
new ilObjFile($file,
false);
2072 $usages = $file_obj->getUsages();
2073 if (count($usages) == 0)
2075 if ($file_obj->getMode() ==
"filelist")
2077 $file_obj->delete();
2114 if (!$this->page_not_found)
2137 include_once(
"./Modules/File/classes/class.ilObjFile.php");
2141 $ilDB->manipulate(
"DELETE FROM page_object ".
2142 "WHERE page_id = ".$ilDB->quote($this->getId(),
"integer").
2143 " AND parent_type= ".$ilDB->quote($this->getParentType(),
"text"));
2147 foreach (
$mobs as $mob_id)
2151 $GLOBALS[
'ilLog']->write(__METHOD__.
': Type mismatch. Ignoring mob with id: '.$mob_id);
2162 include_once(
"./Modules/File/classes/class.ilObjFile.php");
2163 foreach (
$files as $file_id)
2167 $file_obj =&
new ilObjFile($file_id,
false);
2168 $file_obj->delete();
2189 $keywords = array();
2195 for ($i=0; $i < count(
$res->nodeset); $i++)
2197 $k = trim(strip_tags(
$res->nodeset[$i]->get_content()));
2198 if (!in_array($k, $keywords))
2208 $meta_id = $this->
getId();
2210 include_once(
"./Services/MetaData/classes/class.ilMD.php");
2211 $md_obj =
new ilMD($meta_rep_id, $meta_id, $meta_type);
2212 $mkeywords = array();
2214 if(is_object($md_section = $md_obj->getGeneral()))
2216 foreach($ids = $md_section->getKeywordIds() as
$id)
2218 $md_key = $md_section->getKeyword(
$id);
2219 $mkeywords[] = strtolower($md_key->getKeyword());
2222 $lang = $md_key->getKeywordLanguageCode();
2228 foreach($ids = $md_section->getLanguageIds() as
$id)
2230 $md_lang = $md_section->getLanguage(
$id);
2233 $lang = $md_lang->getLanguageCode();
2237 foreach ($keywords as $k)
2239 if (!in_array(strtolower($k), $mkeywords))
2241 if (trim($k) !=
"" &&
$lang !=
"")
2243 $md_key = $md_section->addKeyword();
2248 $mkeywords[] = strtolower($k);
2265 $path =
"//MediaAlias";
2268 for ($i=0; $i < count(
$res->nodeset); $i++)
2270 $id_arr = explode(
"_",
$res->nodeset[$i]->get_attribute(
"OriginId"));
2271 $mob_id = $id_arr[count($id_arr) - 1];
2274 $usages[$mob_id] =
true;
2280 $path =
"//MediaObject/MetaData/General/Identifier";
2282 for ($i=0; $i < count(
$res->nodeset); $i++)
2284 $mob_entry =
$res->nodeset[$i]->get_attribute(
"Entry");
2285 $mob_arr = explode(
"_", $mob_entry);
2286 $mob_id = $mob_arr[count($mob_arr) - 1];
2289 $usages[$mob_id] =
true;
2295 $path =
"//IntLink[@Type='MediaObject']";
2297 for ($i=0; $i < count(
$res->nodeset); $i++)
2299 $mob_target =
$res->nodeset[$i]->get_attribute(
"Target");
2300 $mob_arr = explode(
"_", $mob_target);
2301 $mob_id = $mob_arr[count($mob_arr) - 1];
2304 $usages[$mob_id] =
true;
2308 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2310 foreach($usages as $mob_id => $val)
2322 include_once(
"./Modules/File/classes/class.ilObjFile.php");
2324 foreach($file_ids as $file_id)
2335 include_once(
"./Services/COPage/classes/class.ilPageContentUsage.php");
2338 foreach($ci_ids as $ci_id)
2340 if ((
int) $ci_id[
"inst_id"] <= 0)
2357 $path =
"//ContentInclude";
2364 $path =
"//ContentInclude";
2368 for($i = 0; $i < count(
$res->nodeset); $i++)
2370 $type =
$res->nodeset[$i]->get_attribute(
"ContentType");
2371 $id =
$res->nodeset[$i]->get_attribute(
"ContentId");
2372 $inst_id =
$res->nodeset[$i]->get_attribute(
"InstId");
2373 $ci_ids[
$type.
":".
$id.
":".$inst_id] = array(
2374 "type" =>
$type,
"id" =>
$id,
"inst_id" => $inst_id);
2394 $path =
"//Paragraph | //Section | //MediaAlias | //FileItem".
2395 " | //Table | //TableData | //Tabs | //List";
2398 for ($i=0; $i < count(
$res->nodeset); $i++)
2400 switch (
$res->nodeset[$i]->node_name())
2403 $sname =
$res->nodeset[$i]->get_attribute(
"Characteristic");
2404 $stype =
"text_block";
2409 $sname =
$res->nodeset[$i]->get_attribute(
"Characteristic");
2415 $sname =
$res->nodeset[$i]->get_attribute(
"Class");
2416 $stype =
"media_cont";
2421 $sname =
$res->nodeset[$i]->get_attribute(
"Class");
2422 $stype =
"flist_li";
2427 $sname =
$res->nodeset[$i]->get_attribute(
"Template");
2430 $sname =
$res->nodeset[$i]->get_attribute(
"Class");
2442 $sname =
$res->nodeset[$i]->get_attribute(
"Class");
2443 $stype =
"table_cell";
2448 $sname =
$res->nodeset[$i]->get_attribute(
"Template");
2451 if (
$res->nodeset[$i]->get_attribute(
"Type") ==
"HorizontalAccordion")
2453 $stype =
"haccordion";
2455 if (
$res->nodeset[$i]->get_attribute(
"Type") ==
"VerticalAccordion")
2457 $stype =
"vaccordion";
2464 $sname =
$res->nodeset[$i]->get_attribute(
"Class");
2465 if (
$res->nodeset[$i]->get_attribute(
"Type") ==
"Ordered")
2476 if ($sname !=
"" && $stype !=
"")
2478 $usages[$sname.
":".$stype.
":".$template] = array(
"sname" => $sname,
2479 "stype" => $stype,
"template" => $template);
2483 $ilDB->manipulate(
"DELETE FROM page_style_usage WHERE ".
2484 " page_id = ".$ilDB->quote($this->getId(),
"integer").
2485 " AND page_type = ".$ilDB->quote($this->getParentType(),
"text").
2486 " AND page_nr = ".$ilDB->quote($a_old_nr,
"integer")
2489 foreach ($usages as $u)
2491 $ilDB->manipulate(
"INSERT INTO page_style_usage ".
2492 "(page_id, page_type, page_nr, template, stype, sname) VALUES (".
2493 $ilDB->quote($this->getId(),
"integer").
",".
2494 $ilDB->quote($this->getParentType(),
"text").
",".
2495 $ilDB->quote($a_old_nr,
"integer").
",".
2496 $ilDB->quote($u[
"template"],
"integer").
",".
2497 $ilDB->quote($u[
"stype"],
"text").
",".
2498 $ilDB->quote($u[
"sname"],
"text").
2509 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2510 include_once(
"./Modules/File/classes/class.ilObjFile.php");
2530 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
2535 $path =
"//IntLink";
2537 for ($i=0; $i < count(
$res->nodeset); $i++)
2539 $link_type =
$res->nodeset[$i]->get_attribute(
"Type");
2543 case "StructureObject":
2551 case "GlossaryItem":
2559 case "RepositoryItem":
2564 $target =
$res->nodeset[$i]->get_attribute(
"Target");
2569 if (is_int(strpos($target,
"__")))
2603 for ($i=0; $i < count(
$res->nodeset); $i++)
2605 $name =
$res->nodeset[$i]->get_attribute(
"Name");
2606 if (trim(
$name) !=
"" && !in_array(
$name, $saved))
2622 $st = $ilDB->prepareManip(
"DELETE FROM page_anchor WHERE page_parent_type = ? ".
2623 " AND page_id = ?", array(
"text",
"integer"));
2624 $ilDB->execute($st, array($a_parent_type, $a_page_id));
2630 static function _saveAnchor($a_parent_type, $a_page_id, $a_anchor_name)
2634 $st = $ilDB->prepareManip(
"INSERT INTO page_anchor (page_parent_type, page_id, anchor_name) ".
2635 " VALUES (?,?,?) ", array(
"text",
"integer",
"text"));
2636 $ilDB->execute($st, array($a_parent_type, $a_page_id, $a_anchor_name));
2646 $st = $ilDB->prepare(
"SELECT * FROM page_anchor WHERE page_parent_type = ? ".
2647 " AND page_id = ?", array(
"text",
"integer"));
2648 $set = $ilDB->execute($st, array($a_parent_type, $a_page_id));
2650 while ($rec = $ilDB->fetchAssoc($set))
2652 $anchors[] = $rec[
"anchor_name"];
2675 $curr_node->unlink_node($curr_node);
2692 if (!is_array($a_hids))
2696 foreach($a_hids as $a_hid)
2698 $a_hid = explode(
":", $a_hid);
2701 if (is_object($curr_node))
2703 $parent_node = $curr_node->parent_node();
2704 if ($parent_node->node_name() !=
"TableRow")
2706 $curr_node->unlink_node($curr_node);
2736 if (!is_array($a_hids))
2741 $time = date(
"Y-m-d H:i:s", time());
2743 $hier_ids = array();
2745 foreach($a_hids as $a_hid)
2751 $a_hid = explode(
":", $a_hid);
2755 foreach($hier_ids as $h)
2757 if($h.
"_" == substr($a_hid[0], 0, strlen($h) + 1))
2759 $skip[] = $a_hid[0];
2761 if($a_hid[0].
"_" == substr($h, 0, strlen($a_hid[0]) + 1))
2766 $pc_id[$a_hid[0]] = $a_hid[1];
2767 if ($a_hid[0] !=
"")
2769 $hier_ids[$a_hid[0]] = $a_hid[0];
2772 foreach (
$skip as $s)
2774 unset($hier_ids[$s]);
2776 include_once(
"./Services/COPage/classes/class.ilPageContent.php");
2779 foreach($hier_ids as $hid)
2782 if (is_object($curr_node))
2784 if ($curr_node->node_name() ==
"PageContent")
2786 $content = $this->dom->dump_node($curr_node);
2788 $content = eregi_replace(
"PCID=\"[a-z0-9]*\"",
"",$content);
2789 $content = eregi_replace(
"HierId=\"[a-z0-9_]*\"",
"",$content);
2791 $ilUser->addToPCClipboard($content, $time, $nr);
2796 include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
2807 $a_hid = explode(
":", $a_hier_id);
2808 $content = $ilUser->getPCClipboardContent();
2812 for ($i = count($content) - 1; $i >= 0; $i--)
2816 $temp_dom =
domxml_open_mem(
'<?xml version="1.0" encoding="UTF-8"?>'.$c,
2822 $path =
"//PageContent";
2824 if (count(
$res->nodeset) > 0)
2826 $new_pc_node =
$res->nodeset[0];
2827 $cloned_pc_node = $new_pc_node->clone_node (
true);
2828 $cloned_pc_node->unlink_node ($cloned_pc_node);
2848 if (!is_array($a_hids))
2852 $obj = & $this->content_obj;
2854 foreach($a_hids as $a_hid)
2856 $a_hid = explode(
":", $a_hid);
2859 if (is_object($curr_node))
2861 if ($curr_node->node_name() ==
"PageContent")
2864 if ($cont_obj->isEnabled ())
2865 $cont_obj->disable ();
2867 $cont_obj->enable ();
2891 foreach ($hier_ids as $hier_id)
2894 if (!is_int(strpos($hier_id,
"_")))
2896 if ($hier_id !=
"pg" && $hier_id >= $a_hid)
2899 $curr_node->unlink_node($curr_node);
2921 foreach ($hier_ids as $hier_id)
2924 if (!is_int(strpos($hier_id,
"_")))
2926 if ($hier_id !=
"pg" && $hier_id < $a_hid)
2929 $curr_node->unlink_node($curr_node);
2949 $hier_ids = $a_source_page->getHierIds();
2951 $copy_ids = array();
2954 foreach ($hier_ids as $hier_id)
2957 if (!is_int(strpos($hier_id,
"_")))
2959 if ($hier_id !=
"pg" && $hier_id >= $a_hid)
2961 $copy_ids[] = $hier_id;
2967 $parent_node =& $a_target_page->getContentNode(
"pg");
2968 $target_dom =& $a_target_page->getDom();
2969 $parent_childs =& $parent_node->child_nodes();
2970 $cnt_parent_childs = count($parent_childs);
2972 $first_child =& $parent_childs[0];
2973 foreach($copy_ids as $copy_id)
2975 $source_node =& $a_source_page->getContentNode($copy_id);
2977 $new_node =& $source_node->clone_node(
true);
2978 $new_node->unlink_node($new_node);
2980 $source_node->unlink_node($source_node);
2982 if($cnt_parent_childs == 0)
2984 $new_node =& $parent_node->append_child($new_node);
2989 $new_node =& $first_child->insert_before($new_node, $first_child);
2991 $parent_childs =& $parent_node->child_nodes();
2996 $a_target_page->update();
2997 $a_source_page->update();
3008 $curr_name = $curr_node->node_name();
3009 if (($curr_name ==
"TableData") || ($curr_name ==
"PageObject") ||
3010 ($curr_name ==
"ListItem") || ($curr_name ==
"Section")
3011 || ($curr_name ==
"Tab"))
3016 $hid = $curr_node->get_attribute(
"HierId");
3025 $pos = explode(
"_", $a_pos);
3026 $target_pos = array_pop($pos);
3027 $parent_pos = implode($pos,
"_");
3031 $parent_pos = $a_pos;
3035 if($parent_pos !=
"")
3041 $parent_node =& $this->
getNode();
3045 $parent_childs =& $parent_node->child_nodes();
3046 $cnt_parent_childs = count($parent_childs);
3052 $new_node =& $a_cont_obj->getNode();
3056 if($succ_node =& $curr_node->next_sibling())
3058 $new_node =& $succ_node->insert_before($new_node, $succ_node);
3063 $new_node =& $parent_node->append_child($new_node);
3065 $a_cont_obj->setNode($new_node);
3070 $new_node =& $a_cont_obj->getNode();
3072 $new_node =& $succ_node->insert_before($new_node, $succ_node);
3073 $a_cont_obj->setNode($new_node);
3079 $new_node =& $a_cont_obj->getNode();
3080 if($cnt_parent_childs == 0)
3082 $new_node =& $parent_node->append_child($new_node);
3086 $new_node =& $parent_childs[0]->insert_before($new_node, $parent_childs[0]);
3088 $a_cont_obj->setNode($new_node);
3095 $sub_nodes = $curr_node->child_nodes() ;
3096 foreach ( $sub_nodes as $sub_node ) {
3097 if ($sub_node->node_name() ==
"PlaceHolder") {
3098 $curr_node->unlink_node();
3111 $curr_name = $curr_node->node_name();
3112 if (($curr_name ==
"TableData") || ($curr_name ==
"PageObject") ||
3113 ($curr_name ==
"ListItem") || ($curr_name ==
"Section")
3114 || ($curr_name ==
"Tab"))
3119 $hid = $curr_node->get_attribute(
"HierId");
3127 $pos = explode(
"_", $a_pos);
3128 $target_pos = array_pop($pos);
3129 $parent_pos = implode($pos,
"_");
3133 $parent_pos = $a_pos;
3137 if($parent_pos !=
"")
3143 $parent_node =& $this->
getNode();
3147 $parent_childs =& $parent_node->child_nodes();
3148 $cnt_parent_childs = count($parent_childs);
3155 if($succ_node = $curr_node->next_sibling())
3157 $a_cont_node = $succ_node->insert_before($a_cont_node, $succ_node);
3161 $a_cont_node = $parent_node->append_child($a_cont_node);
3169 $a_cont_node = $succ_node->insert_before($a_cont_node, $succ_node);
3176 if($cnt_parent_childs == 0)
3178 $a_cont_node = $parent_node->append_child($a_cont_node);
3182 $a_cont_node = $parent_childs[0]->insert_before($a_cont_node, $parent_childs[0]);
3195 if($a_source == $a_target)
3202 $source_node =& $content->getNode();
3203 $clone_node =& $source_node->clone_node(
true);
3209 $content->setNode($clone_node);
3221 if($a_source == $a_target)
3228 $source_node =& $content->getNode();
3229 $clone_node =& $source_node->clone_node(
true);
3235 $content->setNode($clone_node);
3245 $a_content = eregi_replace(
"\[com\]",
"<Comment>",$a_content);
3246 $a_content = eregi_replace(
"\[\/com\]",
"</Comment>",$a_content);
3247 $a_content = eregi_replace(
"\[emp]",
"<Emph>",$a_content);
3248 $a_content = eregi_replace(
"\[\/emp\]",
"</Emph>",$a_content);
3249 $a_content = eregi_replace(
"\[str]",
"<Strong>",$a_content);
3250 $a_content = eregi_replace(
"\[\/str\]",
"</Strong>",$a_content);
3261 $path =
"//IntLink";
3263 for($i = 0; $i < count(
$res->nodeset); $i++)
3265 $target =
$res->nodeset[$i]->get_attribute(
"Target");
3266 $type =
$res->nodeset[$i]->get_attribute(
"Type");
3268 if (substr($target, 0, 4) ==
"il__")
3270 $id = substr($target, 4, strlen($target) - 4);
3273 if ($a_res_ref_to_obj_id &&
$type ==
"RepositoryItem")
3275 $id_arr = explode(
"_",
$id);
3280 $id = $otype.
"_".$obj_id;
3283 $new_target =
"il_".$a_inst.
"_".
$id;
3284 $res->nodeset[$i]->set_attribute(
"Target", $new_target);
3291 $path =
"//MediaAlias";
3293 for($i = 0; $i < count(
$res->nodeset); $i++)
3295 $origin_id =
$res->nodeset[$i]->get_attribute(
"OriginId");
3296 if (substr($origin_id, 0, 4) ==
"il__")
3298 $new_id =
"il_".$a_inst.
"_".substr($origin_id, 4, strlen($origin_id) - 4);
3299 $res->nodeset[$i]->set_attribute(
"OriginId", $new_id);
3306 $path =
"//FileItem/Identifier";
3308 for($i = 0; $i < count(
$res->nodeset); $i++)
3310 $origin_id =
$res->nodeset[$i]->get_attribute(
"Entry");
3311 if (substr($origin_id, 0, 4) ==
"il__")
3313 $new_id =
"il_".$a_inst.
"_".substr($origin_id, 4, strlen($origin_id) - 4);
3314 $res->nodeset[$i]->set_attribute(
"Entry", $new_id);
3321 $path =
"//Question";
3323 for($i = 0; $i < count(
$res->nodeset); $i++)
3325 $qref =
$res->nodeset[$i]->get_attribute(
"QRef");
3327 if (substr($qref, 0, 4) ==
"il__")
3329 $new_id =
"il_".$a_inst.
"_".substr($qref, 4, strlen($qref) - 4);
3331 $res->nodeset[$i]->set_attribute(
"QRef", $new_id);
3349 require_once(
"./Services/COPage/syntax_highlight/php/HFile/HFile_".$proglang.
".php");
3350 $classname =
"HFile_$proglang";
3351 $h_instance =
new $classname();
3352 if ($autoindent ==
"n") {
3353 $h_instance ->notrim = 1;
3354 $h_instance ->indent = array (
"");
3355 $h_instance ->unindent = array (
"");
3359 $a_text = $highlighter->highlight_text(html_entity_decode($a_text));
3365 return file_exists (
"Services/COPage/syntax_highlight/php/HFile/HFile_".$hfile_ext.
".php");
3376 $path =
"//Paragraph";
3378 for($i = 0; $i < count(
$res->nodeset); $i++)
3380 $context_node =
$res->nodeset[$i];
3381 $char = $context_node->get_attribute(
'Characteristic');
3383 if ($char !=
"Code")
3386 $n = $context_node->parent_node();
3387 $char = $context_node->get_attribute(
'Characteristic');
3388 $subchar = $context_node->get_attribute(
'SubCharacteristic');
3389 $showlinenumbers = $context_node->get_attribute(
'ShowLineNumbers');
3390 $downloadtitle = $context_node->get_attribute(
'DownloadTitle');
3391 $autoindent = $context_node->get_attribute(
'AutoIndent');
3396 $childs = $context_node->child_nodes();
3398 for($j=0; $j<count($childs); $j++)
3400 $content .= $this->dom->dump_node($childs[$j]);
3403 while ($context_node->has_child_nodes ())
3405 $node_del = $context_node->first_child ();
3406 $context_node->remove_child ($node_del);
3409 $content = str_replace(
"<br />",
"<br/>", utf8_decode($content) );
3410 $content = str_replace(
"<br/>",
"\n", $content);
3411 $rownums = count(split (
"\n",$content));
3413 $plain_content = html_entity_decode($content);
3414 $plain_content = preg_replace (
"/\&#x([1-9a-f]{2});?/ise",
"chr (base_convert (\\1, 16, 10))",$plain_content);
3415 $plain_content = preg_replace (
"/\&#(\d+);?/ise",
"chr (\\1)",$plain_content);
3416 $content = utf8_encode($this->
highlightText($plain_content, $subchar, $autoindent));
3418 $content = str_replace(
"&lt;",
"<", $content);
3419 $content = str_replace(
"&gt;",
">", $content);
3422 $rows =
"<tr valign=\"top\">";
3427 if (strcmp($showlinenumbers,
"y")==0)
3429 $linenumbers =
"<td nowrap=\"nowrap\" class=\"ilc_LineNumbers\" >";
3430 $linenumbers .=
"<pre class=\"ilc_Code\">";
3432 for ($j=0; $j < $rownums; $j++)
3434 $indentno = strlen($rownums) - strlen($j+1) + 2;
3435 $rownumeration = ($j+1);
3436 $linenumbers .=
"<span class=\"ilc_LineNumber\">$rownumeration</span>";
3437 if ($j < $rownums-1)
3439 $linenumbers .=
"\n";
3442 $linenumbers .=
"</pre>";
3443 $linenumbers .=
"</td>";
3446 $rows .= $linenumbers.
"<td class=\"ilc_Sourcecode\"><pre class=\"ilc_Code\">".$content.
"</pre></td>";
3451 $newcontent = str_replace(
"\n",
"<br/>",$rows);
3453 $newcontent = str_replace(
"<br/><br/>",
"<br/> <br/>",$newcontent);
3455 $newcontent = str_replace(
"<br/><br/>",
"<br/> <br/>",$newcontent);
3460 $newcontent = str_replace(
"{",
"{", $newcontent);
3461 $newcontent = str_replace(
"}",
"}", $newcontent);
3464 $a_output = str_replace(
"[[[[[Code;".($i + 1).
"]]]]]", $newcontent, $a_output);
3466 if ($outputmode !=
"presentation" && is_object($this->offline_handler)
3467 && trim($downloadtitle) !=
"")
3470 $this->offline_handler->handleCodeParagraph ($this->
id, $i + 1, $downloadtitle, $plain_content);
3487 foreach ($this->id_elements as $el)
3489 $path.= $sep.
"//".$el.
"[not(@PCID)]";
3496 if (count (
$res->nodeset) > 0)
3514 foreach ($this->id_elements as $el)
3516 $path.= $sep.
"//".$el.
"[@PCID]";
3524 for ($i = 0; $i < count (
$res->nodeset); $i++)
3527 $pcids[] =
$node->get_attribute(
"PCID");
3532 foreach ($this->id_elements as $el)
3534 $path.= $sep.
"//".$el.
"[not(@PCID)]";
3540 for ($i = 0; $i < count (
$res->nodeset); $i++)
3543 $id = ilUtil::randomHash(10, $pcids);
3546 $res->nodeset[$i]->set_attribute(
"PCID",
$id);
3556 $this->addHierIds();
3560 $path =
"//PageContent";
3565 require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
3566 for ($i = 0; $i < count (
$res->nodeset); $i++)
3568 $hier_id =
$res->nodeset[$i]->get_attribute(
"HierId");
3569 $pc_id =
$res->nodeset[$i]->get_attribute(
"PCID");
3570 $dump = $mydom->dump_node(
$res->nodeset[$i]);
3571 if (($hpos = strpos($dump,
' HierId="'.$hier_id.
'"')) > 0)
3573 $dump = substr($dump, 0, $hpos).
3574 substr($dump, $hpos + strlen(
' HierId="'.$hier_id.
'"'));
3577 $childs =
$res->nodeset[$i]->child_nodes();
3579 if ($childs[0] && $childs[0]->node_name() ==
"Paragraph")
3581 $content = $mydom->dump_node($childs[0]);
3582 $content = substr($content, strpos($content,
">") + 1,
3583 strrpos($content,
"<") - (strpos($content,
">") + 1));
3591 array(
"hier_id" => $hier_id,
"hash" => md5($dump),
"content" => $content);
3606 $path =
"//Question";
3611 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
3612 for ($i = 0; $i < count (
$res->nodeset); $i++)
3614 $qref =
$res->nodeset[$i]->get_attribute(
"QRef");
3619 if (!($inst_id > 0))
3641 $path =
"/descendant::Paragraph[position() = $par_id]";
3645 if (count (
$res->nodeset) != 1)
3646 die (
"Should not happen");
3648 $context_node =
$res->nodeset[0];
3652 $childs = $context_node->child_nodes();
3654 for($j=0; $j<count($childs); $j++)
3656 $content .= $mydom->dump_node($childs[$j]);
3659 $content = str_replace(
"<br />",
"\n", $content);
3660 $content = str_replace(
"<br/>",
"\n", $content);
3662 $plain_content = html_entity_decode($content);
3679 $xsl = file_get_contents(
"./Services/COPage/xsl/page_fo.xsl");
3680 $args = array(
'/_xml' =>
$xml,
'/_xsl' => $xsl );
3689 $fo = str_replace(
"\n",
"", $fo);
3690 $fo = str_replace(
"<br/>",
"<br>", $fo);
3691 $fo = str_replace(
"<br>",
"\n", $fo);
3696 $fo = substr($fo, strpos($fo,
">") + 1);
3702 $this->offline_handler = $handler;
3716 $query =
"SELECT * FROM page_object WHERE page_id = ".
3717 $ilDB->quote($a_id,
"integer").
" AND ".
3718 " parent_type = ".$ilDB->quote($a_parent_type,
"text").
" AND ".
3719 " inactive_elements = ".$ilDB->quote(1,
"integer");
3720 $obj_set = $ilDB->query(
$query);
3738 if (strpos($a_content,
" Enabled=\"False\""))
3752 $h_query =
"SELECT * FROM page_history ".
3753 " WHERE page_id = ".$ilDB->quote($this->
getId(),
"integer").
3754 " AND parent_type = ".$ilDB->quote($this->
getParentType(),
"text").
3755 " ORDER BY hdate DESC";
3757 $hset = $ilDB->query($h_query);
3758 $hentries = array();
3760 while ($hrec = $ilDB->fetchAssoc($hset))
3762 $hrec[
"sortkey"] = (int) $hrec[
"nr"];
3763 $hrec[
"user"] = (int) $hrec[
"user_id"];
3764 $hentries[] = $hrec;
3777 $res = $ilDB->queryF(
"SELECT * FROM page_history ".
3778 " WHERE page_id = %s ".
3779 " AND parent_type = %s ".
3781 array(
"integer",
"text",
"integer"),
3783 if ($hrec = $ilDB->fetchAssoc(
$res))
3803 $res = $ilDB->query(
"SELECT MAX(nr) mnr FROM page_history ".
3804 " WHERE page_id = ".$ilDB->quote($this->getId(),
"integer").
3805 " AND parent_type = ".$ilDB->quote($this->getParentType(),
"text").
3806 " AND nr < ".$ilDB->quote((
int) $a_nr,
"integer"));
3808 if (
$row[
"mnr"] > 0)
3810 $res = $ilDB->query(
"SELECT * FROM page_history ".
3811 " WHERE page_id = ".$ilDB->quote($this->getId(),
"integer").
3812 " AND parent_type = ".$ilDB->quote($this->getParentType(),
"text").
3813 " AND nr = ".$ilDB->quote((
int)
$row[
"mnr"],
"integer"));
3814 $row = $ilDB->fetchAssoc(
$res);
3819 $res = $ilDB->query(
"SELECT MIN(nr) mnr FROM page_history ".
3820 " WHERE page_id = ".$ilDB->quote($this->getId(),
"integer").
3821 " AND parent_type = ".$ilDB->quote($this->getParentType(),
"text").
3822 " AND nr > ".$ilDB->quote((
int) $a_nr,
"integer"));
3824 if (
$row[
"mnr"] > 0)
3826 $res = $ilDB->query(
"SELECT * FROM page_history ".
3827 " WHERE page_id = ".$ilDB->quote($this->getId(),
"integer").
3828 " AND parent_type = ".$ilDB->quote($this->getParentType(),
"text").
3829 " AND nr = ".$ilDB->quote((
int)
$row[
"mnr"],
"integer"));
3830 $row = $ilDB->fetchAssoc(
$res);
3835 $res = $ilDB->query(
"SELECT * FROM page_history ".
3836 " WHERE page_id = ".$ilDB->quote($this->getId(),
"integer").
3837 " AND parent_type = ".$ilDB->quote($this->getParentType(),
"text").
3838 " AND nr = ".$ilDB->quote((
int) $a_nr,
"integer"));
3850 $rnode =
$res->nodeset[0];
3853 foreach($a_hashes as $pc_id => $h)
3856 if ($h[
"change"] !=
"")
3859 $dc_node = $this->dom->create_element(
"DivClass");
3860 $dc_node->set_attribute(
"HierId", $h[
"hier_id"]);
3861 $dc_node->set_attribute(
"Class",
"ilEdit".$h[
"change"]);
3862 $dc_node = $rnode->append_child($dc_node);
3881 $l_hashes = $l_page->getPageContentsHashes();
3882 $r_hashes = $r_page->getPageContentsHashes();
3885 foreach ($l_hashes as $pc_id => $h)
3887 if (!isset($r_hashes[$pc_id]))
3889 $l_hashes[$pc_id][
"change"] =
"Deleted";
3893 if ($l_hashes[$pc_id][
"hash"] != $r_hashes[$pc_id][
"hash"])
3895 $l_hashes[$pc_id][
"change"] =
"Modified";
3896 $r_hashes[$pc_id][
"change"] =
"Modified";
3898 include_once(
"./Services/COPage/mediawikidiff/class.WordLevelDiff.php");
3900 if ($l_hashes[$pc_id][
"content"] !=
"" &&
3901 $r_hashes[$pc_id][
"content"] !=
"")
3903 $new_left = str_replace(
"\n",
"<br />", $l_hashes[$pc_id][
"content"]);
3904 $new_right = str_replace(
"\n",
"<br />", $r_hashes[$pc_id][
"content"]);
3907 $new_left = $wldiff->orig();
3908 $new_right = $wldiff->closing();
3909 $l_page->setParagraphContent($l_hashes[$pc_id][
"hier_id"], $new_left[0]);
3910 $r_page->setParagraphContent($l_hashes[$pc_id][
"hier_id"], $new_right[0]);
3917 foreach ($r_hashes as $pc_id => $h)
3919 if (!isset($l_hashes[$pc_id]))
3921 $r_hashes[$pc_id][
"change"] =
"New";
3925 $l_page->addChangeDivClasses($l_hashes);
3926 $r_page->addChangeDivClasses($r_hashes);
3928 return array(
"l_page" => $l_page,
"r_page" => $r_page,
3929 "l_changes" => $l_hashes,
"r_changes" => $r_hashes);
3939 $ilDB->manipulate(
"UPDATE page_object ".
3940 " SET view_cnt = view_cnt + 1 ".
3941 " WHERE page_id = ".$ilDB->quote($this->getId(),
"integer").
3942 " AND parent_type = ".$ilDB->quote($this->getParentType(),
"text"));
3957 $page_changes = array();
3958 $limit_ts = date(
'Y-m-d H:i:s', time() - ($a_period * 24 * 60 * 60));
3959 $q =
"SELECT * FROM page_object ".
3960 " WHERE parent_id = ".$ilDB->quote($a_parent_id,
"integer").
3961 " AND parent_type = ".$ilDB->quote($a_parent_type,
"text").
3962 " AND last_change >= ".$ilDB->quote($limit_ts,
"timestamp");
3964 $set = $ilDB->query(
$q);
3965 while($page = $ilDB->fetchAssoc($set))
3967 $page_changes[] = array(
"date" => $page[
"last_change"],
3968 "id" => $page[
"page_id"],
"type" =>
"page",
3969 "user" => $page[
"last_change_user"]);
3975 $limit_ts = date(
'Y-m-d H:i:s', time() - ($a_period * 24 * 60 * 60));
3976 $and_str =
" AND hdate >= ".$ilDB->quote($limit_ts,
"timestamp").
" ";
3979 $q =
"SELECT * FROM page_history ".
3980 " WHERE parent_id = ".$ilDB->quote($a_parent_id,
"integer").
3981 " AND parent_type = ".$ilDB->quote($a_parent_type,
"text").
3983 $set = $ilDB->query(
$q);
3984 while ($page = $ilDB->fetchAssoc($set))
3986 $page_changes[] = array(
"date" => $page[
"hdate"],
3987 "id" => $page[
"page_id"],
"type" =>
"hist",
"nr" => $page[
"nr"],
3988 "user" => $page[
"user_id"]);
3993 return $page_changes;
4007 $page_changes = array();
4009 $q =
"SELECT * FROM page_object ".
4010 " WHERE parent_id = ".$ilDB->quote($a_parent_id,
"integer").
4011 " AND parent_type = ".$ilDB->quote($a_parent_type,
"text");
4012 $set = $ilDB->query(
$q);
4014 while ($page = $ilDB->fetchAssoc($set))
4016 $pages[$page[
"page_id"]] = array(
"date" => $page[
"last_change"],
4017 "id" => $page[
"page_id"],
"user" => $page[
"last_change_user"]);
4035 $q =
"SELECT * FROM page_object ".
4036 " WHERE parent_id = ".$ilDB->quote($a_parent_id,
"integer").
4037 " AND parent_type = ".$ilDB->quote($a_parent_type,
"text").
4038 " ORDER BY created DESC";
4039 $set = $ilDB->query(
$q);
4040 while($page = $ilDB->fetchAssoc($set))
4042 if ($page[
"created"] !=
"")
4044 $pages[] = array(
"created" => $page[
"created"],
4045 "id" => $page[
"page_id"],
4046 "user" => $page[
"create_user"],
4064 $contributors = array();
4065 $set = $ilDB->queryF(
"SELECT last_change_user FROM page_object ".
4066 " WHERE parent_id = %s AND parent_type = %s ".
4067 " AND last_change_user != %s",
4068 array(
"integer",
"text",
"integer"),
4069 array($a_parent_id, $a_parent_type, 0));
4071 while ($page = $ilDB->fetchAssoc($set))
4073 $contributors[$page[
"last_change_user"]][$page[
"page_id"]] = 1;
4076 $set = $ilDB->queryF(
"SELECT count(*) as cnt, page_id, user_id FROM page_history ".
4077 " WHERE parent_id = %s AND parent_type = %s AND user_id != %s ".
4078 " GROUP BY page_id, user_id ",
4079 array(
"integer",
"text",
"integer"),
4080 array($a_parent_id, $a_parent_type, 0));
4081 while ($hpage = $ilDB->fetchAssoc($set))
4083 $contributors[$hpage[
"user_id"]][$hpage[
"page_id"]] =
4084 $contributors[$hpage[
"user_id"]][$hpage[
"page_id"]] + $hpage[
"cnt"];
4088 foreach ($contributors as $k => $co)
4091 $c[] = array(
"user_id" => $k,
"pages" => $co,
4092 "lastname" =>
$name[
"lastname"],
"firstname" =>
$name[
"firstname"]);
4108 $contributors = array();
4109 $set = $ilDB->queryF(
"SELECT last_change_user FROM page_object ".
4110 " WHERE page_id = %s AND parent_type = %s ".
4111 " AND last_change_user != %s",
4112 array(
"integer",
"text",
"integer"),
4113 array($a_page_id, $a_parent_type, 0));
4115 while ($page = $ilDB->fetchAssoc($set))
4117 $contributors[$page[
"last_change_user"]] = 1;
4120 $set = $ilDB->queryF(
"SELECT count(*) as cnt, page_id, user_id FROM page_history ".
4121 " WHERE page_id = %s AND parent_type = %s AND user_id != %s ".
4122 " GROUP BY user_id, page_id ",
4123 array(
"integer",
"text",
"integer"),
4124 array($a_page_id, $a_parent_type, 0));
4125 while ($hpage = $ilDB->fetchAssoc($set))
4127 $contributors[$hpage[
"user_id"]] =
4128 $contributors[$hpage[
"user_id"]] + $hpage[
"cnt"];
4132 foreach ($contributors as $k => $co)
4135 $c[] = array(
"user_id" => $k,
"pages" => $co,
4136 "lastname" =>
$name[
"lastname"],
"firstname" =>
$name[
"firstname"]);
4149 $ilDB->update(
"page_object", array(
4150 "rendered_content" => array(
"clob", $a_content),
4151 "render_md5" => array(
"text", $a_md5),
4152 "rendered_time" => array(
"timestamp",
ilUtil::now())
4154 "page_id" => array(
"integer", $this->
getId()),
4176 $page_changes = array();
4178 $q =
"SELECT * FROM page_object ".
4179 " WHERE parent_id = ".$ilDB->quote($a_parent_id,
"integer").
4180 " AND parent_type = ".$ilDB->quote($a_parent_type,
"text").
4181 " AND int_links = ".$ilDB->quote(1,
"integer");
4182 $set = $ilDB->query(
$q);
4184 while ($page = $ilDB->fetchAssoc($set))
4186 $pages[$page[
"page_id"]] = array(
"date" => $page[
"last_change"],
4187 "id" => $page[
"page_id"],
"user" => $page[
"last_change_user"]);
4201 if (strpos($a_content,
"IntLink"))