19define(
"IL_INSERT_BEFORE", 0);
20define(
"IL_INSERT_AFTER", 1);
21define(
"IL_INSERT_CHILD", 2);
55 protected \ILIAS\COPage\Link\LinkManager
$link;
73 public ?DOMDocument
$dom =
null;
116 $this->obj_definition =
$DIC[
"objDefinition"];
117 $this->db =
$DIC->database();
118 $this->
user = $DIC->user();
119 $this->
lng = $DIC->language();
120 $this->tree =
$DIC->repositoryTree();
122 $this->lom_services =
$DIC->learningObjectMetadata();
130 $this->contains_int_link =
false;
131 $this->needs_parsing =
false;
132 $this->update_listeners = array();
133 $this->update_listener_cnt = 0;
134 $this->dom_builded =
false;
135 $this->page_not_found =
false;
136 $this->old_nr = $a_old_nr;
137 $this->encoding =
"UTF-8";
150 $this->show_page_act_info =
false;
158 $domain =
$DIC->copage()
161 $this->content_id_manager = $domain
163 $this->page_manager = $domain->page();
164 $this->pc_service = $domain->pc();
165 $this->pc_definition = $domain->pc()->definition();
166 $this->
link = $domain->link();
167 $this->style_manager = $domain->style();
168 $this->dom_util = $domain->domUtil();
186 $this->setPageConfig($cfg);
200 return $this->language;
205 $this->page_config = $a_val;
210 $this->concrete_lang = $a_val;
215 return $this->concrete_lang;
220 return $this->page_config;
225 $this->rendermd5 = $a_rendermd5;
230 return $this->rendermd5;
235 $this->renderedcontent = $a_renderedcontent;
240 return $this->renderedcontent;
245 $this->renderedtime = $a_renderedtime;
250 return $this->renderedtime;
255 $this->lastchange = $a_lastchange;
260 return $this->lastchange;
265 $this->last_change_user = $a_val;
270 return $this->last_change_user;
275 $this->show_page_act_info = $a_val;
280 return $this->show_page_act_info;
285 return $this->create_user;
293 $this->setActive(
true);
294 if ($this->old_nr == 0) {
295 $query =
"SELECT * FROM page_object" .
296 " WHERE page_id = " . $this->db->quote($this->
id,
"integer") .
297 " AND parent_type=" . $this->db->quote($this->getParentType(),
"text") .
298 " AND lang = " . $this->db->quote($this->
getLanguage(),
"text");
299 $pg_set = $this->db->query($query);
300 if (!$this->page_record = $this->db->fetchAssoc($pg_set)) {
302 " (parent type " . $this->getParentType() .
", lang: " . $this->
getLanguage() .
").");
304 $this->setActive($this->page_record[
"active"]);
305 $this->setActivationStart($this->page_record[
"activation_start"]);
306 $this->setActivationEnd($this->page_record[
"activation_end"]);
307 $this->setShowActivationInfo($this->page_record[
"show_activation_info"]);
309 $query =
"SELECT * FROM page_history" .
310 " WHERE page_id = " . $this->db->quote($this->
id,
"integer") .
311 " AND parent_type=" . $this->db->quote($this->getParentType(),
"text") .
312 " AND nr = " . $this->db->quote($this->old_nr,
"integer") .
313 " AND lang = " . $this->db->quote($this->
getLanguage(),
"text");
314 $pg_set = $this->db->query($query);
315 $this->page_record = $this->db->fetchAssoc($pg_set);
317 if (!$this->page_record) {
319 " (parent type " . $this->getParentType() .
", lang: " . $this->
getLanguage() .
").");
321 $this->xml = $this->page_record[
"content"];
322 $this->setParentId((
int) $this->page_record[
"parent_id"]);
323 $this->last_change_user = (
int) ($this->page_record[
"last_change_user"] ?? 0);
324 $this->create_user = (
int) ($this->page_record[
"create_user"] ?? 0);
325 $this->setRenderedContent((
string) ($this->page_record[
"rendered_content"] ??
""));
326 $this->setRenderMd5((
string) ($this->page_record[
"render_md5"] ??
""));
327 $this->setRenderedTime((
string) ($this->page_record[
"rendered_time"] ??
""));
328 $this->setLastChange((
string) ($this->page_record[
"last_change"] ??
""));
336 string $a_parent_type,
339 bool $a_no_cache =
false
343 $db =
$DIC->database();
345 if (!$a_no_cache && isset(self::$exists[$a_parent_type .
":" . $a_id .
":" . $a_lang])) {
346 return self::$exists[$a_parent_type .
":" . $a_id .
":" . $a_lang];
351 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
354 $query =
"SELECT page_id FROM page_object WHERE page_id = " . $db->
quote($a_id,
"integer") .
" " .
355 "AND parent_type = " . $db->
quote($a_parent_type,
"text") . $and_lang;
356 $set = $db->
query($query);
358 self::$exists[$a_parent_type .
":" . $a_id .
":" . $a_lang] =
true;
361 self::$exists[$a_parent_type .
":" . $a_id .
":" . $a_lang] =
false;
370 string $a_parent_type,
382 if ($this->dom_builded && !$a_force) {
386 if ($this->getXMLContent() ===
"") {
387 $this->setXMLContent(
"<PageObject></PageObject>");
389 $this->dom = $this->dom_util->docFromString($this->getXMLContent(
true), $error);
390 $path =
"//PageObject";
391 if (is_null($this->dom)) {
393 $this->
getId() .
"," . $this->
getLanguage() .
"): " . $this->getXMLContent(
true));
395 $nodes = $this->dom_util->path($this->dom,
$path);
396 if (count($nodes) == 1) {
397 $this->node = $nodes->item(0);
400 $this->
getId() .
"," . $this->
getLanguage() .
"): " . $this->getXMLContent(
true));
404 $this->dom_builded =
true;
424 public function setId(
int $a_id): void
436 $this->parent_id = $a_id;
441 return $this->parent_id;
452 $cnt = $this->update_listener_cnt;
453 $this->update_listeners[$cnt][
"object"] = $a_object;
454 $this->update_listeners[$cnt][
"method"] = $a_method;
455 $this->update_listeners[$cnt][
"parameters"] = $a_parameters;
456 $this->update_listener_cnt++;
461 for ($i = 0; $i < $this->update_listener_cnt; $i++) {
462 $object = $this->update_listeners[$i][
"object"];
463 $method = $this->update_listeners[$i][
"method"];
464 $parameters = $this->update_listeners[$i][
"parameters"];
465 $object->$method($parameters);
471 $this->active = $a_active;
475 bool $a_check_scheduled_activation =
false
477 if ($a_check_scheduled_activation && !$this->active) {
485 return $this->active;
495 $db =
$DIC->database();
497 "SELECT page_id, parent_type, lang, active, activation_start, activation_end, show_activation_info FROM page_object " .
498 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer")
501 self::$activation_data[$rec[
"page_id"] .
":" . $rec[
"parent_type"] .
":" . $rec[
"lang"]] = $rec;
510 string $a_parent_type,
511 bool $a_check_scheduled_activation =
false,
516 $db =
$DIC->database();
523 if (isset(self::$activation_data[$a_id .
":" . $a_parent_type .
":" . $a_lang])) {
524 $rec = self::$activation_data[$a_id .
":" . $a_parent_type .
":" . $a_lang];
527 "SELECT active, activation_start, activation_end FROM page_object WHERE page_id = %s" .
528 " AND parent_type = %s AND lang = %s",
529 array(
"integer",
"text",
"text"),
530 array($a_id, $a_parent_type, $a_lang)
539 if (!$rec[
"active"] && $a_check_scheduled_activation) {
540 if ($rec[
"n"] >= $rec[
"activation_start"] &&
541 $rec[
"n"] <= $rec[
"activation_end"]) {
546 return (
bool) $rec[
"active"];
554 string $a_parent_type,
559 $db =
$DIC->database();
568 if (isset(self::$activation_data[$a_id .
":" . $a_parent_type .
":" . $a_lang])) {
569 $rec = self::$activation_data[$a_id .
":" . $a_parent_type .
":" . $a_lang];
572 "SELECT active, activation_start, activation_end FROM page_object WHERE page_id = %s" .
573 " AND parent_type = %s AND lang = %s",
574 array(
"integer",
"text",
"text"),
575 array($a_id, $a_parent_type, $a_lang)
580 if (!$rec[
"active"] && $rec[
"activation_start"] !=
"") {
592 string $a_parent_type,
597 $db =
$DIC->database();
603 "UPDATE page_object SET active = %s, activation_start = %s, " .
604 " activation_end = %s WHERE page_id = %s" .
605 " AND parent_type = %s AND lang = %s",
606 array(
"int",
"timestamp",
"timestamp",
"integer",
"text",
"text"),
607 array((
int) $a_active,
null,
null, $a_id, $a_parent_type, $a_lang)
616 string $a_parent_type,
621 $db =
$DIC->database();
628 if (isset(self::$activation_data[$a_id .
":" . $a_parent_type .
":" . $a_lang])) {
629 $rec = self::$activation_data[$a_id .
":" . $a_parent_type .
":" . $a_lang];
632 "SELECT active, activation_start, activation_end, show_activation_info FROM page_object WHERE page_id = %s" .
633 " AND parent_type = %s AND lang = %s",
634 array(
"integer",
"text",
"text"),
635 array($a_id, $a_parent_type, $a_lang)
641 "activation_start" =>
null,
642 "activation_end" =>
null,
643 "show_activation_info" => 0
655 $db =
$DIC->database();
657 $res = $db->
query(
"SELECT parent_id FROM page_object WHERE page_id = " . $db->
quote($a_id,
"integer") .
" " .
658 "AND parent_type=" . $db->
quote($a_type,
"text"));
660 return (
int) ($rec[
"parent_id"] ?? 0);
663 public static function _writeParentId(
string $a_parent_type,
int $a_pg_id,
int $a_par_id): void
667 $db =
$DIC->database();
669 "UPDATE page_object SET parent_id = %s WHERE page_id = %s" .
670 " AND parent_type = %s",
671 array(
"integer",
"integer",
"text"),
672 array($a_par_id, $a_pg_id, $a_parent_type)
681 if ($a_activationstart ==
"") {
682 $a_activationstart =
null;
684 $this->activationstart = $a_activationstart;
689 return $this->activationstart;
698 if ($a_activationend ==
"") {
699 $a_activationend =
null;
701 $this->activationend = $a_activationend;
706 return $this->activationend;
716 $node = $this->page_manager->content($this->getDomDoc())->getContentDomNode(
720 $this->log->debug(
"getContentObject: " .
" $a_hier_id, $a_pc_id, " . $node->nodeName);
721 return $this->pc_service->getByNode($node, $this);
729 $hier_ids = $this->getHierIdsForPCIds([$pcid]);
730 return $this->getContentObject($hier_ids[$pcid], $pcid);
738 $content_object = $this->getContentObjectForPcId($pcid);
739 $node = $content_object->getDomNode();
740 $node = $node->parentNode;
742 if ($node->nodeName ==
"PageContent") {
743 $pcid = $node->getAttribute(
"PCID");
745 return $this->getContentObjectForPcId($pcid);
748 $node = $node->parentNode;
755 $cm = $this->page_manager->content($this->getDomDoc());
756 return $cm->getContentDomNode($a_hier_id, $a_pc_id);
761 return $this->getContentDomNode(
"", $pc_id);
770 public function setXMLContent(
string $a_xml,
string $a_encoding =
"UTF-8"): void
772 $this->encoding = $a_encoding;
782 $this->xml .= $a_xml;
794 $enc_str = (!empty($this->encoding))
795 ?
"encoding=\"" . $this->encoding .
"\""
797 return "<?xml version=\"1.0\" $enc_str ?>" .
798 "<!DOCTYPE PageObject SYSTEM \"" . $this->getIliasAbsolutePath() .
"/components/ILIAS/Export/xml/" . $this->cur_dtd .
"\">" .
807 return ILIAS_ABSOLUTE_PATH;
816 bool $a_clone_mobs =
false,
817 int $a_new_parent_id = 0,
818 int $obj_copy_id = 0,
819 bool $self_ass =
true
821 $cm = $this->page_manager->contentFromXml($this->getXMLContent());
822 return $cm->copyXmlContent(
842 $pm = $this->page_manager->content($this->getDomDoc());
843 $pm->handleDeleteContent($this, $a_node, $move_operation);
851 bool $a_incl_head =
false,
852 bool $a_append_mobs =
false,
853 bool $a_append_bib =
false,
854 string $a_append_str =
"",
855 bool $a_omit_pageobject_tag =
false,
857 bool $offline =
false
861 return $this->dom_util->dump($this->node);
864 if ($a_append_mobs || $a_append_bib) {
867 if ($a_append_mobs) {
868 $mobs = $this->getMultimediaXML($offline);
874 $trans = $this->getLanguageVariablesXML($style_id);
876 return "<dummy>" . $this->dom_util->dump($this->node) . $mobs . $bibs . $trans . $a_append_str .
"</dummy>";
878 if (is_object($this->dom)) {
879 if ($a_omit_pageobject_tag) {
881 foreach ($this->node->childNodes as $child) {
882 $xml .= $this->dom_util->dump($child);
885 $xml = $this->dom_util->dump($this->node);
886 $xml = preg_replace(
'/<\?xml[^>]*>/i',
"", $xml);
887 $xml = preg_replace(
'/<!DOCTYPE[^>]*>/i',
"", $xml);
919 "ed_align_left_float",
920 "ed_align_right_float",
922 "ed_new_item_before",
929 "ed_split_page_next",
937 "ed_click_to_add_pg",
942 $defs = $this->pc_definition->getPCDefinitions();
943 foreach ($defs as $def) {
944 $lang_vars[] =
"pc_" . $def[
"pc_type"];
945 $lang_vars[] =
"ed_insert_" . $def[
"pc_type"];
947 $cl = $def[
"pc_class"];
948 $lvs = call_user_func($def[
"pc_class"] .
'::getLangVars');
949 foreach ($lvs as $lv) {
956 $dummy_pc->setStyleId($style_id);
957 foreach ([
"section",
"table",
"flist_li",
"list_u",
"list_o",
958 "table",
"table_cell"] as $type) {
959 $dummy_pc->getCharacteristicsOfCurrentStyle([$type]);
960 foreach ($dummy_pc->getCharacteristics() as $char =>
$txt) {
961 $xml .=
"<LV name=\"char_" . $type .
"_" . $char .
"\" value=\"" .
$txt .
"\"/>";
964 $type =
"media_cont";
966 $dummy_pc->setStyleId($style_id);
967 $dummy_pc->getCharacteristicsOfCurrentStyle([$type]);
968 foreach ($dummy_pc->getCharacteristics() as $char =>
$txt) {
969 $xml .=
"<LV name=\"char_" . $type .
"_" . $char .
"\" value=\"" .
$txt .
"\"/>";
971 foreach ([
"text_block",
"heading1",
"heading2",
"heading3"] as $type) {
973 $dummy_pc->setStyleId($style_id);
974 $dummy_pc->getCharacteristicsOfCurrentStyle([$type]);
975 foreach ($dummy_pc->getCharacteristics() as $char =>
$txt) {
976 $xml .=
"<LV name=\"char_" . $type .
"_" . $char .
"\" value=\"" .
$txt .
"\"/>";
979 foreach ($lang_vars as $lang_var) {
980 $xml .= $this->getLangVarXML($lang_var);
982 foreach ($this->pc_service->plugged()->getPluginLangVars() as $k => $v) {
983 $xml .= $this->getLangVarXMLForValue($k, $v);
991 return $this->getLangVarXMLForValue(
993 $this->
lng->txt(
"cont_" . $var)
999 $val = str_replace(
'"',
""", $val);
1000 return "<LV name=\"$var\" value=\"" . $val .
"\"/>";
1005 return $this->pc_service->paragraph()->getFirstParagraphText($this);
1010 return $this->pc_service->paragraph()->getParagraphForPCID($this, $pcid);
1023 $this->contains_int_link = $a_contains_link;
1033 return $this->contains_int_link;
1038 $this->import_mode = $a_val;
1043 return $this->import_mode;
1048 if ($a_parse ===
true) {
1049 $this->needs_parsing =
true;
1051 if ($a_parse ===
false) {
1052 $this->needs_parsing =
false;
1054 return $this->needs_parsing;
1060 $this->contains_question = $a_val;
1065 return $this->contains_question;
1075 $mob_manager = $this->pc_service->mediaObject();
1076 return $mob_manager->collectMediaObjects($this->getDomDoc(), $a_inline_only);
1084 return $this->
link->getInternalLinks($this->getDomDoc());
1092 bool $offline =
false
1094 $mob_manager = $this->pc_service->mediaObject();
1095 return $mob_manager->getMultimediaXML($this->getDomDoc(), $offline);
1103 $mob_manager = $this->pc_service->mediaObject();
1104 return $mob_manager->getMediaAliasElement(
1116 $this->stripHierIDs();
1122 $this->dom_util->validate($this->dom, $error, $throw);
1131 $this->content_id_manager->addHierIDsToDom();
1136 return $this->content_id_manager->getHierIds();
1141 $this->content_id_manager->stripHierIDsFromDom();
1146 $this->content_id_manager->stripPCIDs();
1154 return $this->content_id_manager->getHierIdsForPCIds($a_pc_ids);
1159 return $this->content_id_manager->getHierIdForPcId($pcid);
1167 return $this->content_id_manager->getPCIdsForHierIds($hier_ids);
1172 return $this->content_id_manager->getPCIdForHierId($hier_id);
1180 $this->pc_service->fileList()->addFileSizes($this->getDomDoc());
1189 return $this->
link->resolveIntLinks($this->getDomDoc(), $a_link_map);
1198 bool $a_reuse_existing_by_import =
false
1200 return $this->pc_service->mediaObject()->resolveMediaAliases(
1203 $a_reuse_existing_by_import
1213 return $this->pc_service->interactiveImage()->resolveIIMMediaAliases(
1225 return $this->pc_service->fileList()->resolveFileItems(
1237 $qm = $this->pc_service->question();
1238 return $qm->resolveQuestionReferences(
1252 $this->addHierIDs();
1253 return $this->
link->moveIntLinks(
1265 int $a_source_ref_id
1269 $tree = $this->tree;
1270 $this->log->debug(
"Handle repository links...");
1272 $defs = $this->pc_definition->getPCDefinitions();
1273 foreach ($defs as $def) {
1274 if (method_exists($def[
"pc_class"],
'afterRepositoryCopy')) {
1275 call_user_func($def[
"pc_class"] .
'::afterRepositoryCopy', $this, $a_mapping, $a_source_ref_id);
1279 $this->
link->handleRepositoryLinksOnCopy($this->getDomDoc(), $a_mapping, $a_source_ref_id, $tree);
1284 $this->setXMLContent(
"<PageObject></PageObject>");
1293 if ($this->getXMLContent() ===
"") {
1294 $this->setEmptyPageXml();
1297 $content = $this->getXMLContent();
1298 $this->buildDom(
true);
1299 $dom_doc = $this->getDomDoc();
1301 $errors = $this->validateDom(
true);
1303 $iel = $this->containsDeactivatedElements($content);
1304 $inl = $this->containsIntLinks($content);
1306 $this->db->insert(
"page_object", array(
1307 "page_id" => array(
"integer", $this->
getId()),
1308 "parent_id" => array(
"integer", $this->getParentId()),
1310 "content" => array(
"clob", $content),
1311 "parent_type" => array(
"text", $this->getParentType()),
1312 "create_user" => array(
"integer", $this->
user->getId()),
1313 "last_change_user" => array(
"integer", $this->
user->getId()),
1314 "active" => array(
"integer", (
int) $this->getActive()),
1315 "activation_start" => array(
"timestamp", $this->getActivationStart()),
1316 "activation_end" => array(
"timestamp", $this->getActivationEnd()),
1317 "show_activation_info" => array(
"integer", (
int) $this->getShowActivationInfo()),
1318 "inactive_elements" => array(
"integer", $iel),
1319 "int_links" => array(
"integer", $inl),
1321 "last_change" => array(
"timestamp",
ilUtil::now()),
1322 "is_empty" => array(
"integer", $empty)
1325 $this->__afterUpdate($dom_doc, $content,
true, $empty);
1337 $this->log->debug(
"ilPageObject, updateFromXML(): start, id: " . $this->
getId());
1339 $content = $this->getXMLContent();
1341 $this->log->debug(
"ilPageObject, updateFromXML(): content: " . substr($content, 0, 100));
1343 $this->buildDom(
true);
1344 $dom_doc = $this->getDomDoc();
1346 $errors = $this->validateDom(
true);
1348 $iel = $this->containsDeactivatedElements($content);
1349 $inl = $this->containsIntLinks($content);
1351 $this->db->update(
"page_object", array(
1352 "content" => array(
"clob", $content),
1353 "parent_id" => array(
"integer", $this->getParentId()),
1354 "last_change_user" => array(
"integer", $this->
user->getId()),
1355 "last_change" => array(
"timestamp",
ilUtil::now()),
1356 "active" => array(
"integer", $this->getActive()),
1357 "activation_start" => array(
"timestamp", $this->getActivationStart()),
1358 "activation_end" => array(
"timestamp", $this->getActivationEnd()),
1359 "inactive_elements" => array(
"integer", $iel),
1360 "int_links" => array(
"integer", $inl),
1362 "page_id" => array(
"integer", $this->
getId()),
1363 "parent_type" => array(
"text", $this->getParentType()),
1368 $this->__afterUpdate($dom_doc, $content);
1370 $this->log->debug(
"ilPageObject, updateFromXML(): end");
1380 DOMDocument $a_domdoc,
1382 bool $a_creation =
false,
1383 bool $a_empty =
false
1386 if (!$a_creation || !$a_empty) {
1390 $this->saveInternalLinks($a_domdoc);
1393 $this->saveStyleUsage($a_domdoc);
1396 $this->reading_time_manager->saveTime($this);
1399 $defs = $this->pc_definition->getPCDefinitions();
1400 foreach ($defs as $def) {
1401 $cl = $def[
"pc_class"];
1402 call_user_func($def[
"pc_class"] .
'::afterPageUpdate', $this, $a_domdoc, $a_xml, $a_creation);
1407 $this->afterUpdate($a_domdoc, $a_xml);
1410 $this->callUpdateListeners();
1426 public function update(
bool $a_validate =
true,
bool $a_no_history =
false)
1428 $this->log->debug(
"start..., id: " . $this->
getId());
1432 if (!$this->checkPCIds()) {
1433 $this->insertPCIds();
1438 $this->log->debug($this->dom_util->dump($this->getDomDoc()->documentElement));
1439 $errors = $this->validateDom();
1442 if (empty($errors) && !$this->getEditLock()) {
1443 $lock = $this->getEditLockInfo();
1444 $errors[0] = array(0 => 0,
1445 1 => $this->
lng->txt(
"cont_not_saved_edit_lock_expired") .
"<br />" .
1446 $this->lng->txt(
"obj_usr") .
": " .
1448 $this->lng->txt(
"content_until") .
": " .
1454 $this->log->debug(
"checking duplicate ids");
1455 if ($this->hasDuplicatePCIds()) {
1456 $errors[0] = $this->
lng->txt(
"cont_could_not_save_duplicate_pc_ids") .
1457 " (" . implode(
", ", $this->getDuplicatePCIds()) .
")";
1460 if (!empty($errors)) {
1461 $this->log->debug(
"ilPageObject, update(): errors: " . print_r($errors,
true));
1465 if (empty($errors)) {
1469 $this->log->debug(
"perform automatic modifications");
1470 $this->performAutomaticModifications();
1473 $content = $this->getXMLFromDom();
1474 $dom_doc = $this->getDomDoc();
1479 $old_set = $this->db->query(
"SELECT * FROM page_object WHERE " .
1480 "page_id = " . $this->db->quote($this->getId(),
"integer") .
" AND " .
1481 "parent_type = " . $this->db->quote($this->getParentType(),
"text") .
" AND " .
1482 "lang = " . $this->db->quote($this->getLanguage(),
"text"));
1483 $last_nr_set = $this->db->query(
"SELECT max(nr) as mnr FROM page_history WHERE " .
1484 "page_id = " . $this->db->quote($this->getId(),
"integer") .
" AND " .
1485 "parent_type = " . $this->db->quote($this->getParentType(),
"text") .
" AND " .
1486 "lang = " . $this->db->quote($this->getLanguage(),
"text"));
1487 $last_nr = $this->db->fetchAssoc($last_nr_set);
1488 if ($old_rec = $this->db->fetchAssoc($old_set)) {
1491 if (($content != $old_rec[
"content"] || $this->
user->getId() != $old_rec[
"last_change_user"]) &&
1492 !$a_no_history && !$this->history_saved &&
$lm_set->get(
"page_history", 1)) {
1493 if ($old_rec[
"content"] !=
"<PageObject></PageObject>") {
1494 $this->db->manipulateF(
1495 "DELETE FROM page_history WHERE " .
1496 "page_id = %s AND parent_type = %s AND hdate = %s AND lang = %s",
1497 array(
"integer",
"text",
"timestamp",
"text"),
1498 array($old_rec[
"page_id"],
1499 $old_rec[
"parent_type"],
1500 $old_rec[
"last_change"],
1507 $last_c = $old_rec[
"last_change"];
1508 if ($last_c ==
"") {
1512 $this->db->insert(
"page_history", array(
1513 "page_id" => array(
"integer", $old_rec[
"page_id"]),
1514 "parent_type" => array(
"text", $old_rec[
"parent_type"]),
1515 "lang" => array(
"text", $old_rec[
"lang"]),
1516 "hdate" => array(
"timestamp", $last_c),
1517 "parent_id" => array(
"integer", $old_rec[
"parent_id"]),
1518 "content" => array(
"clob", $old_rec[
"content"]),
1519 "user_id" => array(
"integer", $old_rec[
"last_change_user"]),
1521 "nr" => array(
"integer", (
int) $last_nr[
"mnr"] + 1)
1524 $old_content = $old_rec[
"content"];
1525 $old_domdoc =
new DOMDocument();
1526 $old_nr = $last_nr[
"mnr"] + 1;
1527 $old_domdoc->loadXML(
'<?xml version="1.0" encoding="UTF-8"?>' . $old_content);
1530 $this->log->debug(
"calling __afterHistoryEntry");
1531 $this->__afterHistoryEntry($old_domdoc, $old_content, $old_nr);
1535 $this->history_saved =
true;
1539 $em = (trim($content) ==
"<PageObject/>")
1544 $this->log->debug(
"checking deactivated elements");
1545 $iel = $this->containsDeactivatedElements($content);
1546 $this->log->debug(
"checking internal links");
1547 $inl = $this->containsIntLinks($content);
1550 $this->lastchange = $now;
1551 $this->db->update(
"page_object", array(
1552 "content" => array(
"clob", $content),
1553 "parent_id" => array(
"integer", $this->getParentId()),
1554 "last_change_user" => array(
"integer", $this->
user->getId()),
1555 "last_change" => array(
"timestamp", $now),
1556 "is_empty" => array(
"integer", $em),
1557 "active" => array(
"integer", $this->getActive()),
1558 "activation_start" => array(
"timestamp", $this->getActivationStart()),
1559 "activation_end" => array(
"timestamp", $this->getActivationEnd()),
1560 "show_activation_info" => array(
"integer", $this->getShowActivationInfo()),
1561 "inactive_elements" => array(
"integer", $iel),
1562 "int_links" => array(
"integer", $inl),
1564 "page_id" => array(
"integer", $this->
getId()),
1565 "parent_type" => array(
"text", $this->getParentType()),
1570 $this->log->debug(
"calling __afterUpdate()");
1571 $this->__afterUpdate($dom_doc, $content);
1574 "...ending, updated and returning true, content: " . substr(
1575 $this->getXMLContent(),
1588 public function delete():
void
1591 $copg_logger->debug(
1592 "ilPageObject: Delete called for ID '" . $this->
getId() .
"'," .
1593 " parent type: '" . $this->getParentType() .
"', " .
1594 " hist nr: '" . $this->old_nr .
"', " .
1599 if (!$this->page_not_found) {
1601 $mobs = $this->collectMediaObjects(
false);
1604 $this->getParentType() .
":pg",
1610 foreach ($mobs2 as $m) {
1611 if (!in_array($m, $mobs)) {
1616 $copg_logger->debug(
"ilPageObject: ... found " . count($mobs) .
" media objects.");
1618 $this->__beforeDelete();
1621 $this->handleDeleteContent();
1624 $this->deleteStyleUsages(
false);
1627 $this->deleteInternalLinks();
1633 if (!$this->isTranslationPage()) {
1635 $this->getParentId(),
1636 $this->getParentType(),
1643 $and = $this->isTranslationPage()
1644 ?
" AND lang = " . $this->db->quote($this->
getLanguage(),
"text")
1646 $this->db->manipulate(
"DELETE FROM page_object " .
1647 "WHERE page_id = " . $this->db->quote($this->getId(),
"integer") .
1648 " AND parent_type= " . $this->db->quote($this->getParentType(),
"text") . $and);
1651 foreach ($mobs as $mob_id) {
1652 $copg_logger->debug(
"ilPageObject: ... processing mob " . $mob_id .
".");
1655 $copg_logger->debug(
"ilPageObject: ... type mismatch. Ignoring mob " . $mob_id .
".");
1660 $copg_logger->debug(
"ilPageObject: ... delete mob " . $mob_id .
".");
1665 $copg_logger->debug(
"ilPageObject: ... missing mob " . $mob_id .
".");
1669 $this->__afterDelete();
1674 return !in_array($this->
getLanguage(), [
"",
"-"]);
1683 $defs = $this->pc_definition->getPCDefinitions();
1684 foreach ($defs as $def) {
1685 $cl = $def[
"pc_class"];
1686 call_user_func($def[
"pc_class"] .
'::beforePageDelete', $this);
1692 $this->afterDelete();
1700 DOMDocument $a_old_domdoc,
1701 string $a_old_content,
1705 $this->saveStyleUsage($a_old_domdoc, $a_old_nr);
1708 $defs = $this->pc_definition->getPCDefinitions();
1709 foreach ($defs as $def) {
1710 $cl = $def[
"pc_class"];
1712 $def[
"pc_class"] .
'::afterPageHistoryEntry',
1725 DOMDocument $a_domdoc,
1728 $this->style_manager->saveStyleUsage(
1740 $this->style_manager->deleteStyleUsages($this, $a_old_nr);
1751 $this->getParentType() .
":pg",
1754 $files = ilObjFile::_getFilesOfObject(
1755 $this->getParentType() .
":pg",
1758 $objs = array_merge($mobs, $files);
1767 $this->
link->deleteInternalLinks($this);
1777 $this->
link->saveInternalLinks(
1786 public function create(
bool $a_import =
false): void
1788 $this->createFromXML();
1799 bool $a_update =
true,
1800 string $a_pcid =
"",
1801 bool $move_operation =
false
1803 $pm = $this->page_manager->content($this->getDomDoc());
1804 $pm->deleteContent($this, $a_hid, $a_pcid, $move_operation);
1806 return $this->update();
1820 bool $a_update =
true,
1821 bool $a_self_ass =
false,
1822 bool $move_operation =
false
1824 $pm = $this->page_manager->content($this->getDomDoc());
1825 $pm->deleteContents($this, $a_hids, $a_self_ass, $move_operation);
1827 return $this->update();
1839 $this->copyContents($a_hids);
1840 return $this->deleteContents(
1843 $this->getPageConfig()->getEnableSelfAssessment(),
1853 $cm = $this->page_manager->content($this->getDomDoc());
1854 $cm->copyContents($a_hids, $this->
user);
1864 bool $a_self_ass =
false
1866 $user = $this->user;
1867 $cm = $this->page_manager->content($this->getDomDoc());
1874 return $this->update();
1886 bool $a_update =
true,
1887 bool $a_self_ass =
false
1889 $cm = $this->page_manager->content($this->getDomDoc());
1890 $cm->switchEnableMultiple($this, $a_hids, $a_self_ass);
1892 return $this->update();
1904 string $a_pcid =
"",
1905 bool $remove_placeholder =
true
1907 $cm = $this->page_manager->content($this->getDomDoc());
1913 $remove_placeholder,
1914 $this->getPageConfig()->getEnablePCType(
"PlaceHolder")
1922 DOMNode $a_cont_node,
1927 $cm = $this->page_manager->content($this->getDomDoc());
1928 $cm->insertContentNode(
1952 string $a_spcid =
"",
1953 string $a_tpcid =
""
1955 $cm = $this->page_manager->content($this->getDomDoc());
1956 $cm->moveContentAfter(
1963 return $this->update();
1974 bool $a_res_ref_to_obj_id =
true
1976 $cm = $this->page_manager->content($this->getDomDoc());
1977 $cm->insertInstIntoIDs($a_inst, $a_res_ref_to_obj_id);
1985 return $this->content_id_manager->checkPCIds();
1993 return $this->content_id_manager->getAllPCIds();
1998 return $this->content_id_manager->hasDuplicatePCIds();
2007 return $this->content_id_manager->getDuplicatePCIds();
2012 return $this->content_id_manager->generatePCId();
2020 $this->content_id_manager->insertPCIds();
2027 $this->pc_service->paragraph()->
send(
2041 return $this->offline_handler;
2049 string $a_parent_type,
2050 string $a_lang =
"-"
2054 $db =
$DIC->database();
2056 if ($a_lang ==
"") {
2060 $query =
"SELECT * FROM page_object WHERE page_id = " .
2061 $db->
quote($a_id,
"integer") .
" AND " .
2062 " parent_type = " . $db->
quote($a_parent_type,
"text") .
" AND " .
2063 " lang = " . $db->
quote($a_lang,
"text") .
" AND " .
2064 " inactive_elements = " . $db->
quote(1,
"integer");
2065 $obj_set = $db->
query($query);
2079 if (strpos($a_content,
" Enabled=\"False\"")) {
2092 $h_query =
"SELECT * FROM page_history " .
2093 " WHERE page_id = " . $db->
quote($this->
getId(),
"integer") .
2094 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2096 " ORDER BY hdate DESC";
2098 $hset = $db->
query($h_query);
2099 $hentries = array();
2102 $hrec[
"sortkey"] = (
int) $hrec[
"nr"];
2103 $hrec[
"user"] = (
int) $hrec[
"user_id"];
2104 $hentries[] = $hrec;
2118 "SELECT * FROM page_history " .
2119 " WHERE page_id = %s " .
2120 " AND parent_type = %s " .
2123 array(
"integer",
"text",
"integer",
"text"),
2124 array($this->
getId(), $this->getParentType(), $a_old_nr, $this->
getLanguage())
2143 $and_nr = ($a_nr > 0)
2144 ?
" AND nr < " . $db->
quote($a_nr,
"integer")
2146 $res = $db->
query(
"SELECT MAX(nr) mnr FROM page_history " .
2147 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2148 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2152 if ($row[
"mnr"] > 0) {
2153 $res = $db->
query(
"SELECT * FROM page_history " .
2154 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2155 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2157 " AND nr = " . $db->
quote((
int) $row[
"mnr"],
"integer"));
2159 $ret[
"previous"] = $row;
2163 $res = $db->
query(
"SELECT MIN(nr) mnr FROM page_history " .
2164 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2165 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2167 " AND nr > " . $db->
quote($a_nr,
"integer"));
2169 if ($row[
"mnr"] > 0) {
2170 $res = $db->
query(
"SELECT * FROM page_history " .
2171 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2172 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2174 " AND nr = " . $db->
quote((
int) $row[
"mnr"],
"integer"));
2176 $ret[
"next"] = $row;
2181 $res = $db->
query(
"SELECT * FROM page_history " .
2182 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2183 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2185 " AND nr = " . $db->
quote($a_nr,
"integer"));
2187 $res = $db->
query(
"SELECT page_id, last_change hdate, parent_type, parent_id, last_change_user user_id, content, lang FROM page_object " .
2188 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2189 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2193 $ret[
"current"] = $row;
2210 " SET view_cnt = view_cnt + 1 " .
2211 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2212 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2213 " AND lang = " . $db->
quote($this->getLanguage(),
"text"));
2223 string $a_parent_type,
2230 $db =
$DIC->database();
2233 if ($a_lang !=
"") {
2234 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2237 $page_changes = array();
2238 $limit_ts = date(
'Y-m-d H:i:s', time() - ($a_period * 24 * 60 * 60));
2239 $q =
"SELECT * FROM page_object " .
2240 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer") .
2241 " AND parent_type = " . $db->
quote($a_parent_type,
"text") .
2242 " AND last_change >= " . $db->
quote($limit_ts,
"timestamp") . $and_lang;
2246 $page_changes[] = array(
2247 "date" => $page[
"last_change"],
2248 "id" => $page[
"page_id"],
2249 "lang" => $page[
"lang"],
2251 "user" => $page[
"last_change_user"]
2256 if ($a_period > 0) {
2257 $limit_ts = date(
'Y-m-d H:i:s', time() - ($a_period * 24 * 60 * 60));
2258 $and_str =
" AND hdate >= " . $db->
quote($limit_ts,
"timestamp") .
" ";
2261 $q =
"SELECT * FROM page_history " .
2262 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer") .
2263 " AND parent_type = " . $db->
quote($a_parent_type,
"text") .
2264 $and_str . $and_lang;
2267 $page_changes[] = array(
2268 "date" => $page[
"hdate"],
2269 "id" => $page[
"page_id"],
2270 "lang" => $page[
"lang"],
2272 "nr" => $page[
"nr"],
2273 "user" => $page[
"user_id"]
2279 return $page_changes;
2286 string $a_parent_type,
2288 string $a_lang =
"-"
2292 $db =
$DIC->database();
2295 if ($a_lang !=
"") {
2296 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2299 $q =
"SELECT * FROM page_object " .
2300 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer") .
2301 " AND parent_type = " . $db->
quote($a_parent_type,
"text") . $and_lang;
2305 $key_add = ($a_lang ==
"")
2306 ?
":" . $page[
"lang"]
2308 $pages[$page[
"page_id"] . $key_add] = array(
2309 "date" => $page[
"last_change"],
2310 "id" => $page[
"page_id"],
2311 "lang" => $page[
"lang"],
2312 "user" => $page[
"last_change_user"]
2323 string $a_parent_type,
2325 string $a_lang =
"-"
2329 $db =
$DIC->database();
2332 if ($a_lang !=
"") {
2333 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2338 $q =
"SELECT * FROM page_object " .
2339 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer") .
2340 " AND parent_type = " . $db->
quote($a_parent_type,
"text") . $and_lang .
2341 " ORDER BY created DESC";
2344 if ($page[
"created"] !=
"") {
2346 "created" => $page[
"created"],
2347 "id" => $page[
"page_id"],
2348 "lang" => $page[
"lang"],
2349 "user" => $page[
"create_user"],
2363 string $a_parent_type,
2365 string $a_lang =
"-"
2369 $db =
$DIC->database();
2372 if ($a_lang !=
"") {
2373 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2376 $contributors = array();
2378 "SELECT last_change_user, lang, page_id FROM page_object " .
2379 " WHERE parent_id = %s AND parent_type = %s " .
2380 " AND last_change_user != %s" . $and_lang,
2381 array(
"integer",
"text",
"integer"),
2382 array($a_parent_id, $a_parent_type, 0)
2386 if ($a_lang ==
"") {
2387 $contributors[$page[
"last_change_user"]][$page[
"page_id"]][$page[
"lang"]] = 1;
2389 $contributors[$page[
"last_change_user"]][$page[
"page_id"]] = 1;
2394 "SELECT count(*) as cnt, lang, page_id, user_id FROM page_history " .
2395 " WHERE parent_id = %s AND parent_type = %s AND user_id != %s " . $and_lang .
2396 " GROUP BY page_id, user_id, lang ",
2397 array(
"integer",
"text",
"integer"),
2398 array($a_parent_id, $a_parent_type, 0)
2401 if ($a_lang ==
"") {
2402 $contributors[$hpage[
"user_id"]][$hpage[
"page_id"]][$hpage[
"lang"]] =
2403 ($contributors[$hpage[
"user_id"]][$hpage[
"page_id"]][$hpage[
"lang"]] ?? 0) + $hpage[
"cnt"];
2405 $contributors[$hpage[
"user_id"]][$hpage[
"page_id"]] =
2406 ($contributors[$hpage[
"user_id"]][$hpage[
"page_id"]] ?? 0) + $hpage[
"cnt"];
2411 foreach ($contributors as $k => $co) {
2414 $c[] = array(
"user_id" => $k,
2416 "lastname" => $name[
"lastname"],
2417 "firstname" => $name[
"firstname"]
2429 string $a_parent_type,
2431 string $a_lang =
"-"
2435 $db =
$DIC->database();
2438 if ($a_lang !=
"") {
2439 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2442 $contributors = array();
2444 "SELECT last_change_user, lang FROM page_object " .
2445 " WHERE page_id = %s AND parent_type = %s " .
2446 " AND last_change_user != %s" . $and_lang,
2447 array(
"integer",
"text",
"integer"),
2448 array($a_page_id, $a_parent_type, 0)
2452 if ($a_lang ==
"") {
2453 $contributors[$page[
"last_change_user"]][$page[
"lang"]] = 1;
2455 $contributors[$page[
"last_change_user"]] = 1;
2460 "SELECT count(*) as cnt, lang, page_id, user_id FROM page_history " .
2461 " WHERE page_id = %s AND parent_type = %s AND user_id != %s " . $and_lang .
2462 " GROUP BY user_id, page_id, lang ",
2463 array(
"integer",
"text",
"integer"),
2464 array($a_page_id, $a_parent_type, 0)
2467 if ($a_lang ===
"") {
2468 $contributors[$hpage[
"user_id"]][$page[
"lang"]] =
2469 ($contributors[$hpage[
"user_id"]][$page[
"lang"]] ?? 0) + $hpage[
"cnt"];
2471 $contributors[$hpage[
"user_id"]] =
2472 ($contributors[$hpage[
"user_id"]] ?? 0) + $hpage[
"cnt"];
2477 foreach ($contributors as $k => $co) {
2479 $c[] = array(
"user_id" => $k,
2481 "lastname" => $name[
"lastname"],
2482 "firstname" => $name[
"firstname"]
2498 $db =
$DIC->database();
2500 $db->
update(
"page_object", array(
2501 "rendered_content" => array(
"clob", $a_content),
2502 "render_md5" => array(
"text", $a_md5),
2503 "rendered_time" => array(
"timestamp",
ilUtil::now())
2505 "page_id" => array(
"integer", $this->
getId()),
2507 "parent_type" => array(
"text", $this->getParentType())
2515 string $a_parent_type,
2517 string $a_lang =
"-"
2521 $db =
$DIC->database();
2524 if ($a_lang !=
"") {
2525 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2528 $q =
"SELECT * FROM page_object " .
2529 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer") .
2530 " AND parent_type = " . $db->
quote($a_parent_type,
"text") .
2531 " AND int_links = " . $db->
quote(1,
"integer") . $and_lang;
2535 $key_add = ($a_lang ==
"")
2536 ?
":" . $page[
"lang"]
2538 $pages[$page[
"page_id"] . $key_add] = array(
2539 "date" => $page[
"last_change"],
2540 "id" => $page[
"page_id"],
2541 "lang" => $page[
"lang"],
2542 "user" => $page[
"last_change_user"]
2554 if (strpos($a_content,
"IntLink")) {
2570 return $this->page_manager->content($this->getDomDoc());
2581 $cm = $this->getContentManager();
2582 $cm->setInitialOpenedContent($a_type, $a_id, $a_target);
2591 $cm = $this->getContentManager();
2592 return $cm->getInitialOpenedContent();
2615 string $a_parent_type =
"",
2616 int $a_new_parent_id = 0,
2617 bool $a_clone_mobs =
false,
2618 int $obj_copy_id = 0,
2619 bool $overwrite_existing =
true
2621 if ($a_parent_type ==
"") {
2622 $a_parent_type = $this->getParentType();
2623 if ($a_new_parent_id == 0) {
2624 $a_new_parent_id = $this->getParentId();
2628 foreach (self::lookupTranslations($this->getParentType(), $this->
getId()) as $l) {
2632 if (!$overwrite_existing) {
2639 $new_page_object->setParentId($a_new_parent_id);
2640 $new_page_object->setId($a_id);
2642 $new_page_object->setXMLContent($orig_page->copyXMLContent($a_clone_mobs, $a_new_parent_id, $obj_copy_id));
2643 $new_page_object->setActive($orig_page->getActive());
2644 $new_page_object->setActivationStart($orig_page->getActivationStart());
2645 $new_page_object->setActivationEnd($orig_page->getActivationEnd());
2646 $this->setCopyProperties($new_page_object);
2648 $new_page_object->buildDom();
2649 $new_page_object->update();
2651 $new_page_object->create(
false);
2665 string $a_parent_type,
2670 $db =
$DIC->database();
2673 "SELECT lang FROM page_object " .
2674 " WHERE page_id = " . $db->
quote($a_id,
"integer") .
2675 " AND parent_type = " . $db->
quote($a_parent_type,
"text")
2679 $langs[] = $rec[
"lang"];
2688 string $a_target_lang
2691 $this->getParentType(),
2696 $this->setTranslationProperties($transl_page);
2697 $transl_page->create(
false);
2702 $transl_page->setId($this->
getId());
2703 $transl_page->setParentId($this->getParentId());
2704 $transl_page->setXMLContent($this->copyXmlContent());
2705 $transl_page->setActive($this->getActive());
2706 $transl_page->setActivationStart($this->getActivationStart());
2707 $transl_page->setActivationEnd($this->getActivationEnd());
2721 $user = $this->user;
2723 $min = $this->getEffectiveEditLockTime();
2728 "UPDATE page_object SET " .
2729 " edit_lock_user = " . $db->
quote($user->
getId(),
"integer") .
"," .
2730 " edit_lock_ts = " . $db->
quote($ts,
"integer") .
2731 " WHERE (edit_lock_user = " . $db->
quote($user->
getId(),
"integer") .
" OR " .
2732 " edit_lock_ts < " . $db->
quote(time() - ($min * 60),
"integer") .
") " .
2733 " AND page_id = " . $db->
quote($this->getId(),
"integer") .
2734 " AND parent_type = " . $db->
quote($this->getParentType(),
"text")
2738 "SELECT edit_lock_user FROM page_object " .
2739 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2740 " AND parent_type = " . $db->
quote($this->getParentType(),
"text")
2743 if ($rec[
"edit_lock_user"] != $user->
getId()) {
2757 $user = $this->user;
2760 $min = (
int) $aset->get(
"block_mode_minutes");
2765 "UPDATE page_object SET " .
2766 " edit_lock_user = " . $db->
quote($user->
getId(),
"integer") .
"," .
2767 " edit_lock_ts = 0" .
2768 " WHERE edit_lock_user = " . $db->
quote($user->
getId(),
"integer") .
2769 " AND page_id = " . $db->
quote($this->getId(),
"integer") .
2770 " AND parent_type = " . $db->
quote($this->getParentType(),
"text")
2774 "SELECT edit_lock_user FROM page_object " .
2775 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2776 " AND parent_type = " . $db->
quote($this->getParentType(),
"text")
2779 if ($rec[
"edit_lock_user"] != $user->
getId()) {
2795 $min = (
int) $aset->get(
"block_mode_minutes");
2798 "SELECT edit_lock_user, edit_lock_ts FROM page_object " .
2799 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2800 " AND parent_type = " . $db->
quote($this->getParentType(),
"text")
2803 $rec[
"edit_lock_until"] = $rec[
"edit_lock_ts"] + $min * 60;
2814 int $a_length = 100,
2815 string $a_ending =
'...',
2816 bool $a_exact =
false,
2817 bool $a_consider_html =
true
2820 if ($a_consider_html) {
2822 if (strlen(preg_replace(
'/<.*?>/',
'', $a_text)) <= $a_length) {
2827 $total_length = strlen($a_ending);
2828 $open_tags = array();
2830 preg_match_all(
'/(<.+?>)?([^<>]*)/s', $a_text, $lines, PREG_SET_ORDER);
2831 foreach ($lines as $line_matchings) {
2833 if (!empty($line_matchings[1])) {
2836 '/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is',
2841 elseif (preg_match(
'/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
2843 $pos = array_search($tag_matchings[1], $open_tags);
2844 if ($pos !==
false) {
2845 unset($open_tags[$pos]);
2848 elseif (preg_match(
'/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) {
2850 array_unshift($open_tags, strtolower($tag_matchings[1]));
2853 $truncate .= $line_matchings[1];
2857 $content_length = strlen(preg_replace(
2858 '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i',
2862 if ($total_length + $content_length > $a_length) {
2864 $left = $a_length - $total_length;
2865 $entities_length = 0;
2868 '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i',
2874 foreach ($entities[0] as $entity) {
2875 if ($entity[1] + 1 - $entities_length <= $left) {
2877 $entities_length += strlen($entity[0]);
2891 $truncate .= $line_matchings[2];
2892 $total_length += $content_length;
2896 if ($total_length >= $a_length) {
2901 if (strlen($a_text) <= $a_length) {
2910 if (!count($open_tags)) {
2914 $spacepos = strrpos($truncate,
' ');
2915 if ($spacepos !==
false) {
2924 $truncate .= $a_ending;
2926 if ($a_consider_html) {
2928 foreach ($open_tags as $tag) {
2929 $truncate .=
'</' . $tag .
'>';
2949 string $a_parent_type,
2955 $db =
$DIC->database();
2958 if ($a_lang !=
"") {
2959 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2963 $q =
"SELECT last_change FROM page_object " .
2964 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer") .
2965 " AND parent_type = " . $db->
quote($a_parent_type,
"text") . $and_lang .
2966 " ORDER BY last_change DESC";
2971 return $rec[
"last_change"];
2976 if ($this->getPageConfig()->getEditLockSupport() ==
false) {
2981 $min = (
int) $aset->get(
"block_mode_minutes");
3000 return $this->getParentId();
3025 $config = $this->getPageConfig();
3026 foreach ($this->pc_definition->getPCDefinitions() as $def) {
3027 $model_provider = $this->pc_definition->getPCModelProviderByName($def[
"name"]);
3028 if ($config->getEnablePCType($def[
"name"]) || $def[
"name"] ===
"PlaceHolder") {
3029 if (!is_null($model_provider)) {
3030 foreach ($model_provider->getModels(
3033 ) as $pc_id => $co_model) {
3034 $model[$pc_id] = $co_model;
3055 if (is_array($targets)) {
3056 foreach ($targets as $t) {
3057 $tarr = explode(
":", $t);
3058 $cont_obj = $this->getContentObject($tarr[0], $tarr[1]);
3059 if (is_object($cont_obj) && $cont_obj->getType() ==
"par") {
3060 $cont_obj->setCharacteristic($char_par);
3062 if (is_object($cont_obj) && $cont_obj->getType() ==
"sec") {
3063 $cont_obj->setCharacteristic($char_sec);
3065 if (is_object($cont_obj) && $cont_obj->getType() ==
"media") {
3066 $cont_obj->setClass($char_med);
3069 return $this->update();
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static _after(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
static deleteNewsOfContext(int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="")
Delete all news of a context.
static _lookupName(int $a_user_id)
parses the objects.xml it handles the xml-description of all ilias objects
static _lookupType(int $id, bool $reference=false)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _getLastUpdateOfObjects(array $obj_ids)
Class ilPCParagraphGUI User Interface for Paragraph Editing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static resolveResources(ilPageObject $page, array $ref_mappings)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Content object of ilPageObject (see ILIAS DTD).
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(string $a_parent_type, int $a_id=0, int $a_old_nr=0, string $a_lang="-")
Get page object instance.
static getConfigInstance(string $a_parent_type)
Get page config instance.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
releasePageLock()
Release page lock.
handleRepositoryLinksOnCopy(array $a_mapping, int $a_source_ref_id)
Handle repository links on copy process.
appendXMLContent(string $a_xml)
containsDeactivatedElements(string $a_content)
Check whether content contains deactivated elements.
getEditLockInfo()
Get edit lock info.
__beforeDelete()
Before deletion handler (internal).
create(bool $a_import=false)
create new page (with current xml data)
switchEnableMultiple(array $a_hids, bool $a_update=true, bool $a_self_ass=false)
(De-)activate elements
getRepoObjId()
Get object id of repository object that contains this page, return 0 if page does not belong to a rep...
insertContentNode(DOMNode $a_cont_node, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="")
insert a content node before/after a sibling or as first child of a parent
setCopyProperties(ilPageObject $new_page)
deleteStyleUsages(int $a_old_nr=0)
Delete style usages.
getContentObjectForPcId(string $pcid)
Get content object for pc id.
getActive(bool $a_check_scheduled_activation=false)
deleteContent(string $a_hid, bool $a_update=true, string $a_pcid="", bool $move_operation=false)
delete content object with hierarchical id $a_hid
addFileSizes()
add file sizes
deleteInternalLinks()
Delete internal links.
setContentIdManager(\ILIAS\COPage\ID\ContentIdManager $content_id_manager)
setImportMode(bool $a_val)
ILIAS COPage Page PageManager $page_manager
getLanguageVariablesXML(int $style_id=0)
Get language variables as XML.
afterUpdate(DOMDocument $domdoc, string $xml)
After update.
ILIAS COPage PC DomainService $pc_service
getContentDomNode(string $a_hier_id, string $a_pc_id="")
update(bool $a_validate=true, bool $a_no_history=false)
update complete page content in db (dom xml content is used)
getPCIdsForHierIds(array $hier_ids)
Get hier ids for a set of pc ids.
setLastChange(string $a_lastchange)
getEditLock()
Get page lock.
containsIntLinks(string $a_content)
Check whether content contains internal links.
resolveQuestionReferences(array $a_mapping)
Resolve all quesiont references (after import)
needsImportParsing(?bool $a_parse=null)
cutContents(array $a_hids)
Copy contents to clipboard and cut them from the page.
static getLastChangeByParent(string $a_parent_type, int $a_parent_id, string $a_lang="")
Get all pages for parent object.
deleteContents(array $a_hids, bool $a_update=true, bool $a_self_ass=false, bool $move_operation=false)
Delete multiple content objects.
getHierIdForPcId(string $pcid)
registerOfflineHandler(object $handler)
ILIAS COPage ReadingTime ReadingTimeManager $reading_time_manager
getInitialOpenedContent()
Get initial opened content.
getLangVarXML(string $var)
getContentObject(string $a_hier_id, string $a_pc_id="")
Get a content object of the page.
static getNewPages(string $a_parent_type, int $a_parent_id, string $a_lang="-")
Get new pages.
getDuplicatePCIds()
Get all duplicate PC Ids.
increaseViewCnt()
Increase view cnt.
updateFromXML()
Updates page object with current xml content This function is currently (8 beta) called by:
getPCModel()
Get page component model.
getParentContentObjectForPcId(string $pcid)
Get parent content object for pc id.
copyXmlContent(bool $a_clone_mobs=false, int $a_new_parent_id=0, int $obj_copy_id=0, bool $self_ass=true)
Copy content of page; replace page components with copies where necessary (e.g.
setLanguage(string $a_val)
Set language.
static getAllPages(string $a_parent_type, int $a_parent_id, string $a_lang="-")
Get all pages for parent object.
copy(int $a_id, string $a_parent_type="", int $a_new_parent_id=0, bool $a_clone_mobs=false, int $obj_copy_id=0, bool $overwrite_existing=true)
Copy page.
setActivationStart(?string $a_activationstart)
getLastUpdateOfIncludedElements()
Get last update of included elements (media objects and files).
setLastChangeUser(int $a_val)
LOMServices $lom_services
ilObjectDefinition $obj_definition
getHistoryInfo(int $a_nr)
Get information about a history entry, its predecessor and its successor.
moveContentAfter(string $a_source, string $a_target, string $a_spcid="", string $a_tpcid="")
move content object from position $a_source before position $a_target (both hierarchical content ids)
pasteContents(string $a_hier_id, bool $a_self_ass=false)
Paste contents from pc clipboard.
containsIntLink()
returns true, if page was marked as containing an intern link (via setContainsIntLink) (this method s...
setContainsQuestion(bool $a_val)
static _writeActive(int $a_id, string $a_parent_type, bool $a_active)
write activation status
ILIAS COPage ID ContentIdManager $content_id_manager
__afterHistoryEntry(DOMDocument $a_old_domdoc, string $a_old_content, int $a_old_nr)
setRenderedTime(string $a_renderedtime)
copyPageToTranslation(string $a_target_lang)
Copy page to translation.
ILIAS COPage Dom DomUtil $dom_util
static truncateHTML(string $a_text, int $a_length=100, string $a_ending='...', bool $a_exact=false, bool $a_consider_html=true)
Truncate (html) string.
setContainsIntLink(bool $a_contains_link)
lm parser set this flag to true, if the page contains intern links (this method should only be called...
resolveIntLinks(?array $a_link_map=null)
Resolves all internal link targets of the page, if targets are available (after import)
getParagraphForPCID(string $pcid)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
getContentTemplates()
Get content templates.
static _isScheduledActivation(int $a_id, string $a_parent_type, string $a_lang="-")
Check whether page is activated by time schedule.
setPageConfig(ilPageConfig $a_val)
setRenderMd5(string $a_rendermd5)
resolveFileItems(array $a_mapping)
Resolve file items (after import)
getMultimediaXML(bool $offline=false)
get a xml string that contains all media object elements, that are referenced by any media alias in t...
checkPCIds()
Check, whether (all) page content hashes are set.
setActive(bool $a_active)
setShowActivationInfo(bool $a_val)
getDomDoc()
Get dom doc (DOMDocument)
ILIAS COPage Link LinkManager $link
getXMLFromDom(bool $a_incl_head=false, bool $a_append_mobs=false, bool $a_append_bib=false, string $a_append_str="", bool $a_omit_pageobject_tag=false, int $style_id=0, bool $offline=false)
get xml content of page from dom (use this, if any changes are made to the document)
getHistoryEntry(int $a_old_nr)
Get History Entry.
addHierIDs()
Add hierarchical ID (e.g.
setXMLContent(string $a_xml, string $a_encoding="UTF-8")
set xml content of page, start with <PageObject...>, end with </PageObject>, comply with ILIAS DTD,...
ILIAS COPage Style StyleManager $style_manager
buildDom(bool $a_force=false)
preparePageForCompare(ilPageObject $page)
getXMLContent(bool $a_incl_head=false)
get xml content of page
saveInternalLinks(DOMDocument $a_domdoc)
save internal links of page
sendParagraph(string $par_id, string $filename)
validateDom(bool $throw=false)
Validate the page content agains page DTD.
insertPCIds()
Insert Page Content IDs.
static getPagesWithLinks(string $a_parent_type, int $a_parent_id, string $a_lang="-")
Get all pages for parent object that contain internal links.
getAllPCIds()
Get all pc ids.
performAutomaticModifications()
Perform automatic modifications (may be overwritten by sub classes)
saveInitialOpenedContent(string $a_type, int $a_id, string $a_target)
Save initial opened content.
getEffectiveEditLockTime()
__afterUpdate(DOMDocument $a_domdoc, string $a_xml, bool $a_creation=false, bool $a_empty=false)
After update event handler (internal).
resolveIIMMediaAliases(array $a_mapping)
Resolve iim media aliases (in ilContObjParse)
assignCharacteristic(array $targets, string $char_par, string $char_sec, string $char_med)
Assign characteristic.
saveStyleUsage(DOMDocument $a_domdoc, int $a_old_nr=0)
Save all style class/template usages.
getHistoryEntries()
Get History Entries.
getDomNodeForPCId(string $pc_id)
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
static _writeParentId(string $a_parent_type, int $a_pg_id, int $a_par_id)
writeRenderedContent(string $a_content, string $a_md5)
Write rendered content.
static _lookupActivationData(int $a_id, string $a_parent_type, string $a_lang="-")
Lookup activation data.
ILIAS COPage PC PCDefinition $pc_definition
getPCIdForHierId(string $hier_id)
static lookupParentId(int $a_id, string $a_type)
ilPageConfig $page_config
static getParentObjectContributors(string $a_parent_type, int $a_parent_id, string $a_lang="-")
Get all contributors for parent object.
createFromXML()
Create new page object with current xml content.
copyContents(array $a_hids)
Copy contents to clipboard.
static _existsAndNotEmpty(string $a_parent_type, int $a_id, string $a_lang="-")
Checks whether page exists and is not empty (may return true on some empty pages)
handleDeleteContent(?DOMNode $a_node=null, $move_operation=false)
Handle content before deletion This currently treats only plugged content If no node is given,...
static array $activation_data
resolveResources(array $ref_mapping)
Resolve resources.
setTranslationProperties(self $transl_page)
insertInstIntoIDs(string $a_inst, bool $a_res_ref_to_obj_id=true)
inserts installation id into ids (e.g.
static _lookupContainsDeactivatedElements(int $a_id, string $a_parent_type, string $a_lang="-")
lookup whether page contains deactivated elements
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent
getLangVarXMLForValue(string $var, string $val)
getMediaAliasElement(int $a_mob_id, int $a_nr=1)
get complete media object (alias) element
static lookupTranslations(string $a_parent_type, int $a_id)
Lookup translations.
static preloadActivationDataByParentId(int $a_parent_id)
Preload activation data by Parent Id.
getInternalLinks()
get all internal links that are used within the page
collectMediaObjects(bool $a_inline_only=true)
get all media objects, that are referenced and used within the page
moveIntLinks(array $a_from_to)
Move internal links from one destination to another.
getHierIdsForPCIds(array $a_pc_ids)
Get hier ids for a set of pc ids.
resolveMediaAliases(array $a_mapping, bool $a_reuse_existing_by_import=false)
Resolve media aliases (after import)
setActivationEnd(?string $a_activationend)
Set Activation End.
static getPageContributors(string $a_parent_type, int $a_page_id, string $a_lang="-")
Get all contributors for parent object.
static getRecentChanges(string $a_parent_type, int $a_parent_id, int $a_period=30, string $a_lang="")
Get recent pages changes for parent object.
setConcreteLang(string $a_val)
addUpdateListener(object $a_object, string $a_method, $a_parameters="")
beforePageContentUpdate(ilPageContent $a_page_content)
Before page content update Note: This one is "work in progress", currently only text paragraphs call ...
setRenderedContent(string $a_renderedcontent)
__construct(int $a_id=0, int $a_old_nr=0, string $a_lang="-")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static shortenText(string $a_string, int $a_start_pos, int $a_num_bytes, string $a_encoding='UTF-8')
Shorten text to the given number of bytes.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
static now()
Return current timestamp in Y-m-d H:i:s format.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ILIAS_VERSION_NUMERIC
update(string $table_name, array $values, array $where)
@description $where MUST contain existing columns only.
setLimit(int $limit, int $offset=0)
quote($value, string $type)
manipulate(string $query)
Run a (write) Query on the database.
manipulateF(string $query, array $types, array $values)
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
link(string $caption, string $href, bool $new_viewport=false)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
if(!file_exists('../ilias.ini.php'))
catch(ilCmiXapiException $e) send($response)