19declare(strict_types=1);
36 $this->dom_util =
$DIC->copage()
47 $main_page->preparePageForCompare($l_page);
52 foreach ($l_hashes as $pc_id => $h) {
53 if (!isset($r_hashes[$pc_id])) {
54 $l_hashes[$pc_id][
"change"] =
"Deleted";
56 if ($h[
"hash"] != $r_hashes[$pc_id][
"hash"]) {
57 $l_hashes[$pc_id][
"change"] =
"Modified";
58 $r_hashes[$pc_id][
"change"] =
"Modified";
61 if ($l_hashes[$pc_id][
"content"] !=
"" &&
62 $r_hashes[$pc_id][
"content"] !=
"") {
63 $new_left = str_replace(
"\n",
"<br />", $l_hashes[$pc_id][
"content"]);
64 $new_right = str_replace(
"\n",
"<br />", $r_hashes[$pc_id][
"content"]);
65 $wldiff = new \WordLevelDiff(
69 $new_left = $wldiff->orig();
70 $new_right = $wldiff->closing();
79 foreach ($r_hashes as $pc_id => $h) {
80 if (!isset($l_hashes[$pc_id])) {
81 $r_hashes[$pc_id][
"change"] =
"New";
87 return array(
"l_page" => $l_page,
89 "l_changes" => $l_hashes,
90 "r_changes" => $r_hashes
99 $node = $page->getContentDomNode($a_hier_id);
100 if (is_object($node)) {
101 $this->dom_util->setContent($node, $content);
109 $dom = $page->getDomDoc();
111 $nodes = $this->dom_util->path($dom,
$path);
112 $rnode = $nodes->item(0);
113 foreach ($a_hashes as $h) {
114 if (($h[
"change"] ??
"") !=
"") {
115 $dc_node = $dom->createElement(
"DivClass");
116 $dc_node->setAttribute(
"HierId", $h[
"hier_id"]);
117 $dc_node->setAttribute(
"Class",
"ilEdit" . $h[
"change"]);
118 $dc_node = $rnode->appendChild($dc_node);
134 $path =
"//PageContent";
136 $nodes = $this->dom_util->path($dom,
$path);
137 foreach ($nodes as $node) {
138 $hier_id = $node->getAttribute(
"HierId");
139 $pc_id = $node->getAttribute(
"PCID");
140 $dump = $this->dom_util->dump($node);
141 if (($hpos = strpos($dump,
' HierId="' . $hier_id .
'"')) > 0) {
142 $dump = substr($dump, 0, $hpos) .
143 substr($dump, $hpos + strlen(
' HierId="' . $hier_id .
'"'));
146 $childs = $node->childNodes;
148 if ($childs->item(0) && $childs->item(0)->nodeName ==
"Paragraph") {
149 $content = $this->dom_util->dump($childs->item(0));
152 strpos($content,
">") + 1,
153 strrpos($content,
"<") - (strpos($content,
">") + 1)
158 array(
"hier_id" => $hier_id,
"hash" => md5($dump),
"content" => $content);
getPageContentsHashes(\ilPageObject $page)
Get page contents hashes.
addChangeDivClasses(\ilPageObject $page, array $a_hashes)
compare(\ilPageObject $main_page, \ilPageObject $l_page, \ilPageObject $r_page,)
setParagraphContent(\ilPageObject $page, string $a_hier_id, string $content)
static xml2output(string $a_text, bool $a_wysiwyg=false, bool $a_replace_lists=true, bool $unmask=true)
Converts xml from DB to output in edit textarea.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
getDomDoc()
Get dom doc (DOMDocument)
addHierIDs()
Add hierarchical ID (e.g.
buildDom(bool $a_force=false)
preparePageForCompare(ilPageObject $page)