summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-08-27 14:52:32 -0700
committerEvan Prodromou <evan@status.net>2009-08-27 14:52:32 -0700
commita08c76a4342cfb4b3d772f6880ba0b8f3153b246 (patch)
treee2ba9ef2f670d01cf700a732d36050fe3ce63774 /lib
parent522008dee570aafcc844bf123d25203c7d9c3ebc (diff)
parenteb667d09d9c6ef5a1465a5f8d824661a9387a4da (diff)
Merge branch '0.9.x' of git@gitorious.org:laconica/mainline into 0.9.x
Conflicts: classes/laconica.ini
Diffstat (limited to 'lib')
-rw-r--r--lib/facebookaction.php1
-rw-r--r--lib/facebookutil.php39
-rw-r--r--lib/rssaction.php23
-rw-r--r--lib/twitterapi.php9
4 files changed, 46 insertions, 26 deletions
diff --git a/lib/facebookaction.php b/lib/facebookaction.php
index b86276a0a..411f79594 100644
--- a/lib/facebookaction.php
+++ b/lib/facebookaction.php
@@ -95,6 +95,7 @@ class FacebookAction extends Action
function showStylesheets()
{
$this->cssLink('css/display.css', 'base');
+ $this->cssLink('css/display.css',null,'screen, projection, tv');
$this->cssLink('css/facebookapp.css', 'base');
}
diff --git a/lib/facebookutil.php b/lib/facebookutil.php
index 36b745279..f5121609d 100644
--- a/lib/facebookutil.php
+++ b/lib/facebookutil.php
@@ -109,7 +109,6 @@ function facebookBroadcastNotice($notice)
$can_update = $facebook->api_client->users_hasAppPermission('status_update',
$fbuid);
-
if (!empty($attachments) && $can_publish == 1) {
$fbattachment = format_attachments($attachments);
$facebook->api_client->stream_publish($status, $fbattachment,
@@ -178,20 +177,42 @@ function format_attachments($attachments)
$fbattachment = array();
$fbattachment['media'] = array();
- // Facebook only supports one attachment per item
+ foreach($attachments as $attachment)
+ {
+ if($enclosure = $attachment->getEnclosure()){
+ $fbmedia = get_fbmedia_for_attachment($enclosure);
+ }else{
+ $fbmedia = get_fbmedia_for_attachment($attachment);
+ }
+ if($fbmedia){
+ $fbattachment['media'][]=$fbmedia;
+ }else{
+ $fbattachment['name'] = ($attachment->title ?
+ $attachment->title : $attachment->url);
+ $fbattachment['href'] = $attachment->url;
+ }
+ }
+ if(count($fbattachment['media'])>0){
+ unset($fbattachment['name']);
+ unset($fbattachment['href']);
+ }
+ return $fbattachment;
+}
- $attachment = $attachments[0];
+/**
+* given an File objects, returns an associative array suitable for Facebook media
+*/
+function get_fbmedia_for_attachment($attachment)
+{
$fbmedia = array();
if (strncmp($attachment->mimetype, 'image/', strlen('image/')) == 0) {
$fbmedia['type'] = 'image';
$fbmedia['src'] = $attachment->url;
$fbmedia['href'] = $attachment->url;
- $fbattachment['media'][] = $fbmedia;
} else if ($attachment->mimetype == 'audio/mpeg') {
$fbmedia['type'] = 'mp3';
$fbmedia['src'] = $attachment->url;
- $fbattachment['media'][] = $fbmedia;
}else if ($attachment->mimetype == 'application/x-shockwave-flash') {
$fbmedia['type'] = 'flash';
@@ -200,14 +221,10 @@ function format_attachments($attachments)
// $fbmedia['imgsrc']='';
$fbmedia['swfsrc'] = $attachment->url;
- $fbattachment['media'][] = $fbmedia;
}else{
- $fbattachment['name'] = ($attachment->title ?
- $attachment->title : $attachment->url);
- $fbattachment['href'] = $attachment->url;
+ return false;
}
-
- return $fbattachment;
+ return $fbmedia;
}
function remove_facebook_app($flink)
diff --git a/lib/rssaction.php b/lib/rssaction.php
index 60611e48d..dd0f1005a 100644
--- a/lib/rssaction.php
+++ b/lib/rssaction.php
@@ -258,26 +258,27 @@ class Rss10Action extends Action
$attachments = $notice->attachments();
if($attachments){
foreach($attachments as $attachment){
- if ($attachment->isEnclosure()) {
+ $enclosure=$attachment->getEnclosure();
+ if ($enclosure) {
// DO NOT move xmlns declaration to root element. Making it
// the default namespace here improves compatibility with
// real-world feed readers.
$attribs = array(
- 'rdf:resource' => $attachment->url,
- 'url' => $attachment->url,
+ 'rdf:resource' => $enclosure->url,
+ 'url' => $enclosure->url,
'xmlns' => 'http://purl.oclc.org/net/rss_2.0/enc#'
);
- if ($attachment->title) {
- $attribs['dc:title'] = $attachment->title;
+ if ($enclosure->title) {
+ $attribs['dc:title'] = $enclosure->title;
}
- if ($attachment->modified) {
- $attribs['dc:date'] = common_date_w3dtf($attachment->modified);
+ if ($enclosure->modified) {
+ $attribs['dc:date'] = common_date_w3dtf($enclosure->modified);
}
- if ($attachment->size) {
- $attribs['length'] = $attachment->size;
+ if ($enclosure->size) {
+ $attribs['length'] = $enclosure->size;
}
- if ($attachment->mimetype) {
- $attribs['type'] = $attachment->mimetype;
+ if ($enclosure->mimetype) {
+ $attribs['type'] = $enclosure->mimetype;
}
$this->element('enclosure', $attribs);
}
diff --git a/lib/twitterapi.php b/lib/twitterapi.php
index c8099978f..9055d8b98 100644
--- a/lib/twitterapi.php
+++ b/lib/twitterapi.php
@@ -274,11 +274,12 @@ class TwitterapiAction extends Action
$enclosures = array();
foreach ($attachments as $attachment) {
- if ($attachment->isEnclosure()) {
+ $enclosure_o=$attachment->getEnclosure();
+ if ($enclosure_o) {
$enclosure = array();
- $enclosure['url'] = $attachment->url;
- $enclosure['mimetype'] = $attachment->mimetype;
- $enclosure['size'] = $attachment->size;
+ $enclosure['url'] = $enclosure_o->url;
+ $enclosure['mimetype'] = $enclosure_o->mimetype;
+ $enclosure['size'] = $enclosure_o->size;
$enclosures[] = $enclosure;
}
}