Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-30513: eZXMLText Migration: link tags containing embed-inline + other elements fails #110

Open
wants to merge 2 commits into
base: 1.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/FieldType/XmlText/Converter/EmbedLinking.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class EmbedLinking implements Converter
public function convert(DOMDocument $document)
{
$xpath = new DOMXPath($document);
// Select embeds that are linked
// Select embeds that are linked ( but only where embed is the only child of the link )
// After Expanding converter such links will contain only single embed element
$xpathExpression = '//embed[parent::link]|//embed-inline[parent::link]';
$xpathExpression = '//embed[parent::link][count(preceding-sibling::*)+count(following-sibling::*)=0]|//embed-inline[parent::link][count(preceding-sibling::*)+count(following-sibling::*)=0]';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After giving it more thought, I'm not convinced that we should distinguish here a case where there's only one embed. It should be handled uniformly:

  <para>Link:
    <link xlink:href="ezlocation://333" xlink:show="none">Foo
      <ezembedinline xlink:href="ezcontent://444" view="embed-inline">
        <ezconfig>
          <ezvalue key="size">original</ezvalue>
        </ezconfig>
      </ezembedinline>
      bar
      <ezembedinline xlink:href="ezcontent://445" view="embed-inline">
        <ezconfig>
          <ezvalue key="size">original</ezvalue>
        </ezconfig>
      </ezembedinline>
      2
    </link>
  </para> 

and

  <para>Link:
    <link xlink:href="ezlocation://333" xlink:show="none">Foo
      <ezembedinline xlink:href="ezcontent://444" view="embed-inline">
        <ezconfig>
          <ezvalue key="size">original</ezvalue>
        </ezconfig>
      </ezembedinline>
      bar
    </link>
  </para>

The only reason we would make a distinction here would be if UI was different for both cases. However I cannot imagine UI which would take advantage of link inside of embed-inline.


$linkedEmbeds = $xpath->query($xpathExpression);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<section
xmlns:image="http://ez.no/namespaces/ezpublish3/image/"
xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"
xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">
<paragraph>paragraph text and (
<link node_id="333">
<embed-inline view="embed-inline" size="original" object_id="444"/>
</link> </paragraph>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<section
xmlns:image="http://ez.no/namespaces/ezpublish3/image/"
xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"
xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">
<paragraph>paragraph text and (
<link node_id="333">Foo
<embed-inline view="embed-inline" size="original" object_id="444"/>bar
<embed-inline view="embed-inline" size="original" object_id="445"/>2
</link> </paragraph>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<section
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml"
xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom" version="5.0-variant ezpublish-1.0">
<para>paragraph text and (
<ezembedinline view="embed-inline" xlink:href="ezcontent://444"><ezlink xlink:href="ezlocation://333" xlink:show="none"/><ezconfig><ezvalue key="size">original</ezvalue></ezconfig></ezembedinline> </para>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<section
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml"
xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom" version="5.0-variant ezpublish-1.0">
<para>paragraph text and (
<link xlink:href="ezlocation://333" xlink:show="none">Foo
<ezembedinline xlink:href="ezcontent://444" view="embed-inline"><ezconfig><ezvalue key="size">original</ezvalue></ezconfig></ezembedinline>bar
<ezembedinline xlink:href="ezcontent://445" view="embed-inline"><ezconfig><ezvalue key="size">original</ezvalue></ezconfig></ezembedinline>2
</link> </para>
</section>