Skip to content

Commit

Permalink
41826: On saving a table, the content of some cells is duplicated
Browse files Browse the repository at this point in the history
  • Loading branch information
alex40724 committed Jul 30, 2024
1 parent 5138543 commit cfe50bc
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 28 deletions.
4 changes: 1 addition & 3 deletions Services/COPage/PC/Blog/class.ilPCBlog.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ public function setData(
// remove all children first
$children = $this->getChildNode()->childNodes;
if ($children) {
foreach ($children as $child) {
$this->getChildNode()->removeChild($child);
}
$this->dom_util->deleteAllChilds($this->getChildNode());
}

if (count($a_posting_ids)) {
Expand Down
12 changes: 6 additions & 6 deletions Services/COPage/PC/Plugged/class.ilPCPlugged.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public static function handleCopiedPluggedContent(
DOMDocument $a_domdoc
): void {
global $DIC;
$dom_util = $DIC->copage()->internal()->domain()->domUtil();
$component_repository = $DIC['component.repository'];
$component_factory = $DIC['component.factory'];

Expand All @@ -187,9 +188,7 @@ public static function handleCopiedPluggedContent(
// and allow it to modify the saved parameters
$plugin_obj->onClone($properties, $plugin_version);

foreach ($node->childNodes as $child) {
$node->removeChild($child);
}
$dom_util->deleteAllChilds($node);
foreach ($properties as $name => $value) {
$child = new DOMElement(
'PluggedProperty',
Expand All @@ -208,6 +207,9 @@ public static function handleCopiedPluggedContent(
public static function afterRepositoryCopy(ilPageObject $page, array $mapping, int $source_ref_id): void
{
global $DIC;

$dom_util = $DIC->copage()->internal()->domain()->domUtil();

$ilPluginAdmin = $DIC['ilPluginAdmin'];

/** @var ilComponentFactory $component_factory */
Expand Down Expand Up @@ -238,9 +240,7 @@ public static function afterRepositoryCopy(ilPageObject $page, array $mapping, i
// and allow it to modify the saved parameters
$plugin_obj->afterRepositoryCopy($properties, $mapping, $source_ref_id, $plugin_version);

foreach ($node->childNodes as $child) {
$node->removeChild($child);
}
$dom_util->deleteAllChilds($node);
foreach ($properties as $name => $value) {
$child = new DOMElement(
'PluggedProperty',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ protected function updateData(
$updated = (!is_null($text));
$text = $text["text"];
}

if ($updated) {
$text = \ilPCParagraph::_input2xml(
$text,
Expand Down
8 changes: 2 additions & 6 deletions Services/COPage/PC/Table/class.ilPCDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ public function create(
public function makeEmptyCell(DomNode $td_node): void
{
// delete children of paragraph node
foreach ($td_node->childNodes as $child) {
$td_node->removeChild($child);
}
$this->dom_util->deleteAllChilds($td_node);

// create page content and paragraph node here.
$pc_node = $this->getNewPageContentNode();
Expand Down Expand Up @@ -86,9 +84,7 @@ public function setData(array $a_data)
// remove all childs
if (empty($error) && !is_null($par_node)) {
// delete children of paragraph node
foreach ($par_node->childNodes as $child) {
$par_node->removeChild($child);
}
$this->dom_util->deleteAllChilds($par_node);

// copy new content children in paragraph node
$nodes = $this->dom_util->path(
Expand Down
8 changes: 2 additions & 6 deletions Services/COPage/PC/Table/class.ilPCTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ public function getCellNode(int $i, int $j, bool $create_if_not_exists = false):

if (!is_null($td_node)) {
// delete children of paragraph node
foreach ($td_node->childNodes as $child) {
$td_node->removeChild($child);
}
$this->dom_util->deleteAllChilds($td_node);

// create page content and paragraph node here.
$pc_node = $this->getNewPageContentNode();
Expand Down Expand Up @@ -409,9 +407,7 @@ public function fixHideAndSpans(): void
public function makeEmptyCell(DomNode $td_node): void
{
// delete children of paragraph node
foreach ($td_node->childNodes as $child) {
$td_node->removeChild($child);
}
$this->dom_util->deleteAllChilds($td_node);
}

/**
Expand Down
8 changes: 2 additions & 6 deletions Services/COPage/PC/Table/class.ilPCTableData.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ public function deleteRowContent(
if ($td->hasAttribute("PCID")) {
$td->removeAttribute("PCID");
}
foreach ($td->childNodes as $c) {
$td->removeChild($c);
}
$this->dom_util->deleteAllChilds($td);
}
}

Expand All @@ -97,9 +95,7 @@ public function deleteRowContent(
public function deleteTDContent(
DOMNode $a_td_node
): void {
foreach ($a_td_node->childNodes as $child) {
$a_td_node->removeChild($child);
}
$this->dom_util->deleteAllChilds($a_td_node);
}

public function deleteRow(): void
Expand Down

0 comments on commit cfe50bc

Please sign in to comment.