From 4f5630099fd0042170350f18512dc2cbe3b896b2 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 4 Jun 2009 21:33:04 +0000 Subject: [PATCH 1/6] Facebook Connect auth finally works with all major browsers! --- plugins/FBConnect/FBC_XDReceiver.php | 73 +++++++++++++++++++++++++++ plugins/FBConnect/FBConnectLogin.php | 2 - plugins/FBConnect/FBConnectPlugin.php | 65 ++++++++++++++---------- plugins/FBConnect/xd_receiver.htm | 10 ---- 4 files changed, 111 insertions(+), 39 deletions(-) create mode 100644 plugins/FBConnect/FBC_XDReceiver.php delete mode 100644 plugins/FBConnect/xd_receiver.htm diff --git a/plugins/FBConnect/FBC_XDReceiver.php b/plugins/FBConnect/FBC_XDReceiver.php new file mode 100644 index 0000000000..57c98b4f14 --- /dev/null +++ b/plugins/FBConnect/FBC_XDReceiver.php @@ -0,0 +1,73 @@ +showPage(); + } + + function showPage() + { + // cache the xd_receiver + header('Cache-Control: max-age=225065900'); + header('Expires:'); + header('Pragma:'); + + $this->startXML('html', + '-//W3C//DTD XHTML 1.0 Strict//EN', + 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'); + + $language = $this->getLanguage(); + + $this->elementStart('html', array('xmlns' => 'http://www.w3.org/1999/xhtml', + 'xml:lang' => $language, + 'lang' => $language)); + $this->elementStart('head'); + $this->element('title', null, 'cross domain receiver page'); + $this->element('script', + array('src' => + 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.debug.js', + 'type' => 'text/javascript'), ''); + $this->elementEnd('head'); + $this->elementStart('body'); + $this->elementEnd('body'); + + $this->elementEnd('html'); + } + +} + diff --git a/plugins/FBConnect/FBConnectLogin.php b/plugins/FBConnect/FBConnectLogin.php index 7989dc854d..205086cd8b 100644 --- a/plugins/FBConnect/FBConnectLogin.php +++ b/plugins/FBConnect/FBConnectLogin.php @@ -58,8 +58,6 @@ class FBConnectLoginAction extends Action function showContent() { $this->elementStart('fieldset'); - - $this->element('fb:login-button', array('onlogin' => 'goto_login()', 'length' => 'long')); diff --git a/plugins/FBConnect/FBConnectPlugin.php b/plugins/FBConnect/FBConnectPlugin.php index c85ef432d4..a366985be4 100644 --- a/plugins/FBConnect/FBConnectPlugin.php +++ b/plugins/FBConnect/FBConnectPlugin.php @@ -39,6 +39,7 @@ require_once INSTALLDIR . '/plugins/FBConnect/FBConnectLogin.php'; require_once INSTALLDIR . '/plugins/FBConnect/FBConnectSettings.php'; require_once INSTALLDIR . '/plugins/FBConnect/FBCLoginGroupNav.php'; require_once INSTALLDIR . '/plugins/FBConnect/FBCSettingsNav.php'; +require_once INSTALLDIR . '/plugins/FBConnect/FBC_XDReceiver.php'; /** * Plugin to enable Facebook Connect @@ -62,27 +63,19 @@ class FBConnectPlugin extends Plugin $m->connect('main/facebookconnect', array('action' => 'FBConnectAuth')); $m->connect('main/facebooklogin', array('action' => 'FBConnectLogin')); $m->connect('settings/facebook', array('action' => 'FBConnectSettings')); + $m->connect('xd_receiver.html', array('action' => 'FBC_XDReceiver')); } // Add in xmlns:fb function onStartShowHTML($action) { - $httpaccept = isset($_SERVER['HTTP_ACCEPT']) ? - $_SERVER['HTTP_ACCEPT'] : null; - - // XXX: allow content negotiation for RDF, RSS, or XRDS - - $cp = common_accept_to_prefs($httpaccept); - $sp = common_accept_to_prefs(PAGE_TYPE_PREFS); - - $type = common_negotiate_type($cp, $sp); - - if (!$type) { - throw new ClientException(_('This page is not available in a '. - 'media type you accept'), 406); - } - - header('Content-Type: '.$type); + // XXX: Horrible hack to make Safari, FF2, and Chrome work with + // Facebook Connect. These browser cannot use Facebook's + // DOM parsing routines unless the mime type of the page is + // text/html even though Facebook Connect uses XHTML. This is + // A bug in Facebook Connect, and this is a temporary solution + // until they fix their JavaScript libs. + header('Content-Type: text/html'); $action->extraHeaders(); @@ -101,20 +94,27 @@ class FBConnectPlugin extends Plugin return false; } - function onEndShowLaconicaScripts($action) - { - $action->element('script', - array('type' => 'text/javascript', - 'src' => 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php'), - ' '); + // Note: this script needs to appear in the + function onStartShowHeader($action) + { $apikey = common_config('facebook', 'apikey'); $plugin_path = common_path('plugins/FBConnect'); $login_url = common_local_url('FBConnectAuth'); $logout_url = common_local_url('logout'); - $html = sprintf('', $apikey, $plugin_path, $login_url, $logout_url); - + ', $apikey, + $login_url, $logout_url); $action->raw($html); } + // Note: this script needs to appear as close as possible to + + function onEndShowFooter($action) + { + + $action->element('script', + array('type' => 'text/javascript', + 'src' => 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php'), + ''); + } + function onEndShowLaconicaStyles($action) { $action->element('link', array('rel' => 'stylesheet', @@ -143,7 +153,8 @@ class FBConnectPlugin extends Plugin if ($user) { - $flink = Foreign_link::getByUserId($user->id, FACEBOOK_CONNECT_SERVICE); + $flink = Foreign_link::getByUserId($user->id, + FACEBOOK_CONNECT_SERVICE); $fbuid = 0; if ($flink) { diff --git a/plugins/FBConnect/xd_receiver.htm b/plugins/FBConnect/xd_receiver.htm deleted file mode 100644 index 43fb2c4e48..0000000000 --- a/plugins/FBConnect/xd_receiver.htm +++ /dev/null @@ -1,10 +0,0 @@ - - - - cross domain receiver page - - - - - From b708b81065b4adc46026e570d8e2cb9d37bc24af Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 5 Jun 2009 00:00:04 -0400 Subject: [PATCH 2/6] Init notice_data-attach UI for form_notice --- js/util.js | 11 ----------- lib/noticeform.php | 1 - theme/base/css/display.css | 16 ++++++++++++++++ theme/identica/css/display.css | 7 +++++++ 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/js/util.js b/js/util.js index bffbf916fa..b712ba8e2b 100644 --- a/js/util.js +++ b/js/util.js @@ -17,17 +17,6 @@ */ $(document).ready(function(){ - $('input#notice_data-attach').toggle(); - $('label[for=notice_data-attach]').text('Upload a file as an attachment?'); - $('label[for=notice_data-attach]').click(function () { - if ('Upload a file as an attachment?' == $(this).text()) { - $(this).text('Upload: '); - $('input#notice_data-attach').slideDown('fast'); - } else { - $('input#notice_data-attach').slideUp('fast', function() {$('label[for=notice_data-attach]').text('Upload a file as an attachment?');}); - } - }); - // count character on keyup function counter(event){ var maxLength = 140; diff --git a/lib/noticeform.php b/lib/noticeform.php index 805cd56b13..5a6c7cf38c 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -148,7 +148,6 @@ class NoticeForm extends Form $this->out->element('dd', array('id' => 'notice_text-count'), '140'); $this->out->elementEnd('dl'); - $this->out->element('br', array('style' => 'clear:both')); $this->out->element('label', array('for' => 'notice_data-attach'), _('Attach')); $this->out->element('input', array('id' => 'notice_data-attach', 'type' => 'file', diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 7d495c5395..7eea54eb2a 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -452,6 +452,22 @@ float:left; font-size:1.3em; margin-bottom:7px; } +#form_notice label[for=notice_data-attach] { +text-indent:-9999px; +display:block; +} +#form_notice label[for=notice_data-attach], +#form_notice #notice_data-attach { +position:absolute; +top:25px; +right:49px; +width:16px; +height:16px; +cursor:pointer; +} +#form_notice #notice_data-attach { +text-indent:-279px; +} #form_notice #notice_submit label { display:none; } diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index 1f1298737c..8a03a4d772 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -82,6 +82,13 @@ color:#333; #form_notice.warning #notice_text-count { color:#000; } +#form_notice label[for=notice_data-attach] { +background:transparent url(../../base/images/icons/twotone/green/clip-01.gif) no-repeat 0 45%; +} +#form_notice #notice_data-attach { +opacity:0; +} + #form_notice.processing #notice_action-submit { background:#fff url(../../base/images/icons/icon_processing.gif) no-repeat 47% 47%; cursor:wait; From 1a126032efbcb265a59f4d682bd072251f857c97 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 5 Jun 2009 12:33:46 -0400 Subject: [PATCH 3/6] Adding clip illustration for notice attachments. --- theme/base/images/icons/twotone/green/clip-01.gif | Bin 0 -> 78 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 theme/base/images/icons/twotone/green/clip-01.gif diff --git a/theme/base/images/icons/twotone/green/clip-01.gif b/theme/base/images/icons/twotone/green/clip-01.gif new file mode 100644 index 0000000000000000000000000000000000000000..f2dee7e5e9f0f5f9f99d771128fe88d5b9ae178a GIT binary patch literal 78 zcmZ?wbhEHb6krfwSjfom|NsB^DFP6r_>+Z^fq{uZhXDvc@(fJ!A$>EKz2#SC31Mp} aI1*E48~aGD>3n+Tvh>*O-3Oc)8LR Date: Tue, 9 Jun 2009 17:34:33 +0000 Subject: [PATCH 4/6] Added title and minor CSS cleanup to notice attach --- lib/noticeform.php | 3 ++- theme/base/css/display.css | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/noticeform.php b/lib/noticeform.php index 5a6c7cf38c..5d7cf194ee 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -151,7 +151,8 @@ class NoticeForm extends Form $this->out->element('label', array('for' => 'notice_data-attach'), _('Attach')); $this->out->element('input', array('id' => 'notice_data-attach', 'type' => 'file', - 'name' => 'attach')); + 'name' => 'attach', + 'title' => _('Attach a file'))); if ($this->action) { $this->out->hidden('notice_return-to', $this->action, 'returnto'); } diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 7eea54eb2a..dc275e19f7 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -454,7 +454,6 @@ margin-bottom:7px; } #form_notice label[for=notice_data-attach] { text-indent:-9999px; -display:block; } #form_notice label[for=notice_data-attach], #form_notice #notice_data-attach { From 6af79f47557807dea741f9d31132e5123119a0ad Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 9 Jun 2009 17:49:24 +0000 Subject: [PATCH 5/6] Updated default stylesheet for notice attach --- theme/default/css/display.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/theme/default/css/display.css b/theme/default/css/display.css index e08a4783bd..34f6b3b8a6 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -82,6 +82,13 @@ color:#333; #form_notice.warning #notice_text-count { color:#000; } +#form_notice label[for=notice_data-attach] { +background:transparent url(../../base/images/icons/twotone/green/clip-01.gif) no-repeat 0 45%; +} +#form_notice #notice_data-attach { +opacity:0; +} + #form_notice.processing #notice_action-submit { background:#fff url(../../base/images/icons/icon_processing.gif) no-repeat 47% 47%; cursor:wait; From 388677a6a684754a7dbde13551ab1bffff4d1164 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 9 Jun 2009 17:59:08 +0000 Subject: [PATCH 6/6] Updated notice attach UI for biz theme. --- theme/biz/css/base.css | 21 +++++++++++++++++++++ theme/biz/css/display.css | 7 +++++++ 2 files changed, 28 insertions(+) diff --git a/theme/biz/css/base.css b/theme/biz/css/base.css index 0e37a6ee4e..696fd0645b 100644 --- a/theme/biz/css/base.css +++ b/theme/biz/css/base.css @@ -446,6 +446,27 @@ float:left; font-size:1.3em; margin-bottom:7px; } +#form_notice label { +display:block; +float:left; +font-size:1.3em; +margin-bottom:7px; +} +#form_notice label[for=notice_data-attach] { +text-indent:-9999px; +} +#form_notice label[for=notice_data-attach], +#form_notice #notice_data-attach { +position:absolute; +top:25px; +right:49px; +width:16px; +height:16px; +cursor:pointer; +} +#form_notice #notice_data-attach { +text-indent:-279px; +} #form_notice #notice_submit label { display:none; } diff --git a/theme/biz/css/display.css b/theme/biz/css/display.css index 14092d964e..3af4c06b91 100644 --- a/theme/biz/css/display.css +++ b/theme/biz/css/display.css @@ -102,6 +102,13 @@ color:#333; #form_notice.warning #notice_text-count { color:#000; } +#form_notice label[for=notice_data-attach] { +background:transparent url(../../base/images/icons/twotone/green/clip-01.gif) no-repeat 0 45%; +} +#form_notice #notice_data-attach { +opacity:0; +} + #form_notice.processing #notice_action-submit { background:#fff url(../../base/images/icons/icon_processing.gif) no-repeat 47% 47%; cursor:wait;