Hi,

I see it is much more complicated than I thought ;)
Can you try the following patch to see if it fits your needs?
To apply it, just set the current directory to the root of your Zend Framework 
package and call patch command this way:
patch -p0 < /path/to/the/patch/zend_feed.patch

To enable the support of xhtml atom content, you have to create your entry 
node like this:
<?php
// declare the summary as a valid xhtml content
$node = new Zend_Feed_Builder_Entry($title, $link, $summary, true);

// add a valid xhtml data the the atom content node
$node->setContent($content, true);
?>

Olivier

Le samedi 31 mars 2007, Alexander Netkachev a écrit :
> Hi,
>
> Atom has tree formats for text element content: text, html, xhtml.
>
> "text" means that the content of the element should be displayed as it is,
> so if you write <summary type="text"><![CDATA[<em>test</em>]]></summary>
> then you see exactly that is in the summary.
>
> "html" means that the content of the element is processed like it is html
> with encoded entities.
> So, either of <summary type="html"><![CDATA[<em>test</em>]]></summary> and
> <summary type="html">&lt;em&lt;test&lt;/em&gt;</summary> are the same.
>
> "xhtml" means that the content of the entity is valid xhtml within <div
> xmlns="...">...</div> tag.
> See RFC 4287: 3.1.1.3. XHTML
> <summary type="xhtml"> <div xmlns="http://www.w3.org/1999/xhtml";> This is
> <b>XHTML</b> content. </div> </summary>
> So, CDATA does not help in this case because
> <summary type="xhtml"><![CDATA[<div></div>]]></summary> = <summary
> type="xhtml">&lt;div&lt;&lt;/div&gt;</summary>
> and it is incorrect format of the atom feed.
>
> Check the following feed:
> <feed xmlns="http://www.w3.org/2005/Atom";>
>   <title type="xhtml"><![CDATA[<div
> xmlns="http://www.w3.org/1999/xhtml";>Alex @ Net articles</div>]]></title>
>   <updated>2006-07-20T20:07:00Z</updated>
>   <author>
>     <name>Alexander Netkachev</name>
>   </author>
>   <id>http://alexatnet.com/blog/2</id>
> </feed>
> using the http://validator.w3.org/feed/.
> It says that "Missing xhtml:div element" and "title claims to be inline,
> but may contain html: div".
>
> So, the very right way to add the XML is to use type="xhtml" but it is not
> possible with current Zend_Feed nor in <summary/> nor in <content/>.
> My Atom toolkit (
> http://www.alexatnet.com/blog/2/2006/06/02/atom-syndication-framework) has
> not nice Api, but it supports XHTML content as follows:
>
> $entry = $feed->Add(new Ant_Atom_Entry());
> $content = $entry->Add(Ant_Atom_Content::Inline( '<p><i>[Update: The Atom
> draft is finished.]</i></p>', Ant_Atom_PlainText::Xhtml));
> $content->SetAttribute('xml:lang', 'en');
> $content->SetAttribute('xml:base', 'http://diveintomark.org/');
>
>
> Sincerely,
Index: Zend/Feed/Atom.php
===================================================================
--- Zend/Feed/Atom.php	(révision 4300)
+++ Zend/Feed/Atom.php	(copie de travail)
@@ -282,14 +282,28 @@
             $link->setAttribute('href', $dataentry->link);
             $entry->appendChild($link);
 
-            $summary = $this->_element->createElement('summary');
-            $summary->appendChild($this->_element->createCDATASection($dataentry->description));
+            if (!$dataentry->description['xhtml']) {
+                $summary = $this->_element->createElement('summary');
+                $summary->appendChild($this->_element->createCDATASection($dataentry->description['content']));
+            } else {
+                $summary = $this->_element->createElementNS('http://www.w3.org/1999/xhtml',
+                                                            'feed:summary',
+                                                            $dataentry->description['content']);
+                $summary->setAttribute('type', 'xhtml');
+            }
             $entry->appendChild($summary);
 
             if (isset($dataentry->content)) {
-                $content = $this->_element->createElement('content');
-                $content->setAttribute('type', 'html');
-                $content->appendChild($this->_element->createCDATASection($dataentry->content));
+                if (!$dataentry->content['xhtml']) {
+                    $content = $this->_element->createElement('content');
+                    $content->setAttribute('type', 'html');
+                    $content->appendChild($this->_element->createCDATASection($dataentry->content['content']));
+                } else {
+                    $content = $this->_element->createElementNS('http://www.w3.org/1999/xhtml',
+                                                                'feed:content',
+                                                                $dataentry->content['content']);
+                    $content->setAttribute('type', 'xhtml');
+                }
                 $entry->appendChild($content);
             }
 
Index: Zend/Feed/Builder/Entry.php
===================================================================
--- Zend/Feed/Builder/Entry.php	(révision 4300)
+++ Zend/Feed/Builder/Entry.php	(copie de travail)
@@ -43,16 +43,18 @@
     /**
      * Create a new builder entry
      *
-     * @param  string $title
-     * @param  string $link
-     * @param  string $description short version of the entry, no html
+     * @param  string  $title
+     * @param  string  $link
+     * @param  string  $description short version of the entry
+     * @param  boolean $isXhtml true if $description is a valid xhtml content
      * @return void
      */
-    public function __construct($title, $link, $description)
+    public function __construct($title, $link, $description, $isXhtml = false)
     {
         $this->offsetSet('title', $title);
         $this->offsetSet('link', $link);
-        $this->offsetSet('description', $description);
+        $this->offsetSet('description', array('content' => $description,
+                                              'xhtml' => $isXhtml));
         $this->setLastUpdate(time());
     }
 
@@ -122,12 +124,14 @@
     /**
      * Sets the full html content of the entry
      *
-     * @param  string $content
+     * @param  string  $content
+     * @param  boolean $isXhtml
      * @return Zend_Feed_Builder_Entry
      */
-    public function setContent($content)
+    public function setContent($content, $isXhtml = false)
     {
-        $this->offsetSet('content', $content);
+        $this->offsetSet('content', array('content' => $content,
+                                          'xhtml' => $isXhtml));
         return $this;
     }
 

Reply via email to