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"];
 
  518                 $st = $ilDB->manipulateF(
"UPDATE page_object SET parent_id = %s WHERE page_id = %s".
 
  519                         " AND parent_type = %s", array(
"integer", 
"integer", 
"text"),
 
  520                         array($a_par_id, $a_pg_id, $a_parent_type));
 
  530                 $this->activationstart = $a_activationstart;
 
  540                 return $this->activationstart;
 
  550                 $this->activationend = $a_activationend;
 
  560                 return $this->activationend;
 
  570                 if (!is_object($cont_node))
 
  574                 switch($cont_node->node_name())
 
  577                                 $child_node =& $cont_node->first_child();
 
  579                                 switch($child_node->node_name())
 
  582                                                 require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
 
  584                                                 $par->setNode($cont_node);
 
  585                                                 $par->setHierId($a_hier_id);
 
  586                                                 $par->setPcId($a_pc_id);
 
  590                                                 if ($child_node->get_attribute(
"DataTable") == 
"y")
 
  592                                                         require_once(
"./Services/COPage/classes/class.ilPCDataTable.php");
 
  594                                                         $tab->setNode($cont_node);
 
  595                                                         $tab->setHierId($a_hier_id);
 
  599                                                         require_once(
"./Services/COPage/classes/class.ilPCTable.php");
 
  601                                                         $tab->setNode($cont_node);
 
  602                                                         $tab->setHierId($a_hier_id);
 
  604                                                 $tab->setPcId($a_pc_id);
 
  608 if (
$_GET[
"pgEdMediaMode"] != 
"") {echo 
"ilPageObject::error media"; 
exit;}
 
  611                                                 require_once(
"./Services/COPage/classes/class.ilPCMediaObject.php");
 
  613                                                 $mal_node =& $child_node->first_child();
 
  615                                                 $id_arr = explode(
"_", $mal_node->get_attribute(
"OriginId"));
 
  616                                                 $mob_id = $id_arr[count($id_arr) - 1];
 
  626                                                 $mob->readMediaObject($mob_id);
 
  629                                                 $mob->setNode($cont_node);
 
  630                                                 $mob->setHierId($a_hier_id);
 
  631                                                 $mob->setPcId($a_pc_id);
 
  635                                                 require_once(
"./Services/COPage/classes/class.ilPCList.php");
 
  637                                                 $list->setNode($cont_node);
 
  638                                                 $list->setHierId($a_hier_id);
 
  639                                                 $list->setPcId($a_pc_id);
 
  643                                                 require_once(
"./Services/COPage/classes/class.ilPCFileList.php");
 
  645                                                 $file_list->setNode($cont_node);
 
  646                                                 $file_list->setHierId($a_hier_id);
 
  647                                                 $file_list->setPcId($a_pc_id);
 
  652                                                 require_once(
"./Services/COPage/classes/class.ilPCQuestion.php");
 
  654                                                 $pc_question->setNode($cont_node);
 
  655                                                 $pc_question->setHierId($a_hier_id);
 
  656                                                 $pc_question->setPcId($a_pc_id);
 
  660                                                 require_once(
"./Services/COPage/classes/class.ilPCSection.php");
 
  662                                                 $sec->setNode($cont_node);
 
  663                                                 $sec->setHierId($a_hier_id);
 
  664                                                 $sec->setPcId($a_pc_id);
 
  668                                                 require_once(
"./Services/COPage/classes/class.ilPCResources.php");
 
  670                                                 $res->setNode($cont_node);
 
  671                                                 $res->setHierId($a_hier_id);
 
  672                                                 $res->setPcId($a_pc_id);
 
  676                                                 require_once(
"./Services/COPage/classes/class.ilPCMap.php");
 
  677                                                 $map = 
new ilPCMap($this->dom);
 
  678                                                 $map->setNode($cont_node);
 
  679                                                 $map->setHierId($a_hier_id);
 
  680                                                 $map->setPcId($a_pc_id);
 
  684                                                 require_once(
"./Services/COPage/classes/class.ilPCTabs.php");
 
  686                                                 $map->setNode($cont_node);
 
  687                                                 $map->setHierId($a_hier_id);
 
  688                                                 $map->setPcId($a_pc_id);
 
  692                                                 require_once(
"./Services/COPage/classes/class.ilPCPlugged.php");
 
  694                                                 $plugged->setNode($cont_node);
 
  695                                                 $plugged->setHierId($a_hier_id);
 
  696                                                 $plugged->setPcId($a_pc_id);
 
  701                                                 require_once(
"./Services/COPage/classes/class.ilPCPlaceHolder.php");
 
  703                                                 $placeholder->setNode($cont_node);
 
  704                                                 $placeholder->setHierId($a_hier_id);
 
  705                                                 $placeholder->setPcId($a_pc_id);
 
  708                                         case "ContentInclude":
 
  709                                                 require_once(
"./Services/COPage/classes/class.ilPCContentInclude.php");
 
  711                                                 $inc->setNode($cont_node);
 
  712                                                 $inc->setHierId($a_hier_id);
 
  713                                                 $inc->setPcId($a_pc_id);
 
  719                                 require_once(
"./Services/COPage/classes/class.ilPCTableData.php");
 
  721                                 $td->setNode($cont_node);
 
  722                                 $td->setHierId($a_hier_id);
 
  726                                 require_once(
"./Services/COPage/classes/class.ilPCListItem.php");
 
  728                                 $td->setNode($cont_node);
 
  729                                 $td->setHierId($a_hier_id);
 
  733                                 require_once(
"./Services/COPage/classes/class.ilPCFileItem.php");
 
  735                                 $file_item->setNode($cont_node);
 
  736                                 $file_item->setHierId($a_hier_id);
 
  740                                 require_once(
"./Services/COPage/classes/class.ilPCTab.php");
 
  742                                 $tab->setNode($cont_node);
 
  743                                 $tab->setHierId($a_hier_id);
 
  752                 if($a_hier_id == 
"pg")
 
  761                                 $path = 
"//*[@PCID = '$a_pc_id']";
 
  763                                 if (count(
$res->nodeset) == 1)
 
  765                                         $cont_node =& 
$res->nodeset[0];
 
  771                         $path = 
"//*[@HierId = '$a_hier_id']";
 
  773                         if (count(
$res->nodeset) == 1)
 
  775                                 $cont_node =& 
$res->nodeset[0];
 
  785                 $path = 
"//*[@HierId = '$a_hier_id']";
 
  787                 if (count(
$res->nodeset) == 1)
 
  810                 $this->encoding = $a_encoding;
 
  836                         $enc_str = (!empty($this->encoding))
 
  837                                 ? 
"encoding=\"".$this->encoding.
"\"" 
  839                         return "<?xml version=\"1.0\" $enc_str ?>".
 
  840                 "<!DOCTYPE PageObject SYSTEM \"".ILIAS_ABSOLUTE_PATH.
"/xml/".$this->cur_dtd.
"\">".
 
  855                 $xml = $this->getXmlContent();
 
  861                         if ($a_new_question_copies)
 
  866                 $xml = $temp_dom->dump_mem(0, $this->encoding);
 
  867                 $xml = eregi_replace(
"<\?xml[^>]*>",
"",
$xml);
 
  868                 $xml = eregi_replace(
"<!DOCTYPE[^>]*>",
"",
$xml);
 
  880                 $path = 
"//Question";
 
  885                 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
 
  886                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
  888                         $qref = 
$res->nodeset[$i]->get_attribute(
"QRef");
 
  897                                         include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  902                                         $duplicate_id = $question->duplicate(
false);
 
  903                                         $res->nodeset[$i]->set_attribute(
"QRef", 
"il__qst_".$duplicate_id);
 
  913         function getXMLFromDom($a_incl_head = 
false, $a_append_mobs = 
false, $a_append_bib = 
false,
 
  914                 $a_append_str = 
"", $a_omit_pageobject_tag = 
false)
 
  919                         return $this->dom->dump_mem(0, $this->encoding);
 
  924                         if ($a_append_mobs || $a_append_bib || $a_append_link_info)
 
  937                                 return "<dummy>".$this->dom->dump_node($this->node).$mobs.$bibs.$trans.$a_append_str.
"</dummy>";
 
  941                                 if (is_object($this->dom))
 
  943                                         if ($a_omit_pageobject_tag)
 
  946                                                 $childs =& $this->node->child_nodes();
 
  947                                                 for($i = 0; $i < count($childs); $i++)
 
  949                                                         $xml.= $this->dom->dump_node($childs[$i]);
 
  955                                                 $xml = $this->dom->dump_mem(0, $this->encoding);
 
  956                                                 $xml = eregi_replace(
"<\?xml[^>]*>",
"",
$xml);
 
  957                                                 $xml = eregi_replace(
"<!DOCTYPE[^>]*>",
"",
$xml);
 
  981                 $lang_vars = array(
"ed_insert_par", 
"ed_insert_code",
 
  982                         "ed_insert_dtable", 
"ed_insert_atable", 
"ed_insert_media", 
"ed_insert_list",
 
  983                         "ed_insert_filelist", 
"ed_paste_clip", 
"ed_edit", 
"ed_insert_section",
 
  984                         "ed_edit_prop",
"ed_edit_files", 
"ed_edit_data", 
"ed_delete", 
"ed_moveafter", 
"ed_movebefore",
 
  985                         "ed_go", 
"ed_new_row_after", 
"ed_new_row_before",
 
  986                         "ed_new_col_after", 
"ed_new_col_before", 
"ed_delete_col",
 
  987                         "ed_delete_row", 
"ed_class", 
"ed_width", 
"ed_align_left",
 
  988                         "ed_align_right", 
"ed_align_center", 
"ed_align_left_float",
 
  989                         "ed_align_right_float", 
"ed_delete_item", 
"ed_new_item_before",
 
  990                         "ed_new_item_after", 
"ed_copy_clip", 
"please_select", 
"ed_split_page",
 
  991                         "ed_item_up", 
"ed_item_down", 
"ed_row_up", 
"ed_row_down",
 
  992                         "ed_col_left", 
"ed_col_right", 
"ed_split_page_next",
"ed_enable",
 
  993                         "de_activate", 
"ed_insert_repobj", 
"ed_insert_map", 
"ed_insert_tabs",
 
  994                         "ed_insert_pcqst", 
"empty_question", 
"ed_paste",
"question_placeh",
"media_placeh",
"text_placeh",
 
  995                         "ed_insert_plach",
"question_placehl",
"media_placehl",
"text_placehl",
 
  996                         "pc_flist", 
"pc_par", 
"pc_mob", 
"pc_qst", 
"pc_sec", 
"pc_dtab", 
"pc_tab",
 
  997                         "pc_code", 
"pc_vacc", 
"pc_hacc", 
"pc_res", 
"pc_map", 
"pc_list", 
"ed_insert_incl", 
"pc_incl");
 
  999                 foreach ($lang_vars as $lang_var)
 
 1013                 $xml.= 
