From 593af9feb6cdbb88e250501938722e656fe4a17a Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 14 Jul 2009 13:33:40 -0400 Subject: Moved the decision logic as to whether an attachment should be an enclosure to the File class --- classes/File.php | 13 +++++++++++++ classes/Notice.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/File.php b/classes/File.php index 533cc6e71..289c6e441 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'); + $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 fc28f3558..08125cf7b 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -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; -- cgit v1.2.3-54-g00ecf