浏览代码

Zend_Feed: fix for 'importArray() - no support for item author element'. Closes [ZF-5611].

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15381 44c647ce-9c0f-0410-b52a-842ac1e357ba
alexander 16 年之前
父节点
当前提交
6f003dd6e6
共有 3 个文件被更改,包括 20 次插入0 次删除
  1. 3 0
      library/Zend/Feed/Builder.php
  2. 12 0
      library/Zend/Feed/Builder/Entry.php
  3. 5 0
      library/Zend/Feed/Rss.php

+ 3 - 0
library/Zend/Feed/Builder.php

@@ -354,6 +354,9 @@ class Zend_Feed_Builder implements Zend_Feed_Builder_Interface
                 }
             }
             $entry = new Zend_Feed_Builder_Entry($row['title'], $row['link'], $row['description']);
+            if (isset($row['author'])) {
+                $entry->setAuthor($row['author']);
+            }
             if (isset($row['guid'])) {
                 $entry->setId($row['guid']);
             }

+ 12 - 0
library/Zend/Feed/Builder/Entry.php

@@ -102,6 +102,18 @@ class Zend_Feed_Builder_Entry extends ArrayObject
     }
 
     /**
+     * Sets the author of the entry
+     *
+     * @param  string $author
+     * @return Zend_Feed_Builder_Entry
+     */
+    public function setAuthor($author)
+    {
+        $this->offsetSet('author', $author);
+        return $this;
+    }
+
+    /**
      * Sets the id/guid of the entry
      *
      * @param  string $id

+ 5 - 0
library/Zend/Feed/Rss.php

@@ -401,6 +401,11 @@ class Zend_Feed_Rss extends Zend_Feed_Abstract
             $title->appendChild($this->_element->createCDATASection($dataentry->title));
             $item->appendChild($title);
 
+            if (isset($dataentry->author)) {
+                $author = $this->_element->createElement('author', $dataentry->author);
+                $item->appendChild($author);
+            }
+
             $link = $this->_element->createElement('link', $dataentry->link);
             $item->appendChild($link);