summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-08-26 15:40:51 -0400
committerCraig Andrews <candrews@integralblue.com>2009-08-26 15:40:51 -0400
commit6d60d74093005992701418edda5be4422e46262f (patch)
tree73db603d3b8573a8ef374a21c70c4adae58165a7 /classes
parentd9e8dabaf4c5b38712a3e3ce97b45c5effee4bad (diff)
Display linked oembed resources as enclosures if they are of non-html mime types
Diffstat (limited to 'classes')
-rw-r--r--classes/File.php50
-rw-r--r--classes/Notice.php9
2 files changed, 46 insertions, 13 deletions
diff --git a/classes/File.php b/classes/File.php
index b2c510340..1c64b4d33 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -195,17 +195,49 @@ class File extends Memcached_DataObject
return 'http://'.$server.$path.$filename;
}
- function isEnclosure(){
+ function getEnclosure(){
+ $enclosure = (object) array();
+ $enclosure->title=$this->title;
+ $enclosure->url=$this->url;
+ $enclosure->title=$this->title;
+ $enclosure->date=$this->date;
+ $enclosure->modified=$this->modified;
+ $enclosure->size=$this->size;
+ $enclosure->mimetype=$this->mimetype;
+
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 $enclosure;
+ }else{
+ $notEnclosureMimeTypes = array('text/html','application/xhtml+xml');
+ $mimetype = strtolower($this->mimetype);
+ $semicolon = strpos($mimetype,';');
+ if($semicolon){
+ $mimetype = substr($mimetype,0,$semicolon);
+ }
+ if(in_array($mimetype,$notEnclosureMimeTypes)){
+ $ombed = File_oembed::staticGet('file_id',$this->id);
+ if($oembed){
+ $mimetype = strtolower($ombed->mimetype);
+ $semicolon = strpos($mimetype,';');
+ if($semicolon){
+ $mimetype = substr($mimetype,0,$semicolon);
+ }
+ if(in_array($mimetype,$notEnclosureMimeTypes)){
+ return false;
+ }else{
+ if($ombed->mimetype) $enclosure->mimetype=$ombed->mimetype;
+ if($ombed->url) $enclosure->url=$ombed->url;
+ if($ombed->title) $enclosure->title=$ombed->title;
+ if($ombed->modified) $enclosure->modified=$ombed->modified;
+ unset($ombed->size);
+ }
+ }else{
+ return $enclosure;
+ }
+ }else{
+ return $enclosure;
+ }
}
- return(! in_array($mimetype,$notEnclosureMimeTypes));
}
}
diff --git a/classes/Notice.php b/classes/Notice.php
index 48d4a0940..c4f163c31 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -1199,10 +1199,11 @@ class Notice extends Memcached_DataObject
$attachments = $this->attachments();
if($attachments){
foreach($attachments as $attachment){
- if ($attachment->isEnclosure()) {
- $attributes = array('rel'=>'enclosure','href'=>$attachment->url,'type'=>$attachment->mimetype,'length'=>$attachment->size);
- if($attachment->title){
- $attributes['title']=$attachment->title;
+ $enclosure=$attachment->getEnclosure();
+ if ($enclosure) {
+ $attributes = array('rel'=>'enclosure','href'=>$enclosure->url,'type'=>$enclosure->mimetype,'length'=>$enclosure->size);
+ if($enclosure->title){
+ $attributes['title']=$enclosure->title;
}
$xs->element('link', $attributes, null);
}