"<LV name=\"$var\" value=\"".$lng->txt(
"cont_".$var).
"\"/>";
 
 1018                 require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
 
 1020                 $path = 
"//Paragraph[1]";
 
 1022                 if (count(
$res->nodeset) > 0)
 
 1024                         $cont_node =& 
$res->nodeset[0]->parent_node();
 
 1026                         $par->setNode($cont_node);
 
 1027                         return $par->getText();
 
 1044                 if (is_object(
$node))
 
 1046                         $node->set_content($a_content);
 
 1061                 $this->contains_int_link = $a_contains_link;
 
 1076                 if ($a_parse === 
true)
 
 1078                         $this->needs_parsing = 
true;
 
 1080                 if ($a_parse === 
false)
 
 1082                         $this->needs_parsing = 
false;
 
 1094                 $this->contains_question = $a_val;
 
 1104                 return $this->contains_question;
 
 1119         $r = $ilias->db->query(
"SELECT * FROM object_reference WHERE ref_id=".
 
 1120                         $ilDB->quote(
$_GET[
"ref_id"],
'integer'));
 
 1123         include_once(
"./classes/class.ilNestedSetXML.php");
 
 1125         $bibs_xml = $nested->export(
$row[
"obj_id"], 
"bib");
 
 1140                 $path = 
"//MediaObject/MediaAlias";
 
 1143                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1145                         $id_arr = explode(
"_", 
$res->nodeset[$i]->get_attribute(
"OriginId"));
 
 1146                         $mob_id = $id_arr[count($id_arr) - 1];
 
 1147                         $mob_ids[$mob_id] = $mob_id;
 
 1152                 $path = 
"//IntLink[@Type = 'MediaObject']";
 
 1155                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1157                         if ((
$res->nodeset[$i]->get_attribute(
"TargetFrame") == 
"") ||
 
 1160                                 $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 1161                                 $id_arr = explode(
"_", $target);
 
 1162                                 if (($id_arr[1] == IL_INST_ID) ||
 
 1163                                         (substr($target, 0, 4) == 
"il__"))
 
 1165                                         $mob_id = $id_arr[count($id_arr) - 1];
 
 1168                                                 $mob_ids[$mob_id] = $mob_id;
 
 1185                 $path = 
"//IntLink";
 
 1190                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1193                         if ($a_cnt_multiple)
 
 1195                                 $add = 
":".$cnt_multiple;
 
 1197                         $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 1198                         $type = 
$res->nodeset[$i]->get_attribute(
"Type");
 
 1199                         $targetframe = 
$res->nodeset[$i]->get_attribute(
"TargetFrame");
 
 1200                         $anchor = 
$res->nodeset[$i]->get_attribute(
"Anchor");
 
 1201                         $links[$target.
":".$type.
":".$targetframe.
":".$anchor.$add] =
 
 1202                                 array(
"Target" => $target, 
"Type" => $type,
 
 1203                                         "TargetFrame" => $targetframe, 
"Anchor" => $anchor);
 
 1206                         if ($type == 
"MediaObject" && $targetframe == 
"")
 
 1208                                 if (substr($target, 0, 4) ==
"il__")
 
 1210                                         $id_arr = explode(
"_", $target);
 
 1211                                         $id = $id_arr[count($id_arr) - 1];
 
 1214                                         foreach($med_links as $key => $med_link)
 
 1216                                                 $links[$key] = $med_link;
 
 1228                 $path = 
"//MediaAlias";
 
 1231                 require_once(
"Services/MediaObjects/classes/class.ilMediaItem.php");
 
 1232                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1234                         $oid = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 1235                         if (substr($oid, 0, 4) ==
"il__")
 
 1237                                 $id_arr = explode(
"_", $oid);
 
 1238                                 $id = $id_arr[count($id_arr) - 1];
 
 1241                                 foreach($med_links as $key => $med_link)
 
 1243                                         $links[$key] = $med_link;
 
 1263                         $path = 
"//FileItem/Identifier";
 
 1270                         $path = 
"//FileItem/Identifier";
 
 1273                 $file_ids = array();
 
 1274                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1276                         $id_arr = explode(
"_", 
$res->nodeset[$i]->get_attribute(
"Entry"));
 
 1277                         $file_id = $id_arr[count($id_arr) - 1];
 
 1278                         $file_ids[$file_id] = $file_id;
 
 1283                 $path = 
"//IntLink[@Type='File']";
 
 1285                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1287                         $t = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 1288                         if (substr(
$t, 0, 9) == 
"il__dfile")
 
 1290                                 $id_arr = explode(
"_", 
$t);
 
 1291                                 $file_id = $id_arr[count($id_arr) - 1];
 
 1292                                 $file_ids[$file_id] = $file_id;
 
 1309                 require_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 1310                 foreach($mob_ids as $mob_id => $dummy)
 
 1328                 $path = 
"//MediaObject/MediaAlias[@OriginId='il__mob_$a_mob_id']";
 
 1330                 $mal_node =& 
$res->nodeset[$a_nr - 1];
 
 1331                 $mob_node =& $mal_node->parent_node();
 
 1333                 return $this->dom->dump_node($mob_node);
 
 1344                 $this->dom->validate($error);
 
 1365                 $this->hier_ids = array();
 
 1366                 $this->first_row_ids = array();
 
 1367                 $this->first_col_ids = array();
 
 1368                 $this->list_item_ids = array();
 
 1369                 $this->file_item_ids = array();
 
 1376                 foreach ($this->id_elements as $el)
 
 1378                         $path.= $sep.
"//".$el;
 
 1383                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1385                         $cnode = 
$res->nodeset[$i];
 
 1386                         $ctag = $cnode->node_name();
 
 1390                         while($cnode =& $cnode->previous_sibling())
 
 1392                                 if (($cnode->node_type() == XML_ELEMENT_NODE)
 
 1393                                         && $cnode->has_attribute(
"HierId"))
 
 1395                                         $sib_hier_id = $cnode->get_attribute(
"HierId");
 
 1401                         if ($sib_hier_id != 
"")         
 
 1403                                 require_once(
"./Services/COPage/classes/class.ilPageContent.php");
 
 1405                                 $res->nodeset[$i]->set_attribute(
"HierId", $node_hier_id);
 
 1406                                 $this->hier_ids[] = $node_hier_id;
 
 1407                                 if ($ctag == 
"TableData")
 
 1409                                         if (substr($par_hier_id,strlen($par_hier_id)-2) == 
"_1")
 
 1411                                                 $this->first_row_ids[] = $node_hier_id;
 
 1414                                 if ($ctag == 
"ListItem")
 
 1416                                         $this->list_item_ids[] = $node_hier_id;
 
 1418                                 if ($ctag == 
"FileItem")
 
 1420                                         $this->file_item_ids[] = $node_hier_id;
 
 1426                                 $cnode = 
$res->nodeset[$i];
 
 1428                                 while($cnode =& $cnode->parent_node())
 
 1430                                         if (($cnode->node_type() == XML_ELEMENT_NODE)
 
 1431                                                 && $cnode->has_attribute(
"HierId"))
 
 1433                                                 $par_hier_id = $cnode->get_attribute(
"HierId");
 
 1439                                 if (($par_hier_id != 
"") && ($par_hier_id != 
"pg"))             
 
 1441                                         $node_hier_id = $par_hier_id.
"_1";
 
 1442                                         $res->nodeset[$i]->set_attribute(
"HierId", $node_hier_id);
 
 1443                                         $this->hier_ids[] = $node_hier_id;
 
 1444                                         if ($ctag == 
"TableData")
 
 1446                                                 $this->first_col_ids[] = $node_hier_id;
 
 1447                                                 if (substr($par_hier_id,strlen($par_hier_id)-2) == 
"_1")
 
 1449                                                         $this->first_row_ids[] = $node_hier_id;
 
 1452                                         if ($ctag == 
"ListItem")
 
 1454                                                 $this->list_item_ids[] = $node_hier_id;
 
 1456                                         if ($ctag == 
"FileItem")
 
 1458                                                 $this->file_item_ids[] = $node_hier_id;
 
 1464                                         $node_hier_id = 
"1";
 
 1465                                         $res->nodeset[$i]->set_attribute(
"HierId", $node_hier_id);
 
 1466                                         $this->hier_ids[] = $node_hier_id;
 
 1473                 $path = 
"//PageObject";
 
 1475                 for($i = 0; $i < count(
$res->nodeset); $i++)    
 
 1477                         $res->nodeset[$i]->set_attribute(
"HierId", 
"pg");
 
 1478                         $this->hier_ids[] = 
"pg";
 
 1488                 return $this->hier_ids;
 
 1496                 return $this->first_row_ids;
 
 1504                 return $this->first_col_ids;
 
 1512                 return $this->list_item_ids;
 
 1520                 return $this->file_item_ids;
 
 1528                 if(is_object($this->dom))
 
 1531                         $path = 
"//*[@HierId]";
 
 1533                         for($i = 0; $i < count(
$res->nodeset); $i++)    
 
 1535                                 if (
$res->nodeset[$i]->has_attribute(
"HierId"))
 
 1537                                         $res->nodeset[$i]->remove_attribute(
"HierId");
 
 1550                 $path = 
"//FileItem";
 
 1552                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1554                         $cnode =& 
$res->nodeset[$i];
 
 1555                         $size_node =& $this->dom->create_element(
"Size");
 
 1556                         $size_node =& $cnode->append_child($size_node);
 
 1558                         $childs =& $cnode->child_nodes();
 
 1560                         for($j = 0; $j < count($childs); $j++)
 
 1562                                 if ($childs[$j]->node_name() == 
"Identifier")
 
 1564                                         if ($childs[$j]->has_attribute(
"Entry"))
 
 1566                                                 $entry = $childs[$j]->get_attribute(
"Entry");
 
 1567                                                 $entry_arr = explode(
"_", $entry);
 
 1568                                                 $id = $entry_arr[count($entry_arr) - 1];
 
 1569                                                 require_once(
"./Modules/File/classes/class.ilObjFile.php");
 
 1574                         $size_node->set_content(
$size);
 
 1588                 $path = 
"//IntLink";
 
 1590                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1592                         $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 1593                         $type = 
$res->nodeset[$i]->get_attribute(
"Type");
 
 1596                         if ($new_target !== 
false)
 
 1598                                 $res->nodeset[$i]->set_attribute(
"Target", $new_target);
 
 1603                                         IL_INST_ID > 0 && $type != 
"RepositoryItem")
 
 1608                                                 $res->nodeset[$i]->set_attribute(
"Target", $new_target);        
 
 1618                 $path = 
