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");
 
   73         final public function ilPageObject($a_id = 0, $a_old_nr = 0, $a_lang = 
"-")
 
   78                 require_once(
"./Services/COPage/syntax_highlight/php/Beautifier/Init.php");
 
   79                 require_once(
"./Services/COPage/syntax_highlight/php/Output/Output_css.php");
 
   86                 $this->contains_int_link = 
false;
 
   87                 $this->needs_parsing = 
false;
 
   88                 $this->update_listeners = array();
 
   89                 $this->update_listener_cnt = 0;
 
   90                 $this->dom_builded = 
false;
 
   91                 $this->page_not_found = 
false;
 
   92                 $this->old_nr = $a_old_nr;
 
   93                 $this->encoding = 
"UTF-8";              
 
   95                         array(
"PageContent", 
"TableRow", 
"TableData", 
"ListItem", 
"FileItem",
 
   96                                 "Section", 
"Tab", 
"ContentPopup");
 
  135                 include_once(
"./Services/COPage/classes/class.ilPageObjectFactory.php");
 
  147                 $this->language = $a_val;
 
  167                 $this->page_config = $a_val;
 
  177                 return $this->page_config;
 
  187                 $this->rendermd5 = $a_rendermd5;
 
  197                 return $this->rendermd5;
 
  207                 $this->renderedcontent = $a_renderedcontent;
 
  217                 return $this->renderedcontent;
 
  227                 $this->renderedtime = $a_renderedtime;
 
  237                 return $this->renderedtime;
 
  247                 $this->lastchange = $a_lastchange;
 
  257                 return $this->lastchange;
 
  267                 $this->last_change_user = $a_val;
 
  277                 return $this->last_change_user;
 
  287                 $this->show_page_act_info = $a_val;
 
  297                 return $this->show_page_act_info;
 
  308                 if ($this->old_nr == 0)
 
  310                         $query = 
"SELECT * FROM page_object".
 
  311                                 " WHERE page_id = ".$ilDB->quote($this->
id, 
"integer").
 
  312                                 " AND parent_type=".$ilDB->quote($this->
getParentType(), 
"text").
 
  313                                 " AND lang = ".$ilDB->quote($this->
getLanguage(), 
"text");
 
  314                         $pg_set = $this->ilias->db->query(
$query);
 
  315                         $this->page_record = $ilDB->fetchAssoc($pg_set);
 
  316                         $this->
setActive($this->page_record[
"active"]);
 
  323                         $query = 
"SELECT * FROM page_history".
 
  324                                 " WHERE page_id = ".$ilDB->quote($this->
id, 
"integer").
 
  325                                 " AND parent_type=".$ilDB->quote($this->
getParentType(), 
"text").
 
  326                                 " AND nr = ".$ilDB->quote((
int) $this->old_nr, 
"integer").
 
  327                                 " AND lang = ".$ilDB->quote($this->
getLanguage(), 
"text");
 
  328                         $pg_set = $ilDB->query(
$query);
 
  329                         $this->page_record = $ilDB->fetchAssoc($pg_set);
 
  331                 if (!$this->page_record)
 
  333                         include_once(
"./Services/COPage/exceptions/class.ilCOPageNotFoundException.php");
 
  338                 $this->xml = $this->page_record[
"content"];
 
  339                 $this->
setParentId($this->page_record[
"parent_id"]);
 
  340                 $this->last_change_user = $this->page_record[
"last_change_user"];
 
  341                 $this->create_user = $this->page_record[
"create_user"];
 
  356         static function _exists($a_parent_type, $a_id, $a_lang = 
"")
 
  359                 if (isset(self::$exists[$a_parent_type.
":".$a_id.
":".$a_lang]))
 
  361                         return self::$exists[$a_parent_type.
":".$a_id.
":".$a_lang];
 
  367                         $and_lang = 
" AND lang = ".$ilDB->quote($a_lang, 
"text");
 
  370                 $query = 
"SELECT page_id FROM page_object WHERE page_id = ".$ilDB->quote($a_id, 
"integer").
" ".
 
  371                         "AND parent_type = ".$ilDB->quote($a_parent_type, 
"text").$and_lang;
 
  372                 $set = $ilDB->query(
$query);
 
  373                 if (
$row = $ilDB->fetchAssoc($set))
 
  375                         self::$exists[$a_parent_type.
":".$a_id.
":".$a_lang] = 
true;
 
  380                         self::$exists[$a_parent_type.
":".$a_id.
":".$a_lang] = 
false;
 
  396                 include_once(
"./Services/COPage/classes/class.ilPageUtil.php");
 
  403                 if ($this->dom_builded && !$a_force)
 
  413                 $path = 
"//PageObject";
 
  415                 if (count(
$res->nodeset) == 1)
 
  417                         $this->node =& 
$res->nodeset[0];
 
  422                         $this->dom_builded = 
true;
 
  455                         return $this->dom->myDOMDocument;
 
  477                 $this->parent_id = $a_id;
 
  488                 $this->update_listeners[$cnt][
"object"] =& $a_object;
 
  489                 $this->update_listeners[$cnt][
"method"] = $a_method;
 
  490                 $this->update_listeners[$cnt][
"parameters"] = $a_parameters;
 
  491                 $this->update_listener_cnt++;
 
  498                         $object =& $this->update_listeners[$i][
"object"];
 
  499                         $method = $this->update_listeners[$i][
"method"];
 
  500                         $parameters = $this->update_listeners[$i][
"parameters"];
 
  501                         $object->$method($parameters);
 
  512                 $this->active = $a_active;
 
  520         function getActive($a_check_scheduled_activation = 
false)
 
  522                 if ($a_check_scheduled_activation && !$this->active)
 
  524                         include_once(
"./Services/Calendar/classes/class.ilDateTime.php");
 
  533                 return $this->active;
 
  545                 $set = $ilDB->query(
"SELECT page_id, parent_type, lang, active, activation_start, activation_end, show_activation_info FROM page_object ".
 
  546                         " WHERE parent_id = ".$ilDB->quote($a_parent_id, 
"integer")
 
  548                 while ($rec = $ilDB->fetchAssoc($set))
 
  550                         self::$activation_data[$rec[
"page_id"].
":".$rec[
"parent_type"].
":".$rec[
"lang"]] = $rec;
 
  558         static function _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation = 
false, $a_lang = 
"-")
 
  568                 if (isset(self::$activation_data[$a_id.
":".$a_parent_type.
":".$a_lang]))
 
  570                         $rec = self::$activation_data[$a_id.
":".$a_parent_type.
":".$a_lang];
 
  574                         $set = $ilDB->queryF(
"SELECT active, activation_start, activation_end FROM page_object WHERE page_id = %s".
 
  575                                 " AND parent_type = %s AND lang = %s",
 
  576                                         array(
"integer", 
"text", 
"text"),
 
  577                                         array($a_id, $a_parent_type, $a_lang));
 
  578                         $rec = $ilDB->fetchAssoc($set);
 
  584                 if (!$rec[
"active"] && $a_check_scheduled_activation)
 
  586                         if ($rec[
"n"] >= $rec[
"activation_start"] &&
 
  587                                 $rec[
"n"] <= $rec[
"activation_end"])
 
  593                 return $rec[
"active"];
 
  611                 if (isset(self::$activation_data[$a_id.
":".$a_parent_type.
":".$a_lang]))
 
  613                         $rec = self::$activation_data[$a_id.
":".$a_parent_type.
":".$a_lang];
 
  617                         $set = $ilDB->queryF(
"SELECT active, activation_start, activation_end FROM page_object WHERE page_id = %s".
 
  618                         " AND parent_type = %s AND lang = %s", array(
"integer", 
"text", 
"text"),
 
  619                         array($a_id, $a_parent_type, $a_lang));
 
  620                         $rec = $ilDB->fetchAssoc($set);
 
  623                 if (!$rec[
"active"] && $rec[
"activation_start"] != 
"")
 
  634         function _writeActive($a_id, $a_parent_type, $a_active, $a_reset_scheduled_activation = 
true, $a_lang = 
"-")
 
  644                 if ($a_reset_scheduled_activation)
 
  646                         $st = $ilDB->manipulateF(
"UPDATE page_object SET active = %s, activation_start = %s, ".
 
  647                                 " activation_end = %s WHERE page_id = %s".
 
  648                                 " AND parent_type = %s AND lang = %s", array(
"boolean", 
"timestamp", 
"timestamp", 
"integer", 
"text", 
"text"),
 
  649                                 array($a_active, null, null, $a_id, $a_parent_type, $a_lang));
 
  653                         $st = $ilDB->prepareManip(
"UPDATE page_object SET active = %s WHERE page_id = %s".
 
  654                                 " AND parent_type = %s AND lang = %s", array(
"boolean", 
"integer", 
"text", 
"text"),
 
  655                                 array($a_active, $a_id, $a_parent_type, $a_lang));
 
  672                 if (isset(self::$activation_data[$a_id.
":".$a_parent_type.
":".$a_lang]))
 
  674                         $rec = self::$activation_data[$a_id.
":".$a_parent_type.
":".$a_lang];
 
  678                         $set = $ilDB->queryF(
"SELECT active, activation_start, activation_end, show_activation_info FROM page_object WHERE page_id = %s".
 
  679                         " AND parent_type = %s AND lang = %s",
 
  680                                 array(
"integer", 
"text", 
"text"),
 
  681                                 array($a_id, $a_parent_type, $a_lang));
 
  682                         $rec = $ilDB->fetchAssoc($set);
 
  696                 $res = $ilDB->query(
"SELECT parent_id FROM page_object WHERE page_id = ".$ilDB->quote($a_id, 
"integer").
" ".
 
  697                                 "AND parent_type=".$ilDB->quote($a_type, 
"text"));
 
  698                 $rec = $ilDB->fetchAssoc(
$res);
 
  699                 return $rec[
"parent_id"];
 
  709                 $st = $ilDB->manipulateF(
"UPDATE page_object SET parent_id = %s WHERE page_id = %s".
 
  710                         " AND parent_type = %s", array(
"integer", 
"integer", 
"text"),
 
  711                         array($a_par_id, $a_pg_id, $a_parent_type));
 
  721                 $this->activationstart = $a_activationstart;
 
  731                 return $this->activationstart;
 
  741                 $this->activationend = $a_activationend;
 
  751                 return $this->activationend;
 
  765                 if (!is_object($cont_node))
 
  769                 include_once(
"./Services/COPage/classes/class.ilCOPagePCDef.php");
 
  770                 $node_name = $cont_node->node_name();
 
  771                 if ($node_name == 
"PageObject")
 
  775                 if ($node_name == 
"PageContent")
 
  777                         $child_node = $cont_node->first_child();
 
  778                         $node_name = $child_node->node_name();
 
  782                 if ($node_name == 
"Table")
 
  784                         if ($child_node->get_attribute(
"DataTable") == 
"y")
 
  786                                 require_once(
"./Services/COPage/classes/class.ilPCDataTable.php");
 
  788                                 $tab->setNode($cont_node);
 
  789                                 $tab->setHierId($a_hier_id);
 
  793                                 require_once(
"./Services/COPage/classes/class.ilPCTable.php");
 
  795                                 $tab->setNode($cont_node);
 
  796                                 $tab->setHierId($a_hier_id);
 
  798                         $tab->setPcId($a_pc_id);
 
  803                 if ($node_name == 
"MediaObject")
 
  805                         if (
$_GET[
"pgEdMediaMode"] != 
"") {echo 
"ilPageObject::error media"; 
exit;}
 
  808                         require_once(
"./Services/COPage/classes/class.ilPCMediaObject.php");
 
  810                         $mal_node =& $child_node->first_child();
 
  812                         $id_arr = explode(
"_", $mal_node->get_attribute(
"OriginId"));
 
  813                         $mob_id = $id_arr[count($id_arr) - 1];
 
  823                         $mob->readMediaObject($mob_id);
 
  826                         $mob->setNode($cont_node);
 
  827                         $mob->setHierId($a_hier_id);
 
  828                         $mob->setPcId($a_pc_id);
 
  839                 if (!is_array($pc_def))
 
  841                         include_once(
"./Services/COPage/exceptions/class.ilCOPageUnknownPCTypeException.php");
 
  844                 $pc_class = 
