trac750 Javascript file for Facebook app

This commit is contained in:
Zach Copley 2009-01-18 06:12:47 +00:00
parent 3e18c2f0f8
commit 8fdf888edb
4 changed files with 53 additions and 14 deletions

View File

@ -68,19 +68,18 @@ class FacebooksettingsAction extends FacebookAction
$this->showHeader('Settings', $msg, $success); $this->showHeader('Settings', $msg, $success);
common_element_start('fb:if-section-not-added', array('section' => 'profile')); common_element('form', array('id' => 'redirect_form',
common_element('h2', null, _('Add an Identi.ca box to my profile')); 'style' => 'display: none;'));
common_element_start('p'); common_element_start('p');
common_element('fb:add-section-button', array('section' => 'profile')); common_element_start('fb:prompt-permission', array('perms' => 'status_update',
common_element_end('p'); 'next_fbjs' => 'redirectSettings()'));
common_element_end('fb:if-section-not-added');
common_element_start('p');
common_element_start('fb:prompt-permission', array('perms' => 'status_update'));
common_element('h2', null, _('Allow Identi.ca to update my Facebook status')); common_element('h2', null, _('Allow Identi.ca to update my Facebook status'));
common_element_end('fb:prompt-permission'); common_element_end('fb:prompt-permission');
common_element_end('p'); common_element_end('p');
if ($facebook->api_client->users_hasAppPermission('status_update')) { if ($facebook->api_client->users_hasAppPermission('status_update')) {
common_element_start('form', array('method' => 'post', common_element_start('form', array('method' => 'post',
@ -94,8 +93,6 @@ class FacebooksettingsAction extends FacebookAction
common_checkbox('replysync', _('Send local "@" replies to Facebook.'), common_checkbox('replysync', _('Send local "@" replies to Facebook.'),
($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true); ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true);
// function common_input($id, $label, $value=null,$instructions=null)
$prefix = $facebook->api_client->data_getUserPreference(1); $prefix = $facebook->api_client->data_getUserPreference(1);

25
js/facebookapp.js Normal file
View File

@ -0,0 +1,25 @@
/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Psycho Facebook redirect hack, used because 'document.location'
// simply does not work in FBJS
function redirectSettings() {
form = document.getElementById('redirect_form');
form.setAction('settings.php');
form.submit();
}

View File

@ -37,7 +37,11 @@ class FacebookAction extends Action
common_element('link', array('rel' => 'stylesheet', common_element('link', array('rel' => 'stylesheet',
'type' => 'text/css', 'type' => 'text/css',
'href' => get_facebook_css())); 'href' => getFacebookCSS()));
common_element('script', array('type' => 'text/javascript',
'src' => getFacebookJS()),
' ');
common_element_start('a', array('class' => 'url home bookmark', common_element_start('a', array('class' => 'url home bookmark',
'href' => common_local_url('public'))); 'href' => common_local_url('public')));
@ -58,6 +62,12 @@ class FacebookAction extends Action
start_fbml(); start_fbml();
common_element_start('fb:if-section-not-added', array('section' => 'profile'));
common_element_start('span', array('id' => 'add_to_profile'));
common_element('fb:add-section-button', array('section' => 'profile'));
common_element_end('span');
common_element_end('fb:if-section-not-added');
$this->showLogo(); $this->showLogo();
common_element_start('dl', array("id" => 'site_nav_local_views')); common_element_start('dl', array("id" => 'site_nav_local_views'));
@ -141,8 +151,7 @@ class FacebookAction extends Action
common_element('link', array('rel' => 'stylesheet', common_element('link', array('rel' => 'stylesheet',
'type' => 'text/css', 'type' => 'text/css',
'href' => get_facebook_css())); 'href' => getFacebookCSS()));
$this->showLogo(); $this->showLogo();

View File

@ -105,7 +105,7 @@ function update_profile_box($facebook, $fbuid, $user, $notice)
$facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main); $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main);
} }
function get_facebook_css() function getFacebookCSS()
{ {
# Add a timestamp to the CSS file so Facebook cache wont ignore our changes # Add a timestamp to the CSS file so Facebook cache wont ignore our changes
$ts = filemtime(theme_file('facebookapp.css')); $ts = filemtime(theme_file('facebookapp.css'));
@ -113,6 +113,14 @@ function get_facebook_css()
return $cssurl; return $cssurl;
} }
function getFacebookJS() {
# Add a timestamp to the FBJS file so Facebook cache wont ignore our changes
$ts = filemtime(INSTALLDIR.'/js/facebookapp.js');
$jsurl = common_path('js/facebookapp.js') . "?ts=$ts";
return $jsurl;
}
class FacebookNoticeList extends NoticeList class FacebookNoticeList extends NoticeList
{ {