"//MediaAlias";
 
 1622                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1624                         $orig_id = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 1625                         $id_arr = explode(
"_", $orig_id);
 
 1626                         $mob_id = $id_arr[count($id_arr) - 1];
 
 1641                 $path = 
"//MediaAlias";
 
 1644                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1646                         $old_id = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 1647                         $old_id = explode(
"_", $old_id);
 
 1648                         $old_id = $old_id[count($old_id) - 1];
 
 1649                         if ($a_mapping[$old_id] > 0)
 
 1651                                 $res->nodeset[$i]->set_attribute(
"OriginId", 
"il__mob_".$a_mapping[$old_id]);
 
 1670                 $path = 
"//FileItem/Identifier";
 
 1673                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1675                         $old_id = 
$res->nodeset[$i]->get_attribute(
"Entry");
 
 1676                         $old_id = explode(
"_", $old_id);
 
 1677                         $old_id = $old_id[count($old_id) - 1];
 
 1678                         if ($a_mapping[$old_id] > 0)
 
 1680                                 $res->nodeset[$i]->set_attribute(
"Entry", 
"il__file_".$a_mapping[$old_id]);
 
 1697                 $path = 
"//Question";
 
 1699                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1701                         $qref = 
$res->nodeset[$i]->get_attribute(
"QRef");
 
 1703                         if (isset($a_mapping[$qref]))
 
 1705                                 $res->nodeset[$i]->set_attribute(
"QRef", 
"il__qst_".$a_mapping[$qref][
"pool"]);
 
 1726                 $path = 
"//IntLink";
 
 1728                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1730                         $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 1731                         $type = 
$res->nodeset[$i]->get_attribute(
"Type");
 
 1733                         if ($a_from_to[$obj_id] > 0 && is_int(strpos($target, 
"__")))
 
 1737                                         $res->nodeset[$i]->set_attribute(
"Target", 
"il__pg_".$a_from_to[$obj_id]);
 
 1742                                         $res->nodeset[$i]->set_attribute(
"Target", 
"il__st_".$a_from_to[$obj_id]);
 
 1752                 $path = 
"//MediaAlias";
 
 1755                 require_once(
"Services/MediaObjects/classes/class.ilMediaItem.php");
 
 1756                 require_once(
"Services/COPage/classes/class.ilMediaAliasItem.php");
 
 1758                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1760                         $media_object_node = 
$res->nodeset[$i]->parent_node();
 
 1761                         $page_content_node = $media_object_node->parent_node();
 
 1762                         $c_hier_id = $page_content_node->get_attribute(
"HierId");
 
 1766                                 $c_hier_id, 
"Standard");
 
 1767                         $areas = $std_alias_item->getMapAreas();
 
 1768                         $correction_needed = 
false;
 
 1769                         if (count($areas) > 0)
 
 1772                                 foreach($areas as $area)
 
 1774                                         if ($area[
"Type"] == 
"PageObject" ||
 
 1775                                                 $area[
"Type"] == 
"StructureObject")
 
 1777                                                 $t = $area[
"Target"];
 
 1778                                                 $tid = _extractObjIdOfTarget(
$t);
 
 1779                                                 if ($a_from_to[$tid] > 0)
 
 1781                                                         $correction_needed = 
true;
 
 1792                                 $oid = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 1793                                 if (substr($oid, 0, 4) ==
"il__")
 
 1795                                         $id_arr = explode(
"_", $oid);
 
 1796                                         $id = $id_arr[count($id_arr) - 1];
 
 1799                                         $med_item = $mob->getMediaItem(
"Standard");
 
 1800                                         $med_areas = $med_item->getMapAreas();
 
 1802                                         foreach($med_areas as $area)
 
 1804                                                 $link_type = ($area->getLinkType() == 
"int")
 
 1809                                                         "Nr" => $area->getNr(),
 
 1810                                                         "Shape" => $area->getShape(),
 
 1811                                                         "Coords" => $area->getCoords(),
 
 1813                                                                 "LinkType" => $link_type,
 
 1814                                                                 "Href" => $area->getHref(),
 
 1815                                                                 "Title" => $area->getTitle(),
 
 1816                                                                 "Target" => $area->getTarget(),
 
 1817                                                                 "Type" => $area->getType(),
 
 1818                                                                 "TargetFrame" => $area->getTargetFrame()
 
 1822                                                 if ($area->getType() == 
"PageObject" ||
 
 1823                                                         $area->getType() == 
"StructureObject")
 
 1825                                                         $t = $area->getTarget();
 
 1827                                                         if ($a_from_to[$tid] > 0)
 
 1829                                                                 $correction_needed = 
