ezsystems/ezpublish-kernel — pull request #443 by pspanja (2013-07-05 07:22:31+00:00)
Title: Fix ezp 21136 xmltext html5

NOT FOR MERGING

This PR relates to issue https://jira.ez.no/browse/EZP-21136

The purpose of the issue is to look into how HTML5 based editing with XmlText could be done.
As a part of the 5.x Rich Text Editor epic, this also looks into a possible new internal format for XmlText (or future rich text FieldType).

For the new format [Docbook](http://en.wikipedia.org/wiki/DocBook) was chosen. Docbook is semantical XML language and was already intended for new internal format by the [Zeta Document component](http://zetacomponents.org/documentation/trunk/Document/tutorial.html) effort. This component was considered as a base for conversion, but XSLT converters were chosen as a better solution instead.

XSLT converters on a small subset are implemented between ezxml and Docbook and between XHTML5 and Docbook (XHTML5 / Docbook / ezxml):

* section / section / section
* p / para / paragraph
* h1..h6 / title / heading
* em / emphasis / emphasized
* strong / emphasis[role="strong"] / strong

As we only have Legacy Storage at the moment, which requires storing data in ezxml format, new Docbook format in this implementation is never stored and is used only for conversion between XHTML5 and ezxml. At the moment conversion to and from ezxml is done in FieldType (in fromPersistenceValue() and toPersistenceValue() methods), but it should be eventually moved to the Legacy Storage converter for the FieldType, so that Docbook format is passed to the storage and ezxml is contained inside Legacy Storage.

Implementation for new storage or of a new FieldType based on this should directly store Docbook to the database and avoid ezxml completely.

XmlText in this implementation always expects XML input, which is converted based on document's root element namespace. This will need to be expanded when non-XML formats are implemented.

For the demo purposes a bundle is implemented, providing HTML5 editing with TinyMCE editor. Steps to enable `EzPublishXhtml5EditTestBundle` bundle are:

1. register the bundle with kernel
2. import routes
3. disable CSRF protection
4. create content with XmlText field definition "test"
5. authenticate into frontend
6. open created content with `http://ezpublish.local/test/`

Some known TODOs:

* move Docbook<->ezxml conversion to the Legacy Storage
* refactor converter tests so that tests between two formats are coupled in a way that makes easy to test that there is no loss of information, or to document loss of information in the conversion process
* look into what can be done to deliver XHTML5 output over REST
* complete XSLT converters so that ezxml is fully supported
* remove XSLT converter from ezxml to HTML5
* fix `acceptValue()` to accept different Inputs
* implement XHTML5 Input
* implement validation on XHTML5 and Docbook input
* implement `validate()` method for the FieldType
* update tests :)