summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorJeffery To <jeffery.to@gmail.com>2009-07-17 16:54:46 +0800
committerJeffery To <jeffery.to@gmail.com>2009-07-17 16:54:46 +0800
commit1aea5989776e75f3b7af236049d511a28c3f1ff7 (patch)
treefbf355767238df2dbdebf086fa2c9e5f51f7dbed /classes
parent5015505f16c9ce412e6f5535f80188f33d24c4ea (diff)
parentc32e494c0c480e30317b0f0a8dcae7103c4ff89e (diff)
Merge branch '0.9.x' into private-rss
Diffstat (limited to 'classes')
-rw-r--r--classes/File.php13
-rw-r--r--classes/Notice.php10
2 files changed, 19 insertions, 4 deletions
diff --git a/classes/File.php b/classes/File.php
index 533cc6e71..56d9f9827 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -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','application/xhtml+xml');
+ $mimetype = strtolower($this->mimetype);
+ $semicolon = strpos($mimetype,';');
+ if($semicolon){
+ $mimetype = substr($mimetype,0,$semicolon);
+ }
+ return(! in_array($mimetype,$notEnclosureMimeTypes));
+ }
}
diff --git a/classes/Notice.php b/classes/Notice.php
index 75044cf63..08125cf7b 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -1170,11 +1170,13 @@ class Notice extends Memcached_DataObject
$attachments = $this->attachments();
if($attachments){
foreach($attachments as $attachment){
- $attributes = array('rel'=>'enclosure','href'=>$attachment->url,'type'=>$attachment->mimetype,'length'=>$attachment->size);
- if($attachment->title){
- $attributes['title']=$attachment->title;
+ if ($attachment->isEnclosure()) {
+ $attributes = array('rel'=>'enclosure','href'=>$attachment->url,'type'=>$attachment->mimetype,'length'=>$attachment->size);
+ if($attachment->title){
+ $attributes['title']=$attachment->title;
+ }
+ $xs->element('link', $attributes, null);
}
- $xs->element('link', $attributes, null);
}
}