Patch: Recognise line feeds in XML text fields

Author Message

Bruce Morrison

Monday 10 February 2003 11:24:39 pm

I've created and submitted a patch to recognise linefeeds in XML text fields and render these as <br /> in the final output.

It is availiable at
http://developer.ez.no/bug/bugview/1870/

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Arash Molavi

Monday 10 February 2003 11:51:12 pm

> I've created and submitted a patch to recognise linefeeds in
> XML text fields and render these as <br /> in the
> final output.
>
> It is availiable at
> http://developer.ez.no/bug/bugview/1870/

Sorry.. feel stupid, but where should it go?

Bruce Morrison

Tuesday 11 February 2003 4:41:25 pm

> > I've created and submitted a patch to recognise linefeeds
> in
> > XML text fields and render these as <br /> in the
> > final output.
> >
> > It is availiable at
> > http://developer.ez.no/bug/bugview/1870/
>
> Sorry.. feel stupid, but where should it go?

The patch if actually a "patch" file - you need to apply it to a clean copy of RC2. If you have not done this before it would probally be easier to do it by hand.

There are 2 files that require editing in
kernel/classes/datatypes/ezxmltext/

Firstly ezsimpifiedxmlinput.php

after line 236 add the line
$paragraph =& preg_replace( "#\n#", "<br />", $paragraph );

so this section now looks liike

foreach ( $paragraphArray as $paragraph )
{
if ( trim( $paragraph ) != "" )
{
# BPM add <br / > tags for single newlines 20030211 15:09
$paragraph =& preg_replace( "#\n#", "<br />", $paragraph );
$sectionData .= "<paragraph>" . trim( $paragraph ) . "</paragraph>\n";
}
}

at around line 710
add the line
case 'br' :

so this section now looks like
case 'tr' :
case 'td' :
case 'paragraph' :
// BPM 20030211 15:21
case 'br' :
{
}break;

In file ezxhtmloutput.php

at around line 357 add the line

case 'br' :

so this section now looks like
// normal content tags
case 'emphasize' :
case 'strong' :
#BPM 20030211 13:36
case 'br' :
{

Hope this helps
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Jan Borsodi

Thursday 13 February 2003 6:08:26 am

> I've created and submitted a patch to recognise linefeeds in
> XML text fields and render these as <br /> in the
> final output.
>
> It is availiable at
> http://developer.ez.no/bug/bugview/1870/

This patch will break the XML format since it introduces a new tag br which will not be supported by the standard eZ publish format.
New tags such as this must be stored as a custom tag, you should create a new input handler and output viewer for XML if you want to preserve newlines in this way.
The next release features support for xml input/output handlers in extensions which should be used for this feature.

I also recommend not using a single br tag(as stored format), it's not a structured tag but rather a visual processing instructions. A better solution is to use a line tag(as custom tag) which wraps around the text which should be on a line.
<line>this is some text</line>
vs
this is some text<br/>

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Brendan Pike

Thursday 13 February 2003 7:19:47 am

Slightly off topic, but does anyone know if there is an actual page break either in the code or planned for yet?

i.e. So you can break a long article into muliple pages like the <page> tag did in 2.2.x

www.dbinformatics.com.au

We are always interested in hearing from experienced eZ PHP programmers and eZ template designers interested in contract work.

Bruce Morrison

Thursday 13 February 2003 2:41:17 pm

Hi Jan

Thanks for the info.

> > I've created and submitted a patch to recognise linefeeds
> in
> > XML text fields and render these as <br /> in the
> > final output.
> >
> > It is availiable at
> > http://developer.ez.no/bug/bugview/1870/
>
> This patch will break the XML format since it introduces a
> new tag br which will not be supported by the standard eZ
> publish format.

I guess this raises some questions.

Will the eZ team be adding the ability to insert line breaks (not paragraph breaks) into the core program (It seems that this will not be the case from your message)?

Is the DTD that ezPublish is using availiable? Is it based on any existing standards?

> New tags such as this must be stored as a custom tag, you
> should create a new input handler and output viewer for XML
> if you want to preserve newlines in this way.

I would have though that this would be a very common requirment. We are currently developing a number of sites using eZpublish3 and on all occasions clients asked for this ability. Thay have ben quite confused that it is not there. (it was in ezPublish 2 I think?)

> The next release features support for xml input/output
> handlers in extensions which should be used for this
> feature.
>
> I also recommend not using a single br tag(as stored
> format), it's not a structured tag but rather a visual
> processing instructions. A better solution is to use a line
> tag(as custom tag) which wraps around the text which should
> be on a line.
> <line>this is some text</line>
> vs
> this is some text<br/>

If I modify the patch to work in the way you suggest would it then be considered for addition to the core distribution?

This is one feature that needs to be available without the need for data entry staff to enter tags. i.e. it needs to be automatically handled by ezpublish.

On a related note - will there be a desktop version availiable for eZ Publish3 and if so, is there a time-frame on it's availability?

Thanks
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Jan Borsodi

Monday 17 February 2003 7:11:13 am

> Slightly off topic, but does anyone know if there is an
> actual page break either in the code or planned for yet?
>
> i.e. So you can break a long article into muliple pages like
> the <page> tag did in 2.2.x

Page breaks, like line breaks, are very layout specific and will not be supported by the eZXML datatype.
For now I can recommend using two article classes, one that has the intro etc. which works like a folder, then an Article Page class which contains one page of the article. Create the article pages as children of the article holder and you'll get the wanted functionality.

Another way is to program a custom XML output handler, it could for instance use the top level sections as the pages. Right now it's not possible to add custom url elements so it's not 100% possible yet to detect which "page" you are on.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

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 18 2025 11:30:05
Script start
Timing: Jan 18 2025 11:30:05
Module start 'layout'
Timing: Jan 18 2025 11:30:05
Module start 'content'
Timing: Jan 18 2025 11:30:06
Module end 'content'
Timing: Jan 18 2025 11:30:06
Script end

Main resources:

Total runtime1.3512 sec
Peak memory usage4,096.0000 KB
Database Queries96

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0078 588.1641152.6563
Module start 'layout' 0.00780.0037 740.820339.5078
Module start 'content' 0.01151.3375 780.3281809.2891
Module end 'content' 1.34900.0022 1,589.617232.1094
Script end 1.3512  1,621.7266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.2663160.0002
Check MTime0.00150.1139160.0001
Mysql Total
Database connection0.00170.126710.0017
Mysqli_queries1.226590.7696960.0128
Looping result0.00110.0820940.0000
Template Total1.315197.320.6575
Template load0.00210.157520.0011
Template processing1.312997.166020.6565
Template load and register function0.00010.008110.0001
states
state_id_array0.00150.109610.0015
state_identifier_array0.00160.115120.0008
Override
Cache load0.00220.16241470.0000
Sytem overhead
Fetch class attribute can translate value0.00070.048650.0001
Fetch class attribute name0.00140.1053170.0001
XML
Image XML parsing0.00190.140850.0004
class_abstraction
Instantiating content class attribute0.00000.0024200.0000
General
dbfile0.00130.0968300.0000
String conversion0.00000.000940.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
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
14content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
29content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
19content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 70
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs