Extra <br /> tag while using linebreaks with paragraph

Author Message

John Smith

Monday 20 March 2006 6:24:17 am

If you enter a text with a linebreak you will get the following results:

<p>test<br />text<br /></p>

The issue is with the last <br /> in the example. It is completly unneeded..

Is it a bug, has anybody solved it?

Please help

Cheers

John Smith

Kirill Subbotin

Thursday 23 March 2006 1:34:31 am

It's a bug. We will try to fix it soon.

I've added a bug report http://ez.no/bugs/view/8028

John Smith

Friday 24 March 2006 6:16:48 am

hi Kirill,

Thanks for your reply. Mate I think you have solved the bug. Would it be possible to know the changes, so that i can update my version.

Cheers

Regards
John..

Kirill Subbotin

Monday 27 March 2006 1:13:01 am

Yes, here is the patch:

Modified: trunk/kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php
===================================================================
--- trunk/kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php	2006-03-24 11:26:45 UTC (rev 15292)
+++ trunk/kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php	2006-03-24 11:29:44 UTC (rev 15293)
@@ -341,8 +341,20 @@
 
         $sectionLevel = $currentSectionLevel;
         $class = $paragraph->attributeValue( 'class' );
+        $curChildIndex = 0;
+        $totalChildren = count( $paragraph->children() );
         foreach ( $paragraph->children() as $paragraphNode )
         {
+            $curChildIndex++;
+
+            if ( $curChildIndex == $totalChildren ) 
+            {
+              $this->LastParagraphChild = true;
+            }
+            else
+            {
+                $this->LastParagraphChild = false;
+            }
             $isBlockTag = false;
             $content =& $this->renderXHTMLTag( $tpl, $paragraphNode, $sectionLevel, $isBlockTag, $tdSectionLevel );
             if ( $isBlockTag === true )
@@ -1020,6 +1032,12 @@
                 $tpl->setVariable( 'content', $childTagText, 'xmltagns' );
                 $uri = "design:content/datatype/view/ezxmltags/$tagName.tpl";
 
+                //force rendering last line without <br> i.e. as plain text
+                if ( $tagName == 'line' && $this->LastParagraphChild ) 
+                {
+                    $uri = "design:content/datatype/view/ezxmltags/text.tpl";
+                }
+
                 $textElements = array();
                 include_once( 'lib/eztemplate/classes/eztemplateincludefunction.php' );
                 eZTemplateIncludeFunction::handleInclude( $textElements, $uri, $tpl, 'foo', 'xmltagns' );
@@ -1110,6 +1128,10 @@
 
     /// Contains the Nodes hashed by ID
     var $NodeArray = array();
+    
+    /// Contains boolean flag if current child is last among paragraph children
+    /// used when rendering last <line> tag.
+    var $LastParagraphChild = false;
 
     /// Array of parameters for rendering tags that are children of 'link' tag
     var $LinkParameters = array();

John Smith

Monday 27 March 2006 1:42:13 am

hi Kirill,

Thanks for your kind help. I just want to know whether this patch is applicable to ezpublish 3.6.1

I am using ez 3.6.1 at the moment.

Thanks in advance.

Cheers

John...

Kirill Subbotin

Monday 27 March 2006 2:02:50 am

Not sure about 3.6.1, may be, but most likely it should work with the latest 3.6.*

John Smith

Monday 27 March 2006 2:19:27 am

Thanks,

I have tried on ezpublish 3.6.1, it seems to be working.Obviously the line numbers are different what you said in your last reply.

Once again thanks for your kind help.

Cheers.

John...

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 04:20:41
Script start
Timing: Jan 19 2025 04:20:41
Module start 'layout'
Timing: Jan 19 2025 04:20:41
Module start 'content'
Timing: Jan 19 2025 04:20:42
Module end 'content'
Timing: Jan 19 2025 04:20:42
Script end

Main resources:

Total runtime1.1178 sec
Peak memory usage4,096.0000 KB
Database Queries69

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 589.2813152.6406
Module start 'layout' 0.00560.0040 741.921939.4766
Module start 'content' 0.00961.1068 781.3984512.8359
Module end 'content' 1.11640.0013 1,294.234416.1250
Script end 1.1177  1,310.3594 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2817160.0002
Check MTime0.00130.1197160.0001
Mysql Total
Database connection0.00080.067310.0008
Mysqli_queries1.066695.4194690.0155
Looping result0.00060.0531670.0000
Template Total1.083696.920.5418
Template load0.00190.166220.0009
Template processing1.081796.771520.5408
Template load and register function0.00010.012910.0001
states
state_id_array0.00220.200010.0022
state_identifier_array0.00160.143820.0008
Override
Cache load0.00160.1424370.0000
Sytem overhead
Fetch class attribute can translate value0.00060.058120.0003
Fetch class attribute name0.00110.099370.0002
XML
Image XML parsing0.00040.032920.0002
class_abstraction
Instantiating content class attribute0.00000.000970.0000
General
dbfile0.00130.1173100.0001
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs