Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-20079

custom attributes not working for embed tag due to improper xml handling

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: High High
    • Resolution: Unresolved
    • Affects Version/s: 2012.8
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      PHP 5.3.18

      Description

      When the embed tag has custom attributes defined, the don't get saved after publishing content that has embed object in some OE attribute.
      The values entered into custom attributes in OE popup, just disappear after publishing the object.

      After inspecting the code I have found that there's a problem in handling xml of the embed element and it's namespaces.
      The generated xml for the embed element ends up like this:

      <embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="test_attr1|1111attribute_separationtest_attr2|icon_right" view="embed" size="medium" object_id="106" default:test_attr1="1111" default2:test_attr2="222"/>

      while it should be like this:

      <embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="test_attr1|1111attribute_separationtest_attr2|icon_right" view="embed" size="medium" object_id="106" custom:test_attr1="1111" custom:test_attr2="222"/>

      After further inspecting I found out that the thing that helps is adding the namespace "xmlns:custom" BEFORE and AFTER adding the attribute with setAttributeNS() while processing custom tags.
      Also the $removeAttr variable should be set to false for custom tags.

      So in order to work I had to make changes in 2 file. Change in kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php this code:

                      elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                      {
                          // add 'custom' prefix if it is not given
                          $allowed = true;
                          $removeAttr = true;
                          $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                      }
      

      into this:

                      elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                      {
                          // add 'custom' prefix if it is not given
                          $allowed = true;
                          $removeAttr = false;
                          $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:custom',  $this->Namespaces['custom'] );
                          $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                          $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:custom',  $this->Namespaces['custom'] );
       
                      }
      

      And change in extension/ezoe/ezxmltext/handlers/input/ezoeinputparser.php this code:

                      if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                      {
                          list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                          $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/',
                                                    'custom:' . $attrName,
                                                    $attrValue );
                      }
      

      into this:

                      if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                      {
                          list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                          $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/' );
                          $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/',
                                                    'custom:' . $attrName,
                                                    $attrValue );
                          $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/', 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/' );
       
                      }
      

      I don't know why this worked (I'm not that much of an XML expert), but it works.

      Anyone from the eZ crew wishes to inspect this?

      P.S. This was all on PHP 5.3.15

        Activity

        Mavko Žmak - Žmale created issue -
        Mavko Žmak - Žmale made changes -
        Field Original Value New Value
        Description When the embed tag has custom attributes defined, the don't get saved after publishing content that has embed object in some OE attribute.
        The values entered into custom attributes in OE popup, just disappear after publishing the object.

        After inspecting the code I have found that there's a problem in handling xml of the embed element and it's namespaces.
        The generated xml for the embed element ends up like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="link_title|1111attribute_separationlink_style|icon_right" view="embed" size="medium" object_id="106" *default:test_attr1="1111"* *default2:test_attr2="222"*/>}}

        while it should be like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="link_title|1111attribute_separationlink_style|icon_right" view="embed" size="medium" object_id="106" *custom:test_attr1="1111"* *custom:test_attr2="222"*/>}}

        After further inspecting I found out that the thing that helps is adding the namespace "xmlns:custom" BEFORE and AFTER adding the attribute with setAttributeNS().
        SO in order to work I had to make changes in 2 file. Change in {{kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php}} this code:
        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                        }
        {code}

        into this:

        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );

                        }
        {code}

        And change in {{extension/ezoe/ezxmltext/handlers/input/ezoeinputparser.php}} this code:
        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                        }
        {code}

        into this:

        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                        }
        {code}

        I don't know why this worked (I'm not that much of an XML expert), but it works.

        Anyone from the eZ crew wishes to inspect this?

        P.S. This was all on PHP 5.3.15
        When the embed tag has custom attributes defined, the don't get saved after publishing content that has embed object in some OE attribute.
        The values entered into custom attributes in OE popup, just disappear after publishing the object.

        After inspecting the code I have found that there's a problem in handling xml of the embed element and it's namespaces.
        The generated xml for the embed element ends up like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="link_title|1111attribute_separationlink_style|icon_right" view="embed" size="medium" object_id="106" *default:test_attr1="1111"* *default2:test_attr2="222"*/>}}

        while it should be like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="link_title|1111attribute_separationlink_style|icon_right" view="embed" size="medium" object_id="106" *custom:test_attr1="1111"* *custom:test_attr2="222"*/>}}

        After further inspecting I found out that the thing that helps is adding the namespace "xmlns:custom" BEFORE and AFTER adding the attribute with setAttributeNS().

        So in order to work I had to make changes in 2 file. Change in {{kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php}} this code:
        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                        }
        {code}

        into this:

        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );

                        }
        {code}

        And change in {{extension/ezoe/ezxmltext/handlers/input/ezoeinputparser.php}} this code:
        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                        }
        {code}

        into this:

        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                        }
        {code}

        I don't know why this worked (I'm not that much of an XML expert), but it works.

        Anyone from the eZ crew wishes to inspect this?

        P.S. This was all on PHP 5.3.15
        Mavko Žmak - Žmale made changes -
        Description When the embed tag has custom attributes defined, the don't get saved after publishing content that has embed object in some OE attribute.
        The values entered into custom attributes in OE popup, just disappear after publishing the object.

        After inspecting the code I have found that there's a problem in handling xml of the embed element and it's namespaces.
        The generated xml for the embed element ends up like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="link_title|1111attribute_separationlink_style|icon_right" view="embed" size="medium" object_id="106" *default:test_attr1="1111"* *default2:test_attr2="222"*/>}}

        while it should be like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="link_title|1111attribute_separationlink_style|icon_right" view="embed" size="medium" object_id="106" *custom:test_attr1="1111"* *custom:test_attr2="222"*/>}}

        After further inspecting I found out that the thing that helps is adding the namespace "xmlns:custom" BEFORE and AFTER adding the attribute with setAttributeNS().

        So in order to work I had to make changes in 2 file. Change in {{kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php}} this code:
        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                        }
        {code}

        into this:

        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );

                        }
        {code}

        And change in {{extension/ezoe/ezxmltext/handlers/input/ezoeinputparser.php}} this code:
        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                        }
        {code}

        into this:

        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                        }
        {code}

        I don't know why this worked (I'm not that much of an XML expert), but it works.

        Anyone from the eZ crew wishes to inspect this?

        P.S. This was all on PHP 5.3.15
        When the embed tag has custom attributes defined, the don't get saved after publishing content that has embed object in some OE attribute.
        The values entered into custom attributes in OE popup, just disappear after publishing the object.

        After inspecting the code I have found that there's a problem in handling xml of the embed element and it's namespaces.
        The generated xml for the embed element ends up like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="test_attr1|1111attribute_separationtest_attr2|icon_right" view="embed" size="medium" object_id="106" *default:test_attr1="1111"* *default2:test_attr2="222"*/>}}

        while it should be like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="test_attr1|1111attribute_separationtest_attr2|icon_right" view="embed" size="medium" object_id="106" *custom:test_attr1="1111"* *custom:test_attr2="222"*/>}}

        After further inspecting I found out that the thing that helps is adding the namespace "xmlns:custom" BEFORE and AFTER adding the attribute with setAttributeNS().

        So in order to work I had to make changes in 2 file. Change in {{kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php}} this code:
        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                        }
        {code}

        into this:

        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );

                        }
        {code}

        And change in {{extension/ezoe/ezxmltext/handlers/input/ezoeinputparser.php}} this code:
        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                        }
        {code}

        into this:

        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                        }
        {code}

        I don't know why this worked (I'm not that much of an XML expert), but it works.

        Anyone from the eZ crew wishes to inspect this?

        P.S. This was all on PHP 5.3.15
        Mavko Žmak - Žmale made changes -
        Description When the embed tag has custom attributes defined, the don't get saved after publishing content that has embed object in some OE attribute.
        The values entered into custom attributes in OE popup, just disappear after publishing the object.

        After inspecting the code I have found that there's a problem in handling xml of the embed element and it's namespaces.
        The generated xml for the embed element ends up like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="test_attr1|1111attribute_separationtest_attr2|icon_right" view="embed" size="medium" object_id="106" *default:test_attr1="1111"* *default2:test_attr2="222"*/>}}

        while it should be like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="test_attr1|1111attribute_separationtest_attr2|icon_right" view="embed" size="medium" object_id="106" *custom:test_attr1="1111"* *custom:test_attr2="222"*/>}}

        After further inspecting I found out that the thing that helps is adding the namespace "xmlns:custom" BEFORE and AFTER adding the attribute with setAttributeNS().

        So in order to work I had to make changes in 2 file. Change in {{kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php}} this code:
        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                        }
        {code}

        into this:

        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );

                        }
        {code}

        And change in {{extension/ezoe/ezxmltext/handlers/input/ezoeinputparser.php}} this code:
        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                        }
        {code}

        into this:

        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                        }
        {code}

        I don't know why this worked (I'm not that much of an XML expert), but it works.

        Anyone from the eZ crew wishes to inspect this?

        P.S. This was all on PHP 5.3.15
        When the embed tag has custom attributes defined, the don't get saved after publishing content that has embed object in some OE attribute.
        The values entered into custom attributes in OE popup, just disappear after publishing the object.

        After inspecting the code I have found that there's a problem in handling xml of the embed element and it's namespaces.
        The generated xml for the embed element ends up like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="test_attr1|1111attribute_separationtest_attr2|icon_right" view="embed" size="medium" object_id="106" *default:test_attr1="1111"* *default2:test_attr2="222"*/>}}

        while it should be like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="test_attr1|1111attribute_separationtest_attr2|icon_right" view="embed" size="medium" object_id="106" *custom:test_attr1="1111"* *custom:test_attr2="222"*/>}}

        After further inspecting I found out that the thing that helps is adding the namespace "xmlns:custom" BEFORE and AFTER adding the attribute with setAttributeNS() while processing custom tags.
        Also the $removeAttr variable should be set to false for custom tags.

        So in order to work I had to make changes in 2 file. Change in {{kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php}} this code:
        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                        }
        {code}

        into this:

        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = false;
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );

                        }
        {code}

        And change in {{extension/ezoe/ezxmltext/handlers/input/ezoeinputparser.php}} this code:
        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                        }
        {code}

        into this:

        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                        }
        {code}

        I don't know why this worked (I'm not that much of an XML expert), but it works.

        Anyone from the eZ crew wishes to inspect this?

        P.S. This was all on PHP 5.3.15
        Mavko Žmak - Žmale made changes -
        Description When the embed tag has custom attributes defined, the don't get saved after publishing content that has embed object in some OE attribute.
        The values entered into custom attributes in OE popup, just disappear after publishing the object.

        After inspecting the code I have found that there's a problem in handling xml of the embed element and it's namespaces.
        The generated xml for the embed element ends up like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="test_attr1|1111attribute_separationtest_attr2|icon_right" view="embed" size="medium" object_id="106" *default:test_attr1="1111"* *default2:test_attr2="222"*/>}}

        while it should be like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="test_attr1|1111attribute_separationtest_attr2|icon_right" view="embed" size="medium" object_id="106" *custom:test_attr1="1111"* *custom:test_attr2="222"*/>}}

        After further inspecting I found out that the thing that helps is adding the namespace "xmlns:custom" BEFORE and AFTER adding the attribute with setAttributeNS() while processing custom tags.
        Also the $removeAttr variable should be set to false for custom tags.

        So in order to work I had to make changes in 2 file. Change in {{kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php}} this code:
        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                        }
        {code}

        into this:

        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = false;
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );

                        }
        {code}

        And change in {{extension/ezoe/ezxmltext/handlers/input/ezoeinputparser.php}} this code:
        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                        }
        {code}

        into this:

        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                        }
        {code}

        I don't know why this worked (I'm not that much of an XML expert), but it works.

        Anyone from the eZ crew wishes to inspect this?

        P.S. This was all on PHP 5.3.15
        When the embed tag has custom attributes defined, the don't get saved after publishing content that has embed object in some OE attribute.
        The values entered into custom attributes in OE popup, just disappear after publishing the object.

        After inspecting the code I have found that there's a problem in handling xml of the embed element and it's namespaces.
        The generated xml for the embed element ends up like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="test_attr1|1111attribute_separationtest_attr2|icon_right" view="embed" size="medium" object_id="106" *default:test_attr1="1111"* *default2:test_attr2="222"*/>}}

        while it should be like this:

        {{<embed xmlns:default="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default1="http://ez.no/namespaces/ezpublish3/custom/" xmlns:default2="http://ez.no/namespaces/ezpublish3/custom/" title="test file" customattributes="test_attr1|1111attribute_separationtest_attr2|icon_right" view="embed" size="medium" object_id="106" *custom:test_attr1="1111"* *custom:test_attr2="222"*/>}}

        After further inspecting I found out that the thing that helps is adding the namespace "xmlns:custom" BEFORE and AFTER adding the attribute with setAttributeNS() while processing custom tags.
        Also the $removeAttr variable should be set to false for custom tags.

        So in order to work I had to make changes in 2 file. Change in {{kernel/classes/datatypes/ezxmltext/ezxmlinputparser.php}} this code:
        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = true;
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                        }
        {code}

        into this:

        {code}
                        elseif ( in_array( $fullName, $schemaCustomAttributes ) )
                        {
                            // add 'custom' prefix if it is not given
                            $allowed = true;
                            $removeAttr = false;
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );
                            $element->setAttributeNS( $this->Namespaces['custom'], 'custom:' . $fullName, $attr->value );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', $this->Namespaces['custom'] );

                        }
        {code}

        And change in {{extension/ezoe/ezxmltext/handlers/input/ezoeinputparser.php}} this code:
        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                        }
        {code}

        into this:

        {code}
                        if ( $attr !== '' && strpos( $attr, '|' ) !== false )
                        {
                            list( $attrName, $attrValue ) = explode( '|', $attr, 2 );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );
                            $element->setAttributeNS( 'http://ez.no/namespaces/ezpublish3/custom/&#39;,
                                                      'custom:' . $attrName,
                                                      $attrValue );
                            $element->setAttributeNS( 'http://www.w3.org/2000/xmlns/&#39;, 'xmlns:custom', 'http://ez.no/namespaces/ezpublish3/custom/&#39; );

                        }
        {code}

        I don't know why this worked (I'm not that much of an XML expert), but it works.

        Anyone from the eZ crew wishes to inspect this?

        P.S. This was all on PHP 5.3.15
        Hide
        Nathan Kelly added a comment -

        Hi Mavko,

        I tried your patches on my 2012.8 install on PHP 5.3.4 but sadly they haven't helped.

        I have no problems when adding CustomAttributes to tags alone (eg: [embed]) but adding them to a tag/class_identifier combo fails (eg: [embed_my_class_identifier]).

        if I disable the editor after adding an embedded object my custom attributes disappear, however I've also discovered that adding them manually I get a validation error along the lines of "Attribute 'custom:my_custom_attribute' is not allowed in <embed> element." which leads me to think this issue might be related to the ezxml datatype rather than ezoe?

        This is a pretty frustrating issue, we have all that power just waiting to be exploited but we can't use it!

        Cheers
        Nathan.

        Show
        Nathan Kelly added a comment - Hi Mavko, I tried your patches on my 2012.8 install on PHP 5.3.4 but sadly they haven't helped. I have no problems when adding CustomAttributes to tags alone (eg: [embed] ) but adding them to a tag/class_identifier combo fails (eg: [embed_my_class_identifier] ). if I disable the editor after adding an embedded object my custom attributes disappear, however I've also discovered that adding them manually I get a validation error along the lines of "Attribute 'custom:my_custom_attribute' is not allowed in <embed> element." which leads me to think this issue might be related to the ezxml datatype rather than ezoe? This is a pretty frustrating issue, we have all that power just waiting to be exploited but we can't use it! Cheers Nathan.
        Hide
        Mavko Žmak - Žmale added a comment -

        Hi Nathan.

        Yes the problem you described has also happened to me several times.
        I suspect that this is also connected with the bug I have reported here or some other improper xml handling.

        After having a look at the code that handles the XML from OE, I can conclude that this was never done properly and in an organised way. It looks more like some parts were added as a quickfix from time to time when needed. There are a lot of "hacks" in there.
        Since the whole eZ Publish CMS is currently being reworked, I doubt that there's will to go fixing all this bugs in the old code.

        I only hope that the new XML handling that will come in the newer versions will be more organised and that we will have soon a stable version to use.

        Show
        Mavko Žmak - Žmale added a comment - Hi Nathan. Yes the problem you described has also happened to me several times. I suspect that this is also connected with the bug I have reported here or some other improper xml handling. After having a look at the code that handles the XML from OE, I can conclude that this was never done properly and in an organised way. It looks more like some parts were added as a quickfix from time to time when needed. There are a lot of "hacks" in there. Since the whole eZ Publish CMS is currently being reworked, I doubt that there's will to go fixing all this bugs in the old code. I only hope that the new XML handling that will come in the newer versions will be more organised and that we will have soon a stable version to use.
        Hide
        Nathan Kelly added a comment -

        Hi Mavko,

        I agree there are a lot of hacks in this code, it really does look unfinished when you start digging through it, the confusing thing is that the content.ini in ezoe/settings remarks on these configurations being possible but in reality there is no code to handle these setting properly, it's almost as though they just rushed this release out without bothering to complete it.

        I'm going to look into it further, I began setting up some content classes that were designed to use this functionality only to discover the functionality doesn't exist and now I'm stuck with a half baked development that requires this functionality or it's back to the drawing board!

        I'll keep this issue updated if i make any progress.

        Cheers
        Nathan.

        Show
        Nathan Kelly added a comment - Hi Mavko, I agree there are a lot of hacks in this code, it really does look unfinished when you start digging through it, the confusing thing is that the content.ini in ezoe/settings remarks on these configurations being possible but in reality there is no code to handle these setting properly, it's almost as though they just rushed this release out without bothering to complete it. I'm going to look into it further, I began setting up some content classes that were designed to use this functionality only to discover the functionality doesn't exist and now I'm stuck with a half baked development that requires this functionality or it's back to the drawing board! I'll keep this issue updated if i make any progress. Cheers Nathan.
        André Rømcke made changes -
        Workflow eZ Community Workflow [ 34574 ] eZ Engineering Scrumban Workflow [ 35703 ]
        Bertrand Dunogier made changes -
        Component/s Extensions/eZ Online Editor [ 10700 ]
        Component/s Extensions/eZ Online Editor/Online Editor [ 10839 ]
        André Rømcke made changes -
        Workflow eZ Engineering Scrumban Workflow [ 35703 ] EZ* Development Workflow [ 68950 ]
        Alex Schuster made changes -
        Workflow EZ* Development Workflow [ 68950 ] EZEE Development Workflow [ 107087 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Mavko Žmak - Žmale
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: