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) {
27 parent::handle($args);
30 function get_facebook() {
31 $apikey = common_config('facebook', 'apikey');
32 $secret = common_config('facebook', 'secret');
33 return new Facebook($apikey, $secret);
39 function show_header($selected ='Home') {
41 $header = '<link rel="stylesheet" type="text/css" href="'. theme_path('facebookapp.css') . '" />';
42 # $header .='<script src="" ></script>';
43 $header .= '<fb:dashboard/>';
47 .'<fb:tab-item title="Home" href="index.php" selected="' . ($selected == 'Home') .'" />'
48 .'<fb:tab-item title="Invite Friends" href="invite.php" selected="' . ($selected == 'Invite') . '" />'
49 .'<fb:tab-item title="Settings" href="settings.php" selected="' . ($selected == 'Settings') . '" />'
51 $header .= '<div id="main_body">';
57 function show_footer() {
62 function show_login_form() {
65 ' <h2>To add the Identi.ca application, you need to log into your Identi.ca account.</h2>'
66 .'<a href="http://identi.ca/">'
67 .' <img src="http://theme.identi.ca/identica/logo.png" alt="Identi.ca" id="logo"/>'
69 .'<h1 class="pagetitle">Login</h1>'
70 .'<div class="instructions">'
71 .' <p>Login with your username and password. Don\'t have a username yet?'
72 .' <a href="http://identi.ca/main/register">Register</a> a new account.'
76 .' <form method="post" id="login">'
78 .' <label for="nickname">Nickname</label>'
79 .' <input name="nickname" type="text" class="input_text" id="nickname"/>'
82 .' <label for="password">Password</label>'
83 .' <input name="password" type="password" class="password" id="password"/>'
86 .' <input type="submit" id="submit" name="submit" class="submit" value="Login"/>'
90 .' <a href="http://identi.ca/main/recoverpassword">Lost or forgotten password?</a>'
97 function render_notice($notice) {
101 $profile = $notice->getProfile();
102 $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
104 $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
106 # XXX: we need to figure this out better. Is this right?
107 if (strcmp($notice->uri, $noticeurl) != 0 && preg_match('/^http/', $notice->uri)) {
108 $noticeurl = $notice->uri;
112 '<li class="notice_single" id="' . $notice->id . '">'
113 .'<a href="' . $profile->profileurl . '">'
117 $html .= common_avatar_display_url($avatar);
119 $html .= common_default_avatar(AVATAR_STREAM_SIZE);
123 '" class="avatar stream" width="'
124 . AVATAR_STREAM_SIZE . '" height="' . AVATAR_STREAM_SIZE .'"'
127 if ($profile->fullname) {
128 $html .= $profile->fullname;
130 $html .= $profile->nickname;
135 .'<a href="' . $profile->profileurl . '" class="nickname">' . $profile->nickname . '</a>'
136 .'<p class="content">' . $notice->rendered . '</p>'
138 .'<a class="permalink" href="' . $noticeurl . '" title="' . common_exact_date($notice->created) . '">' . common_date_string($notice->created) . '</a>';
140 if ($notice->source) {
141 $html .= _(' from ');
142 $html .= $this->source_link($notice->source);
145 if ($notice->reply_to) {
146 $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
148 ' (<a class="inreplyto" href="' . $replyurl . '">' . _('in reply to...') . ')';
151 $html .= '</p></li>';
156 function source_link($source) {
157 $source_name = _($source);
159 $html = '<span class="noticesource">';
167 $html .= $source_name;
170 $ns = Notice_source::staticGet($source);
172 $html .= '<a href="' . $ns->url . '">' . $ns->name . '</a>';
174 $html .= $source_name;
184 function pagination($have_before, $have_after, $page, $fbaction, $args=NULL) {
188 if ($have_before || $have_after) {
189 $html = '<div id="pagination">';
190 $html .'<ul id="nav_pagination">';
194 $pargs = array('page' => $page-1);
195 $newargs = ($args) ? array_merge($args,$pargs) : $pargs;
196 $html .= '<li class="before">';
197 $html .'<a href="' . $this->pagination_url($fbaction, $newargs) . '">' . _('« After') . '</a>';
202 $pargs = array('page' => $page+1);
203 $newargs = ($args) ? array_merge($args,$pargs) : $pargs;
204 $html .= '<li class="after">';
205 $html .'<a href="' . $this->pagination_url($fbaction, $newargs) . '">' . _('Before »') . '</a>';
209 if ($have_before || $have_after) {
215 function pagination_url($fbaction, $args=NULL) {
221 foreach ($args as $key => $value) {
222 $extra .= "&${key}=${value}";
226 return "$fbaction?${extra}";