"ilPC".$pc_def[
"name"];
 
  845                 $pc_path = 
"./".$pc_def[
"component"].
"/".$pc_def[
"directory"].
"/class.".$pc_class.
".php";
 
  846                 require_once($pc_path);
 
  847                 $pc = 
new $pc_class($this);
 
  848                 $pc->setNode($cont_node);
 
  849                 $pc->setHierId($a_hier_id);
 
  850                 $pc->setPcId($a_pc_id);
 
  863                 if($a_hier_id == 
"pg")
 
  872                                 $path = 
"//*[@PCID = '$a_pc_id']";
 
  874                                 if (count(
$res->nodeset) == 1)
 
  876                                         $cont_node =& 
$res->nodeset[0];
 
  882                         $path = 
"//*[@HierId = '$a_hier_id']";
 
  884                         if (count(
$res->nodeset) == 1)
 
  886                                 $cont_node =& 
$res->nodeset[0];
 
  904                         $path = 
"//*[@PCID = '$a_pc_id']//".$a_content_tag;
 
  906                         if (count(
$res->nodeset) > 0)
 
  913                 $path = 
"//*[@HierId = '$a_hier_id']//".$a_content_tag;
 
  915                 if (count(
$res->nodeset) > 0)
 
  926                 $path = 
"//*[@HierId = '$a_hier_id']";
 
  928                 if (count(
$res->nodeset) == 1)
 
  951                 $this->encoding = $a_encoding;
 
  977                         $enc_str = (!empty($this->encoding))
 
  978                                 ? 
"encoding=\"".$this->encoding.
"\"" 
  980                         return "<?xml version=\"1.0\" $enc_str ?>".
 
  981                 "<!DOCTYPE PageObject SYSTEM \"".ILIAS_ABSOLUTE_PATH.
"/xml/".$this->cur_dtd.
"\">".
 
  996                 $xml = $this->getXmlContent();
 
 1003                 $xml = $temp_dom->dump_mem(0, $this->encoding);
 
 1004                 $xml = eregi_replace(
"<\?xml[^>]*>",
"",
$xml);
 
 1005                 $xml = eregi_replace(
"<!DOCTYPE[^>]*>",
"",
$xml);
 
 1023                 include_once(
"./Services/COPage/classes/class.ilCOPagePCDef.php");
 
 1048                         $a_dom = $a_dom->myDOMDocument;
 
 1050                 foreach ($defs as $def)
 
 1053                         $cl = $def[
"pc_class"];
 
 1066                 $path = 
"//InteractiveImage/MediaAlias";
 
 1071                 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
 
 1072                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
 1074                         $or_id = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 1079                         if (!($inst_id > 0))
 
 1083                                         include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 1088                                         $new_mob = $media_object->duplicate();
 
 1090                                         $res->nodeset[$i]->set_attribute(
"OriginId", 
"il__mob_".$new_mob->getId());
 
 1102                 $path = 
"//MediaObject/MediaAlias";
 
 1107                 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
 
 1108                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
 1110                         $or_id = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 1115                         if (!($inst_id > 0))
 
 1119                                         include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 1124                                         $new_mob = $media_object->duplicate();
 
 1126                                         $res->nodeset[$i]->set_attribute(
"OriginId", 
"il__mob_".$new_mob->getId());
 
 1139                 $path = 
"//Question";
 
 1144                 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
 
 1145                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
 1147                         $qref = 
$res->nodeset[$i]->get_attribute(
"QRef");
 
 1152                         if (!($inst_id > 0))
 
 1156                                         include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
 1163                                                 $question->createPageObject();
 
 1168                                         $duplicate_id = $question->duplicate(
false);
 
 1169                                         $res->nodeset[$i]->set_attribute(
"QRef", 
"il__qst_".$duplicate_id);
 
 1184                 $path = 
"//Question";
 
 1187                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
 1189                         $parent_node = 
$res->nodeset[$i]->parent_node();
 
 1190                         $parent_node->unlink_node($parent_node);
 
 1206                 $path = 
"//PageContent";
 
 1209                 return count (
$res->nodeset);
 
 1216         function getXMLFromDom($a_incl_head = 
false, $a_append_mobs = 
false, $a_append_bib = 
false,
 
 1217                 $a_append_str = 
"", $a_omit_pageobject_tag = 
false)
 
 1222                         return $this->dom->dump_mem(0, $this->encoding);
 
 1227                         if ($a_append_mobs || $a_append_bib || $a_append_link_info)
 
 1241                                 return "<dummy>".$this->dom->dump_node($this->node).$mobs.$bibs.$trans.$a_append_str.
"</dummy>";
 
 1245                                 if (is_object($this->dom))
 
 1247                                         if ($a_omit_pageobject_tag)
 
 1250                                                 $childs =& $this->node->child_nodes();
 
 1251                                                 for($i = 0; $i < count($childs); $i++)
 
 1253                                                         $xml.= $this->dom->dump_node($childs[$i]);
 
 1259                                                 $xml = $this->dom->dump_mem(0, $this->encoding);
 
 1260                                                 $xml = eregi_replace(
"<\?xml[^>]*>",
"",
$xml);
 
 1261                                                 $xml = eregi_replace(
"<!DOCTYPE[^>]*>",
"",
$xml);
 
 1286                         "ed_paste_clip", 
"ed_edit", 
"ed_edit_prop", 
"ed_delete", 
"ed_moveafter",
 
 1287                         "ed_movebefore", 
"ed_go", 
"ed_class", 
"ed_width", 
"ed_align_left",
 
 1288                         "ed_align_right", 
"ed_align_center", 
"ed_align_left_float",
 
 1289                         "ed_align_right_float", 
"ed_delete_item", 
"ed_new_item_before",
 
 1290                         "ed_new_item_after", 
"ed_copy_clip", 
"please_select", 
"ed_split_page",
 
 1291                         "ed_item_up", 
"ed_item_down", 
"ed_split_page_next",
"ed_enable",
 
 1292                         "de_activate", 
"ed_paste", 
"ed_edit_multiple", 
"ed_cut", 
"ed_copy");
 
 1295                 include_once(
"./Services/COPage/classes/class.ilCOPagePCDef.php");
 
 1297                 foreach ($defs as $def)
 
 1299                         $lang_vars[] = 
"pc_".$def[
"pc_type"];
 
 1300                         $lang_vars[] = 
"ed_insert_".$def[
"pc_type"];
 
 1303                         $cl = $def[
"pc_class"];
 
 1304                         $lvs = call_user_func($def[
"pc_class"].
'::getLangVars');
 
 1305                         foreach ($lvs as $lv)
 
 1311                 foreach ($lang_vars as $lang_var)
 
 1325                 $xml.= 
"<LV name=\"$var\" value=\"".$lng->txt(
"cont_".$var).
"\"/>";
 
 1334                         require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
 
 1336                         $path = 
"//Paragraph[1]";
 
 1338                         if (count(
$res->nodeset) > 0)
 
 1340                                 $cont_node =& 
$res->nodeset[0]->parent_node();
 
 1342                                 $par->setNode($cont_node);
 
 1343                                 return $par->getText();
 
 1358                 if (is_object(
$node))
 
 1360                         $node->set_content($a_content);
 
 1378                 $this->contains_int_link = $a_contains_link;
 
 1394                 if ($a_parse === 
true)
 
 1396                         $this->needs_parsing = 
true;
 
 1398                 if ($a_parse === 
false)
 
 1400                         $this->needs_parsing = 
false;
 
 1413                 $this->contains_question = $a_val;
 
 1423                 return $this->contains_question;
 
 1437                 $path = 
"//MediaObject/MediaAlias";
 
 1440                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1442                         $id_arr = explode(
"_", 
$res->nodeset[$i]->get_attribute(
"OriginId"));
 
 1443                         $mob_id = $id_arr[count($id_arr) - 1];
 
 1444                         $mob_ids[$mob_id] = $mob_id;
 
 1449                 $path = 
"//InteractiveImage/MediaAlias";
 
 1451                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1453                         $id_arr = explode(
"_", 
$res->nodeset[$i]->get_attribute(
"OriginId"));
 
 1454                         $mob_id = $id_arr[count($id_arr) - 1];
 
 1455                         $mob_ids[$mob_id] = $mob_id;
 
 1460                 $path = 
