From f2f2ce7d5c00c8f1d8d7b98afa849889597d0b3c Mon Sep 17 00:00:00 2001 From: Alex Arnaud <alex.arnaud@biblibre.com> Date: Thu, 27 Nov 2014 09:13:26 +0100 Subject: [PATCH] rel #18044 refacto linkToAnchor in a while --- library/Class/Import/Typo3.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/library/Class/Import/Typo3.php b/library/Class/Import/Typo3.php index 411e3a14ae2..9faa068f206 100644 --- a/library/Class/Import/Typo3.php +++ b/library/Class/Import/Typo3.php @@ -152,19 +152,16 @@ class Class_Import_Typo3 { public function manipulate_body($body) { $body = $this->wrapWithHtml($body); $body = $this->translateLinksToAnchor($body); - $lf=["\r\n", "\n\r","\n","\r"]; - foreach($lf as $return_char) - $body = str_replace($return_char,"<br />",$body); - return $body; + return str_replace(["\r\n", "\n\r","\n","\r"],"<br />",$body); } protected function translateLinksToAnchor($content) { - if(!$start = strpos($content, '<link ')) - return $content; - - $link = substr($content, $start, strpos($content, '</link>') - $start + 7); - return $this->translateLinksToAnchor(str_replace($link, $this->linkToAnchor($link), $content)); + while(false !== ($start = strpos($content, '<link ')) && false !== ($end = strpos($content, '</link>'))) { + $link = substr($content, $start, $end - $start + 7); + $content = str_replace($link, $this->linkToAnchor($link), $content); + } + return $content; } -- GitLab