diff --git a/Services/COPage/PC/Blog/class.ilPCBlog.php b/Services/COPage/PC/Blog/class.ilPCBlog.php index dedac6941107..6bcdeea9c235 100644 --- a/Services/COPage/PC/Blog/class.ilPCBlog.php +++ b/Services/COPage/PC/Blog/class.ilPCBlog.php @@ -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)) { diff --git a/Services/COPage/PC/Plugged/class.ilPCPlugged.php b/Services/COPage/PC/Plugged/class.ilPCPlugged.php index 12013df4b3d6..0333866ffc70 100755 --- a/Services/COPage/PC/Plugged/class.ilPCPlugged.php +++ b/Services/COPage/PC/Plugged/class.ilPCPlugged.php @@ -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']; @@ -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', @@ -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 */ @@ -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', diff --git a/Services/COPage/PC/Table/class.TableCommandActionHandler.php b/Services/COPage/PC/Table/class.TableCommandActionHandler.php index ec2b94a6e108..626e73f3c9ae 100644 --- a/Services/COPage/PC/Table/class.TableCommandActionHandler.php +++ b/Services/COPage/PC/Table/class.TableCommandActionHandler.php @@ -223,7 +223,6 @@ protected function updateData( $updated = (!is_null($text)); $text = $text["text"]; } - if ($updated) { $text = \ilPCParagraph::_input2xml( $text, diff --git a/Services/COPage/PC/Table/class.ilPCDataTable.php b/Services/COPage/PC/Table/class.ilPCDataTable.php index f33150f46de4..9d4080d8825e 100755 --- a/Services/COPage/PC/Table/class.ilPCDataTable.php +++ b/Services/COPage/PC/Table/class.ilPCDataTable.php @@ -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(); @@ -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( diff --git a/Services/COPage/PC/Table/class.ilPCTable.php b/Services/COPage/PC/Table/class.ilPCTable.php index 1f1ed0d7faa4..e5eacfb6fdbc 100755 --- a/Services/COPage/PC/Table/class.ilPCTable.php +++ b/Services/COPage/PC/Table/class.ilPCTable.php @@ -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(); @@ -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); } /** diff --git a/Services/COPage/PC/Table/class.ilPCTableData.php b/Services/COPage/PC/Table/class.ilPCTableData.php index e2558f060092..d48119252aa7 100755 --- a/Services/COPage/PC/Table/class.ilPCTableData.php +++ b/Services/COPage/PC/Table/class.ilPCTableData.php @@ -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); } } @@ -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