Moved the decision logic as to whether an attachment should be an enclosure to the File class
This commit is contained in:
parent
e047ba52c7
commit
593af9feb6
|
@ -193,5 +193,18 @@ class File extends Memcached_DataObject
|
||||||
|
|
||||||
return 'http://'.$server.$path.$filename;
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1170,7 +1170,7 @@ class Notice extends Memcached_DataObject
|
||||||
$attachments = $this->attachments();
|
$attachments = $this->attachments();
|
||||||
if($attachments){
|
if($attachments){
|
||||||
foreach($attachments as $attachment){
|
foreach($attachments as $attachment){
|
||||||
if (isset($attachment->filename)) {
|
if ($attachment->isEnclosure()) {
|
||||||
$attributes = array('rel'=>'enclosure','href'=>$attachment->url,'type'=>$attachment->mimetype,'length'=>$attachment->size);
|
$attributes = array('rel'=>'enclosure','href'=>$attachment->url,'type'=>$attachment->mimetype,'length'=>$attachment->size);
|
||||||
if($attachment->title){
|
if($attachment->title){
|
||||||
$attributes['title']=$attachment->title;
|
$attributes['title']=$attachment->title;
|
||||||
|
|
|
@ -237,7 +237,7 @@ class Rss10Action extends Action
|
||||||
$attachments = $notice->attachments();
|
$attachments = $notice->attachments();
|
||||||
if($attachments){
|
if($attachments){
|
||||||
foreach($attachments as $attachment){
|
foreach($attachments as $attachment){
|
||||||
if (isset($attachment->filename)) {
|
if ($attachment->isEnclosure()) {
|
||||||
// DO NOT move xmlns declaration to root element. Making it
|
// DO NOT move xmlns declaration to root element. Making it
|
||||||
// the default namespace here improves compatibility with
|
// the default namespace here improves compatibility with
|
||||||
// real-world feed readers.
|
// real-world feed readers.
|
||||||
|
|
|
@ -218,7 +218,7 @@ class TwitterapiAction extends Action
|
||||||
if($attachments){
|
if($attachments){
|
||||||
$entry['enclosures']=array();
|
$entry['enclosures']=array();
|
||||||
foreach($attachments as $attachment){
|
foreach($attachments as $attachment){
|
||||||
if (isset($attachment->filename)) {
|
if ($attachment->isEnclosure()) {
|
||||||
$enclosure=array();
|
$enclosure=array();
|
||||||
$enclosure['url']=$attachment->url;
|
$enclosure['url']=$attachment->url;
|
||||||
$enclosure['mimetype']=$attachment->mimetype;
|
$enclosure['mimetype']=$attachment->mimetype;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user