3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('LACONICA')) { exit(1); }
22 require_once(INSTALLDIR.'/extlib/facebook/facebook.php');
24 class FacebookAction extends Action {
26 function handle($args)
28 parent::handle($args);
31 function get_facebook()
33 $apikey = common_config('facebook', 'apikey');
34 $secret = common_config('facebook', 'secret');
35 return new Facebook($apikey, $secret);
38 function update_profile_box($facebook, $fbuid, $user)
41 $notice = $user->getCurrentNotice();
43 # Need to include inline CSS for styling the Profile box
50 list-style-type: none;
52 border-top: 1px solid #dec5b5;
55 text-decoration: underline;
61 padding: 5px 5px 5px 0;
63 font-family: Georgia, "Times New Roman", Times, serif;
66 border-bottom: 1px solid #dec5b5;
67 background-color:#FCFFF5;
70 .notice_single:hover {
71 background-color: #f7ebcc;
80 $html = $this->render_notice($notice);
82 $fbml = "<fb:wide>$content $html</fb:wide>";
83 $fbml .= "<fb:narrow>$content $html</fb:narrow>";
85 $fbml_main = "<fb:narrow>$content $html</fb:narrow>";
87 $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main);
92 function show_header($selected ='Home')
95 # Add a timestamp to the CSS file so Facebook cache wont ignore our changes
96 $ts = filemtime(theme_file('facebookapp.css'));
97 $cssurl = theme_path('facebookapp.css') . "?ts=$ts";
99 $header = '<link rel="stylesheet" type="text/css" href="'. $cssurl . '" />';
100 # $header .='<script src="" ></script>';
101 $header .= '<fb:dashboard/>';
105 .'<fb:tab-item title="Home" href="index.php" selected="' . ($selected == 'Home') .'" />'
106 .'<fb:tab-item title="Invite Friends" href="invite.php" selected="' . ($selected == 'Invite') . '" />'
107 .'<fb:tab-item title="Settings" href="settings.php" selected="' . ($selected == 'Settings') . '" />'
109 $header .= '<div id="main_body">';
115 function show_footer()
121 function show_login_form()
125 ' <h2>To add the Identi.ca application, you need to log into your Identi.ca account.</h2>'
126 .'<a href="http://identi.ca/">'
127 .' <img src="http://theme.identi.ca/identica/logo.png" alt="Identi.ca" id="logo"/>'
129 .'<h1 class="pagetitle">Login</h1>'
130 .'<div class="instructions">'
131 .' <p>Login with your username and password. Don\'t have a username yet?'
132 .' <a href="http://identi.ca/main/register">Register</a> a new account.'
135 .'<div id="content">'
136 .' <form method="post" id="login">'
138 .' <label for="nickname">Nickname</label>'
139 .' <input name="nickname" type="text" class="input_text" id="nickname"/>'
142 .' <label for="password">Password</label>'
143 .' <input name="password" type="password" class="password" id="password"/>'
146 .' <input type="submit" id="submit" name="submit" class="submit" value="Login"/>'
150 .' <a href="http://identi.ca/main/recoverpassword">Lost or forgotten password?</a>'
157 function render_notice($notice)
162 $profile = $notice->getProfile();
163 $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
165 $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
167 # XXX: we need to figure this out better. Is this right?
168 if (strcmp($notice->uri, $noticeurl) != 0 && preg_match('/^http/', $notice->uri)) {
169 $noticeurl = $notice->uri;
173 '<li class="notice_single" id="' . $notice->id . '">'
174 .'<a href="' . $profile->profileurl . '">'
178 $html .= common_avatar_display_url($avatar);
180 $html .= common_default_avatar(AVATAR_STREAM_SIZE);
184 '" class="avatar stream" width="'
185 . AVATAR_STREAM_SIZE . '" height="' . AVATAR_STREAM_SIZE .'"'
188 if ($profile->fullname) {
189 $html .= $profile->fullname;
191 $html .= $profile->nickname;
196 .'<a href="' . $profile->profileurl . '" class="nickname">' . $profile->nickname . '</a>'
197 .'<p class="content">' . $notice->rendered . '</p>'
199 .'<a class="permalink" href="' . $noticeurl . '" title="' . common_exact_date($notice->created) . '">' . common_date_string($notice->created) . '</a>';
201 if ($notice->source) {
202 $html .= _(' from ');
203 $html .= $this->source_link($notice->source);
206 if ($notice->reply_to) {
207 $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
209 ' (<a class="inreplyto" href="' . $replyurl . '">' . _('in reply to...') . ')';
212 $html .= '</p></li>';
217 function source_link($source)
219 $source_name = _($source);
221 $html = '<span class="noticesource">';
229 $html .= $source_name;
232 $ns = Notice_source::staticGet($source);
234 $html .= '<a href="' . $ns->url . '">' . $ns->name . '</a>';
236 $html .= $source_name;
246 function pagination($have_before, $have_after, $page, $fbaction, $args=null)
251 if ($have_before || $have_after) {
252 $html = '<div id="pagination">';
253 $html .'<ul id="nav_pagination">';
257 $pargs = array('page' => $page-1);
258 $newargs = ($args) ? array_merge($args,$pargs) : $pargs;
259 $html .= '<li class="before">';
260 $html .'<a href="' . $this->pagination_url($fbaction, $newargs) . '">' . _('« After') . '</a>';
265 $pargs = array('page' => $page+1);
266 $newargs = ($args) ? array_merge($args,$pargs) : $pargs;
267 $html .= '<li class="after">';
268 $html .'<a href="' . $this->pagination_url($fbaction, $newargs) . '">' . _('Before »') . '</a>';
272 if ($have_before || $have_after) {
278 function pagination_url($fbaction, $args=null)
285 foreach ($args as $key => $value) {
286 $extra .= "&${key}=${value}";
290 return "$fbaction?${extra}";