]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - inc/3rdparty/libraries/feedwriter/FeedItem.php
update to 3.2 version of full-text-rss, issue #694
[github/wallabag/wallabag.git] / inc / 3rdparty / libraries / feedwriter / FeedItem.php
old mode 100644 (file)
new mode 100755 (executable)
index 54a56f2..4078659
@@ -1,7 +1,7 @@
 <?php\r
  /**\r
  * Univarsel Feed Writer\r
- * \r
+ *\r
  * FeedItem class - Used as feed element in FeedWriter class\r
  *\r
  * @package         UnivarselFeedWriter\r
  {\r
     private $elements = array();    //Collection of feed elements\r
     private $version;\r
-    \r
+\r
     /**\r
-    * Constructor \r
-    * \r
-    * @param    contant     (RSS1/RSS2/ATOM) RSS2 is default. \r
-    */ \r
+    * Constructor\r
+    *\r
+    * @param    contant     (RSS1/RSS2/ATOM) RSS2 is default.\r
+    */\r
     function __construct($version = RSS2)\r
-    {    \r
+    {\r
         $this->version = $version;\r
     }\r
 \r
     /**\r
     * Set element (overwrites existing elements with $elementName)\r
-    * \r
+    *\r
     * @access   public\r
     * @param    srting  The tag name of an element\r
     * @param    srting  The content of tag\r
             unset($this->elements[$elementName]);\r
         }\r
         $this->addElement($elementName, $content, $attributes);\r
-    }    \r
-    \r
+    }\r
+\r
     /**\r
     * Add an element to elements array\r
-    * \r
+    *\r
     * @access   public\r
     * @param    srting  The tag name of an element\r
     * @param    srting  The content of tag\r
         $this->elements[$elementName][$i]['content']    = $content;\r
         $this->elements[$elementName][$i]['attributes'] = $attributes;\r
     }\r
-    \r
+\r
     /**\r
-    * Set multiple feed elements from an array. \r
+    * Set multiple feed elements from an array.\r
     * Elements which have attributes cannot be added by this method\r
-    * \r
+    *\r
     * @access   public\r
     * @param    array   array of elements in 'tagName' => 'tagContent' format.\r
     * @return   void\r
     public function addElementArray($elementArray)\r
     {\r
         if(! is_array($elementArray)) return;\r
-        foreach ($elementArray as $elementName => $content) \r
+        foreach ($elementArray as $elementName => $content)\r
         {\r
             $this->addElement($elementName, $content);\r
         }\r
     }\r
-    \r
+\r
     /**\r
     * Return the collection of elements in this feed item\r
-    * \r
+    *\r
     * @access   public\r
     * @return   array\r
     */\r
     {\r
         return $this->elements;\r
     }\r
-    \r
+\r
     // Wrapper functions ------------------------------------------------------\r
-    \r
+\r
     /**\r
     * Set the 'dscription' element of feed item\r
-    * \r
+    *\r
     * @access   public\r
     * @param    string  The content of 'description' element\r
     * @return   void\r
     */\r
-    public function setDescription($description) \r
+    public function setDescription($description)\r
     {\r
-        $this->setElement('description', $description);\r
+        $tag = ($this->version == ATOM)? 'summary' : 'description';\r
+        $this->setElement($tag, $description);\r
     }\r
-    \r
+\r
     /**\r
     * @desc     Set the 'title' element of feed item\r
     * @access   public\r
     * @param    string  The content of 'title' element\r
     * @return   void\r
     */\r
-    public function setTitle($title) \r
+    public function setTitle($title)\r
     {\r
-        $this->setElement('title', $title);      \r
+        $this->setElement('title', $title);\r
     }\r
-    \r
+\r
     /**\r
     * Set the 'date' element of feed item\r
-    * \r
+    *\r
     * @access   public\r
     * @param    string  The content of 'date' element\r
     * @return   void\r
     */\r
-    public function setDate($date) \r
+    public function setDate($date)\r
     {\r
         if(! is_numeric($date))\r
         {\r
             $date = strtotime($date);\r
         }\r
-      \r
-        if($this->version == RSS2) \r
+\r
+        if($this->version == ATOM)\r
+        {\r
+               $tag    = 'updated';\r
+               $value  = date(DATE_ATOM, $date);\r
+        }\r
+        elseif($this->version == RSS2)\r
         {\r
-            $tag    = 'pubDate';\r
-            $value  = date(DATE_RSS, $date);\r
+               $tag    = 'pubDate';\r
+               $value  = date(DATE_RSS, $date);\r
         }\r
-        else                                \r
+        else\r
         {\r
-            $tag    = 'dc:date';\r
-            $value  = date("Y-m-d", $date);\r
+               $tag    = 'dc:date';\r
+               $value  = date("Y-m-d", $date);\r
         }\r
-        \r
-        $this->setElement($tag, $value);    \r
+\r
+        $this->setElement($tag, $value);\r
     }\r
-    \r
+\r
     /**\r
     * Set the 'link' element of feed item\r
-    * \r
+    *\r
     * @access   public\r
     * @param    string  The content of 'link' element\r
     * @return   void\r
     */\r
-    public function setLink($link) \r
+    public function setLink($link)\r
     {\r
         if($this->version == RSS2 || $this->version == RSS1)\r
         {\r
         {\r
             $this->setElement('link','',array('href'=>$link));\r
             $this->setElement('id', FeedWriter::uuid($link,'urn:uuid:'));\r
-        } \r
-        \r
+        }\r
+\r
     }\r
 \r
     /**\r
     * Set the 'source' element of feed item\r
-    * \r
+    *\r
     * @access   public\r
     * @param    string  The content of 'source' element\r
     * @return   void\r
     */\r
-    public function setSource($link) \r
+    public function setSource($link)\r
     {\r
         $attributes = array('url'=>$link);\r
         $this->setElement('source', "wallabag",$attributes);\r
     }\r
-    \r
+\r
     /**\r
     * Set the 'encloser' element of feed item\r
     * For RSS 2.0 only\r
-    * \r
+    *\r
     * @access   public\r
     * @param    string  The url attribute of encloser tag\r
     * @param    string  The length attribute of encloser tag\r
         $attributes = array('url'=>$url, 'length'=>$length, 'type'=>$type);\r
         $this->setElement('enclosure','',$attributes);\r
     }\r
-    \r
+\r
  } // end of class FeedItem\r
 ?>
\ No newline at end of file