]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Moved the decision logic as to whether an attachment should be an enclosure to the...
authorCraig Andrews <candrews@integralblue.com>
Tue, 14 Jul 2009 17:33:40 +0000 (13:33 -0400)
committerCraig Andrews <candrews@integralblue.com>
Tue, 14 Jul 2009 17:33:40 +0000 (13:33 -0400)
classes/File.php
classes/Notice.php
lib/rssaction.php
lib/twitterapi.php

index 533cc6e71dbe12792c077070cab82c71e21d4a10..289c6e4418d24084007ddaf6beb0ca05a181ae95 100644 (file)
@@ -193,5 +193,18 @@ class File extends Memcached_DataObject
 
         return 'http://'.$server.$path.$filename;
     }
+
+    function isEnclosure(){
+        if(isset($this->filename)){
+            return true;
+        }
+        $notEnclosureMimeTypes = array('text/html');
+        $mimetype = strtolower($this->mimetype);
+        $semicolon = strpos($mimetype,';');
+        if($semicolon){
+            $mimetype = substr($mimetype,0,$semicolon);
+        }
+        return(! in_array($mimetype,$notEnclosureMimeTypes));
+    }
 }
 
index fc28f355882c3445932470e0d7a366830e7a2935..08125cf7b0d7c77f9546c39bf80c2a248a58c031 100644 (file)
@@ -1170,7 +1170,7 @@ class Notice extends Memcached_DataObject
         $attachments = $this->attachments();
         if($attachments){
             foreach($attachments as $attachment){
-                if (isset($attachment->filename)) {
+                if ($attachment->isEnclosure()) {
                     $attributes = array('rel'=>'enclosure','href'=>$attachment->url,'type'=>$attachment->mimetype,'length'=>$attachment->size);
                     if($attachment->title){
                         $attributes['title']=$attachment->title;
index 183c09f473ae4b42389ee343094ce91eaf20418b..ffa1f9e99ff00605a50d7be3eacf3344a9ac483e 100644 (file)
@@ -237,7 +237,7 @@ class Rss10Action extends Action
         $attachments = $notice->attachments();
         if($attachments){
             foreach($attachments as $attachment){
-                if (isset($attachment->filename)) {
+                if ($attachment->isEnclosure()) {
                     // DO NOT move xmlns declaration to root element. Making it
                     // the default namespace here improves compatibility with
                     // real-world feed readers.
index ce188e00d896b3347e034a14191f72da3333f349..655b6c77786fff82a7432fa5f3c5f8ad26852a46 100644 (file)
@@ -218,7 +218,7 @@ class TwitterapiAction extends Action
         if($attachments){
             $entry['enclosures']=array();
             foreach($attachments as $attachment){
-                if (isset($attachment->filename)) {
+                if ($attachment->isEnclosure()) {
                     $enclosure=array();
                     $enclosure['url']=$attachment->url;
                     $enclosure['mimetype']=$attachment->mimetype;