From 9df764fc6561e0464ee4705f1365726929716a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20R=C3=B8mcke?= Date: Thu, 27 May 2010 12:01:36 +0000 Subject: [PATCH] - Fixed bug #016814: Rendering problems in ezxmltext datatype git-svn-id: file:///home/patrick.allaert/svn-git/ezp-repo/ezpublish/trunk@25307 a01eee8c-daba-0310-acae-fa49f3023285 --- .../CHANGELOG-4.4.0alpha1-to-4.4.0alpha2 | 1 + .../handlers/output/ezxhtmlxmloutput.php | 11 +++- .../output/ezxhtmlxmloutput_regression.php | 63 +++++++++++++++++-- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/doc/changelogs/4.4/unstable/CHANGELOG-4.4.0alpha1-to-4.4.0alpha2 b/doc/changelogs/4.4/unstable/CHANGELOG-4.4.0alpha1-to-4.4.0alpha2 index fa945e1e8bf..856e0522f6b 100644 --- a/doc/changelogs/4.4/unstable/CHANGELOG-4.4.0alpha1-to-4.4.0alpha2 +++ b/doc/changelogs/4.4/unstable/CHANGELOG-4.4.0alpha1-to-4.4.0alpha2 @@ -22,6 +22,7 @@ Changes from 4.4.0alpha1 to 4.4.0alpha2 - Fixed bug #016830: kernel/setup/systemupgrade.php - typo in php classname - Fixed bug #016829: Bug in user/preferences - Fixed bug #016828: content/view/full => if node_id is no numeric or < 2 ez should return an error_code +- Fixed bug #016814: Rendering problems in ezxmltext datatype - Fixed bug #016799: CSS class doesn't show when link is image, not text - Fixed bug #016797: eZSimplifiedXMLEditOutput does not unescape   like output handler does - Fixed bug #016713: eZImageType doesn't use real main node for image path diff --git a/kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php b/kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php index 942daf96b1b..35deb2686fe 100644 --- a/kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php +++ b/kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php @@ -449,7 +449,10 @@ function renderParagraph( $element, $childrenOutput, $vars ) { if( $childOutput[1] === ' ' ) { - continue; + if ( isset( $childrenOutput[ $key + 1 ] ) ) + continue; + else if ( isset( $childrenOutput[ $key - 1 ] ) && $childrenOutput[ $key - 1 ][0] === false ) + continue; } $inlineContent .= $childOutput[1]; @@ -539,6 +542,12 @@ function renderLine( $element, $childrenOutput, $vars ) elseif ( $childOutput[0] === true && !isset( $childrenOutput[ $key + 1 ] ) ) { $next = $element->nextSibling; + // Make sure we get next element that is an element (ignoring whitespace) + while ( $next && !$next instanceof DOMElement ) + { + $next = $next->nextSibling; + } + if ( $next && $next->nodeName == 'line' ) { $tagText = $this->renderTag( $element, $inlineContent, $vars ); diff --git a/tests/tests/kernel/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput_regression.php b/tests/tests/kernel/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput_regression.php index e531d41294b..19a72e0831b 100644 --- a/tests/tests/kernel/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput_regression.php +++ b/tests/tests/kernel/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput_regression.php @@ -9,7 +9,6 @@ class eZXHTMLXMLOutputRegression extends ezpDatabaseTestCase { - public function __construct() { parent::__construct(); @@ -60,7 +59,7 @@ public function testRenderParagraphBlockTags() $XMLString = '
-
foo
+
foo
'; $outputHandler = new eZXHTMLXMLOutput( $XMLString, false ); @@ -79,8 +78,64 @@ public function testRenderParagraphBlockTags() } /** - * Tests that eZXML from ezp3 and ezp4 produces the same - * result + * Regression in renderParagraph() after #16184 causing last paragraphs to not be shown + * + * @link http://issues.ez.no/16814 + * @note Test depends on template output!! + */ + public function testMissingParagraphs() + { + $XMLString = ' +
+ + Haustsemesteret, + 7,5 studiepoeng + + FP 336 620 Naturfag, del 1: Individuell, skriftleg mappe (HSF Oppdrag/betalingsemne) + + + FP334 620 Naturfag, del 2 : Individuell, skriftleg eksamen. + Tid: 4 timar + +
'; + + $outputHandler = new eZXHTMLXMLOutput( $XMLString, false ); + $result = $outputHandler->outputText(); + + $html = '

+Haustsemesteret, 7,5 studiepoeng
FP 336 620 Naturfag, del 1: Individuell, skriftleg mappe (HSF Oppdrag/betalingsemne)

+FP334 620 Naturfag, del 2 : Individuell, skriftleg eksamen.
Tid: 4 timar

'; + + $this->assertEquals( $html, $result ); + } + + /** + * Regression in renderParagraph() after #15310 causing lines to not have line breaks in ouput + * + * @link http://issues.ez.no/16814 + * @note Test depends on template output!! + */ + public function testMissingBreak() + { + $XMLString = ' +
+ + Telephone #1 + Telephone #2 + +
'; + + $outputHandler = new eZXHTMLXMLOutput( $XMLString, false ); + $result = $outputHandler->outputText(); + + $html = '

+Telephone #1
Telephone #2

'; + + $this->assertEquals( $html, $result ); + } + + /** + * Tests that eZXML from ezp3 and ezp4 produces the same result * * @link http://issues.ez.no/16184 * @note XML is from actual customer xml