true;
 
 1838                         if ($correction_needed)
 
 1841                                 $std_alias_item->deleteAllMapAreas();
 
 1842                                 foreach($areas as $area)
 
 1844                                         if ($area[
"Link"][
"LinkType"] == 
"IntLink")
 
 1846                                                 $target = $area[
"Link"][
"Target"];
 
 1847                                                 $type = $area[
"Link"][
"Type"];
 
 1849                                                 if ($a_from_to[$obj_id] > 0)
 
 1853                                                                 $area[
"Link"][
"Target"] = 
"il__pg_".$a_from_to[$obj_id];
 
 1857                                                                 $area[
"Link"][
"Target"] = 
"il__st_".$a_from_to[$obj_id];
 
 1862                                         $std_alias_item->addMapArea($area[
"Shape"], $area[
"Coords"],
 
 1863                                                 $area[
"Link"][
"Title"],
 
 1864                                                 array(  
"Type" => $area[
"Link"][
"Type"],
 
 1865                                                                 "TargetFrame" => $area[
"Link"][
"TargetFrame"],
 
 1866                                                                 "Target" => $area[
"Link"][
"Target"],
 
 1867                                                                 "Href" => $area[
"Link"][
"Href"],
 
 1868                                                                 "LinkType" => $area[
"Link"][
"LinkType"],
 
 1885                 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
 
 1892                 foreach($sources as $source)
 
 1895                         if ($source[
"type"] == 
"lm:pg")
 
 1898                                 $page_obj = 
new ilPageObject(
"lm", $source[
"id"], 
false);
 
 1899                                 if  (!$page_obj->page_not_found)
 
 1902                                         $page_obj->handleImportRepositoryLink($a_rep_import_id,
 
 1903                                                 $a_rep_type, $a_rep_ref_id);
 
 1905                                 $page_obj->update();
 
 1916                 $path = 
"//IntLink";
 
 1919                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1922                         $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 1923                         $type = 
$res->nodeset[$i]->get_attribute(
"Type");
 
 1924                         if ($target == $a_rep_import_id && $type == 
"RepositoryItem")
 
 1927                                 $res->nodeset[$i]->set_attribute(
"Target",
 
 1928                                         "il__".$a_rep_type.
"_".$a_rep_ref_id);
 
 1963                 $ilDB->insert(
"page_object", array(
 
 1964                         "page_id" => array(
"integer", $this->
getId()),
 
 1965                         "parent_id" => array(
"integer", $this->
getParentId()),
 
 1968                         "create_user" => array(
"integer", $ilUser->getId()),
 
 1969                         "last_change_user" => array(
"integer", $ilUser->getId()),
 
 1970                         "inactive_elements" => array(
"integer", $iel),
 
 1971                         "int_links" => array(
"integer", $inl),
 
 1973                         "last_change" => array(
"timestamp", 
ilUtil::now())
 
 2014                 $ilDB->update(
"page_object", array(
 
 2016                         "parent_id" => array(
"integer", $this->
getParentId()),
 
 2017                         "last_change_user" => array(
"integer", $ilUser->getId()),
 
 2018                         "last_change" => array(
"timestamp", 
ilUtil::now()),
 
 2019                         "active" => array(
"integer", $this->
getActive()),
 
 2022                         "inactive_elements" => array(
"integer", $iel),
 
 2023                         "int_links" => array(
"integer", $inl),
 
 2025                         "page_id" => array(
"integer", $this->
getId()),
 
 2047         function update($a_validate = 
true, $a_no_history = 
false, $skip_handle_usages = 
false)
 
 2079                         $old_set = $ilDB->query(
"SELECT * FROM page_object WHERE ".
 
 2080                                 "page_id = ".$ilDB->quote($this->getId(), 
"integer").
" AND ".
 
 2081                                 "parent_type = ".$ilDB->quote($this->getParentType(), 
"text"));
 
 2082                         $last_nr_set = $ilDB->query(
"SELECT max(nr) as mnr FROM page_history WHERE ".
 
 2083                                 "page_id = ".$ilDB->quote($this->getId(), 
"integer").
" AND ".
 
 2084                                 "parent_type = ".$ilDB->quote($this->getParentType(), 
"text"));
 
 2085                         $last_nr = $ilDB->fetchAssoc($last_nr_set);
 
 2086                         if ($old_rec = $ilDB->fetchAssoc($old_set))
 
 2089                                 if (($content != $old_rec[
"content"]) && !$a_no_history &&
 
 2092                                         if ($old_rec[
"content"] != 
"<PageObject></PageObject>")
 
 2094                                                 $ilDB->manipulateF(
"DELETE FROM page_history WHERE ".
 
 2095                                                         "page_id = %s AND parent_type = %s AND hdate = %s",
 
 2096                                                         array(
"integer", 
"text", 
"timestamp"),
 
 2097                                                         array($old_rec[
"page_id"], $old_rec[
"parent_type"], $old_rec[
"last_change"]));
 
 2101                                                 $last_c = $old_rec[
"last_change"];
 
 2107                                                 $ilDB->insert(
"page_history", array(
 
 2108                                                         "page_id" =>            array(
"integer", $old_rec[
"page_id"]),
 
 2109                                                         "parent_type" =>        array(
"text", $old_rec[
"parent_type"]),
 
 2110                                                         "hdate" =>                      array(
"timestamp", $last_c),
 
 2111                                                         "parent_id" =>          array(
"integer", $old_rec[
"parent_id"]),
 
 2112                                                         "content" =>            array(
"clob", $old_rec[
"content"]),
 
 2113                                                         "user_id" =>            array(
"integer", $old_rec[
"last_change_user"]),
 
 2115                                                         "nr" =>                         array(
"integer", (
int) $last_nr[
"mnr"] + 1)
 
 2129                                                 $this->
saveMobUsage($old_rec[
"content"], $last_nr[
"mnr"] + 1);
 
 2131                                                 $this->
saveFileUsage($old_rec[
"content"], $last_nr[
"mnr"] + 1);
 
 2133                                                 $this->history_saved = 
true;            
 
 2137                                                 $this->history_saved = 
true;            
 
 2142                         $em = (trim($content) == 
"<PageObject/>")
 
 2162                         $ilDB->update(
"page_object", array(
 
 2163                                 "content" => array(
"clob", $content),
 
 2164                                 "parent_id" => array(
"integer", $this->
getParentId()),
 
 2165                                 "last_change_user" => array(
"integer", $ilUser->getId()),
 
 2166                                 "last_change" => array(
"timestamp", 
ilUtil::now()),
 
 2167                                 "is_empty" => array(
"integer", $em),
 
 2168                                 "active" => array(
"integer", $this->
getActive()),
 
 2171                                 "inactive_elements" => array(
"integer", $iel),
 
 2172                                 "int_links" => array(
"integer", $inl),
 
 2174                                 "page_id" => array(
"integer", $this->
getId()),
 
 2187                         if (!$skip_handle_usages)
 
 2190                                 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 2195                                 foreach($mob_ids as $mob)       
 
 2200                                                 $usages = $mob_obj->getUsages(
false);
 
 2201                                                 if (count($usages) == 0)        
 
 2209                                 include_once(
"./Modules/File/classes/class.ilObjFile.php");
 
 2213                                 foreach($file_ids as 
$file)     
 
 2217                                                 $file_obj = 
new ilObjFile($file, 
false);
 
 2218                                                 $usages = $file_obj->getUsages();
 
 2219                                                 if (count($usages) == 0)        
 
 2221                                                         if ($file_obj->getMode() == 
"filelist")         
 
 2223                                                                 $file_obj->delete();
 
 2260                 if (!$this->page_not_found)
 
 2283                 include_once(
"./Modules/File/classes/class.ilObjFile.php");
 
 2287                 include_once(
"./Services/News/classes/class.ilNewsItem.php");
 
 2292                 $ilDB->manipulate(
"DELETE FROM page_object ".
 
 2293                         "WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 2294                         " AND parent_type= ".$ilDB->quote($this->getParentType(), 
"text"));
 
 2298                 foreach (
$mobs as $mob_id)
 
 2302                                 $GLOBALS[
'ilLog']->write(__METHOD__.
': Type mismatch. Ignoring mob with id: '.$mob_id);
 
 2313                 include_once(
"./Modules/File/classes/class.ilObjFile.php");
 
 2314                 foreach (
$files as $file_id)
 
 2318                                 $file_obj =& 
new ilObjFile($file_id, 
false);
 
 2319                                 $file_obj->delete();
 
 2340                         $keywords = array();
 
 2346                         for ($i=0; $i < count(
$res->nodeset); $i++)
 
 2348                                 $k =  trim(strip_tags(
$res->nodeset[$i]->get_content()));
 
 2349                                 if (!in_array($k, $keywords))
 
 2359                         $meta_id = $this->
getId();
 
 2361                         include_once(
"./Services/MetaData/classes/class.ilMD.php");
 
 2362                         $md_obj = 
new ilMD($meta_rep_id, $meta_id, $meta_type);
 
 2363                         $mkeywords = array();
 
 2365                         if(is_object($md_section = $md_obj->getGeneral()))
 
 2367                                 foreach($ids = $md_section->getKeywordIds() as 
$id)
 
 2369                                         $md_key = $md_section->getKeyword(
$id);
 
 2370                                         $mkeywords[] = strtolower($md_key->getKeyword());
 
 2373                                                 $lang = $md_key->getKeywordLanguageCode();
 
 2379                                 foreach($ids = $md_section->getLanguageIds() as 
$id)
 
 2381                                         $md_lang = $md_section->getLanguage(
$id);
 
 2384                                                 $lang = $md_lang->getLanguageCode();
 
 2388                         foreach ($keywords as $k)
 
 2390                                 if (!in_array(strtolower($k), $mkeywords))
 
 2392                                         if (trim($k) != 
"" && 
$lang != 
"")
 
 2394                                                 $md_key = $md_section->addKeyword();
 
 2399                                         $mkeywords[] = strtolower($k);
 
 2416                 $path = 
"//MediaAlias";
 
 2419                 for ($i=0; $i < count(
$res->nodeset); $i++)
 
 2421                         $id_arr = explode(
"_", 
$res->nodeset[$i]->get_attribute(
"OriginId"));
 
 2422                         $mob_id = $id_arr[count($id_arr) - 1];
 
 2425                                 $usages[$mob_id] = 
true;
 
 2431                 $path = 
"//MediaObject/MetaData/General/Identifier";
 
 2433                 for ($i=0; $i < count(
$res->nodeset); $i++)
 
 2435                         $mob_entry = 
$res->nodeset[$i]->get_attribute(
"Entry");
 
 2436                         $mob_arr = explode(
"_", $mob_entry);
 
 2437                         $mob_id = $mob_arr[count($mob_arr) - 1];
 
 2440                                 $usages[$mob_id] = 
true;
 
 2446                 $path = 
"//IntLink[@Type='MediaObject']";
 
 2448                 for ($i=0; $i < count(
$res->nodeset); $i++)
 
 2450                         $mob_target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 2451                         $mob_arr = explode(
"_", $mob_target);
 
 2452                         $mob_id = $mob_arr[count($mob_arr) - 1];
 
 2455                                 $usages[$mob_id] = 
true;
 
 2459                 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 2461                 foreach($usages as $mob_id => $val)
 
 2475                 include_once(
"./Modules/File/classes/class.ilObjFile.php");
 
 2477                 foreach($file_ids as $file_id)
 
 2488                 include_once(
"./Services/COPage/classes/class.ilPageContentUsage.php");
 
 2491                 foreach($ci_ids as $ci_id)
 
 2493                         if ((
int) $ci_id[
"inst_id"] <= 0)
 
 2510                         $path = 
"//ContentInclude";
 
 2517                         $path = 
"//ContentInclude";
 
 2521                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 2523                         $type = 
$res->nodeset[$i]->get_attribute(
"ContentType");
 
 2524                         $id = 
$res->nodeset[$i]->get_attribute(
"ContentId");
 
 2525                         $inst_id = 
$res->nodeset[$i]->get_attribute(
"InstId");
 
 2526                         $ci_ids[$type.
":".
$id.
":".$inst_id] = array(
 
 2527                                 "type" => $type, 
"id" => 
$id, 
"inst_id" => $inst_id);
 
 2547                 $path = 
"//Paragraph | //Section | //MediaAlias | //FileItem".
 
 2548                         " | //Table | //TableData | //Tabs | //List";
 
 2551                 for ($i=0; $i < count(
$res->nodeset); $i++)
 
 2553                         switch (
$res->nodeset[$i]->node_name())
 
 2556                                         $sname = 
$res->nodeset[$i]->get_attribute(
"Characteristic");
 
 2557                                         $stype = 
"text_block";
 
 2562                                         $sname = 
$res->nodeset[$i]->get_attribute(
"Characteristic");
 
 2568                                         $sname = 
$res->nodeset[$i]->get_attribute(
"Class");
 
 2569                                         $stype = 
"media_cont";
 
 2574                                         $sname = 
$res->nodeset[$i]->get_attribute(
"Class");
 
 2575                                         $stype = 
"flist_li";
 
 2580                                         $sname = 
$res->nodeset[$i]->get_attribute(
"Template");
 
 2583                                                 $sname = 
$res->nodeset[$i]->get_attribute(
"Class");
 
 2595                                         $sname = 
$res->nodeset[$i]->get_attribute(
"Class");
 
 2596                                         $stype = 
"table_cell";
 
 2601                                         $sname = 
$res->nodeset[$i]->get_attribute(
"Template");
 
 2604                                                 if (
$res->nodeset[$i]->get_attribute(
"Type") == 
"HorizontalAccordion")
 
 2606                                                         $stype = 
"haccordion";
 
 2608                                                 if (
$res->nodeset[$i]->get_attribute(
"Type") == 
"VerticalAccordion")
 
 2610                                                         $stype = 
"vaccordion";
 
 2617                                         $sname = 
$res->nodeset[$i]->get_attribute(
"Class");
 
 2618                                         if (
$res->nodeset[$i]->get_attribute(
"Type") == 
"Ordered")
 
 2629                         if ($sname != 
"" &&  $stype != 
"")
 
 2631                                 $usages[$sname.
":".$stype.
":".$template] = array(
"sname" => $sname,
 
 2632                                         "stype" => $stype, 
"template" => $template);
 
 2636                 $ilDB->manipulate(
"DELETE FROM page_style_usage WHERE ".
 
 2637                         " page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 2638                         " AND page_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 2639                         " AND page_nr = ".$ilDB->quote($a_old_nr, 
"integer")
 
 2642                 foreach ($usages as $u)
 
 2644                         $ilDB->manipulate(
"INSERT INTO page_style_usage ".
 
 2645                                 "(page_id, page_type, page_nr, template, stype, sname) VALUES (".
 
 2646                                 $ilDB->quote($this->getId(), 
"integer").
",".
 
 2647                                 $ilDB->quote($this->getParentType(), 
"text").
",".
 
 2648                                 $ilDB->quote($a_old_nr, 
"integer").
",".
 
 2649                                 $ilDB->quote($u[
"template"], 
"integer").
",".
 
 2650                                 $ilDB->quote($u[
"stype"], 
"text").
",".
 
 2651                                 $ilDB->quote($u[
"sname"], 
"text").
 
 2662                 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 2663                 include_once(
"./Modules/File/classes/class.ilObjFile.php");
 
 2685                 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
 
 2690                 $path = 
"//IntLink";
 
 2692                 for ($i=0; $i < count(
$res->nodeset); $i++)
 
 2694                         $link_type = 
$res->nodeset[$i]->get_attribute(
"Type");
 
 2698                                 case "StructureObject":
 
 2706                                 case "GlossaryItem":
 
 2714                                 case "RepositoryItem":
 
 2723                         $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 2728                         if (is_int(strpos($target, 
"__")))
 
 2747                 $ilDB->manipulateF(
"DELETE FROM page_question WHERE page_parent_type = %s ".
 
 2748                         " AND page_id = %s", array(
"text", 
"integer"),
 
 2754                 $path = 
"//Question";
 
 2757                 for ($i=0; $i < count(
$res->nodeset); $i++)
 
 2759                         $q_ref = 
$res->nodeset[$i]->get_attribute(
"QRef");
 
 2762                         if (!($inst_id > 0))
 
 2767                                         $q_ids[$q_id] = $q_id;
 
 2771                 foreach($q_ids as $qid)
 
 2773                         $ilDB->manipulateF(
"INSERT INTO page_question (page_parent_type, page_id, question_id)".
 
 2774                                 " VALUES (%s,%s,%s)",
 
 2775                                 array(
"text", 
"integer", 
"integer"),
 
 2787                 $res = $ilDB->queryF(
"SELECT * FROM page_question WHERE page_parent_type = %s ".
 
 2788                         " AND page_id = %s",
 
 2789                         array(
"text", 
"integer"),
 
 2790                         array($a_parent_type, $a_page_id));
 
 2792                 while ($rec = $ilDB->fetchAssoc(
$res))
 
 2794                         $q_ids[] = $rec[
"question_id"];
 
 2816                 for ($i=0; $i < count(
$res->nodeset); $i++)
 
 2818                         $name = 
$res->nodeset[$i]->get_attribute(
"Name");
 
 2819                         if (trim($name) != 
"" && !in_array($name, $saved))
 
 2835                 $st = $ilDB->prepareManip(
"DELETE FROM page_anchor WHERE page_parent_type = ? ".
 
 2836                         " AND page_id = ?", array(
"text", 
"integer"));
 
 2837                 $ilDB->execute($st, array($a_parent_type, $a_page_id));
 
 2843         static function _saveAnchor($a_parent_type, $a_page_id, $a_anchor_name)
 
 2847                 $st = $ilDB->prepareManip(
"INSERT INTO page_anchor (page_parent_type, page_id, anchor_name) ".
 
 2848                         " VALUES (?,?,?) ", array(
"text", 
"integer", 
"text"));
 
 2849                 $ilDB->execute($st, array($a_parent_type, $a_page_id, $a_anchor_name));
 
 2859                 $st = $ilDB->prepare(
"SELECT * FROM page_anchor WHERE page_parent_type = ? ".
 
 2860                         " AND page_id = ?", array(
"text", 
"integer"));
 
 2861                 $set = $ilDB->execute($st, array($a_parent_type, $a_page_id));
 
 2863                 while ($rec = $ilDB->fetchAssoc($set))
 
 2865                         $anchors[] = $rec[
"anchor_name"];
 
 2888                 $curr_node->unlink_node($curr_node);
 
 2905                 if (!is_array($a_hids))
 
 2909                 foreach($a_hids as $a_hid)
 
 2911                         $a_hid = explode(
":", $a_hid);
 
 2914                         if (is_object($curr_node))
 
 2916                                 $parent_node = $curr_node->parent_node();
 
 2917                                 if ($parent_node->node_name() != 
"TableRow")
 
 2919                                         $curr_node->unlink_node($curr_node);
 
 2949                 if (!is_array($a_hids))
 
 2954                 $time = date(
"Y-m-d H:i:s", time());
 
 2956                 $hier_ids = array();
 
 2958                 foreach($a_hids as $a_hid)
 
 2964                         $a_hid = explode(
":", $a_hid);
 
 2968                         foreach($hier_ids as $h)
 
 2970                                 if($h.
"_" == substr($a_hid[0], 0, strlen($h) + 1))
 
 2972                                         $skip[] = $a_hid[0];
 
 2974                                 if($a_hid[0].
"_" == substr($h, 0, strlen($a_hid[0]) + 1))
 
 2979                         $pc_id[$a_hid[0]] = $a_hid[1];
 
 2980                         if ($a_hid[0] != 
"")
 
 2982                                 $hier_ids[$a_hid[0]] = $a_hid[0];
 
 2985                 foreach (
$skip as $s)
 
 2987                         unset($hier_ids[$s]);
 
 2989                 include_once(
"./Services/COPage/classes/class.ilPageContent.php");
 
 2992                 foreach($hier_ids as $hid)
 
 2995                         if (is_object($curr_node))
 
 2997                                 if ($curr_node->node_name() == 
"PageContent")
 
 2999                                         $content = $this->dom->dump_node($curr_node);
 
 3001                                         $content = eregi_replace(
"PCID=\"[a-z0-9]*\"",
"",$content);
 
 3002                                         $content = eregi_replace(
"HierId=\"[a-z0-9_]*\"",
"",$content);
 
 3004                                         $ilUser->addToPCClipboard($content, $time, $nr);
 
 3009                 include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
 
 3020                 $a_hid = explode(
":", $a_hier_id);
 
 3021                 $content = $ilUser->getPCClipboardContent();
 
 3025                 for ($i = count($content) - 1; $i >= 0; $i--)
 
 3029                         $temp_dom = 
domxml_open_mem(
'<?xml version="1.0" encoding="UTF-8"?>'.$c,
 
 3035                                 $path = 
"//PageContent";
 
 3037                                 if (count(
$res->nodeset) > 0)
 
 3039                                         $new_pc_node = 
$res->nodeset[0];
 
 3040                                         $cloned_pc_node = $new_pc_node->clone_node (
true);
 
 3041                                         $cloned_pc_node->unlink_node ($cloned_pc_node);
 
 3061                 if (!is_array($a_hids))
 
 3065                 $obj = & $this->content_obj;
 
 3067                 foreach($a_hids as $a_hid)
 
 3069                         $a_hid = explode(
":", $a_hid);
 
 3072                         if (is_object($curr_node))
 
 3074                                 if ($curr_node->node_name() == 
"PageContent")
 
 3077                                         if ($cont_obj->isEnabled ()) 
 
 3078                                                 $cont_obj->disable ();
 
 3080                                                 $cont_obj->enable ();
 
 3104                 foreach ($hier_ids as $hier_id)
 
 3107                         if (!is_int(strpos($hier_id, 
"_")))
 
 3109                                 if ($hier_id != 
"pg" && $hier_id >= $a_hid)
 
 3112                                         $curr_node->unlink_node($curr_node);
 
 3134                 foreach ($hier_ids as $hier_id)
 
 3137                         if (!is_int(strpos($hier_id, 
"_")))
 
 3139                                 if ($hier_id != 
"pg" && $hier_id < $a_hid)
 
 3142                                         $curr_node->unlink_node($curr_node);
 
 3162                 $hier_ids = $a_source_page->getHierIds();
 
 3164                 $copy_ids = array();
 
 3167                 foreach ($hier_ids as $hier_id)
 
 3170                         if (!is_int(strpos($hier_id, 
"_")))
 
 3172                                 if ($hier_id != 
"pg" && $hier_id >= $a_hid)
 
 3174                                         $copy_ids[] = $hier_id;
 
 3180                 $parent_node =& $a_target_page->getContentNode(
"pg");
 
 3181                 $target_dom =& $a_target_page->getDom();
 
 3182                 $parent_childs =& $parent_node->child_nodes();
 
 3183                 $cnt_parent_childs = count($parent_childs);
 
 3185                 $first_child =& $parent_childs[0];
 
 3186                 foreach($copy_ids as $copy_id)
 
 3188                         $source_node =& $a_source_page->getContentNode($copy_id);
 
 3190                         $new_node =& $source_node->clone_node(
true);
 
 3191                         $new_node->unlink_node($new_node);
 
 3193                         $source_node->unlink_node($source_node);
 
 3195                         if($cnt_parent_childs == 0)
 
 3197                                 $new_node =& $parent_node->append_child($new_node);
 
 3202                                 $new_node =& $first_child->insert_before($new_node, $first_child);
 
 3204                         $parent_childs =& $parent_node->child_nodes();
 
 3209                 $a_target_page->update();
 
 3210                 $a_source_page->update();
 
 3221                 $curr_name = $curr_node->node_name();
 
 3222                 if (($curr_name == 
"TableData") || ($curr_name == 
"PageObject") ||
 
 3223                         ($curr_name == 
"ListItem") || ($curr_name == 
"Section")
 
 3224                         || ($curr_name == 
"Tab"))
 
 3229                 $hid = $curr_node->get_attribute(
"HierId");
 
 3238                         $pos = explode(
"_", $a_pos);
 
 3239                         $target_pos = array_pop($pos);
 
 3240                         $parent_pos = implode($pos, 
"_");
 
 3244                         $parent_pos = $a_pos;
 
 3248                 if($parent_pos != 
"")
 
 3254                         $parent_node =& $this->
getNode();
 
 3258                 $parent_childs =& $parent_node->child_nodes();
 
 3259                 $cnt_parent_childs = count($parent_childs);
 
 3265                                 $new_node =& $a_cont_obj->getNode();
 
 3269                                 if($succ_node =& $curr_node->next_sibling())
 
 3271                                         $new_node =& $succ_node->insert_before($new_node, $succ_node);
 
 3276                                         $new_node =& $parent_node->append_child($new_node);
 
 3278                                 $a_cont_obj->setNode($new_node);
 
 3283                                 $new_node =& $a_cont_obj->getNode();
 
 3285                                 $new_node =& $succ_node->insert_before($new_node, $succ_node);
 
 3286                                 $a_cont_obj->setNode($new_node);
 
 3292                                 $new_node =& $a_cont_obj->getNode();
 
 3293                                 if($cnt_parent_childs == 0)
 
 3295                                         $new_node =& $parent_node->append_child($new_node);
 
 3299                                         $new_node =& $parent_childs[0]->insert_before($new_node, $parent_childs[0]);
 
 3301                                 $a_cont_obj->setNode($new_node);
 
 3308                         $sub_nodes = $curr_node->child_nodes() ;
 
 3309                         foreach ( $sub_nodes as $sub_node ) {
 
 3310                                 if ($sub_node->node_name() == 
"PlaceHolder") {
 
 3311                                         $curr_node->unlink_node();
 
 3324                 $curr_name = $curr_node->node_name();
 
 3325                 if (($curr_name == 
"TableData") || ($curr_name == 
"PageObject") ||
 
 3326                         ($curr_name == 
"ListItem") || ($curr_name == 
"Section")
 
 3327                         || ($curr_name == 
"Tab"))
 
 3332                 $hid = $curr_node->get_attribute(
"HierId");
 
 3340                         $pos = explode(
"_", $a_pos);
 
 3341                         $target_pos = array_pop($pos);
 
 3342                         $parent_pos = implode($pos, 
"_");
 
 3346                         $parent_pos = $a_pos;
 
 3350                 if($parent_pos != 
"")
 
 3356                         $parent_node =& $this->
getNode();
 
 3360                 $parent_childs =& $parent_node->child_nodes();
 
 3361                 $cnt_parent_childs = count($parent_childs);
 
 3368                                 if($succ_node = $curr_node->next_sibling())
 
 3370                                         $a_cont_node = $succ_node->insert_before($a_cont_node, $succ_node);
 
 3374                                         $a_cont_node = $parent_node->append_child($a_cont_node);
 
 3382                                 $a_cont_node = $succ_node->insert_before($a_cont_node, $succ_node);
 
 3389                                 if($cnt_parent_childs == 0)
 
 3391                                         $a_cont_node = $parent_node->append_child($a_cont_node);
 
 3395                                         $a_cont_node = $parent_childs[0]->insert_before($a_cont_node, $parent_childs[0]);
 
 3408                 if($a_source == $a_target)
 
 3415                 $source_node =& $content->getNode();
 
 3416                 $clone_node =& $source_node->clone_node(
true);
 
 3422                 $content->setNode($clone_node);
 
 3434                 if($a_source == $a_target)
 
 3441                 $source_node =& $content->getNode();
 
 3442                 $clone_node =& $source_node->clone_node(
true);
 
 3448                 $content->setNode($clone_node);
 
 3458                 $a_content = eregi_replace(
"\[com\]",
"<Comment>",$a_content);
 
 3459                 $a_content = eregi_replace(
"\[\/com\]",
"</Comment>",$a_content);
 
 3460                 $a_content = eregi_replace(
"\[emp]",
"<Emph>",$a_content);
 
 3461                 $a_content = eregi_replace(
"\[\/emp\]",
"</Emph>",$a_content);
 
 3462                 $a_content = eregi_replace(
"\[str]",
"<Strong>",$a_content);
 
 3463                 $a_content = eregi_replace(
"\[\/str\]",
"</Strong>",$a_content);
 
 3474                 $path = 
"//IntLink";
 
 3476                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 3478                         $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 3479                         $type = 
$res->nodeset[$i]->get_attribute(
"Type");
 
 3481                         if (substr($target, 0, 4) == 
"il__")
 
 3483                                 $id = substr($target, 4, strlen($target) - 4);
 
 3486                                 if ($a_res_ref_to_obj_id && $type == 
"RepositoryItem")
 
 3488                                         $id_arr = explode(
"_", 
$id);
 
 3493                                                 $id = $otype.
"_".$obj_id;
 
 3496                                 $new_target = 
"il_".$a_inst.
"_".
$id;
 
 3497                                 $res->nodeset[$i]->set_attribute(
"Target", $new_target);
 
 3504                 $path = 
"//MediaAlias";
 
 3506                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 3508                         $origin_id = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 3509                         if (substr($origin_id, 0, 4) == 
"il__")
 
 3511                                 $new_id = 
"il_".$a_inst.
"_".substr($origin_id, 4, strlen($origin_id) - 4);
 
 3512                                 $res->nodeset[$i]->set_attribute(
"OriginId", $new_id);
 
 3519                 $path = 
"//FileItem/Identifier";
 
 3521                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 3523                         $origin_id = 
$res->nodeset[$i]->get_attribute(
"Entry");
 
 3524                         if (substr($origin_id, 0, 4) == 
"il__")
 
 3526                                 $new_id = 
"il_".$a_inst.
"_".substr($origin_id, 4, strlen($origin_id) - 4);
 
 3527                                 $res->nodeset[$i]->set_attribute(
"Entry", $new_id);
 
 3534                 $path = 
"//Question";
 
 3536                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 3538                         $qref = 
$res->nodeset[$i]->get_attribute(
"QRef");
 
 3540                         if (substr($qref, 0, 4) == 
"il__")
 
 3542                                 $new_id = 
"il_".$a_inst.
"_".substr($qref, 4, strlen($qref) - 4);
 
 3544                                 $res->nodeset[$i]->set_attribute(
"QRef", $new_id);
 
 3562                 require_once(
"./Services/COPage/syntax_highlight/php/HFile/HFile_".$proglang.
".php");
 
 3563                 $classname =  
"HFile_$proglang";
 
 3564                 $h_instance = 
new $classname();
 
 3565                 if ($autoindent == 
"n") {
 
 3566                         $h_instance ->notrim   = 1;
 
 3567                         $h_instance ->indent   = array (
"");
 
 3568                         $h_instance ->unindent = array (
"");
 
 3572                 $a_text = $highlighter->highlight_text(html_entity_decode($a_text));
 
 3578                 return file_exists (
"Services/COPage/syntax_highlight/php/HFile/HFile_".$hfile_ext.
".php");
 
 3589                 $path = 
"//Paragraph"; 
 
 3591                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 3593                         $context_node = 
$res->nodeset[$i];
 
 3594                         $char = $context_node->get_attribute(
'Characteristic');
 
 3596                         if ($char != 
"Code")                    
 
 3599                         $n = $context_node->parent_node();
 
 3600                         $char = $context_node->get_attribute(
'Characteristic');
 
 3601                         $subchar = $context_node->get_attribute(
'SubCharacteristic');
 
 3602                         $showlinenumbers = $context_node->get_attribute(
'ShowLineNumbers');
 
 3603                         $downloadtitle = $context_node->get_attribute(
'DownloadTitle');
 
 3604                         $autoindent = $context_node->get_attribute(
'AutoIndent');
 
 3609                         $childs = $context_node->child_nodes();
 
 3611                         for($j=0; $j<count($childs); $j++)
 
 3613                                 $content .= $this->dom->dump_node($childs[$j]);
 
 3616                         while ($context_node->has_child_nodes ())
 
 3618                                 $node_del = $context_node->first_child ();
 
 3619                                 $context_node->remove_child ($node_del);
 
 3622                         $content = str_replace(
"<br />", 
"<br/>", utf8_decode($content) );
 
 3623                         $content = str_replace(
"<br/>", 
"\n", $content);
 
 3624                         $rownums = count(split (
"\n",$content));
 
 3626                         $plain_content = html_entity_decode($content);
 
 3627                         $plain_content = preg_replace (
"/\&#x([1-9a-f]{2});?/ise",
"chr (base_convert (\\1, 16, 10))",$plain_content);
 
 3628                         $plain_content = preg_replace (
"/\&#(\d+);?/ise",
"chr (\\1)",$plain_content);                   
 
 3629                         $content = utf8_encode($this->
highlightText($plain_content, $subchar, $autoindent));
 
 3631                         $content = str_replace(
"&lt;", 
"<", $content);
 
 3632                         $content = str_replace(
"&gt;", 
">", $content);
 
 3635                         $rows    = 
"<tr valign=\"top\">";
 
 3640                         if (strcmp($showlinenumbers,
"y")==0)
 
 3642                                 $linenumbers = 
"<td nowrap=\"nowrap\" class=\"ilc_LineNumbers\" >";
 
 3643                                 $linenumbers .= 
"<pre class=\"ilc_Code\">";
 
 3645                                 for ($j=0; $j < $rownums; $j++)
 
 3647                                         $indentno      = strlen($rownums) - strlen($j+1) + 2;
 
 3648                                         $rownumeration = ($j+1);
 
 3649                                         $linenumbers   .= 
"<span class=\"ilc_LineNumber\">$rownumeration</span>";
 
 3650                                         if ($j < $rownums-1)
 
 3652                                                 $linenumbers .= 
"\n";
 
 3655                                 $linenumbers .= 
"</pre>";
 
 3656                                 $linenumbers .= 
"</td>";
 
 3659                         $rows .= $linenumbers.
"<td class=\"ilc_Sourcecode\"><pre class=\"ilc_Code\">".$content.
"</pre></td>";
 
 3664                         $newcontent = str_replace(
"\n", 
"<br/>",$rows);
 
 3666                         $newcontent = str_replace(
"<br/><br/>", 
"<br/> <br/>",$newcontent);     
 
 3668                         $newcontent = str_replace(
"<br/><br/>", 
"<br/> <br/>",$newcontent);
 
 3673                         $newcontent = str_replace(
"{", 
"{", $newcontent);
 
 3674                         $newcontent = str_replace(
"}", 
"}", $newcontent);
 
 3677                         $a_output = str_replace(
"[[[[[Code;".($i + 1).
"]]]]]", $newcontent, $a_output);
 
 3679                         if ($outputmode != 
"presentation" && is_object($this->offline_handler)
 
 3680                                 && trim($downloadtitle) != 
"")
 
 3683                                 $this->offline_handler->handleCodeParagraph ($this->
id, $i + 1, $downloadtitle, $plain_content);
 
 3700                 foreach ($this->id_elements as $el)
 
 3702                         $path.= $sep.
"//".$el.
"[not(@PCID)]";
 
 3709                 if (count (
$res->nodeset) > 0)
 
 3727                 foreach ($this->id_elements as $el)
 
 3729                         $path.= $sep.
"//".$el.
"[@PCID]";
 
 3737                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
 3740                         $pcids[] = 
$node->get_attribute(
"PCID");
 
 3745                 foreach ($this->id_elements as $el)
 
 3747                         $path.= $sep.
"//".$el.
"[not(@PCID)]";
 
 3753                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
 3756                         $id = ilUtil::randomHash(10, $pcids);
 
 3759                         $res->nodeset[$i]->set_attribute(
"PCID", 
$id);
 
 3769                 $this->addHierIds();
 
 3773                 $path = 
"//PageContent";
 
 3778                 require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
 
 3779                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
 3781                         $hier_id = 
$res->nodeset[$i]->get_attribute(
"HierId");
 
 3782                         $pc_id = 
$res->nodeset[$i]->get_attribute(
"PCID");
 
 3783                         $dump = $mydom->dump_node(
$res->nodeset[$i]);
 
 3784                         if (($hpos = strpos($dump, 
' HierId="'.$hier_id.
'"')) > 0)
 
 3786                                 $dump = substr($dump, 0, $hpos).
 
 3787                                         substr($dump, $hpos + strlen(
' HierId="'.$hier_id.
'"'));
 
 3790                         $childs = 
$res->nodeset[$i]->child_nodes();
 
 3792                         if ($childs[0] && $childs[0]->node_name() == 
"Paragraph")
 
 3794                                 $content = $mydom->dump_node($childs[0]);
 
 3795                                 $content = substr($content, strpos($content, 
">") + 1,
 
 3796                                         strrpos($content, 
"<") - (strpos($content, 
">") + 1));
 
 3804                                 array(
"hier_id" => $hier_id, 
"hash" => md5($dump), 
"content" => $content);
 
 3819                 $path = 
"//Question";
 
 3824                 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
 
 3825                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
 3827                         $qref = 
$res->nodeset[$i]->get_attribute(
"QRef");
 
 3832                         if (!($inst_id > 0))
 
 3853                 $path = 
"/descendant::Paragraph[position() = $par_id]";
 
 3857                 if (count (
$res->nodeset) != 1)
 
 3858                         die (
"Should not happen");
 
 3860                 $context_node = 
$res->nodeset[0];
 
 3864                 $childs = $context_node->child_nodes();
 
 3866                 for($j=0; $j<count($childs); $j++)
 
 3868                         $content .= $mydom->dump_node($childs[$j]);
 
 3871                 $content = str_replace(
"<br />", 
"\n", $content);
 
 3872                 $content = str_replace(
"<br/>", 
"\n", $content);
 
 3874                 $plain_content = html_entity_decode($content);
 
 3891                 $xsl = file_get_contents(
"./Services/COPage/xsl/page_fo.xsl");
 
 3892                 $args = array( 
'/_xml' => 
$xml, 
'/_xsl' => $xsl );
 
 3898                 $fo = 
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args, $params);
 
 3901                 $fo = str_replace(
"\n", 
"", $fo);
 
 3902                 $fo = str_replace(
"<br/>", 
"<br>", $fo);
 
 3903                 $fo = str_replace(
"<br>", 
"\n", $fo);
 
 3908                 $fo = substr($fo, strpos($fo,
">") + 1);
 
 3914                 $this->offline_handler = $handler;
 
 3928                 $query = 
"SELECT * FROM page_object WHERE page_id = ".
 
 3929                         $ilDB->quote($a_id, 
"integer").
" AND ".
 
 3930                         " parent_type = ".$ilDB->quote($a_parent_type, 
"text").
" AND ".
 
 3931                         " inactive_elements = ".$ilDB->quote(1, 
"integer");
 
 3932                 $obj_set = $ilDB->query(
$query);
 
 3950                 if (strpos($a_content,  
" Enabled=\"False\""))
 
 3964                 $h_query = 
"SELECT * FROM page_history ".
 
 3965                         " WHERE page_id = ".$ilDB->quote($this->
getId(), 
"integer").
 
 3966                         " AND parent_type = ".$ilDB->quote($this->
getParentType(), 
"text").
 
 3967                         " ORDER BY hdate DESC";
 
 3969                 $hset = $ilDB->query($h_query);
 
 3970                 $hentries = array();
 
 3972                 while ($hrec = $ilDB->fetchAssoc($hset))
 
 3974                         $hrec[
"sortkey"] = (int) $hrec[
"nr"];
 
 3975                         $hrec[
"user"] = (int) $hrec[
"user_id"];
 
 3976                         $hentries[] = $hrec;
 
 3989                 $res = $ilDB->queryF(
"SELECT * FROM page_history ".
 
 3990                         " WHERE page_id = %s ".
 
 3991                         " AND parent_type = %s ".
 
 3993                         array(
"integer", 
"text", 
"integer"),
 
 3995                 if ($hrec = $ilDB->fetchAssoc(
$res))
 
 4015                 $res = $ilDB->query(
"SELECT MAX(nr) mnr FROM page_history ".
 
 4016                         " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4017                         " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 4018                         " AND nr < ".$ilDB->quote((
int) $a_nr, 
"integer"));
 
 4020                 if (
$row[
"mnr"] > 0)
 
 4022                         $res = $ilDB->query(
"SELECT * FROM page_history ".
 
 4023                                 " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4024                                 " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 4025                                 " AND nr = ".$ilDB->quote((
int) 
$row[
"mnr"], 
"integer"));
 
 4026                         $row = $ilDB->fetchAssoc(
$res);
 
 4031                 $res = $ilDB->query(
"SELECT MIN(nr) mnr FROM page_history ".
 
 4032                         " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4033                         " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 4034                         " AND nr > ".$ilDB->quote((
int) $a_nr, 
"integer"));
 
 4036                 if (
$row[
"mnr"] > 0)
 
 4038                         $res = $ilDB->query(
"SELECT * FROM page_history ".
 
 4039                                 " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4040                                 " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 4041                                 " AND nr = ".$ilDB->quote((
int) 
$row[
"mnr"], 
"integer"));
 
 4042                         $row = $ilDB->fetchAssoc(
$res);
 
 4047                 $res = $ilDB->query(
"SELECT * FROM page_history ".
 
 4048                         " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4049                         " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 4050                         " AND nr = ".$ilDB->quote((
int) $a_nr, 
"integer"));
 
 4062                 $rnode = 
$res->nodeset[0];
 
 4065                 foreach($a_hashes as $pc_id => $h)
 
 4068                         if ($h[
"change"] != 
"")
 
 4071                                 $dc_node = $this->dom->create_element(
"DivClass");
 
 4072                                 $dc_node->set_attribute(
"HierId", $h[
"hier_id"]);
 
 4073                                 $dc_node->set_attribute(
"Class", 
"ilEdit".$h[
"change"]);
 
 4074                                 $dc_node = $rnode->append_child($dc_node);
 
 4093                 $l_hashes = $l_page->getPageContentsHashes();
 
 4094                 $r_hashes = $r_page->getPageContentsHashes();
 
 4097                 foreach ($l_hashes as $pc_id => $h)
 
 4099                         if (!isset($r_hashes[$pc_id]))
 
 4101                                 $l_hashes[$pc_id][
"change"] = 
"Deleted";
 
 4105                                 if ($l_hashes[$pc_id][
"hash"] != $r_hashes[$pc_id][
"hash"])
 
 4107                                         $l_hashes[$pc_id][
"change"] = 
"Modified";
 
 4108                                         $r_hashes[$pc_id][
"change"] = 
"Modified";
 
 4110                                         include_once(
"./Services/COPage/mediawikidiff/class.WordLevelDiff.php");
 
 4112                                         if ($l_hashes[$pc_id][
"content"] != 
"" &&
 
 4113                                                 $r_hashes[$pc_id][
"content"] != 
"")
 
 4115                                                 $new_left = str_replace(
"\n", 
"<br />", $l_hashes[$pc_id][
"content"]);
 
 4116                                                 $new_right = str_replace(
"\n", 
"<br />", $r_hashes[$pc_id][
"content"]);
 
 4119                                                 $new_left = $wldiff->orig();
 
 4120                                                 $new_right = $wldiff->closing();
 
 4121                                                 $l_page->setParagraphContent($l_hashes[$pc_id][
"hier_id"], $new_left[0]);
 
 4122                                                 $r_page->setParagraphContent($l_hashes[$pc_id][
"hier_id"], $new_right[0]);
 
 4129                 foreach ($r_hashes as $pc_id => $h)
 
 4131                         if (!isset($l_hashes[$pc_id]))
 
 4133                                 $r_hashes[$pc_id][
"change"] = 
"New";
 
 4137                 $l_page->addChangeDivClasses($l_hashes);
 
 4138                 $r_page->addChangeDivClasses($r_hashes);
 
 4140                 return array(
"l_page" => $l_page, 
"r_page" => $r_page,
 
 4141                         "l_changes" => $l_hashes, 
"r_changes" => $r_hashes);
 
 4151                 $ilDB->manipulate(
"UPDATE page_object ".
 
 4152                         " SET view_cnt = view_cnt + 1 ".
 
 4153                         " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4154                         " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text"));
 
 4169                 $page_changes = array();
 
 4170                 $limit_ts = date(
'Y-m-d H:i:s', time() - ($a_period * 24 * 60 * 60));
 
 4171                 $q = 
"SELECT * FROM page_object ".
 
 4172                         " WHERE parent_id = ".$ilDB->quote($a_parent_id, 
"integer").
 
 4173                         " AND parent_type = ".$ilDB->quote($a_parent_type, 
"text").
 
 4174                         " AND last_change >= ".$ilDB->quote($limit_ts, 
"timestamp");
 
 4176                 $set = $ilDB->query($q);
 
 4177                 while($page = $ilDB->fetchAssoc($set))
 
 4179                         $page_changes[] = array(
"date" => $page[
"last_change"],
 
 4180                                 "id" => $page[
"page_id"], 
"type" => 
"page",
 
 4181                                 "user" => $page[
"last_change_user"]);
 
 4187                         $limit_ts = date(
'Y-m-d H:i:s', time() - ($a_period * 24 * 60 * 60));
 
 4188                         $and_str = 
" AND hdate >= ".$ilDB->quote($limit_ts, 
"timestamp").
" ";
 
 4191                 $q = 
"SELECT * FROM page_history ".
 
 4192                         " WHERE parent_id = ".$ilDB->quote($a_parent_id, 
"integer").
 
 4193                         " AND parent_type = ".$ilDB->quote($a_parent_type, 
"text").
 
 4195                 $set = $ilDB->query($q);
 
 4196                 while ($page = $ilDB->fetchAssoc($set))
 
 4198                         $page_changes[] = array(
"date" => $page[
"hdate"],
 
 4199                                 "id" => $page[
"page_id"], 
"type" => 
"hist", 
"nr" => $page[
"nr"],
 
 4200                                 "user" => $page[
"user_id"]);
 
 4205                 return $page_changes;
 
 4219                 $page_changes = array();
 
 4221                 $q = 
"SELECT * FROM page_object ".
 
 4222                         " WHERE parent_id = ".$ilDB->quote($a_parent_id, 
"integer").
 
 4223                         " AND parent_type = ".$ilDB->quote($a_parent_type, 
"text");
 
 4224                 $set = $ilDB->query($q);
 
 4226                 while ($page = $ilDB->fetchAssoc($set))
 
 4228                         $pages[$page[
"page_id"]] = array(
"date" => $page[
"last_change"],
 
 4229                                 "id" => $page[
"page_id"], 
"user" => $page[
"last_change_user"]);
 
 4247                 $q = 
"SELECT * FROM page_object ".
 
 4248                         " WHERE parent_id = ".$ilDB->quote($a_parent_id, 
"integer").
 
 4249                         " AND parent_type = ".$ilDB->quote($a_parent_type, 
"text").
 
 4250                         " ORDER BY created DESC";
 
 4251                 $set = $ilDB->query($q);
 
 4252                 while($page = $ilDB->fetchAssoc($set))
 
 4254                         if ($page[
"created"] != 
"")
 
 4256                                 $pages[] = array(
"created" => $page[
"created"],
 
 4257                                         "id" => $page[
"page_id"],
 
 4258                                         "user" => $page[
"create_user"],
 
 4276                 $contributors = array();
 
 4277                 $set = $ilDB->queryF(
"SELECT last_change_user FROM page_object ".
 
 4278                         " WHERE parent_id = %s AND parent_type = %s ".
 
 4279                         " AND last_change_user != %s",
 
 4280                         array(
"integer", 
"text", 
"integer"),
 
 4281                         array($a_parent_id, $a_parent_type, 0));
 
 4283                 while ($page = $ilDB->fetchAssoc($set))
 
 4285                         $contributors[$page[
"last_change_user"]][$page[
"page_id"]] = 1;
 
 4288                 $set = $ilDB->queryF(
"SELECT count(*) as cnt, page_id, user_id FROM page_history ".
 
 4289                         " WHERE parent_id = %s AND parent_type = %s AND user_id != %s ".
 
 4290                         " GROUP BY page_id, user_id ",
 
 4291                         array(
"integer", 
"text", 
"integer"),
 
 4292                         array($a_parent_id, $a_parent_type, 0));
 
 4293                 while ($hpage = $ilDB->fetchAssoc($set))
 
 4295                         $contributors[$hpage[
"user_id"]][$hpage[
"page_id"]] =
 
 4296                                 $contributors[$hpage[
"user_id"]][$hpage[
"page_id"]] + $hpage[
"cnt"];
 
 4300                 foreach ($contributors as $k => $co)
 
 4303                         $c[] = array(
"user_id" => $k, 
"pages" => $co,
 
 4304                                 "lastname" => $name[
"lastname"], 
"firstname" => $name[
"firstname"]);
 
 4320                 $contributors = array();
 
 4321                 $set = $ilDB->queryF(
"SELECT last_change_user FROM page_object ".
 
 4322                         " WHERE page_id = %s AND parent_type = %s ".
 
 4323                         " AND last_change_user != %s",
 
 4324                         array(
"integer", 
"text", 
"integer"),
 
 4325                         array($a_page_id, $a_parent_type, 0));
 
 4327                 while ($page = $ilDB->fetchAssoc($set))
 
 4329                         $contributors[$page[
"last_change_user"]] = 1;
 
 4332                 $set = $ilDB->queryF(
"SELECT count(*) as cnt, page_id, user_id FROM page_history ".
 
 4333                         " WHERE page_id = %s AND parent_type = %s AND user_id != %s ".
 
 4334                         " GROUP BY user_id, page_id ",
 
 4335                         array(
"integer", 
"text", 
"integer"),
 
 4336                         array($a_page_id, $a_parent_type, 0));
 
 4337                 while ($hpage = $ilDB->fetchAssoc($set))
 
 4339                         $contributors[$hpage[
"user_id"]] =
 
 4340                                 $contributors[$hpage[
"user_id"]] + $hpage[
"cnt"];
 
 4344                 foreach ($contributors as $k => $co)
 
 4347                         $c[] = array(
"user_id" => $k, 
"pages" => $co,
 
 4348                                 "lastname" => $name[
"lastname"], 
"firstname" => $name[
"firstname"]);
 
 4361                 $ilDB->update(
"page_object", array(
 
 4362                         "rendered_content" => array(
"clob", $a_content),
 
 4363                         "render_md5" => array(
"text", $a_md5),
 
 4364                         "rendered_time" => array(
"timestamp", 
ilUtil::now())
 
 4366                         "page_id" => array(
"integer", $this->
getId()),
 
 4388                 $page_changes = array();
 
 4390                 $q = 
"SELECT * FROM page_object ".
 
 4391                         " WHERE parent_id = ".$ilDB->quote($a_parent_id, 
"integer").
 
 4392                         " AND parent_type = ".$ilDB->quote($a_parent_type, 
"text").
 
 4393                         " AND int_links = ".$ilDB->quote(1, 
"integer");
 
 4394                 $set = $ilDB->query($q);
 
 4396                 while ($page = $ilDB->fetchAssoc($set))
 
 4398                         $pages[$page[
"page_id"]] = array(
"date" => $page[
"last_change"],
 
 4399                                 "id" => $page[
"page_id"], 
"user" => $page[
"last_change_user"]);
 
 4413                 if (strpos($a_content,  
"IntLink"))