19define(
"IL_INSERT_BEFORE", 0);
20define(
"IL_INSERT_AFTER", 1);
21define(
"IL_INSERT_CHILD", 2);
54 protected \ILIAS\COPage\InternalDomainService
$domain;
56 protected \ILIAS\COPage\Link\LinkManager
$link;
74 public ?DOMDocument
$dom =
null;
118 $this->domain =
$DIC->copage()->internal()->domain();
120 $this->obj_definition = $this->domain->objectDefinition();
121 $this->db =
$DIC->database();
122 $this->
user = $this->domain->user();
123 $this->
lng = $this->domain->lng();
124 $this->tree = $this->domain->repositoryTree();
126 $this->lom_services =
$DIC->learningObjectMetadata();
134 $this->contains_int_link =
false;
135 $this->needs_parsing =
false;
136 $this->update_listeners = array();
137 $this->update_listener_cnt = 0;
138 $this->dom_builded =
false;
139 $this->page_not_found =
false;
140 $this->old_nr = $a_old_nr;
141 $this->encoding =
"UTF-8";
154 $this->show_page_act_info =
false;
162 $domain =
$DIC->copage()
165 $this->content_id_manager =
$domain
167 $this->page_manager =
$domain->page();
168 $this->pc_service =
$domain->pc();
169 $this->pc_definition =
$domain->pc()->definition();
170 $this->
link = $domain->link();
171 $this->style_manager =
$domain->style();
172 $this->dom_util =
$domain->domUtil();
189 $this->setPageConfig(
190 $this->domain->pageConfig($this->getParentType())
205 return $this->language;
210 $this->page_config = $a_val;
215 $this->concrete_lang = $a_val;
220 return $this->concrete_lang;
225 return $this->page_config;
230 $this->rendermd5 = $a_rendermd5;
235 return $this->rendermd5;
240 $this->renderedcontent = $a_renderedcontent;
245 return $this->renderedcontent;
250 $this->renderedtime = $a_renderedtime;
255 return $this->renderedtime;
260 $this->lastchange = $a_lastchange;
265 return $this->lastchange;
270 $this->last_change_user = $a_val;
275 return $this->last_change_user;
280 $this->show_page_act_info = $a_val;
285 return $this->show_page_act_info;
290 return $this->create_user;
298 $this->setActive(
true);
299 if ($this->old_nr == 0) {
300 $query =
"SELECT * FROM page_object" .
301 " WHERE page_id = " . $this->db->quote($this->
id,
"integer") .
302 " AND parent_type=" . $this->db->quote($this->getParentType(),
"text") .
303 " AND lang = " . $this->db->quote($this->
getLanguage(),
"text");
304 $pg_set = $this->db->query($query);
305 if (!$this->page_record = $this->db->fetchAssoc($pg_set)) {
307 " (parent type " . $this->getParentType() .
", lang: " . $this->
getLanguage() .
").");
309 $this->setActive($this->page_record[
"active"]);
310 $this->setActivationStart($this->page_record[
"activation_start"]);
311 $this->setActivationEnd($this->page_record[
"activation_end"]);
312 $this->setShowActivationInfo($this->page_record[
"show_activation_info"]);
314 $query =
"SELECT * FROM page_history" .
315 " WHERE page_id = " . $this->db->quote($this->
id,
"integer") .
316 " AND parent_type=" . $this->db->quote($this->getParentType(),
"text") .
317 " AND nr = " . $this->db->quote($this->old_nr,
"integer") .
318 " AND lang = " . $this->db->quote($this->
getLanguage(),
"text");
319 $pg_set = $this->db->query($query);
320 $this->page_record = $this->db->fetchAssoc($pg_set);
322 if (!$this->page_record) {
324 " (parent type " . $this->getParentType() .
", lang: " . $this->
getLanguage() .
").");
326 $this->xml = $this->page_record[
"content"];
327 $this->setParentId((
int) $this->page_record[
"parent_id"]);
328 $this->last_change_user = (
int) ($this->page_record[
"last_change_user"] ?? 0);
329 $this->create_user = (
int) ($this->page_record[
"create_user"] ?? 0);
330 $this->setRenderedContent((
string) ($this->page_record[
"rendered_content"] ??
""));
331 $this->setRenderMd5((
string) ($this->page_record[
"render_md5"] ??
""));
332 $this->setRenderedTime((
string) ($this->page_record[
"rendered_time"] ??
""));
333 $this->setLastChange((
string) ($this->page_record[
"last_change"] ??
""));
341 string $a_parent_type,
344 bool $a_no_cache =
false
348 $db =
$DIC->database();
350 if (!$a_no_cache && isset(self::$exists[$a_parent_type .
":" . $a_id .
":" . $a_lang])) {
351 return self::$exists[$a_parent_type .
":" . $a_id .
":" . $a_lang];
356 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
359 $query =
"SELECT page_id FROM page_object WHERE page_id = " . $db->
quote($a_id,
"integer") .
" " .
360 "AND parent_type = " . $db->
quote($a_parent_type,
"text") . $and_lang;
361 $set = $db->
query($query);
363 self::$exists[$a_parent_type .
":" . $a_id .
":" . $a_lang] =
true;
366 self::$exists[$a_parent_type .
":" . $a_id .
":" . $a_lang] =
false;
375 string $a_parent_type,
382 public function buildDom(
bool $a_force =
false): string|bool|null
384 if ($this->dom_builded && !$a_force) {
388 if ($this->getXMLContent() ===
"") {
389 $this->setXMLContent(
"<PageObject></PageObject>");
391 $this->dom = $this->dom_util->docFromString($this->getXMLContent(
true), $error);
392 $path =
"//PageObject";
393 if (is_null($this->dom)) {
395 $this->
getId() .
"," . $this->
getLanguage() .
"): " . $this->getXMLContent(
true));
397 $nodes = $this->dom_util->path($this->dom,
$path);
398 if (count($nodes) == 1) {
399 $this->node = $nodes->item(0);
402 $this->
getId() .
"," . $this->
getLanguage() .
"): " . $this->getXMLContent(
true));
406 $this->dom_builded =
true;
426 public function setId(
int $a_id): void
438 $this->parent_id = $a_id;
443 return $this->parent_id;
454 $cnt = $this->update_listener_cnt;
455 $this->update_listeners[$cnt][
"object"] = $a_object;
456 $this->update_listeners[$cnt][
"method"] = $a_method;
457 $this->update_listeners[$cnt][
"parameters"] = $a_parameters;
458 $this->update_listener_cnt++;
463 for ($i = 0; $i < $this->update_listener_cnt; $i++) {
464 $object = $this->update_listeners[$i][
"object"];
465 $method = $this->update_listeners[$i][
"method"];
466 $parameters = $this->update_listeners[$i][
"parameters"];
467 $object->$method($parameters);
473 $this->active = $a_active;
477 bool $a_check_scheduled_activation =
false
479 if ($a_check_scheduled_activation && !$this->active) {
487 return $this->active;
497 $db =
$DIC->database();
499 "SELECT page_id, parent_type, lang, active, activation_start, activation_end, show_activation_info FROM page_object " .
500 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer")
503 self::$activation_data[$rec[
"page_id"] .
":" . $rec[
"parent_type"] .
":" . $rec[
"lang"]] = $rec;
512 string $a_parent_type,
513 bool $a_check_scheduled_activation =
false,
518 $db =
$DIC->database();
525 if (isset(self::$activation_data[$a_id .
":" . $a_parent_type .
":" . $a_lang])) {
526 $rec = self::$activation_data[$a_id .
":" . $a_parent_type .
":" . $a_lang];
529 "SELECT active, activation_start, activation_end FROM page_object WHERE page_id = %s" .
530 " AND parent_type = %s AND lang = %s",
531 array(
"integer",
"text",
"text"),
532 array($a_id, $a_parent_type, $a_lang)
541 if (!$rec[
"active"] && $a_check_scheduled_activation) {
542 if ($rec[
"n"] >= $rec[
"activation_start"] &&
543 $rec[
"n"] <= $rec[
"activation_end"]) {
548 return (
bool) $rec[
"active"];
556 string $a_parent_type,
561 $db =
$DIC->database();
570 if (isset(self::$activation_data[$a_id .
":" . $a_parent_type .
":" . $a_lang])) {
571 $rec = self::$activation_data[$a_id .
":" . $a_parent_type .
":" . $a_lang];
574 "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)
582 if (!$rec[
"active"] && $rec[
"activation_start"] !=
"") {
594 string $a_parent_type,
599 $db =
$DIC->database();
605 "UPDATE page_object SET active = %s, activation_start = %s, " .
606 " activation_end = %s WHERE page_id = %s" .
607 " AND parent_type = %s AND lang = %s",
608 array(
"int",
"timestamp",
"timestamp",
"integer",
"text",
"text"),
609 array((
int) $a_active,
null,
null, $a_id, $a_parent_type, $a_lang)
618 string $a_parent_type,
623 $db =
$DIC->database();
630 if (isset(self::$activation_data[$a_id .
":" . $a_parent_type .
":" . $a_lang])) {
631 $rec = self::$activation_data[$a_id .
":" . $a_parent_type .
":" . $a_lang];
634 "SELECT active, activation_start, activation_end, show_activation_info FROM page_object WHERE page_id = %s" .
635 " AND parent_type = %s AND lang = %s",
636 array(
"integer",
"text",
"text"),
637 array($a_id, $a_parent_type, $a_lang)
643 "activation_start" =>
null,
644 "activation_end" =>
null,
645 "show_activation_info" => 0
657 $db =
$DIC->database();
659 $res = $db->
query(
"SELECT parent_id FROM page_object WHERE page_id = " . $db->
quote($a_id,
"integer") .
" " .
660 "AND parent_type=" . $db->
quote($a_type,
"text"));
662 return (
int) ($rec[
"parent_id"] ?? 0);
665 public static function _writeParentId(
string $a_parent_type,
int $a_pg_id,
int $a_par_id): void
669 $db =
$DIC->database();
671 "UPDATE page_object SET parent_id = %s WHERE page_id = %s" .
672 " AND parent_type = %s",
673 array(
"integer",
"integer",
"text"),
674 array($a_par_id, $a_pg_id, $a_parent_type)
683 if ($a_activationstart ==
"") {
684 $a_activationstart =
null;
686 $this->activationstart = $a_activationstart;
691 return $this->activationstart;
700 if ($a_activationend ==
"") {
701 $a_activationend =
null;
703 $this->activationend = $a_activationend;
708 return $this->activationend;
718 $node = $this->page_manager->content($this->getDomDoc())->getContentDomNode(
722 $this->log->debug(
"getContentObject: " .
" $a_hier_id, $a_pc_id, " . $node?->nodeName);
723 return $this->pc_service->getByNode($node, $this);
731 $hier_ids = $this->getHierIdsForPCIds([$pcid]);
732 return $this->getContentObject($hier_ids[$pcid], $pcid);
740 $content_object = $this->getContentObjectForPcId($pcid);
741 $node = $content_object->getDomNode();
742 $node = $node->parentNode;
744 if ($node->nodeName ==
"PageContent") {
745 $pcid = $node->getAttribute(
"PCID");
747 return $this->getContentObjectForPcId($pcid);
750 $node = $node->parentNode;
757 $cm = $this->page_manager->content($this->getDomDoc());
758 return $cm->getContentDomNode($a_hier_id, $a_pc_id);
763 return $this->getContentDomNode(
"", $pc_id);
772 public function setXMLContent(
string $a_xml,
string $a_encoding =
"UTF-8"): void
774 $this->encoding = $a_encoding;
784 $this->xml .= $a_xml;
796 $enc_str = (!empty($this->encoding))
797 ?
"encoding=\"" . $this->encoding .
"\""
799 return "<?xml version=\"1.0\" $enc_str ?>" .
800 "<!DOCTYPE PageObject SYSTEM \"" . $this->getIliasAbsolutePath() .
"/components/ILIAS/Export/xml/" . $this->cur_dtd .
"\">" .
809 return ILIAS_ABSOLUTE_PATH;
818 bool $a_clone_mobs =
false,
819 int $a_new_parent_id = 0,
820 int $obj_copy_id = 0,
821 bool $self_ass =
true
823 $cm = $this->page_manager->contentFromXml($this->getXMLContent());
824 return $cm->copyXmlContent(
844 $pm = $this->page_manager->content($this->getDomDoc());
845 $pm->handleDeleteContent($this, $a_node, $move_operation);
853 bool $a_incl_head =
false,
854 bool $a_append_mobs =
false,
855 bool $a_append_bib =
false,
856 string $a_append_str =
"",
857 bool $a_omit_pageobject_tag =
false,
859 bool $offline =
false
863 return $this->dom_util->dump($this->node);
866 if ($a_append_mobs || $a_append_bib) {
869 if ($a_append_mobs) {
870 $mobs = $this->getMultimediaXML($offline);
876 $trans = $this->getLanguageVariablesXML($style_id);
878 return "<dummy>" . $this->dom_util->dump($this->node) . $mobs . $bibs . $trans . $a_append_str .
"</dummy>";
880 if (is_object($this->dom)) {
881 if ($a_omit_pageobject_tag) {
883 foreach ($this->node->childNodes as $child) {
884 $xml .= $this->dom_util->dump($child);
887 $xml = $this->dom_util->dump($this->node);
888 $xml = preg_replace(
'/<\?xml[^>]*>/i',
"", $xml);
889 $xml = preg_replace(
'/<!DOCTYPE[^>]*>/i',
"", $xml);
921 "ed_align_left_float",
922 "ed_align_right_float",
924 "ed_new_item_before",
931 "ed_split_page_next",
939 "ed_click_to_add_pg",
944 $defs = $this->pc_definition->getPCDefinitions();
945 foreach ($defs as $def) {
946 $lang_vars[] =
"pc_" . $def[
"pc_type"];
947 $lang_vars[] =
"ed_insert_" . $def[
"pc_type"];
949 $cl = $def[
"pc_class"];
950 $lvs = call_user_func($def[
"pc_class"] .
'::getLangVars');
951 foreach ($lvs as $lv) {
958 $dummy_pc->setStyleId($style_id);
959 foreach ([
"section",
"table",
"flist_li",
"list_u",
"list_o",
960 "table",
"table_cell"] as $type) {
961 $dummy_pc->getCharacteristicsOfCurrentStyle([$type]);
962 foreach ($dummy_pc->getCharacteristics() as $char => $txt) {
963 $xml .=
"<LV name=\"char_" . $type .
"_" . $char .
"\" value=\"" . $txt .
"\"/>";
966 $type =
"media_cont";
968 $dummy_pc->setStyleId($style_id);
969 $dummy_pc->getCharacteristicsOfCurrentStyle([$type]);
970 foreach ($dummy_pc->getCharacteristics() as $char => $txt) {
971 $xml .=
"<LV name=\"char_" . $type .
"_" . $char .
"\" value=\"" . $txt .
"\"/>";
973 foreach ([
"text_block",
"heading1",
"heading2",
"heading3"] as $type) {
975 $dummy_pc->setStyleId($style_id);
976 $dummy_pc->getCharacteristicsOfCurrentStyle([$type]);
977 foreach ($dummy_pc->getCharacteristics() as $char => $txt) {
978 $xml .=
"<LV name=\"char_" . $type .
"_" . $char .
"\" value=\"" . $txt .
"\"/>";
981 foreach ($lang_vars as $lang_var) {
982 $xml .= $this->getLangVarXML($lang_var);
984 foreach ($this->pc_service->plugged()->getPluginLangVars() as $k => $v) {
985 $xml .= $this->getLangVarXMLForValue($k, $v);
993 return $this->getLangVarXMLForValue(
995 $this->
lng->txt(
"cont_" . $var)
1001 $val = str_replace(
'"',
""", $val);
1002 return "<LV name=\"$var\" value=\"" . $val .
"\"/>";
1007 return $this->pc_service->paragraph()->getFirstParagraphText($this);
1012 return $this->pc_service->paragraph()->getParagraphForPCID($this, $pcid);
1025 $this->contains_int_link = $a_contains_link;
1035 return $this->contains_int_link;
1040 $this->import_mode = $a_val;
1045 return $this->import_mode;
1050 if ($a_parse ===
true) {
1051 $this->needs_parsing =
true;
1053 if ($a_parse ===
false) {
1054 $this->needs_parsing =
false;
1056 return $this->needs_parsing;
1062 $this->contains_question = $a_val;
1067 return $this->contains_question;
1077 $mob_manager = $this->pc_service->mediaObject();
1078 return $mob_manager->collectMediaObjects($this->getDomDoc(), $a_inline_only);
1086 return $this->
link->getInternalLinks($this->getDomDoc());
1094 bool $offline =
false
1096 $mob_manager = $this->pc_service->mediaObject();
1097 return $mob_manager->getMultimediaXML($this->getDomDoc(), $offline);
1105 $mob_manager = $this->pc_service->mediaObject();
1106 return $mob_manager->getMediaAliasElement(
1118 $this->stripHierIDs();
1124 $this->dom_util->validate($this->dom, $error, $throw);
1133 $this->content_id_manager->addHierIDsToDom();
1138 return $this->content_id_manager->getHierIds();
1143 $this->content_id_manager->stripHierIDsFromDom();
1148 $this->content_id_manager->stripPCIDs();
1156 return $this->content_id_manager->getHierIdsForPCIds($a_pc_ids);
1161 return $this->content_id_manager->getHierIdForPcId($pcid);
1169 return $this->content_id_manager->getPCIdsForHierIds($hier_ids);
1174 return $this->content_id_manager->getPCIdForHierId($hier_id);
1182 $this->pc_service->fileList()->addFileSizes($this->getDomDoc());
1191 return $this->
link->resolveIntLinks($this->getDomDoc(), $a_link_map);
1200 bool $a_reuse_existing_by_import =
false
1202 return $this->pc_service->mediaObject()->resolveMediaAliases(
1205 $a_reuse_existing_by_import
1215 return $this->pc_service->interactiveImage()->resolveIIMMediaAliases(
1227 return $this->pc_service->fileList()->resolveFileItems(
1239 $qm = $this->pc_service->question();
1240 return $qm->resolveQuestionReferences(
1254 $this->addHierIDs();
1255 return $this->
link->moveIntLinks(
1267 int $a_source_ref_id
1271 $tree = $this->tree;
1272 $this->log->debug(
"Handle repository links...");
1274 $defs = $this->pc_definition->getPCDefinitions();
1275 foreach ($defs as $def) {
1276 if (method_exists($def[
"pc_class"],
'afterRepositoryCopy')) {
1277 call_user_func($def[
"pc_class"] .
'::afterRepositoryCopy', $this, $a_mapping, $a_source_ref_id);
1281 $this->
link->handleRepositoryLinksOnCopy($this->getDomDoc(), $a_mapping, $a_source_ref_id, $tree);
1286 $this->setXMLContent(
"<PageObject></PageObject>");
1295 if ($this->getXMLContent() ===
"") {
1296 $this->setEmptyPageXml();
1299 $content = $this->getXMLContent();
1300 $this->buildDom(
true);
1301 $dom_doc = $this->getDomDoc();
1303 $errors = $this->validateDom(
true);
1305 $iel = $this->containsDeactivatedElements($content);
1306 $inl = $this->containsIntLinks($content);
1308 $this->db->insert(
"page_object", array(
1309 "page_id" => array(
"integer", $this->
getId()),
1310 "parent_id" => array(
"integer", $this->getParentId()),
1312 "content" => array(
"clob", $content),
1313 "parent_type" => array(
"text", $this->getParentType()),
1314 "create_user" => array(
"integer", $this->
user->getId()),
1315 "last_change_user" => array(
"integer", $this->
user->getId()),
1316 "active" => array(
"integer", (
int) $this->getActive()),
1317 "activation_start" => array(
"timestamp", $this->getActivationStart()),
1318 "activation_end" => array(
"timestamp", $this->getActivationEnd()),
1319 "show_activation_info" => array(
"integer", (
int) $this->getShowActivationInfo()),
1320 "inactive_elements" => array(
"integer", $iel),
1321 "int_links" => array(
"integer", $inl),
1323 "last_change" => array(
"timestamp",
ilUtil::now()),
1324 "is_empty" => array(
"integer", $empty)
1327 $this->__afterUpdate($dom_doc, $content,
true, $empty);
1339 $this->log->debug(
"ilPageObject, updateFromXML(): start, id: " . $this->
getId());
1341 $content = $this->getXMLContent();
1343 $this->log->debug(
"ilPageObject, updateFromXML(): content: " . substr($content, 0, 100));
1345 $this->buildDom(
true);
1346 $dom_doc = $this->getDomDoc();
1348 $errors = $this->validateDom(
true);
1350 $iel = $this->containsDeactivatedElements($content);
1351 $inl = $this->containsIntLinks($content);
1353 $this->db->update(
"page_object", array(
1354 "content" => array(
"clob", $content),
1355 "parent_id" => array(
"integer", $this->getParentId()),
1356 "last_change_user" => array(
"integer", $this->
user->getId()),
1357 "last_change" => array(
"timestamp",
ilUtil::now()),
1358 "active" => array(
"integer", $this->getActive()),
1359 "activation_start" => array(
"timestamp", $this->getActivationStart()),
1360 "activation_end" => array(
"timestamp", $this->getActivationEnd()),
1361 "inactive_elements" => array(
"integer", $iel),
1362 "int_links" => array(
"integer", $inl),
1364 "page_id" => array(
"integer", $this->
getId()),
1365 "parent_type" => array(
"text", $this->getParentType()),
1370 $this->__afterUpdate($dom_doc, $content);
1372 $this->log->debug(
"ilPageObject, updateFromXML(): end");
1382 DOMDocument $a_domdoc,
1384 bool $a_creation =
false,
1385 bool $a_empty =
false
1388 if (!$a_creation || !$a_empty) {
1392 $this->saveInternalLinks($a_domdoc);
1395 $this->saveStyleUsage($a_domdoc);
1398 $this->reading_time_manager->saveTime($this);
1401 $defs = $this->pc_definition->getPCDefinitions();
1402 foreach ($defs as $def) {
1403 $cl = $def[
"pc_class"];
1404 call_user_func($def[
"pc_class"] .
'::afterPageUpdate', $this, $a_domdoc, $a_xml, $a_creation);
1409 $this->afterUpdate($a_domdoc, $a_xml);
1412 $this->callUpdateListeners();
1428 public function update(
bool $a_validate =
true,
bool $a_no_history =
false): array|bool
1430 $this->log->debug(
"start..., id: " . $this->
getId());
1434 if (!$this->checkPCIds()) {
1435 $this->insertPCIds();
1440 $this->log->debug($this->dom_util->dump($this->getDomDoc()->documentElement));
1441 $errors = $this->validateDom();
1444 if (empty($errors) && !$this->getEditLock()) {
1445 $lock = $this->getEditLockInfo();
1446 $errors[0] = array(0 => 0,
1447 1 => $this->
lng->txt(
"cont_not_saved_edit_lock_expired") .
"<br />" .
1448 $this->lng->txt(
"obj_usr") .
": " .
1450 $this->lng->txt(
"content_until") .
": " .
1456 $this->log->debug(
"checking duplicate ids");
1457 if ($this->hasDuplicatePCIds()) {
1458 $errors[0] = $this->
lng->txt(
"cont_could_not_save_duplicate_pc_ids") .
1459 " (" . implode(
", ", $this->getDuplicatePCIds()) .
")";
1462 if (!empty($errors)) {
1463 $this->log->debug(
"ilPageObject, update(): errors: " . print_r($errors,
true));
1467 if (empty($errors)) {
1471 $this->log->debug(
"perform automatic modifications");
1472 $this->performAutomaticModifications();
1475 $content = $this->getXMLFromDom();
1476 $dom_doc = $this->getDomDoc();
1481 $old_set = $this->db->query(
"SELECT * FROM page_object WHERE " .
1482 "page_id = " . $this->db->quote($this->getId(),
"integer") .
" AND " .
1483 "parent_type = " . $this->db->quote($this->getParentType(),
"text") .
" AND " .
1484 "lang = " . $this->db->quote($this->getLanguage(),
"text"));
1485 $last_nr_set = $this->db->query(
"SELECT max(nr) as mnr FROM page_history WHERE " .
1486 "page_id = " . $this->db->quote($this->getId(),
"integer") .
" AND " .
1487 "parent_type = " . $this->db->quote($this->getParentType(),
"text") .
" AND " .
1488 "lang = " . $this->db->quote($this->getLanguage(),
"text"));
1489 $last_nr = $this->db->fetchAssoc($last_nr_set);
1490 if ($old_rec = $this->db->fetchAssoc($old_set)) {
1493 if (($content != $old_rec[
"content"] || $this->
user->getId() != $old_rec[
"last_change_user"]) &&
1494 !$a_no_history && !$this->history_saved &&
$lm_set->get(
"page_history", 1)) {
1495 if ($old_rec[
"content"] !=
"<PageObject></PageObject>") {
1496 $this->db->manipulateF(
1497 "DELETE FROM page_history WHERE " .
1498 "page_id = %s AND parent_type = %s AND hdate = %s AND lang = %s",
1499 array(
"integer",
"text",
"timestamp",
"text"),
1500 array($old_rec[
"page_id"],
1501 $old_rec[
"parent_type"],
1502 $old_rec[
"last_change"],
1509 $last_c = $old_rec[
"last_change"];
1510 if ($last_c ==
"") {
1514 $this->db->insert(
"page_history", array(
1515 "page_id" => array(
"integer", $old_rec[
"page_id"]),
1516 "parent_type" => array(
"text", $old_rec[
"parent_type"]),
1517 "lang" => array(
"text", $old_rec[
"lang"]),
1518 "hdate" => array(
"timestamp", $last_c),
1519 "parent_id" => array(
"integer", $old_rec[
"parent_id"]),
1520 "content" => array(
"clob", $old_rec[
"content"]),
1521 "user_id" => array(
"integer", $old_rec[
"last_change_user"]),
1523 "nr" => array(
"integer", (
int) $last_nr[
"mnr"] + 1)
1526 $old_content = $old_rec[
"content"];
1527 $old_domdoc =
new DOMDocument();
1528 $old_nr = $last_nr[
"mnr"] + 1;
1529 $old_domdoc->loadXML(
'<?xml version="1.0" encoding="UTF-8"?>' . $old_content);
1532 $this->log->debug(
"calling __afterHistoryEntry");
1533 $this->__afterHistoryEntry($old_domdoc, $old_content, $old_nr);
1537 $this->history_saved =
true;
1541 $em = (trim($content) ==
"<PageObject/>")
1546 $this->log->debug(
"checking deactivated elements");
1547 $iel = $this->containsDeactivatedElements($content);
1548 $this->log->debug(
"checking internal links");
1549 $inl = $this->containsIntLinks($content);
1552 $this->lastchange = $now;
1553 $this->db->update(
"page_object", array(
1554 "content" => array(
"clob", $content),
1555 "parent_id" => array(
"integer", $this->getParentId()),
1556 "last_change_user" => array(
"integer", $this->
user->getId()),
1557 "last_change" => array(
"timestamp", $now),
1558 "is_empty" => array(
"integer", $em),
1559 "active" => array(
"integer", $this->getActive()),
1560 "activation_start" => array(
"timestamp", $this->getActivationStart()),
1561 "activation_end" => array(
"timestamp", $this->getActivationEnd()),
1562 "show_activation_info" => array(
"integer", $this->getShowActivationInfo()),
1563 "inactive_elements" => array(
"integer", $iel),
1564 "int_links" => array(
"integer", $inl),
1566 "page_id" => array(
"integer", $this->
getId()),
1567 "parent_type" => array(
"text", $this->getParentType()),
1572 $this->log->debug(
"calling __afterUpdate()");
1573 $this->__afterUpdate($dom_doc, $content);
1576 "...ending, updated and returning true, content: " . substr(
1577 $this->getXMLContent(),
1590 public function delete():
void
1593 $copg_logger->debug(
1594 "ilPageObject: Delete called for ID '" . $this->
getId() .
"'," .
1595 " parent type: '" . $this->getParentType() .
"', " .
1596 " hist nr: '" . $this->old_nr .
"', " .
1601 if (!$this->page_not_found) {
1603 $mobs = $this->collectMediaObjects(
false);
1606 $this->getParentType() .
":pg",
1612 foreach ($mobs2 as $m) {
1613 if (!in_array($m, $mobs)) {
1618 $copg_logger->debug(
"ilPageObject: ... found " . count($mobs) .
" media objects.");
1620 $this->__beforeDelete();
1623 $this->handleDeleteContent();
1626 $this->deleteStyleUsages(
false);
1629 $this->deleteInternalLinks();
1635 if (!$this->isTranslationPage()) {
1637 $this->getParentId(),
1638 $this->getParentType(),
1645 $and = $this->isTranslationPage()
1646 ?
" AND lang = " . $this->db->quote($this->
getLanguage(),
"text")
1648 $this->db->manipulate(
"DELETE FROM page_object " .
1649 "WHERE page_id = " . $this->db->quote($this->getId(),
"integer") .
1650 " AND parent_type= " . $this->db->quote($this->getParentType(),
"text") . $and);
1653 foreach ($mobs as $mob_id) {
1654 $copg_logger->debug(
"ilPageObject: ... processing mob " . $mob_id .
".");
1657 $copg_logger->debug(
"ilPageObject: ... type mismatch. Ignoring mob " . $mob_id .
".");
1662 $copg_logger->debug(
"ilPageObject: ... delete mob " . $mob_id .
".");
1667 $copg_logger->debug(
"ilPageObject: ... missing mob " . $mob_id .
".");
1671 $this->__afterDelete();
1676 return !in_array($this->
getLanguage(), [
"",
"-"]);
1685 $defs = $this->pc_definition->getPCDefinitions();
1686 foreach ($defs as $def) {
1687 $cl = $def[
"pc_class"];
1688 call_user_func($def[
"pc_class"] .
'::beforePageDelete', $this);
1694 $this->afterDelete();
1702 DOMDocument $a_old_domdoc,
1703 string $a_old_content,
1707 $this->saveStyleUsage($a_old_domdoc, $a_old_nr);
1710 $defs = $this->pc_definition->getPCDefinitions();
1711 foreach ($defs as $def) {
1712 $cl = $def[
"pc_class"];
1714 $def[
"pc_class"] .
'::afterPageHistoryEntry',
1727 DOMDocument $a_domdoc,
1730 $this->style_manager->saveStyleUsage(
1742 $this->style_manager->deleteStyleUsages($this, $a_old_nr);
1753 $this->getParentType() .
":pg",
1756 $files = ilObjFile::_getFilesOfObject(
1757 $this->getParentType() .
":pg",
1760 $objs = array_merge($mobs, $files);
1769 $this->
link->deleteInternalLinks($this);
1779 $this->
link->saveInternalLinks(
1788 public function create(
bool $a_import =
false): void
1790 $this->createFromXML();
1801 bool $a_update =
true,
1802 string $a_pcid =
"",
1803 bool $move_operation =
false
1805 $pm = $this->page_manager->content($this->getDomDoc());
1806 $pm->deleteContent($this, $a_hid, $a_pcid, $move_operation);
1808 return $this->update();
1822 bool $a_update =
true,
1823 bool $a_self_ass =
false,
1824 bool $move_operation =
false
1826 $pm = $this->page_manager->content($this->getDomDoc());
1827 $pm->deleteContents($this, $a_hids, $a_self_ass, $move_operation);
1829 return $this->update();
1841 $this->copyContents($a_hids);
1842 return $this->deleteContents(
1845 $this->getPageConfig()->getEnableSelfAssessment(),
1855 $cm = $this->page_manager->content($this->getDomDoc());
1856 $cm->copyContents($a_hids, $this->
user);
1866 bool $a_self_ass =
false
1868 $user = $this->
user;
1869 $cm = $this->page_manager->content($this->getDomDoc());
1876 return $this->update();
1888 bool $a_update =
true,
1889 bool $a_self_ass =
false
1891 $cm = $this->page_manager->content($this->getDomDoc());
1892 $cm->switchEnableMultiple($this, $a_hids, $a_self_ass);
1894 return $this->update();
1906 string $a_pcid =
"",
1907 bool $remove_placeholder =
true
1909 $cm = $this->page_manager->content($this->getDomDoc());
1915 $remove_placeholder,
1916 $this->getPageConfig()->getEnablePCType(
"PlaceHolder")
1924 DOMNode $a_cont_node,
1929 $cm = $this->page_manager->content($this->getDomDoc());
1930 $cm->insertContentNode(
1954 string $a_spcid =
"",
1955 string $a_tpcid =
""
1957 $cm = $this->page_manager->content($this->getDomDoc());
1958 $cm->moveContentAfter(
1965 return $this->update();
1976 bool $a_res_ref_to_obj_id =
true
1978 $cm = $this->page_manager->content($this->getDomDoc());
1979 $cm->insertInstIntoIDs($a_inst, $a_res_ref_to_obj_id);
1987 return $this->content_id_manager->checkPCIds();
1995 return $this->content_id_manager->getAllPCIds();
2000 return $this->content_id_manager->hasDuplicatePCIds();
2009 return $this->content_id_manager->getDuplicatePCIds();
2014 return $this->content_id_manager->generatePCId();
2022 $this->content_id_manager->insertPCIds();
2029 $this->pc_service->paragraph()->
send(
2043 return $this->offline_handler;
2051 string $a_parent_type,
2052 string $a_lang =
"-"
2056 $db =
$DIC->database();
2058 if ($a_lang ==
"") {
2062 $query =
"SELECT * FROM page_object WHERE page_id = " .
2063 $db->
quote($a_id,
"integer") .
" AND " .
2064 " parent_type = " . $db->
quote($a_parent_type,
"text") .
" AND " .
2065 " lang = " . $db->
quote($a_lang,
"text") .
" AND " .
2066 " inactive_elements = " . $db->
quote(1,
"integer");
2067 $obj_set = $db->
query($query);
2081 if (strpos($a_content,
" Enabled=\"False\"")) {
2094 $h_query =
"SELECT * FROM page_history " .
2095 " WHERE page_id = " . $db->
quote($this->
getId(),
"integer") .
2096 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2098 " ORDER BY hdate DESC";
2100 $hset = $db->
query($h_query);
2101 $hentries = array();
2104 $hrec[
"sortkey"] = (
int) $hrec[
"nr"];
2105 $hrec[
"user"] = (
int) $hrec[
"user_id"];
2106 $hentries[] = $hrec;
2120 "SELECT * FROM page_history " .
2121 " WHERE page_id = %s " .
2122 " AND parent_type = %s " .
2125 array(
"integer",
"text",
"integer",
"text"),
2126 array($this->
getId(), $this->getParentType(), $a_old_nr, $this->
getLanguage())
2145 $and_nr = ($a_nr > 0)
2146 ?
" AND nr < " . $db->
quote($a_nr,
"integer")
2148 $res = $db->
query(
"SELECT MAX(nr) mnr FROM page_history " .
2149 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2150 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2154 if ($row[
"mnr"] > 0) {
2155 $res = $db->
query(
"SELECT * FROM page_history " .
2156 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2157 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2159 " AND nr = " . $db->
quote((
int) $row[
"mnr"],
"integer"));
2161 $ret[
"previous"] = $row;
2165 $res = $db->
query(
"SELECT MIN(nr) mnr FROM page_history " .
2166 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2167 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2169 " AND nr > " . $db->
quote($a_nr,
"integer"));
2171 if ($row[
"mnr"] > 0) {
2172 $res = $db->
query(
"SELECT * FROM page_history " .
2173 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2174 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2176 " AND nr = " . $db->
quote((
int) $row[
"mnr"],
"integer"));
2178 $ret[
"next"] = $row;
2183 $res = $db->
query(
"SELECT * FROM page_history " .
2184 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2185 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2187 " AND nr = " . $db->
quote($a_nr,
"integer"));
2189 $res = $db->
query(
"SELECT page_id, last_change hdate, parent_type, parent_id, last_change_user user_id, content, lang FROM page_object " .
2190 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2191 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2195 $ret[
"current"] = $row;
2212 " SET view_cnt = view_cnt + 1 " .
2213 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2214 " AND parent_type = " . $db->
quote($this->getParentType(),
"text") .
2215 " AND lang = " . $db->
quote($this->getLanguage(),
"text"));
2225 string $a_parent_type,
2232 $db =
$DIC->database();
2235 if ($a_lang !=
"") {
2236 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2239 $page_changes = array();
2240 $limit_ts = date(
'Y-m-d H:i:s', time() - ($a_period * 24 * 60 * 60));
2241 $q =
"SELECT * FROM page_object " .
2242 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer") .
2243 " AND parent_type = " . $db->
quote($a_parent_type,
"text") .
2244 " AND last_change >= " . $db->
quote($limit_ts,
"timestamp") . $and_lang;
2248 $page_changes[] = array(
2249 "date" => $page[
"last_change"],
2250 "id" => $page[
"page_id"],
2251 "lang" => $page[
"lang"],
2253 "user" => $page[
"last_change_user"]
2258 if ($a_period > 0) {
2259 $limit_ts = date(
'Y-m-d H:i:s', time() - ($a_period * 24 * 60 * 60));
2260 $and_str =
" AND hdate >= " . $db->
quote($limit_ts,
"timestamp") .
" ";
2263 $q =
"SELECT * FROM page_history " .
2264 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer") .
2265 " AND parent_type = " . $db->
quote($a_parent_type,
"text") .
2266 $and_str . $and_lang;
2269 $page_changes[] = array(
2270 "date" => $page[
"hdate"],
2271 "id" => $page[
"page_id"],
2272 "lang" => $page[
"lang"],
2274 "nr" => $page[
"nr"],
2275 "user" => $page[
"user_id"]
2281 return $page_changes;
2288 string $a_parent_type,
2290 string $a_lang =
"-"
2294 $db =
$DIC->database();
2297 if ($a_lang !=
"") {
2298 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2301 $q =
"SELECT * FROM page_object " .
2302 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer") .
2303 " AND parent_type = " . $db->
quote($a_parent_type,
"text") . $and_lang;
2307 $key_add = ($a_lang ==
"")
2308 ?
":" . $page[
"lang"]
2310 $pages[$page[
"page_id"] . $key_add] = array(
2311 "date" => $page[
"last_change"],
2312 "id" => $page[
"page_id"],
2313 "lang" => $page[
"lang"],
2314 "user" => $page[
"last_change_user"]
2325 string $a_parent_type,
2327 string $a_lang =
"-"
2331 $db =
$DIC->database();
2334 if ($a_lang !=
"") {
2335 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2340 $q =
"SELECT * FROM page_object " .
2341 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer") .
2342 " AND parent_type = " . $db->
quote($a_parent_type,
"text") . $and_lang .
2343 " ORDER BY created DESC";
2346 if ($page[
"created"] !=
"") {
2348 "created" => $page[
"created"],
2349 "id" => $page[
"page_id"],
2350 "lang" => $page[
"lang"],
2351 "user" => $page[
"create_user"],
2365 string $a_parent_type,
2367 string $a_lang =
"-"
2371 $db =
$DIC->database();
2374 if ($a_lang !=
"") {
2375 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2378 $contributors = array();
2380 "SELECT last_change_user, lang, page_id FROM page_object " .
2381 " WHERE parent_id = %s AND parent_type = %s " .
2382 " AND last_change_user != %s" . $and_lang,
2383 array(
"integer",
"text",
"integer"),
2384 array($a_parent_id, $a_parent_type, 0)
2388 if ($a_lang ==
"") {
2389 $contributors[$page[
"last_change_user"]][$page[
"page_id"]][$page[
"lang"]] = 1;
2391 $contributors[$page[
"last_change_user"]][$page[
"page_id"]] = 1;
2396 "SELECT count(*) as cnt, lang, page_id, user_id FROM page_history " .
2397 " WHERE parent_id = %s AND parent_type = %s AND user_id != %s " . $and_lang .
2398 " GROUP BY page_id, user_id, lang ",
2399 array(
"integer",
"text",
"integer"),
2400 array($a_parent_id, $a_parent_type, 0)
2403 if ($a_lang ==
"") {
2404 $contributors[$hpage[
"user_id"]][$hpage[
"page_id"]][$hpage[
"lang"]] =
2405 ($contributors[$hpage[
"user_id"]][$hpage[
"page_id"]][$hpage[
"lang"]] ?? 0) + $hpage[
"cnt"];
2407 $contributors[$hpage[
"user_id"]][$hpage[
"page_id"]] =
2408 ($contributors[$hpage[
"user_id"]][$hpage[
"page_id"]] ?? 0) + $hpage[
"cnt"];
2413 foreach ($contributors as $k => $co) {
2416 $c[] = array(
"user_id" => $k,
2418 "lastname" => $name[
"lastname"],
2419 "firstname" => $name[
"firstname"]
2431 string $a_parent_type,
2433 string $a_lang =
"-"
2437 $db =
$DIC->database();
2440 if ($a_lang !=
"") {
2441 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2444 $contributors = array();
2446 "SELECT last_change_user, lang FROM page_object " .
2447 " WHERE page_id = %s AND parent_type = %s " .
2448 " AND last_change_user != %s" . $and_lang,
2449 array(
"integer",
"text",
"integer"),
2450 array($a_page_id, $a_parent_type, 0)
2454 if ($a_lang ==
"") {
2455 $contributors[$page[
"last_change_user"]][$page[
"lang"]] = 1;
2457 $contributors[$page[
"last_change_user"]] = 1;
2462 "SELECT count(*) as cnt, lang, page_id, user_id FROM page_history " .
2463 " WHERE page_id = %s AND parent_type = %s AND user_id != %s " . $and_lang .
2464 " GROUP BY user_id, page_id, lang ",
2465 array(
"integer",
"text",
"integer"),
2466 array($a_page_id, $a_parent_type, 0)
2469 if ($a_lang ===
"") {
2470 $contributors[$hpage[
"user_id"]][$page[
"lang"]] =
2471 ($contributors[$hpage[
"user_id"]][$page[
"lang"]] ?? 0) + $hpage[
"cnt"];
2473 $contributors[$hpage[
"user_id"]] =
2474 ($contributors[$hpage[
"user_id"]] ?? 0) + $hpage[
"cnt"];
2479 foreach ($contributors as $k => $co) {
2481 $c[] = array(
"user_id" => $k,
2483 "lastname" => $name[
"lastname"],
2484 "firstname" => $name[
"firstname"]
2500 $db =
$DIC->database();
2502 $db->
update(
"page_object", array(
2503 "rendered_content" => array(
"clob", $a_content),
2504 "render_md5" => array(
"text", $a_md5),
2505 "rendered_time" => array(
"timestamp",
ilUtil::now())
2507 "page_id" => array(
"integer", $this->
getId()),
2509 "parent_type" => array(
"text", $this->getParentType())
2517 string $a_parent_type,
2519 string $a_lang =
"-"
2523 $db =
$DIC->database();
2526 if ($a_lang !=
"") {
2527 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2530 $q =
"SELECT * FROM page_object " .
2531 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer") .
2532 " AND parent_type = " . $db->
quote($a_parent_type,
"text") .
2533 " AND int_links = " . $db->
quote(1,
"integer") . $and_lang;
2537 $key_add = ($a_lang ==
"")
2538 ?
":" . $page[
"lang"]
2540 $pages[$page[
"page_id"] . $key_add] = array(
2541 "date" => $page[
"last_change"],
2542 "id" => $page[
"page_id"],
2543 "lang" => $page[
"lang"],
2544 "user" => $page[
"last_change_user"]
2556 if (strpos($a_content,
"IntLink")) {
2572 return $this->page_manager->content($this->getDomDoc());
2583 $cm = $this->getContentManager();
2584 $cm->setInitialOpenedContent($a_type, $a_id, $a_target);
2593 $cm = $this->getContentManager();
2594 return $cm->getInitialOpenedContent();
2617 string $a_parent_type =
"",
2618 int $a_new_parent_id = 0,
2619 bool $a_clone_mobs =
false,
2620 int $obj_copy_id = 0,
2621 bool $overwrite_existing =
true
2623 if ($a_parent_type ==
"") {
2624 $a_parent_type = $this->getParentType();
2625 if ($a_new_parent_id == 0) {
2626 $a_new_parent_id = $this->getParentId();
2630 foreach (self::lookupTranslations($this->getParentType(), $this->
getId()) as $l) {
2634 if (!$overwrite_existing) {
2641 $new_page_object->setParentId($a_new_parent_id);
2642 $new_page_object->setId($a_id);
2644 $new_page_object->setXMLContent($orig_page->copyXMLContent($a_clone_mobs, $a_new_parent_id, $obj_copy_id));
2645 $new_page_object->setActive($orig_page->getActive());
2646 $new_page_object->setActivationStart($orig_page->getActivationStart());
2647 $new_page_object->setActivationEnd($orig_page->getActivationEnd());
2648 $this->setCopyProperties($new_page_object);
2650 $new_page_object->buildDom();
2651 $new_page_object->update();
2653 $new_page_object->create(
false);
2667 string $a_parent_type,
2672 $db =
$DIC->database();
2675 "SELECT lang FROM page_object " .
2676 " WHERE page_id = " . $db->
quote($a_id,
"integer") .
2677 " AND parent_type = " . $db->
quote($a_parent_type,
"text")
2681 $langs[] = $rec[
"lang"];
2690 string $a_target_lang
2693 $this->getParentType(),
2698 $this->setTranslationProperties($transl_page);
2699 $transl_page->create(
false);
2704 $transl_page->setId($this->
getId());
2705 $transl_page->setParentId($this->getParentId());
2706 $transl_page->setXMLContent($this->copyXmlContent());
2707 $transl_page->setActive($this->getActive());
2708 $transl_page->setActivationStart($this->getActivationStart());
2709 $transl_page->setActivationEnd($this->getActivationEnd());
2723 $user = $this->user;
2725 $min = $this->getEffectiveEditLockTime();
2730 "UPDATE page_object SET " .
2731 " edit_lock_user = " . $db->
quote($user->
getId(),
"integer") .
"," .
2732 " edit_lock_ts = " . $db->
quote($ts,
"integer") .
2733 " WHERE (edit_lock_user = " . $db->
quote($user->
getId(),
"integer") .
" OR " .
2734 " edit_lock_ts < " . $db->
quote(time() - ($min * 60),
"integer") .
") " .
2735 " AND page_id = " . $db->
quote($this->getId(),
"integer") .
2736 " AND parent_type = " . $db->
quote($this->getParentType(),
"text")
2740 "SELECT edit_lock_user FROM page_object " .
2741 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2742 " AND parent_type = " . $db->
quote($this->getParentType(),
"text")
2745 if ($rec[
"edit_lock_user"] != $user->
getId()) {
2759 $user = $this->user;
2762 $min = (
int) $aset->get(
"block_mode_minutes");
2767 "UPDATE page_object SET " .
2768 " edit_lock_user = " . $db->
quote($user->
getId(),
"integer") .
"," .
2769 " edit_lock_ts = 0" .
2770 " WHERE edit_lock_user = " . $db->
quote($user->
getId(),
"integer") .
2771 " AND page_id = " . $db->
quote($this->getId(),
"integer") .
2772 " AND parent_type = " . $db->
quote($this->getParentType(),
"text")
2776 "SELECT edit_lock_user FROM page_object " .
2777 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2778 " AND parent_type = " . $db->
quote($this->getParentType(),
"text")
2781 if ($rec[
"edit_lock_user"] != $user->
getId()) {
2797 $min = (
int) $aset->get(
"block_mode_minutes");
2800 "SELECT edit_lock_user, edit_lock_ts FROM page_object " .
2801 " WHERE page_id = " . $db->
quote($this->getId(),
"integer") .
2802 " AND parent_type = " . $db->
quote($this->getParentType(),
"text")
2805 $rec[
"edit_lock_until"] = $rec[
"edit_lock_ts"] + $min * 60;
2816 int $a_length = 100,
2817 string $a_ending =
'...',
2818 bool $a_exact =
false,
2819 bool $a_consider_html =
true
2822 if ($a_consider_html) {
2824 if (strlen(preg_replace(
'/<.*?>/',
'', $a_text)) <= $a_length) {
2829 $total_length = strlen($a_ending);
2830 $open_tags = array();
2832 preg_match_all(
'/(<.+?>)?([^<>]*)/s', $a_text, $lines, PREG_SET_ORDER);
2833 foreach ($lines as $line_matchings) {
2835 if (!empty($line_matchings[1])) {
2838 '/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is',
2843 elseif (preg_match(
'/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
2845 $pos = array_search($tag_matchings[1], $open_tags);
2846 if ($pos !==
false) {
2847 unset($open_tags[$pos]);
2850 elseif (preg_match(
'/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) {
2852 array_unshift($open_tags, strtolower($tag_matchings[1]));
2855 $truncate .= $line_matchings[1];
2859 $content_length = strlen(preg_replace(
2860 '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i',
2864 if ($total_length + $content_length > $a_length) {
2866 $left = $a_length - $total_length;
2867 $entities_length = 0;
2870 '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i',
2876 foreach ($entities[0] as $entity) {
2877 if ($entity[1] + 1 - $entities_length <= $left) {
2879 $entities_length += strlen($entity[0]);
2893 $truncate .= $line_matchings[2];
2894 $total_length += $content_length;
2898 if ($total_length >= $a_length) {
2903 if (strlen($a_text) <= $a_length) {
2912 if (!count($open_tags)) {
2916 $spacepos = strrpos($truncate,
' ');
2917 if ($spacepos !==
false) {
2926 $truncate .= $a_ending;
2928 if ($a_consider_html) {
2930 foreach ($open_tags as $tag) {
2931 $truncate .=
'</' . $tag .
'>';
2951 string $a_parent_type,
2957 $db =
$DIC->database();
2960 if ($a_lang !=
"") {
2961 $and_lang =
" AND lang = " . $db->
quote($a_lang,
"text");
2965 $q =
"SELECT last_change FROM page_object " .
2966 " WHERE parent_id = " . $db->
quote($a_parent_id,
"integer") .
2967 " AND parent_type = " . $db->
quote($a_parent_type,
"text") . $and_lang .
2968 " ORDER BY last_change DESC";
2973 return $rec[
"last_change"];
2978 if ($this->getPageConfig()->getEditLockSupport() ==
false) {
2983 $min = (
int) $aset->get(
"block_mode_minutes");
3002 return $this->getParentId();
3027 $config = $this->getPageConfig();
3028 foreach ($this->pc_definition->getPCDefinitions() as $def) {
3029 $model_provider = $this->pc_definition->getPCModelProviderByName($def[
"name"]);
3030 if ($config->getEnablePCType($def[
"name"]) || $def[
"name"] ===
"PlaceHolder") {
3031 if (!is_null($model_provider)) {
3032 foreach ($model_provider->getModels(
3035 ) as $pc_id => $co_model) {
3036 $model[$pc_id] = $co_model;
3057 if (is_array($targets)) {
3058 foreach ($targets as $t) {
3059 $tarr = explode(
":", $t);
3060 $cont_obj = $this->getContentObject($tarr[0], $tarr[1]);
3061 if (is_object($cont_obj) && $cont_obj->getType() ==
"par") {
3062 $cont_obj->setCharacteristic($char_par);
3064 if (is_object($cont_obj) && $cont_obj->getType() ==
"sec") {
3065 $cont_obj->setCharacteristic($char_sec);
3067 if (is_object($cont_obj) && $cont_obj->getType() ==
"media") {
3068 $cont_obj->setClass($char_med);
3071 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).
static getInstance(string $a_parent_type, int $a_id=0, int $a_old_nr=0, string $a_lang="-")
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 PageManagerInterface $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)
ILIAS COPage InternalDomainService $domain
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)