Exemple #1
0
    public function testConvertReturnsNotValidXml()
    {
        $dom = new DomDocument();
        $dom->loadXML('<?xml version="1.0" encoding="utf-8"?>
<section xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/" xmlns:image="http://ez.no/namespaces/ezpublish3/image/" xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"><paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/"><literal class="html">This is only a literal with &lt;strong&gt;strong&lt;/strong&gt; text</literal></paragraph></section>');
        $html5 = new Html5($this->getDefaultStylesheet(), array());
        $result = $html5->convert($dom);
        $this->assertEquals($result, 'This is only a literal with <strong>strong</strong> text
');
        $dom->loadXML('<?xml version="1.0" encoding="utf-8"?>
<section xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/" xmlns:image="http://ez.no/namespaces/ezpublish3/image/" xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"><paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/"><literal class="html">This is text followed by an iframe &lt;iframe src="http://www.ez.no" /&gt;</literal></paragraph></section>');
        $html5 = new Html5($this->getDefaultStylesheet(), array());
        $result = $html5->convert($dom);
        $this->assertEquals($result, 'This is text followed by an iframe <iframe src="http://www.ez.no" />
');
    }
 /**
  * Method for parsing ezxmltext field.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Field $field
  *
  * @return string
  */
 public function ezxmltext(Field $field)
 {
     return $this->html5Converter->convert($field->value->xml);
 }
    /**
     * @param string $inputFilePath
     * @param string $outputFilePath
     *
     * @dataProvider providerForTestConvert
     */
    public function testConvert( $inputFilePath, $outputFilePath )
    {
        $inputDocument = $this->createDocument( $inputFilePath );

        $html5 = new Html5(
            $this->getDefaultStylesheet(),
            array(),
            array(
                new Expanding(),
                new EmbedLinking(),
            )
        );

        $result = $html5->convert( $inputDocument );
        // Make <br> tags valid
        $result = str_replace( "<br>", "<br/>", $result );
        // Make a valid XML document string
        $result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><section xmlns=\"http://ez.no/namespaces/ezpublish5/xhtml5\">{$result}</section>";

        $convertedDocument = $this->createDocument( $result, false );
        $expectedDocument = $this->createDocument( $outputFilePath );

        $this->assertEquals(
            $expectedDocument,
            $convertedDocument
        );
    }
 /**
  * Implements the "xmltext_to_html5" filter
  *
  * @param string $xmlData
  *
  * @return string
  */
 public function xmltextToHtml5($xmlData)
 {
     return $this->xmlTextConverter->convert($xmlData);
 }
 /**
  * Method for parsing ezxmltext field.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Field $field
  *
  * @return string
  */
 public function ezxmltext(Field $field)
 {
     return '<![CDATA[' . $this->html5Converter->convert($field->value->xml) . ']]>';
 }
 /**
  * @dataProvider dataProviderAnchor
  */
 public function testAnchorRendering($xml, $xpathCheck, $checkClosure)
 {
     $dom = new DomDocument();
     $dom->loadXML($xml);
     $html5 = new Html5($this->getDefaultStylesheet(), array());
     $result = new DomDocument();
     $result->loadXML($html5->convert($dom));
     $xpath = new DOMXPath($result);
     $checkClosure($xpath->query($xpathCheck));
 }
 /**
  * @dataProvider dataProviderEmbedRendering
  */
 public function testEmbedRendering($xml, $expected)
 {
     $dom = new DomDocument();
     $dom->loadXML($xml);
     $html5 = new Html5($this->getDefaultStylesheet(), array());
     $result = $html5->convert($dom);
     $this->assertEquals($expected, trim($result));
 }
 /**
  * Get a Text from a XML
  *
  * @param XmlTextValue $value
  *
  * @return string
  */
 protected function handleXmlTextValue(XmlTextValue $value)
 {
     return trim(strip_tags($this->html5Converter->convert($value->xml)));
 }