"//IntLink[@Type = 'MediaObject']";
 
 1463                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1465                         if ((
$res->nodeset[$i]->get_attribute(
"TargetFrame") == 
"") ||
 
 1468                                 $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 1469                                 $id_arr = explode(
"_", $target);
 
 1470                                 if (($id_arr[1] == IL_INST_ID) ||
 
 1471                                         (substr($target, 0, 4) == 
"il__"))
 
 1473                                         $mob_id = $id_arr[count($id_arr) - 1];
 
 1476                                                 $mob_ids[$mob_id] = $mob_id;
 
 1494                 $path = 
"//IntLink";
 
 1499                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1502                         if ($a_cnt_multiple)
 
 1504                                 $add = 
":".$cnt_multiple;
 
 1506                         $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 1507                         $type = 
$res->nodeset[$i]->get_attribute(
"Type");
 
 1508                         $targetframe = 
$res->nodeset[$i]->get_attribute(
"TargetFrame");
 
 1509                         $anchor = 
$res->nodeset[$i]->get_attribute(
"Anchor");
 
 1510                         $links[$target.
":".$type.
":".$targetframe.
":".$anchor.$add] =
 
 1511                                 array(
"Target" => $target, 
"Type" => $type,
 
 1512                                         "TargetFrame" => $targetframe, 
"Anchor" => $anchor);
 
 1515                         if ($type == 
"MediaObject" && $targetframe == 
"")
 
 1517                                 if (substr($target, 0, 4) ==
"il__")
 
 1519                                         $id_arr = explode(
"_", $target);
 
 1520                                         $id = $id_arr[count($id_arr) - 1];
 
 1523                                         foreach($med_links as $key => $med_link)
 
 1525                                                 $links[$key] = $med_link;
 
 1537                 $path = 
"//MediaAlias";
 
 1540                 require_once(
"Services/MediaObjects/classes/class.ilMediaItem.php");
 
 1541                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1543                         $oid = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 1544                         if (substr($oid, 0, 4) ==
"il__")
 
 1546                                 $id_arr = explode(
"_", $oid);
 
 1547                                 $id = $id_arr[count($id_arr) - 1];
 
 1550                                 foreach($med_links as $key => $med_link)
 
 1552                                         $links[$key] = $med_link;
 
 1572                 require_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 1573                 foreach($mob_ids as $mob_id => $dummy)
 
 1592                 $path = 
"//MediaObject/MediaAlias[@OriginId='il__mob_$a_mob_id']";
 
 1594                 $mal_node =& 
$res->nodeset[$a_nr - 1];
 
 1595                 $mob_node =& $mal_node->parent_node();
 
 1597                 return $this->dom->dump_node($mob_node);
 
 1610                 libxml_disable_entity_loader(
false);
 
 1612                 @$this->dom->validate($error);
 
 1635                 $this->hier_ids = array();
 
 1636                 $this->first_row_ids = array();
 
 1637                 $this->first_col_ids = array();
 
 1638                 $this->list_item_ids = array();
 
 1639                 $this->file_item_ids = array();
 
 1646                 foreach ($this->id_elements as $el)
 
 1648                         $path.= $sep.
"//".$el;
 
 1653                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1655                         $cnode = 
$res->nodeset[$i];
 
 1656                         $ctag = $cnode->node_name();
 
 1660                         while($cnode =& $cnode->previous_sibling())
 
 1662                                 if (($cnode->node_type() == XML_ELEMENT_NODE)
 
 1663                                         && $cnode->has_attribute(
"HierId"))
 
 1665                                         $sib_hier_id = $cnode->get_attribute(
"HierId");
 
 1671                         if ($sib_hier_id != 
"")         
 
 1673                                 require_once(
"./Services/COPage/classes/class.ilPageContent.php");
 
 1675                                 $res->nodeset[$i]->set_attribute(
"HierId", $node_hier_id);
 
 1676                                 $this->hier_ids[] = $node_hier_id;
 
 1677                                 if ($ctag == 
"TableData")
 
 1679                                         if (substr($par_hier_id,strlen($par_hier_id)-2) == 
"_1")
 
 1681                                                 $this->first_row_ids[] = $node_hier_id;
 
 1684                                 if ($ctag == 
"ListItem")
 
 1686                                         $this->list_item_ids[] = $node_hier_id;
 
 1688                                 if ($ctag == 
"FileItem")
 
 1690                                         $this->file_item_ids[] = $node_hier_id;
 
 1696                                 $cnode = 
$res->nodeset[$i];
 
 1698                                 while($cnode =& $cnode->parent_node())
 
 1700                                         if (($cnode->node_type() == XML_ELEMENT_NODE)
 
 1701                                                 && $cnode->has_attribute(
"HierId"))
 
 1703                                                 $par_hier_id = $cnode->get_attribute(
"HierId");
 
 1709                                 if (($par_hier_id != 
"") && ($par_hier_id != 
"pg"))             
 
 1711                                         $node_hier_id = $par_hier_id.
"_1";
 
 1712                                         $res->nodeset[$i]->set_attribute(
"HierId", $node_hier_id);
 
 1713                                         $this->hier_ids[] = $node_hier_id;
 
 1714                                         if ($ctag == 
"TableData")
 
 1716                                                 $this->first_col_ids[] = $node_hier_id;
 
 1717                                                 if (substr($par_hier_id,strlen($par_hier_id)-2) == 
"_1")
 
 1719                                                         $this->first_row_ids[] = $node_hier_id;
 
 1722                                         if ($ctag == 
"ListItem")
 
 1724                                                 $this->list_item_ids[] = $node_hier_id;
 
 1726                                         if ($ctag == 
"FileItem")
 
 1728                                                 $this->file_item_ids[] = $node_hier_id;
 
 1734                                         $node_hier_id = 
"1";
 
 1735                                         $res->nodeset[$i]->set_attribute(
"HierId", $node_hier_id);
 
 1736                                         $this->hier_ids[] = $node_hier_id;
 
 1743                 $path = 
"//PageObject";
 
 1745                 for($i = 0; $i < count(
$res->nodeset); $i++)    
 
 1747                         $res->nodeset[$i]->set_attribute(
"HierId", 
"pg");
 
 1748                         $this->hier_ids[] = 
"pg";
 
 1758                 return $this->hier_ids;
 
 1767                 return $this->first_row_ids;
 
 1776                 return $this->first_col_ids;
 
 1785                 return $this->list_item_ids;
 
 1794                 return $this->file_item_ids;
 
 1802                 if(is_object($this->dom))
 
 1805                         $path = 
"//*[@HierId]";
 
 1807                         for($i = 0; $i < count(
$res->nodeset); $i++)    
 
 1809                                 if (
$res->nodeset[$i]->has_attribute(
"HierId"))
 
 1811                                         $res->nodeset[$i]->remove_attribute(
"HierId");
 
 1823                 if (!is_array($a_pc_ids) || count($a_pc_ids) == 0)
 
 1829                 if(is_object($this->dom))
 
 1832                         $path = 
"//*[@PCID]";
 
 1834                         for($i = 0; $i < count(
$res->nodeset); $i++)    
 
 1836                                 $pc_id = 
$res->nodeset[$i]->get_attribute(
"PCID");
 
 1837                                 if (in_array($pc_id, $a_pc_ids))
 
 1839                                         $ret[$pc_id] = 
$res->nodeset[$i]->get_attribute(
"HierId");
 
 1855                 $path = 
"//FileItem";
 
 1857                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1859                         $cnode =& 
$res->nodeset[$i];
 
 1860                         $size_node =& $this->dom->create_element(
"Size");
 
 1861                         $size_node =& $cnode->append_child($size_node);
 
 1863                         $childs =& $cnode->child_nodes();
 
 1865                         for($j = 0; $j < count($childs); $j++)
 
 1867                                 if ($childs[$j]->node_name() == 
"Identifier")
 
 1869                                         if ($childs[$j]->has_attribute(
"Entry"))
 
 1871                                                 $entry = $childs[$j]->get_attribute(
"Entry");
 
 1872                                                 $entry_arr = explode(
"_", $entry);
 
 1873                                                 $id = $entry_arr[count($entry_arr) - 1];
 
 1874                                                 require_once(
"./Modules/File/classes/class.ilObjFile.php");
 
 1879                         $size_node->set_content(
$size);
 
 1894                 $path = 
"//IntLink";
 
 1896                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1898                         $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 1899                         $type = 
$res->nodeset[$i]->get_attribute(
"Type");
 
 1902                         if ($new_target !== 
false)
 
 1904                                 $res->nodeset[$i]->set_attribute(
"Target", $new_target);
 
 1909                                         IL_INST_ID > 0 && $type != 
"RepositoryItem")
 
 1914                                                 $res->nodeset[$i]->set_attribute(
"Target", $new_target);        
 
 1924                 $path = 
"//MediaAlias";
 
 1928                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1930                         $orig_id = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 1931                         $id_arr = explode(
"_", $orig_id);
 
 1932                         $mob_id = $id_arr[count($id_arr) - 1];
 
 1948                 $path = 
"//MediaAlias";
 
 1951                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1953                         $old_id = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 1954                         $old_id = explode(
"_", $old_id);
 
 1955                         $old_id = $old_id[count($old_id) - 1];
 
 1956                         if ($a_mapping[$old_id] > 0)
 
 1958                                 $res->nodeset[$i]->set_attribute(
"OriginId", 
"il__mob_".$a_mapping[$old_id]);
 
 1978                 $path = 
"//InteractiveImage/MediaAlias";
 
 1981                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 1983                         $old_id = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 1984                         if ($a_mapping[$old_id] > 0)
 
 1986                                 $res->nodeset[$i]->set_attribute(
"OriginId", 
"il__mob_".$a_mapping[$old_id]);
 
 2006                 $path = 
"//FileItem/Identifier";
 
 2009                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 2011                         $old_id = 
$res->nodeset[$i]->get_attribute(
"Entry");
 
 2012                         $old_id = explode(
"_", $old_id);
 
 2013                         $old_id = $old_id[count($old_id) - 1];
 
 2014                         if ($a_mapping[$old_id] > 0)
 
 2016                                 $res->nodeset[$i]->set_attribute(
"Entry", 
"il__file_".$a_mapping[$old_id]);
 
 2034                 $path = 
"//Question";
 
 2036                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 2038                         $qref = 
$res->nodeset[$i]->get_attribute(
"QRef");
 
 2040                         if (isset($a_mapping[$qref]))
 
 2042                                 $res->nodeset[$i]->set_attribute(
"QRef", 
"il__qst_".$a_mapping[$qref][
"pool"]);
 
 2064                 $path = 
"//IntLink";
 
 2066                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 2068                         $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 2069                         $type = 
$res->nodeset[$i]->get_attribute(
"Type");
 
 2071                         if ($a_from_to[$obj_id] > 0 && is_int(strpos($target, 
"__")))
 
 2075                                         $res->nodeset[$i]->set_attribute(
"Target", 
"il__pg_".$a_from_to[$obj_id]);
 
 2080                                         $res->nodeset[$i]->set_attribute(
"Target", 
"il__st_".$a_from_to[$obj_id]);
 
 2090                 $path = 
"//MediaAlias";
 
 2093                 require_once(
"Services/MediaObjects/classes/class.ilMediaItem.php");
 
 2094                 require_once(
"Services/COPage/classes/class.ilMediaAliasItem.php");
 
 2096                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 2098                         $media_object_node = 
$res->nodeset[$i]->parent_node();
 
 2099                         $page_content_node = $media_object_node->parent_node();
 
 2100                         $c_hier_id = $page_content_node->get_attribute(
"HierId");
 
 2104                                 $c_hier_id, 
"Standard");
 
 2105                         $areas = $std_alias_item->getMapAreas();
 
 2106                         $correction_needed = 
false;
 
 2107                         if (count($areas) > 0)
 
 2110                                 foreach($areas as $area)
 
 2112                                         if ($area[
"Type"] == 
"PageObject" ||
 
 2113                                                 $area[
"Type"] == 
"StructureObject")
 
 2115                                                 $t = $area[
"Target"];
 
 2116                                                 $tid = _extractObjIdOfTarget(
$t);
 
 2117                                                 if ($a_from_to[$tid] > 0)
 
 2119                                                         $correction_needed = 
true;
 
 2130                                 $oid = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 2131                                 if (substr($oid, 0, 4) ==
"il__")
 
 2133                                         $id_arr = explode(
"_", $oid);
 
 2134                                         $id = $id_arr[count($id_arr) - 1];
 
 2137                                         $med_item = $mob->getMediaItem(
"Standard");
 
 2138                                         $med_areas = $med_item->getMapAreas();
 
 2140                                         foreach($med_areas as $area)
 
 2142                                                 $link_type = ($area->getLinkType() == 
"int")
 
 2147                                                         "Nr" => $area->getNr(),
 
 2148                                                         "Shape" => $area->getShape(),
 
 2149                                                         "Coords" => $area->getCoords(),
 
 2151                                                                 "LinkType" => $link_type,
 
 2152                                                                 "Href" => $area->getHref(),
 
 2153                                                                 "Title" => $area->getTitle(),
 
 2154                                                                 "Target" => $area->getTarget(),
 
 2155                                                                 "Type" => $area->getType(),
 
 2156                                                                 "TargetFrame" => $area->getTargetFrame()
 
 2160                                                 if ($area->getType() == 
"PageObject" ||
 
 2161                                                         $area->getType() == 
"StructureObject")
 
 2163                                                         $t = $area->getTarget();
 
 2165                                                         if ($a_from_to[$tid] > 0)
 
 2167                                                                 $correction_needed = 
true;
 
 2176                         if ($correction_needed)
 
 2179                                 $std_alias_item->deleteAllMapAreas();
 
 2180                                 foreach($areas as $area)
 
 2182                                         if ($area[
"Link"][
"LinkType"] == 
"IntLink")
 
 2184                                                 $target = $area[
"Link"][
"Target"];
 
 2185                                                 $type = $area[
"Link"][
"Type"];
 
 2187                                                 if ($a_from_to[$obj_id] > 0)
 
 2191                                                                 $area[
"Link"][
"Target"] = 
"il__pg_".$a_from_to[$obj_id];
 
 2195                                                                 $area[
"Link"][
"Target"] = 
"il__st_".$a_from_to[$obj_id];
 
 2200                                         $std_alias_item->addMapArea($area[
"Shape"], $area[
"Coords"],
 
 2201                                                 $area[
"Link"][
"Title"],
 
 2202                                                 array(  
"Type" => $area[
"Link"][
"Type"],
 
 2203                                                                 "TargetFrame" => $area[
"Link"][
"TargetFrame"],
 
 2204                                                                 "Target" => $area[
"Link"][
"Target"],
 
 2205                                                                 "Href" => $area[
"Link"][
"Href"],
 
 2206                                                                 "LinkType" => $area[
"Link"][
"LinkType"],
 
 2224                 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
 
 2231                 foreach($sources as $source)
 
 2234                         if ($source[
"type"] == 
"lm:pg")
 
 2237                                 include_once(
"./Modules/LearningModule/classes/class.ilLMPage.php");
 
 2238                                 if (self::_exists(
"lm", $source[
"id"], $source[
"lang"]))
 
 2240                                         $page_obj = 
new ilLMPage($source[
"id"], 0, $source[
"lang"]);
 
 2241                                         if  (!$page_obj->page_not_found)
 
 2244                                                 $page_obj->handleImportRepositoryLink($a_rep_import_id,
 
 2245                                                         $a_rep_type, $a_rep_ref_id);
 
 2247                                         $page_obj->update();
 
 2260                 $path = 
"//IntLink";
 
 2263                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 2266                         $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 2267                         $type = 
$res->nodeset[$i]->get_attribute(
"Type");
 
 2268                         if ($target == $a_rep_import_id && $type == 
"RepositoryItem")
 
 2271                                 $res->nodeset[$i]->set_attribute(
"Target",
 
 2272                                         "il__".$a_rep_type.
"_".$a_rep_ref_id);
 
 2302                 $ilDB->insert(
"page_object", array(
 
 2303                         "page_id" => array(
"integer", $this->
getId()),
 
 2304                         "parent_id" => array(
"integer", $this->
getParentId()),
 
 2306                         "content" => array(
"clob", $content),
 
 2308                         "create_user" => array(
"integer", $ilUser->getId()),
 
 2309                         "last_change_user" => array(
"integer", $ilUser->getId()),
 
 2310                         "active" => array(
"integer", $this->
getActive()),
 
 2311                         "inactive_elements" => array(
"integer", $iel),
 
 2312                         "int_links" => array(
"integer", $inl),
 
 2314                         "last_change" => array(
"timestamp", 
ilUtil::now())
 
 2346                 $ilDB->update(
"page_object", array(
 
 2347                         "content" => array(
"clob", $content),
 
 2348                         "parent_id" => array(
"integer", $this->
getParentId()),
 
 2349                         "last_change_user" => array(
"integer", $ilUser->getId()),
 
 2350                         "last_change" => array(
"timestamp", 
ilUtil::now()),
 
 2351                         "active" => array(
"integer", $this->
getActive()),
 
 2354                         "inactive_elements" => array(
"integer", $iel),
 
 2355                         "int_links" => array(
"integer", $inl),
 
 2357                         "page_id" => array(
"integer", $this->
getId()),
 
 2374         protected final function __afterUpdate($a_domdoc, $a_xml, $a_creation = 
false, $a_empty = 
false)
 
 2377                 if (!$a_creation || !$a_empty)
 
 2388                         include_once(
"./Services/COPage/classes/class.ilCOPagePCDef.php");
 
 2390                         foreach ($defs as $def)
 
 2393                                 $cl = $def[
"pc_class"];
 
 2394                                 call_user_func($def[
"pc_class"].
'::afterPageUpdate', $this, $a_domdoc, $a_xml, $a_creation);
 
 2420         function update($a_validate = 
true, $a_no_history = 
false)
 
 2447                         include_once(
"./Services/User/classes/class.ilUserUtil.php");
 
 2449                         $errors = $lng->txt(
"cont_not_saved_edit_lock_expired");
 
 2450                         $errors.= 
"</br>".$lng->txt(
"obj_usr").
": ".
 
 2452                         $errors.= 
"</br>".$lng->txt(
"content_until").
": ".
 
 2470                         $old_set = $ilDB->query(
"SELECT * FROM page_object WHERE ".
 
 2471                                 "page_id = ".$ilDB->quote($this->getId(), 
"integer").
" AND ".
 
 2472                                 "parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
" AND ".
 
 2473                                 "lang = ".$ilDB->quote($this->getLanguage(), 
"text"));
 
 2474                         $last_nr_set = $ilDB->query(
"SELECT max(nr) as mnr FROM page_history WHERE ".
 
 2475                                 "page_id = ".$ilDB->quote($this->getId(), 
"integer").
" AND ".
 
 2476                                 "parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
" AND ".
 
 2477                                 "lang = ".$ilDB->quote($this->getLanguage(), 
"text"));
 
 2478                         $last_nr = $ilDB->fetchAssoc($last_nr_set);
 
 2479                         if ($old_rec = $ilDB->fetchAssoc($old_set))
 
 2482                                 if (($content != $old_rec[
"content"]) && !$a_no_history &&
 
 2483                                         !$this->history_saved &&
 
 2484                                         $lm_set->get(
"page_history", 1))
 
 2486                                         if ($old_rec[
"content"] != 
"<PageObject></PageObject>")
 
 2488                                                 $ilDB->manipulateF(
"DELETE FROM page_history WHERE ".
 
 2489                                                         "page_id = %s AND parent_type = %s AND hdate = %s AND lang = %s",
 
 2490                                                         array(
"integer", 
"text", 
"timestamp", 
"text"),
 
 2491                                                         array($old_rec[
"page_id"], $old_rec[
"parent_type"], $old_rec[
"last_change"], $old_rec[
"lang"]));
 
 2495                                                 $last_c = $old_rec[
"last_change"];
 
 2501                                                 $ilDB->insert(
"page_history", array(
 
 2502                                                         "page_id" =>            array(
"integer", $old_rec[
"page_id"]),
 
 2503                                                         "parent_type" =>        array(
"text", $old_rec[
"parent_type"]),
 
 2504                                                         "lang" =>       array(
"text", $old_rec[
"lang"]),
 
 2505                                                         "hdate" =>                      array(
"timestamp", $last_c),
 
 2506                                                         "parent_id" =>          array(
"integer", $old_rec[
"parent_id"]),
 
 2507                                                         "content" =>            array(
"clob", $old_rec[
"content"]),
 
 2508                                                         "user_id" =>            array(
"integer", $old_rec[
"last_change_user"]),
 
 2510                                                         "nr" =>                         array(
"integer", (
int) $last_nr[
"mnr"] + 1)
 
 2513                                                 $old_content = $old_rec[
"content"];
 
 2514                                                 $old_domdoc = 
new DOMDocument();
 
 2515                                                 $old_nr = $last_nr[
"mnr"] + 1;
 
 2516                                                 $old_domdoc->loadXML(
'<?xml version="1.0" encoding="UTF-8"?>'.$old_content);
 
 2521                                                 $this->history_saved = 
true;            
 
 2525                                                 $this->history_saved = 
true;            
 
 2530                         $em = (trim($content) == 
"<PageObject/>")
 
 2538                         $ilDB->update(
"page_object", array(
 
 2539                                 "content" => array(
"clob", $content),
 
 2540                                 "parent_id" => array(
"integer", $this->
getParentId()),
 
 2541                                 "last_change_user" => array(
"integer", $ilUser->getId()),
 
 2542                                 "last_change" => array(
"timestamp", 
ilUtil::now()),
 
 2543                                 "is_empty" => array(
"integer", $em),
 
 2544                                 "active" => array(
"integer", $this->
getActive()),
 
 2548                                 "inactive_elements" => array(
"integer", $iel),
 
 2549                                 "int_links" => array(
"integer", $inl),
 
 2551                                 "page_id" => array(
"integer", $this->
getId()),
 
 2580                 if (!$this->page_not_found)
 
 2595                 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 2599                 include_once(
"./Services/News/classes/class.ilNewsItem.php");
 
 2604                 $ilDB->manipulate(
"DELETE FROM page_object ".
 
 2605                         "WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 2606                         " AND parent_type= ".$ilDB->quote($this->getParentType(), 
"text"));
 
 2610                 foreach (
$mobs as $mob_id)
 
 2614                                 $GLOBALS[
'ilLog']->write(__METHOD__.
': Type mismatch. Ignoring mob with id: '.$mob_id);
 
 2648                 include_once(
"./Services/COPage/classes/class.ilCOPagePCDef.php");
 
 2650                 foreach ($defs as $def)
 
 2653                         $cl = $def[
"pc_class"];
 
 2654                         call_user_func($def[
"pc_class"].
'::beforePageDelete', $this);
 
 2669                 include_once(
"./Services/COPage/classes/class.ilCOPagePCDef.php");
 
 2671                 foreach ($defs as $def)
 
 2674                         $cl = $def[
"pc_class"];
 
 2675                         call_user_func($def[
"pc_class"].
'::afterPageHistoryEntry', $this, $a_old_domdoc, $a_old_content, $a_old_nr);
 
 2689                 $xpath = 
new DOMXPath($a_domdoc);
 
 2690                 $path = 
"//Paragraph | //Section | //MediaAlias | //FileItem".
 
 2691                         " | //Table | //TableData | //Tabs | //List";
 
 2692                 $nodes = $xpath->query(
$path);  
 
 2694                 foreach($nodes as 
$node)
 
 2696                         switch ($node->localName)
 
 2699                                         $sname = $node->getAttribute(
"Characteristic");
 
 2700                                         $stype = 
"text_block";
 
 2705                                         $sname = $node->getAttribute(
"Characteristic");
 
 2711                                         $sname = $node->getAttribute(
"Class");
 
 2712                                         $stype = 
"media_cont";
 
 2717                                         $sname = $node->getAttribute(
"Class");
 
 2718                                         $stype = 
"flist_li";
 
 2723                                         $sname = $node->getAttribute(
"Template");
 
 2726                                                 $sname = $node->getAttribute(
"Class");
 
 2738                                         $sname = $node->getAttribute(
"Class");
 
 2739                                         $stype = 
"table_cell";
 
 2744                                         $sname = $node->getAttribute(
"Template");
 
 2747                                                 if ($node->getAttribute(
"Type") == 
"HorizontalAccordion")
 
 2749                                                         $stype = 
"haccordion";
 
 2751                                                 if ($node->getAttribute(
"Type") == 
"VerticalAccordion")
 
 2753                                                         $stype = 
"vaccordion";
 
 2760                                         $sname = $node->getAttribute(
"Class");
 
 2761                                         if ($node->getAttribute(
"Type") == 
"Ordered")
 
 2772                         if ($sname != 
"" &&  $stype != 
"")
 
 2774                                 $usages[$sname.
":".$stype.
":".$template] = array(
"sname" => $sname,
 
 2775                                         "stype" => $stype, 
"template" => $template);
 
 2782                 foreach ($usages as $u)
 
 2784                         $ilDB->manipulate(
"INSERT INTO page_style_usage ".
 
 2785                                 "(page_id, page_type, page_lang, page_nr, template, stype, sname) VALUES (".
 
 2786                                 $ilDB->quote($this->getId(), 
"integer").
",".
 
 2787                                 $ilDB->quote($this->getParentType(), 
"text").
",".
 
 2788                                 $ilDB->quote($this->getLanguage(), 
"text").
",".
 
 2789                                 $ilDB->quote($a_old_nr, 
"integer").
",".
 
 2790                                 $ilDB->quote($u[
"template"], 
"integer").
",".
 
 2791                                 $ilDB->quote($u[
"stype"], 
"text").
",".
 
 2792                                 $ilDB->quote($u[
"sname"], 
"text").
 
 2807                 if ($a_old_nr !== 
false)
 
 2809                         $and_old_nr = 
" AND page_nr = ".$ilDB->quote($a_old_nr, 
"integer");
 
 2812                 $ilDB->manipulate(
"DELETE FROM page_style_usage WHERE ".
 
 2813                         " page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 2814                         " AND page_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 2815                         " AND page_lang = ".$ilDB->quote($this->getLanguage(), 
"text").
 
 2828                 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 2829                 include_once(
"./Modules/File/classes/class.ilObjFile.php");
 
 2834                 $objs = array_merge(
$mobs, $files);
 
 2846                 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
 
 2865                 $xpath = 
new DOMXPath($a_domdoc);
 
 2866                 $nodes = $xpath->query(
'//IntLink');
 
 2867                 foreach($nodes as 
$node)
 
 2869                         $link_type = $node->getAttribute(
"Type");
 
 2873                                 case "StructureObject":
 
 2881                                 case "GlossaryItem":
 
 2889                                 case "RepositoryItem":
 
 2902                         $target = $node->getAttribute(
"Target");
 
 2907                         if (is_int(strpos($target, 
"__")))
 
 2942                 $curr_node->unlink_node($curr_node);
 
 2959                 if (!is_array($a_hids))
 
 2963                 foreach($a_hids as $a_hid)
 
 2965                         $a_hid = explode(
":", $a_hid);
 
 2970                         if (!$this->
checkForTag(
"Question", $a_hid[0], $a_hid[1]) || $a_self_ass)
 
 2973                                 if (is_object($curr_node))
 
 2975                                         $parent_node = $curr_node->parent_node();
 
 2976                                         if ($parent_node->node_name() != 
"TableRow")
 
 2978                                                 $curr_node->unlink_node($curr_node);
 
 3009                 if (!is_array($a_hids))
 
 3014                 $time = date(
"Y-m-d H:i:s", time());
 
 3016                 $hier_ids = array();
 
 3018                 foreach($a_hids as $a_hid)
 
 3024                         $a_hid = explode(
":", $a_hid);
 
 3028                         foreach($hier_ids as $h)
 
 3030                                 if($h.
"_" == substr($a_hid[0], 0, strlen($h) + 1))
 
 3032                                         $skip[] = $a_hid[0];
 
 3034                                 if($a_hid[0].
"_" == substr($h, 0, strlen($a_hid[0]) + 1))
 
 3039                         $pc_id[$a_hid[0]] = $a_hid[1];
 
 3040                         if ($a_hid[0] != 
"")
 
 3042                                 $hier_ids[$a_hid[0]] = $a_hid[0];
 
 3045                 foreach ($skip as $s)
 
 3047                         unset($hier_ids[$s]);
 
 3049                 include_once(
"./Services/COPage/classes/class.ilPageContent.php");
 
 3052                 foreach($hier_ids as $hid)
 
 3055                         if (is_object($curr_node))
 
 3057                                 if ($curr_node->node_name() == 
"PageContent")
 
 3059                                         $content = $this->dom->dump_node($curr_node);
 
 3061                                         $content = eregi_replace(
"PCID=\"[a-z0-9]*\"",
"",$content);
 
 3062                                         $content = eregi_replace(
"HierId=\"[a-z0-9_]*\"",
"",$content);
 
 3064                                         $ilUser->addToPCClipboard($content, $time, $nr);
 
 3069                 include_once(
"./Modules/LearningModule/classes/class.ilEditClipboard.php");
 
 3080                 $a_hid = explode(
":", $a_hier_id);
 
 3081                 $content = $ilUser->getPCClipboardContent();
 
 3085                 for ($i = count($content) - 1; $i >= 0; $i--)
 
 3089                         $temp_dom = 
domxml_open_mem(
'<?xml version="1.0" encoding="UTF-8"?>'.$c,
 
 3095                                 $path = 
"//PageContent";
 
 3097                                 if (count(
$res->nodeset) > 0)
 
 3099                                         $new_pc_node = 
$res->nodeset[0];
 
 3100                                         $cloned_pc_node = $new_pc_node->clone_node (
true);
 
 3101                                         $cloned_pc_node->unlink_node ($cloned_pc_node);
 
 3120                 if (!is_array($a_hids))
 
 3124                 $obj = & $this->content_obj;
 
 3126                 foreach($a_hids as $a_hid)
 
 3128                         $a_hid = explode(
":", $a_hid);
 
 3130                         if (is_object($curr_node))
 
 3132                                 if ($curr_node->node_name() == 
"PageContent")
 
 3135                                         if ($cont_obj->isEnabled ())
 
 3138                                                 if (!$this->
checkForTag(
"Question", $a_hid[0], $a_hid[1]) || $a_self_ass)
 
 3140                                                         $cont_obj->disable();
 
 3145                                                 $cont_obj->enable();
 
 3170                 foreach ($hier_ids as $hier_id)
 
 3173                         if (!is_int(strpos($hier_id, 
"_")))
 
 3175                                 if ($hier_id != 
"pg" && $hier_id >= $a_hid)
 
 3178                                         $curr_node->unlink_node($curr_node);
 
 3200                 foreach ($hier_ids as $hier_id)
 
 3203                         if (!is_int(strpos($hier_id, 
"_")))
 
 3205                                 if ($hier_id != 
"pg" && $hier_id < $a_hid)
 
 3208                                         $curr_node->unlink_node($curr_node);
 
 3228                 $hier_ids = $a_source_page->getHierIds();
 
 3230                 $copy_ids = array();
 
 3233                 foreach ($hier_ids as $hier_id)
 
 3236                         if (!is_int(strpos($hier_id, 
"_")))
 
 3238                                 if ($hier_id != 
"pg" && $hier_id >= $a_hid)
 
 3240                                         $copy_ids[] = $hier_id;
 
 3246                 $parent_node =& $a_target_page->getContentNode(
"pg");
 
 3247                 $target_dom =& $a_target_page->getDom();
 
 3248                 $parent_childs =& $parent_node->child_nodes();
 
 3249                 $cnt_parent_childs = count($parent_childs);
 
 3251                 $first_child =& $parent_childs[0];
 
 3252                 foreach($copy_ids as $copy_id)
 
 3254                         $source_node =& $a_source_page->getContentNode($copy_id);
 
 3256                         $new_node =& $source_node->clone_node(
true);
 
 3257                         $new_node->unlink_node($new_node);
 
 3259                         $source_node->unlink_node($source_node);
 
 3261                         if($cnt_parent_childs == 0)
 
 3263                                 $new_node =& $parent_node->append_child($new_node);
 
 3268                                 $new_node =& $first_child->insert_before($new_node, $first_child);
 
 3270                         $parent_childs =& $parent_node->child_nodes();
 
 3275                 $a_target_page->update();
 
 3276                 $a_source_page->update();
 
 3288                 $curr_name = $curr_node->node_name();
 
 3291                 if (($curr_name == 
"TableData") || ($curr_name == 
"PageObject") ||
 
 3292                         ($curr_name == 
"ListItem") || ($curr_name == 
"Section")
 
 3293                         || ($curr_name == 
"Tab") || ($curr_name == 
"ContentPopup"))
 
 3298                 $hid = $curr_node->get_attribute(
"HierId");
 
 3307                         $pos = explode(
"_", $a_pos);
 
 3308                         $target_pos = array_pop($pos);
 
 3309                         $parent_pos = implode($pos, 
"_");
 
 3313                         $parent_pos = $a_pos;
 
 3317                 if($parent_pos != 
"")
 
 3323                         $parent_node =& $this->
getNode();
 
 3327                 $parent_childs =& $parent_node->child_nodes();
 
 3328                 $cnt_parent_childs = count($parent_childs);
 
 3334                                 $new_node =& $a_cont_obj->getNode();
 
 3338                                 if($succ_node =& $curr_node->next_sibling())
 
 3340                                         $new_node =& $succ_node->insert_before($new_node, $succ_node);
 
 3345                                         $new_node =& $parent_node->append_child($new_node);
 
 3347                                 $a_cont_obj->setNode($new_node);
 
 3352                                 $new_node =& $a_cont_obj->getNode();
 
 3354                                 $new_node =& $succ_node->insert_before($new_node, $succ_node);
 
 3355                                 $a_cont_obj->setNode($new_node);
 
 3361                                 $new_node =& $a_cont_obj->getNode();
 
 3362                                 if($cnt_parent_childs == 0)
 
 3364                                         $new_node =& $parent_node->append_child($new_node);
 
 3368                                         $new_node =& $parent_childs[0]->insert_before($new_node, $parent_childs[0]);
 
 3370                                 $a_cont_obj->setNode($new_node);
 
 3376                 if (!$this->
getPageConfig()->getEnablePCType(
"PlaceHolder")) {
 
 3377                         $sub_nodes = $curr_node->child_nodes() ;
 
 3378                         foreach ( $sub_nodes as $sub_node ) {
 
 3379                                 if ($sub_node->node_name() == 
"PlaceHolder") {
 
 3380                                         $curr_node->unlink_node();
 
 3393                 $curr_name = $curr_node->node_name();
 
 3396                 if (($curr_name == 
"TableData") || ($curr_name == 
"PageObject") ||
 
 3397                         ($curr_name == 
"ListItem") || ($curr_name == 
"Section")
 
 3398                         || ($curr_name == 
"Tab") || ($curr_name == 
"ContentPopup"))
 
 3403                 $hid = $curr_node->get_attribute(
"HierId");
 
 3411                         $pos = explode(
"_", $a_pos);
 
 3412                         $target_pos = array_pop($pos);
 
 3413                         $parent_pos = implode($pos, 
"_");
 
 3417                         $parent_pos = $a_pos;
 
 3421                 if($parent_pos != 
"")
 
 3427                         $parent_node =& $this->
getNode();
 
 3431                 $parent_childs =& $parent_node->child_nodes();
 
 3432                 $cnt_parent_childs = count($parent_childs);
 
 3439                                 if($succ_node = $curr_node->next_sibling())
 
 3441                                         $a_cont_node = $succ_node->insert_before($a_cont_node, $succ_node);
 
 3445                                         $a_cont_node = $parent_node->append_child($a_cont_node);
 
 3453                                 $a_cont_node = $succ_node->insert_before($a_cont_node, $succ_node);
 
 3460                                 if($cnt_parent_childs == 0)
 
 3462                                         $a_cont_node = $parent_node->append_child($a_cont_node);
 
 3466                                         $a_cont_node = $parent_childs[0]->insert_before($a_cont_node, $parent_childs[0]);
 
 3479                 if($a_source == $a_target)
 
 3486                 $source_node =& $content->getNode();
 
 3487                 $clone_node =& $source_node->clone_node(
true);
 
 3493                 $content->setNode($clone_node);
 
 3505                 if($a_source == $a_target)
 
 3512                 $source_node =& $content->getNode();
 
 3513                 $clone_node =& $source_node->clone_node(
true);
 
 3519                 $content->setNode($clone_node);
 
 3530                 $a_content = eregi_replace(
"\[com\]",
"<Comment>",$a_content);
 
 3531                 $a_content = eregi_replace(
"\[\/com\]",
"</Comment>",$a_content);
 
 3532                 $a_content = eregi_replace(
"\[emp]",
"<Emph>",$a_content);
 
 3533                 $a_content = eregi_replace(
"\[\/emp\]",
"</Emph>",$a_content);
 
 3534                 $a_content = eregi_replace(
"\[str]",
"<Strong>",$a_content);
 
 3535                 $a_content = eregi_replace(
"\[\/str\]",
"</Strong>",$a_content);
 
 3546                 $path = 
"//IntLink";
 
 3548                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 3550                         $target = 
$res->nodeset[$i]->get_attribute(
"Target");
 
 3551                         $type = 
$res->nodeset[$i]->get_attribute(
"Type");
 
 3553                         if (substr($target, 0, 4) == 
"il__")
 
 3555                                 $id = substr($target, 4, strlen($target) - 4);
 
 3559                                 if ($a_res_ref_to_obj_id && $type == 
"RepositoryItem")
 
 3561                                         $id_arr = explode(
"_", 
$id);
 
 3580                                 $new_target = 
"il_".$a_inst.
"_".
$id;
 
 3581                                 $res->nodeset[$i]->set_attribute(
"Target", $new_target);
 
 3590                 $path = 
"//MediaAlias";
 
 3592                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 3594                         $origin_id = 
$res->nodeset[$i]->get_attribute(
"OriginId");
 
 3595                         if (substr($origin_id, 0, 4) == 
"il__")
 
 3597                                 $new_id = 
"il_".$a_inst.
"_".substr($origin_id, 4, strlen($origin_id) - 4);
 
 3598                                 $res->nodeset[$i]->set_attribute(
"OriginId", $new_id);
 
 3605                 $path = 
"//FileItem/Identifier";
 
 3607                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 3609                         $origin_id = 
$res->nodeset[$i]->get_attribute(
"Entry");
 
 3610                         if (substr($origin_id, 0, 4) == 
"il__")
 
 3612                                 $new_id = 
"il_".$a_inst.
"_".substr($origin_id, 4, strlen($origin_id) - 4);
 
 3613                                 $res->nodeset[$i]->set_attribute(
"Entry", $new_id);
 
 3620                 $path = 
"//Question";
 
 3622                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 3624                         $qref = 
$res->nodeset[$i]->get_attribute(
"QRef");
 
 3626                         if (substr($qref, 0, 4) == 
"il__")
 
 3628                                 $new_id = 
"il_".$a_inst.
"_".substr($qref, 4, strlen($qref) - 4);
 
 3630                                 $res->nodeset[$i]->set_attribute(
"QRef", $new_id);
 
 3648                 require_once(
"./Services/COPage/syntax_highlight/php/HFile/HFile_".$proglang.
".php");
 
 3649                 $classname =  
"HFile_$proglang";
 
 3650                 $h_instance = 
new $classname();
 
 3651                 if ($autoindent == 
"n") {
 
 3652                         $h_instance ->notrim   = 1;
 
 3653                         $h_instance ->indent   = array (
"");
 
 3654                         $h_instance ->unindent = array (
"");
 
 3658                 $a_text = $highlighter->highlight_text(html_entity_decode($a_text));
 
 3664                 return file_exists (
"Services/COPage/syntax_highlight/php/HFile/HFile_".$hfile_ext.
".php");
 
 3675                 $path = 
"//Paragraph"; 
 
 3677                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
 3679                         $context_node = 
$res->nodeset[$i];
 
 3680                         $char = $context_node->get_attribute(
'Characteristic');
 
 3682                         if ($char != 
"Code")                    
 
 3685                         $n = $context_node->parent_node();
 
 3686                         $char = $context_node->get_attribute(
'Characteristic');
 
 3687                         $subchar = $context_node->get_attribute(
'SubCharacteristic');
 
 3688                         $showlinenumbers = $context_node->get_attribute(
'ShowLineNumbers');
 
 3689                         $downloadtitle = $context_node->get_attribute(
'DownloadTitle');
 
 3690                         $autoindent = $context_node->get_attribute(
'AutoIndent');
 
 3695                         $childs = $context_node->child_nodes();
 
 3697                         for($j=0; $j<count($childs); $j++)
 
 3699                                 $content .= $this->dom->dump_node($childs[$j]);
 
 3702                         while ($context_node->has_child_nodes ())
 
 3704                                 $node_del = $context_node->first_child ();
 
 3705                                 $context_node->remove_child ($node_del);
 
 3708                         $content = str_replace(
"<br />", 
"<br/>", utf8_decode($content) );
 
 3709                         $content = str_replace(
"<br/>", 
"\n", $content);
 
 3710                         $rownums = count(split (
"\n",$content));
 
 3712                         $plain_content = html_entity_decode($content);
 
 3713                         $plain_content = preg_replace (
"/\&#x([1-9a-f]{2});?/ise",
"chr (base_convert (\\1, 16, 10))",$plain_content);
 
 3714                         $plain_content = preg_replace (
"/\&#(\d+);?/ise",
"chr (\\1)",$plain_content);                   
 
 3715                         $content = utf8_encode($this->
highlightText($plain_content, $subchar, $autoindent));
 
 3717                         $content = str_replace(
"&lt;", 
"<", $content);
 
 3718                         $content = str_replace(
"&gt;", 
">", $content);
 
 3721                         $rows    = 
"<tr valign=\"top\">";
 
 3726                         if (strcmp($showlinenumbers,
"y")==0)
 
 3728                                 $linenumbers = 
"<td nowrap=\"nowrap\" class=\"ilc_LineNumbers\" >";
 
 3729                                 $linenumbers .= 
"<pre class=\"ilc_Code\">";
 
 3731                                 for ($j=0; $j < $rownums; $j++)
 
 3733                                         $indentno      = strlen($rownums) - strlen($j+1) + 2;
 
 3734                                         $rownumeration = ($j+1);
 
 3735                                         $linenumbers   .= 
"<span class=\"ilc_LineNumber\">$rownumeration</span>";
 
 3736                                         if ($j < $rownums-1)
 
 3738                                                 $linenumbers .= 
"\n";
 
 3741                                 $linenumbers .= 
"</pre>";
 
 3742                                 $linenumbers .= 
"</td>";
 
 3745                         $rows .= $linenumbers.
"<td class=\"ilc_Sourcecode\"><pre class=\"ilc_Code\">".$content.
"</pre></td>";
 
 3750                         $newcontent = str_replace(
"\n", 
"<br/>",$rows);
 
 3752                         $newcontent = str_replace(
"<br/><br/>", 
"<br/> <br/>",$newcontent);     
 
 3754                         $newcontent = str_replace(
"<br/><br/>", 
"<br/> <br/>",$newcontent);
 
 3759                         $newcontent = str_replace(
"{", 
"{", $newcontent);
 
 3760                         $newcontent = str_replace(
"}", 
"}", $newcontent);
 
 3763                         $a_output = str_replace(
"[[[[[Code;".($i + 1).
"]]]]]", $newcontent, $a_output);
 
 3765                         if ($outputmode != 
"presentation" && is_object($this->offline_handler)
 
 3766                                 && trim($downloadtitle) != 
"")
 
 3769                                 $this->offline_handler->handleCodeParagraph ($this->
id, $i + 1, $downloadtitle, $plain_content);
 
 3786                 foreach ($this->id_elements as $el)
 
 3788                         $path.= $sep.
"//".$el.
"[not(@PCID)]";
 
 3795                 if (count (
$res->nodeset) > 0)
 
 3816                 foreach ($this->id_elements as $el)
 
 3818                         $path.= $sep.
"//".$el.
"[@PCID]";
 
 3826                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
 3829                         $pcids[] = 
$node->get_attribute(
"PCID");
 
 3848                 foreach ($this->id_elements as $el)
 
 3850                         $path.= $sep.
"//".$el.
"[@PCID='".$a_pc_id.
"']";
 
 3857                 return (count(
$res->nodeset) > 0);
 
 3868                 if ($a_pc_ids === 
false)
 
 3872                 $id = ilUtil::randomHash(10, $a_pc_ids);
 
 3889                 foreach ($this->id_elements as $el)
 
 3891                         $path.= $sep.
"//".$el.
"[not(@PCID)]";
 
 3897                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
 3900                         $id = ilUtil::randomHash(10, $pcids);
 
 3903                         $res->nodeset[$i]->set_attribute(
"PCID", 
$id);
 
 3913                 $this->addHierIds();
 
 3917                 $path = 
"//PageContent";
 
 3922                 require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
 
 3923                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
 3925                         $hier_id = 
$res->nodeset[$i]->get_attribute(
"HierId");
 
 3926                         $pc_id = 
$res->nodeset[$i]->get_attribute(
"PCID");
 
 3927                         $dump = $mydom->dump_node(
$res->nodeset[$i]);
 
 3928                         if (($hpos = strpos($dump, 
' HierId="'.$hier_id.
'"')) > 0)
 
 3930                                 $dump = substr($dump, 0, $hpos).
 
 3931                                         substr($dump, $hpos + strlen(
' HierId="'.$hier_id.
'"'));
 
 3934                         $childs = 
$res->nodeset[$i]->child_nodes();
 
 3936                         if ($childs[0] && $childs[0]->node_name() == 
"Paragraph")
 
 3938                                 $content = $mydom->dump_node($childs[0]);
 
 3939                                 $content = substr($content, strpos($content, 
">") + 1,
 
 3940                                         strrpos($content, 
"<") - (strpos($content, 
">") + 1));
 
 3948                                 array(
"hier_id" => $hier_id, 
"hash" => md5($dump), 
"content" => $content);
 
 3964                 $path = 
"//Question";
 
 3969                 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
 
 3970                 for ($i = 0; $i < count (
$res->nodeset); $i++)
 
 3972                         $qref = 
$res->nodeset[$i]->get_attribute(
"QRef");
 
 3977                         if (!($inst_id > 0))
 
 3999                 $path = 
"/descendant::Paragraph[position() = $par_id]";
 
 4003                 if (count (
$res->nodeset) != 1)
 
 4004                         die (
"Should not happen");
 
 4006                 $context_node = 
$res->nodeset[0];
 
 4010                 $childs = $context_node->child_nodes();
 
 4012                 for($j=0; $j<count($childs); $j++)
 
 4014                         $content .= $mydom->dump_node($childs[$j]);
 
 4017                 $content = str_replace(
"<br />", 
"\n", $content);
 
 4018                 $content = str_replace(
"<br/>", 
"\n", $content);
 
 4020                 $plain_content = html_entity_decode($content);
 
 4038                 $xsl = file_get_contents(
"./Services/COPage/xsl/page_fo.xsl");
 
 4039                 $args = array( 
'/_xml' => 
$xml, 
'/_xsl' => $xsl );
 
 4045                 $fo = 
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args, $params);
 
 4048                 $fo = str_replace(
"\n", 
"", $fo);
 
 4049                 $fo = str_replace(
"<br/>", 
"<br>", $fo);
 
 4050                 $fo = str_replace(
"<br>", 
"\n", $fo);
 
 4055                 $fo = substr($fo, strpos($fo,
">") + 1);
 
 4061                 $this->offline_handler = $handler;
 
 4076                 $query = 
"SELECT * FROM page_object WHERE page_id = ".
 
 4077                         $ilDB->quote($a_id, 
"integer").
" AND ".
 
 4078                         " parent_type = ".$ilDB->quote($a_parent_type, 
"text").
" AND ".
 
 4079                         " lang = ".$ilDB->quote($a_lang, 
"text").
" AND ".
 
 4080                         " inactive_elements = ".$ilDB->quote(1, 
"integer");
 
 4081                 $obj_set = $ilDB->query(
$query);
 
 4099                 if (strpos($a_content,  
" Enabled=\"False\""))
 
 4113                 $h_query = 
"SELECT * FROM page_history ".
 
 4114                         " WHERE page_id = ".$ilDB->quote($this->
getId(), 
"integer").
 
 4115                         " AND parent_type = ".$ilDB->quote($this->
getParentType(), 
"text").
 
 4116                         " AND lang = ".$ilDB->quote($this->
getLanguage(), 
"text").
 
 4117                         " ORDER BY hdate DESC";
 
 4119                 $hset = $ilDB->query($h_query);
 
 4120                 $hentries = array();
 
 4122                 while ($hrec = $ilDB->fetchAssoc($hset))
 
 4124                         $hrec[
"sortkey"] = (int) $hrec[
"nr"];
 
 4125                         $hrec[
"user"] = (int) $hrec[
"user_id"];
 
 4126                         $hentries[] = $hrec;
 
 4139                 $res = $ilDB->queryF(
"SELECT * FROM page_history ".
 
 4140                         " WHERE page_id = %s ".
 
 4141                         " AND parent_type = %s ".
 
 4144                         array(
"integer", 
"text", 
"integer", 
"text"),
 
 4146                 if ($hrec = $ilDB->fetchAssoc(
$res))
 
 4166                 $res = $ilDB->query(
"SELECT MAX(nr) mnr FROM page_history ".
 
 4167                         " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4168                         " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 4169                         " AND lang = ".$ilDB->quote($this->getLanguage(), 
"text").
 
 4170                         " AND nr < ".$ilDB->quote((
int) $a_nr, 
"integer"));
 
 4172                 if (
$row[
"mnr"] > 0)
 
 4174                         $res = $ilDB->query(
"SELECT * FROM page_history ".
 
 4175                                 " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4176                                 " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 4177                                 " AND lang = ".$ilDB->quote($this->getLanguage(), 
"text").
 
 4178                                 " AND nr = ".$ilDB->quote((
int) 
$row[
"mnr"], 
"integer"));
 
 4179                         $row = $ilDB->fetchAssoc(
$res);
 
 4184                 $res = $ilDB->query(
"SELECT MIN(nr) mnr FROM page_history ".
 
 4185                         " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4186                         " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 4187                         " AND lang = ".$ilDB->quote($this->getLanguage(), 
"text").
 
 4188                         " AND nr > ".$ilDB->quote((
int) $a_nr, 
"integer"));
 
 4190                 if (
$row[
"mnr"] > 0)
 
 4192                         $res = $ilDB->query(
"SELECT * FROM page_history ".
 
 4193                                 " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4194                                 " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 4195                                 " AND lang = ".$ilDB->quote($this->getLanguage(), 
"text").
 
 4196                                 " AND nr = ".$ilDB->quote((
int) 
$row[
"mnr"], 
"integer"));
 
 4197                         $row = $ilDB->fetchAssoc(
$res);
 
 4202                 $res = $ilDB->query(
"SELECT * FROM page_history ".
 
 4203                         " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4204                         " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 4205                         " AND lang = ".$ilDB->quote($this->getLanguage(), 
"text").
 
 4206                         " AND nr = ".$ilDB->quote((
int) $a_nr, 
"integer"));
 
 4218                 $rnode = 
$res->nodeset[0];
 
 4221                 foreach($a_hashes as $pc_id => $h)
 
 4224                         if ($h[
"change"] != 
"")
 
 4227                                 $dc_node = $this->dom->create_element(
"DivClass");
 
 4228                                 $dc_node->set_attribute(
"HierId", $h[
"hier_id"]);
 
 4229                                 $dc_node->set_attribute(
"Class", 
"ilEdit".$h[
"change"]);
 
 4230                                 $dc_node = $rnode->append_child($dc_node);
 
 4247                 include_once(
"./Services/COPage/classes/class.ilPageObjectFactory.php");
 
 4251                 $l_hashes = $l_page->getPageContentsHashes();
 
 4252                 $r_hashes = $r_page->getPageContentsHashes();
 
 4255                 foreach ($l_hashes as $pc_id => $h)
 
 4257                         if (!isset($r_hashes[$pc_id]))
 
 4259                                 $l_hashes[$pc_id][
"change"] = 
"Deleted";
 
 4263                                 if ($l_hashes[$pc_id][
"hash"] != $r_hashes[$pc_id][
"hash"])
 
 4265                                         $l_hashes[$pc_id][
"change"] = 
"Modified";
 
 4266                                         $r_hashes[$pc_id][
"change"] = 
"Modified";
 
 4268                                         include_once(
"./Services/COPage/mediawikidiff/class.WordLevelDiff.php");
 
 4270                                         if ($l_hashes[$pc_id][
"content"] != 
"" &&
 
 4271                                                 $r_hashes[$pc_id][
"content"] != 
"")
 
 4273                                                 $new_left = str_replace(
"\n", 
"<br />", $l_hashes[$pc_id][
"content"]);
 
 4274                                                 $new_right = str_replace(
"\n", 
"<br />", $r_hashes[$pc_id][
"content"]);
 
 4277                                                 $new_left = $wldiff->orig();
 
 4278                                                 $new_right = $wldiff->closing();
 
 4279                                                 $l_page->setParagraphContent($l_hashes[$pc_id][
"hier_id"], $new_left[0]);
 
 4280                                                 $r_page->setParagraphContent($l_hashes[$pc_id][
"hier_id"], $new_right[0]);
 
 4287                 foreach ($r_hashes as $pc_id => $h)
 
 4289                         if (!isset($l_hashes[$pc_id]))
 
 4291                                 $r_hashes[$pc_id][
"change"] = 
"New";
 
 4295                 $l_page->addChangeDivClasses($l_hashes);
 
 4296                 $r_page->addChangeDivClasses($r_hashes);
 
 4298                 return array(
"l_page" => $l_page, 
"r_page" => $r_page,
 
 4299                         "l_changes" => $l_hashes, 
"r_changes" => $r_hashes);
 
 4309                 $ilDB->manipulate(
"UPDATE page_object ".
 
 4310                         " SET view_cnt = view_cnt + 1 ".
 
 4311                         " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4312                         " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text").
 
 4313                         " AND lang = ".$ilDB->quote($this->getLanguage(), 
"text"));
 
 4330                         $and_lang = 
" AND lang = ".$ilDB->quote($a_lang, 
"text");
 
 4333                 $page_changes = array();
 
 4334                 $limit_ts = date(
'Y-m-d H:i:s', time() - ($a_period * 24 * 60 * 60));
 
 4335                 $q = 
"SELECT * FROM page_object ".
 
 4336                         " WHERE parent_id = ".$ilDB->quote($a_parent_id, 
"integer").
 
 4337                         " AND parent_type = ".$ilDB->quote($a_parent_type, 
"text").
 
 4338                         " AND last_change >= ".$ilDB->quote($limit_ts, 
"timestamp").$and_lang;
 
 4340                 $set = $ilDB->query($q);
 
 4341                 while($page = $ilDB->fetchAssoc($set))
 
 4343                         $page_changes[] = array(
 
 4344                                 "date" => $page[
"last_change"],
 
 4345                                 "id" => $page[
"page_id"],
 
 4346                                 "lang" => $page[
"lang"],
 
 4348                                 "user" => $page[
"last_change_user"]);
 
 4354                         $limit_ts = date(
'Y-m-d H:i:s', time() - ($a_period * 24 * 60 * 60));
 
 4355                         $and_str = 
" AND hdate >= ".$ilDB->quote($limit_ts, 
"timestamp").
" ";
 
 4358                 $q = 
"SELECT * FROM page_history ".
 
 4359                         " WHERE parent_id = ".$ilDB->quote($a_parent_id, 
"integer").
 
 4360                         " AND parent_type = ".$ilDB->quote($a_parent_type, 
"text").
 
 4362                 $set = $ilDB->query($q);
 
 4363                 while ($page = $ilDB->fetchAssoc($set))
 
 4365                         $page_changes[] = array(
 
 4366                                 "date" => $page[
"hdate"],
 
 4367                                 "id" => $page[
"page_id"],
 
 4368                                 "lang" => $page[
"lang"],
 
 4370                                 "nr" => $page[
"nr"],
 
 4371                                 "user" => $page[
"user_id"]);
 
 4376                 return $page_changes;
 
 4386         static function getAllPages($a_parent_type, $a_parent_id, $a_lang = 
"-")
 
 4393                         $and_lang = 
" AND lang = ".$ilDB->quote($a_lang, 
"text");
 
 4396                 $page_changes = array();
 
 4398                 $q = 
"SELECT * FROM page_object ".
 
 4399                         " WHERE parent_id = ".$ilDB->quote($a_parent_id, 
"integer").
 
 4400                         " AND parent_type = ".$ilDB->quote($a_parent_type, 
"text").$and_lang;
 
 4401                 $set = $ilDB->query($q);
 
 4403                 while ($page = $ilDB->fetchAssoc($set))
 
 4405                         $key_add = ($a_lang == 
"")
 
 4408                         $pages[$page[
"page_id"].$key_add] = array(
 
 4409                                 "date" => $page[
"last_change"],
 
 4410                                 "id" => $page[
"page_id"],
 
 4411                                 "lang" => $page[
"lang"],
 
 4412                                 "user" => $page[
"last_change_user"]);
 
 4424         static function getNewPages($a_parent_type, $a_parent_id, $a_lang = 
"-")
 
 4431                         $and_lang = 
" AND lang = ".$ilDB->quote($a_lang, 
"text");
 
 4436                 $q = 
"SELECT * FROM page_object ".
 
 4437                         " WHERE parent_id = ".$ilDB->quote($a_parent_id, 
"integer").
 
 4438                         " AND parent_type = ".$ilDB->quote($a_parent_type, 
"text").$and_lang.
 
 4439                         " ORDER BY created DESC";
 
 4440                 $set = $ilDB->query($q);
 
 4441                 while($page = $ilDB->fetchAssoc($set))
 
 4443                         if ($page[
"created"] != 
"")
 
 4446                                         "created" => $page[
"created"],
 
 4447                                         "id" => $page[
"page_id"],
 
 4448                                         "lang" => $page[
"lang"],
 
 4449                                         "user" => $page[
"create_user"],
 
 4470                         $and_lang = 
" AND lang = ".$ilDB->quote($a_lang, 
"text");
 
 4473                 $contributors = array();
 
 4474                 $set = $ilDB->queryF(
"SELECT last_change_user, lang, page_id FROM page_object ".
 
 4475                         " WHERE parent_id = %s AND parent_type = %s ".
 
 4476                         " AND last_change_user != %s".$and_lang,
 
 4477                         array(
"integer", 
"text", 
"integer"),
 
 4478                         array($a_parent_id, $a_parent_type, 0));
 
 4480                 while ($page = $ilDB->fetchAssoc($set))
 
 4484                                 $contributors[$page[
"last_change_user"]][$page[
"page_id"]][$page[
"lang"]] = 1;
 
 4488                                 $contributors[$page[
"last_change_user"]][$page[
"page_id"]] = 1;
 
 4492                 $set = $ilDB->queryF(
"SELECT count(DISTINCT page_id, parent_type, hdate, lang) as cnt, lang, page_id, user_id FROM page_history ".
 
 4493                         " WHERE parent_id = %s AND parent_type = %s AND user_id != %s ".$and_lang.
 
 4494                         " GROUP BY page_id, user_id, lang ",
 
 4495                         array(
"integer", 
"text", 
"integer"),
 
 4496                         array($a_parent_id, $a_parent_type, 0));
 
 4497                 while ($hpage = $ilDB->fetchAssoc($set))
 
 4501                                 $contributors[$hpage[
"user_id"]][$hpage[
"page_id"]][$hpage[
"lang"]] =
 
 4502                                         $contributors[$hpage[
"user_id"]][$hpage[
"page_id"]][$hpage[
"lang"]] + $hpage[
"cnt"];
 
 4506                                 $contributors[$hpage[
"user_id"]][$hpage[
"page_id"]] =
 
 4507                                         $contributors[$hpage[
"user_id"]][$hpage[
"page_id"]] + $hpage[
"cnt"];
 
 4512                 foreach ($contributors as $k => $co)
 
 4517                                 $c[] = array(
"user_id" => $k, 
"pages" => $co,
 
 4518                                         "lastname" => $name[
"lastname"], 
"firstname" => $name[
"firstname"]);
 
 4538                         $and_lang = 
" AND lang = ".$ilDB->quote($a_lang, 
"text");
 
 4541                 $contributors = array();
 
 4542                 $set = $ilDB->queryF(
"SELECT last_change_user, lang FROM page_object ".
 
 4543                         " WHERE page_id = %s AND parent_type = %s ".
 
 4544                         " AND last_change_user != %s".$and_lang,
 
 4545                         array(
"integer", 
"text", 
"integer"),
 
 4546                         array($a_page_id, $a_parent_type, 0));
 
 4548                 while ($page = $ilDB->fetchAssoc($set))
 
 4552                                 $contributors[$page[
"last_change_user"]][$page[
"lang"]] = 1;
 
 4556                                 $contributors[$page[
"last_change_user"]] = 1;
 
 4560                 $set = $ilDB->queryF(
"SELECT count(DISTINCT page_id, parent_type, hdate, lang) as cnt, lang, page_id, user_id FROM page_history ".
 
 4561                         " WHERE page_id = %s AND parent_type = %s AND user_id != %s ".$and_lang.
 
 4562                         " GROUP BY user_id, page_id, lang ",
 
 4563                         array(
"integer", 
"text", 
"integer"),
 
 4564                         array($a_page_id, $a_parent_type, 0));
 
 4565                 while ($hpage = $ilDB->fetchAssoc($set))
 
 4569                                 $contributors[$hpage[
"user_id"]][$page[
"lang"]] =
 
 4570                                         $contributors[$hpage[
"user_id"]][$page[
"lang"]] + $hpage[
"cnt"];
 
 4574                                 $contributors[$hpage[
"user_id"]] =
 
 4575                                         $contributors[$hpage[
"user_id"]] + $hpage[
"cnt"];
 
 4580                 foreach ($contributors as $k => $co)
 
 4583                         $c[] = array(
"user_id" => $k, 
"pages" => $co,
 
 4584                                 "lastname" => $name[
"lastname"], 
"firstname" => $name[
"firstname"]);
 
 4597                 $ilDB->update(
"page_object", array(
 
 4598                         "rendered_content" => array(
"clob", $a_content),
 
 4599                         "render_md5" => array(
"text", $a_md5),
 
 4600                         "rendered_time" => array(
"timestamp", 
ilUtil::now())
 
 4602                         "page_id" => array(
"integer", $this->
getId()),
 
 4619                 $page_changes = array();
 
 4624                         $and_lang = 
" AND lang = ".$ilDB->quote($a_lang, 
"text");
 
 4627                 $q = 
"SELECT * FROM page_object ".
 
 4628                         " WHERE parent_id = ".$ilDB->quote($a_parent_id, 
"integer").
 
 4629                         " AND parent_type = ".$ilDB->quote($a_parent_type, 
"text").
 
 4630                         " AND int_links = ".$ilDB->quote(1, 
"integer").$and_lang;
 
 4631                 $set = $ilDB->query($q);
 
 4633                 while ($page = $ilDB->fetchAssoc($set))
 
 4635                         $key_add = ($a_lang == 
"")
 
 4638                         $pages[$page[
"page_id"].$key_add] = array(
 
 4639                                 "date" => $page[
"last_change"],
 
 4640                                 "id" => $page[
"page_id"],
 
 4641                                 "lang" => $page[
"lang"],
 
 4642                                 "user" => $page[
"last_change_user"]);
 
 4656                 if (strpos($a_content,  
"IntLink"))
 
 4683                                 $link_type = 
"MediaObject";
 
 4684                                 $a_id = 
"il__mob_".$a_id;
 
 4688                                 $link_type = 
"PageObject";
 
 4689                                 $a_id = 
"il__pg_".$a_id;
 
 4693                                 $link_type = 
"GlossaryItem";
 
 4694                                 $a_id = 
"il__git_".$a_id;
 
 4695                                 $a_target = 
"Glossary";
 
 4700                 if ($link_type == 
"" || $a_id == 
"")
 
 4703                         $path = 
"//PageObject/InitOpenedContent";
 
 4705                         if (count(
$res->nodeset) > 0)
 
 4707                                 $res->nodeset[0]->unlink_node(
$res->nodeset[0]);
 
 4713                         $path = 
"//PageObject/InitOpenedContent";
 
 4715                         if (count(
$res->nodeset) > 0)
 
 4717                                 $init_node = 
$res->nodeset[0];
 
 4718                                 $childs = $init_node->child_nodes();
 
 4719                                 for($i = 0; $i < count($childs); $i++)
 
 4721                                         if ($childs[$i]->node_name() == 
"IntLink")
 
 4723                                                 $il_node = $childs[$i];
 
 4729                                 $path = 
"//PageObject";
 
 4731                                 $page_node = 
$res->nodeset[0];
 
 4732                                 $init_node = $this->dom->create_element(
"InitOpenedContent");
 
 4733                                 $init_node = $page_node->append_child($init_node);
 
 4734                                 $il_node = $this->dom->create_element(
"IntLink");
 
 4735                                 $il_node = $init_node->append_child($il_node);
 
 4737                         $il_node->set_attribute(
"Target", $a_id);
 
 4738                         $il_node->set_attribute(
"Type", $link_type);
 
 4739                         $il_node->set_attribute(
"TargetFrame", $a_target);
 
 4756                 $path = 
"//PageObject/InitOpenedContent";
 
 4759                 if (count(
$res->nodeset) > 0)
 
 4761                         $init_node = 
$res->nodeset[0];
 
 4762                         $childs = $init_node->child_nodes();
 
 4763                         for($i = 0; $i < count($childs); $i++)
 
 4765                                 if ($childs[$i]->node_name() == 
"IntLink")
 
 4767                                         $il_node = $childs[$i];
 
 4771                 if (!is_null($il_node))
 
 4773                         $id = $il_node->get_attribute(
"Target");
 
 4774                         $link_type = $il_node->get_attribute(
"Type");
 
 4775                         $target = $il_node->get_attribute(
"TargetFrame");
 
 4787                                 case "GlossaryItem":
 
 4791                         include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
 
 4793                         return array(
"id" => 
$id, 
"type" => $type, 
"target" => $target);
 
 4822         function copy($a_id, $a_parent_type = 
"", $a_parent_id = 0, $a_clone_mobs = 
false)
 
 4824                 if ($a_parent_type == 
"")
 
 4827                         if ($a_parent_id == 0)
 
 4833                 include_once(
"./Services/COPage/classes/class.ilPageObjectFactory.php");
 
 4846                                 $new_page_object->setParentId($a_parent_id);
 
 4847                                 $new_page_object->setId($a_id);
 
 4849                         $new_page_object->setXMLContent($orig_page->copyXMLContent($a_clone_mobs));
 
 4850                         $new_page_object->setActive($orig_page->getActive());
 
 4851                         $new_page_object->setActivationStart($orig_page->getActivationStart());
 
 4852                         $new_page_object->setActivationEnd($orig_page->getActivationEnd());
 
 4855                                 $new_page_object->buildDom();
 
 4856                                 $new_page_object->update();
 
 4860                                 $new_page_object->create();
 
 4877                 $set = $ilDB->query(
"SELECT lang FROM page_object ".
 
 4878                         " WHERE page_id = ".$ilDB->quote($a_id, 
"integer").
 
 4879                         " AND parent_type = ".$ilDB->quote($a_parent_type, 
"text")
 
 4882                 while ($rec = $ilDB->fetchAssoc($set))
 
 4884                         $langs[] = $rec[
"lang"];
 
 4898                         0, 0, $a_target_lang);
 
 4899                 $transl_page->setId($this->
getId());
 
 4901                 $transl_page->setXMLContent($this->copyXMLContent());
 
 4902                 $transl_page->setActive($this->
getActive());
 
 4905                 $transl_page->create();
 
 4921                 $min = (int) $aset->get(
"block_mode_minutes") ;
 
 4926                         $ilDB->manipulate(
"UPDATE page_object SET ".
 
 4927                                 " edit_lock_user = ".$ilDB->quote($ilUser->getId(), 
"integer").
",".
 
 4928                                 " edit_lock_ts = ".$ilDB->quote($ts, 
"integer").
 
 4929                                 " WHERE (edit_lock_user = ".$ilDB->quote($ilUser->getId(), 
"integer").
" OR ".
 
 4930                                 " edit_lock_ts < ".$ilDB->quote(time() - ($min * 60), 
"integer").
") ".
 
 4931                                 " AND page_id = ".$ilDB->quote($this->
getId(), 
"integer").
 
 4932                                 " AND parent_type = ".$ilDB->quote($this->
getParentType(), 
"text")
 
 4935                         $set = $ilDB->query(
"SELECT edit_lock_user FROM page_object ".
 
 4936                                 " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4937                                 " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text")
 
 4939                         $rec = $ilDB->fetchAssoc($set);
 
 4940                         if ($rec[
"edit_lock_user"] != $ilUser->getId())
 
 4958                 $min = (int) $aset->get(
"block_mode_minutes") ;
 
 4963                         $ilDB->manipulate(
"UPDATE page_object SET ".
 
 4964                                 " edit_lock_user = ".$ilDB->quote($ilUser->getId(), 
"integer").
",".
 
 4965                                 " edit_lock_ts = 0".
 
 4966                                 " WHERE edit_lock_user = ".$ilDB->quote($ilUser->getId(), 
"integer").
 
 4967                                 " AND page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4968                                 " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text")
 
 4971                         $set = $ilDB->query(
"SELECT edit_lock_user FROM page_object ".
 
 4972                                 " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4973                                 " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text")
 
 4975                         $rec = $ilDB->fetchAssoc($set);
 
 4976                         if ($rec[
"edit_lock_user"] != $ilUser->getId())
 
 4995                 $min = (int) $aset->get(
"block_mode_minutes");
 
 4997                 $set = $ilDB->query(
"SELECT edit_lock_user, edit_lock_ts FROM page_object ".
 
 4998                         " WHERE page_id = ".$ilDB->quote($this->getId(), 
"integer").
 
 4999                         " AND parent_type = ".$ilDB->quote($this->getParentType(), 
"text")
 
 5001                 $rec = $ilDB->fetchAssoc($set);
 
 5002                 $rec[
"edit_lock_until"] = $rec[
"edit_lock_ts"] + $min * 60;