summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/facebookaction.php185
1 files changed, 185 insertions, 0 deletions
diff --git a/lib/facebookaction.php b/lib/facebookaction.php
new file mode 100644
index 000000000..5505a12c3
--- /dev/null
+++ b/lib/facebookaction.php
@@ -0,0 +1,185 @@
+<?php
+/*
+ * 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/>.
+ */
+
+if (!defined('LACONICA')) { exit(1); }
+
+require_once(INSTALLDIR.'/extlib/facebook/facebook.php');
+
+class FacebookAction extends Action {
+
+ function handle($args) {
+ parent::handle($args);
+ }
+
+ function get_facebook() {
+ $apikey = common_config('facebook', 'apikey');
+ $secret = common_config('facebook', 'secret');
+ return new Facebook($apikey, $secret);
+ }
+
+
+ # Display methods
+
+ function show_header($selected ='Home') {
+
+ # $header = '<link rel="stylesheet" type="text/css" href="" />';
+ # $header .='<script src="" ></script>';
+ $header .= '<fb:dashboard/>';
+
+ $header .=
+ '<fb:tabs>'
+ .'<fb:tab-item title="Home" href="index.php" selected="' . ($selected == 'Home') .'" />'
+ .'<fb:tab-item title="Invite Friends" href="invite.php" selected="' . ($selected == 'Invite') . '" />'
+ .'<fb:tab-item title="Settings" href="settings.php" selected="' . ($selected == 'Settings') . '" />'
+ .'</fb:tabs>';
+ $header .= '<div id="main_body">';
+
+ echo $header;
+
+ }
+
+ function show_footer() {
+ $footer = '</div>';
+ echo $footer;
+ }
+
+ function show_login_form() {
+
+ $loginform =
+ ' <h2>To add the Identi.ca application, you need to log into your Identi.ca account.</h2>'
+ .'<a href="http://identi.ca/">'
+ .' <img src="http://theme.identi.ca/identica/logo.png" alt="Identi.ca" id="logo"/>'
+ .'</a>'
+ .'<h1 class="pagetitle">Login</h1>'
+ .'<div class="instructions">'
+ .' <p>Login with your username and password. Don\'t have a username yet?'
+ .' <a href="http://identi.ca/main/register">Register</a> a new account.'
+ .' </p>'
+ .'</div>'
+ .'<div id="content">'
+ .' <form method="post" id="login">'
+ .' <p>'
+ .' <label for="nickname">Nickname</label>'
+ .' <input name="nickname" type="text" class="input_text" id="nickname"/>'
+ .' </p>'
+ .' <p>'
+ .' <label for="password">Password</label>'
+ .' <input name="password" type="password" class="password" id="password"/>'
+ .' </p>'
+ .' <p>'
+ .' <input type="submit" id="submit" name="submit" class="submit" value="Login"/>'
+ .' </p>'
+ .' </form>'
+ .' <p>'
+ .' <a href="http://identi.ca/main/recoverpassword">Lost or forgotten password?</a>'
+ .' </p>'
+ .'</div';
+
+ echo $loginform;
+ }
+
+ function render_notice($notice) {
+
+ global $config;
+
+ $profile = $notice->getProfile();
+ $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
+
+ $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
+
+ # XXX: we need to figure this out better. Is this right?
+ if (strcmp($notice->uri, $noticeurl) != 0 && preg_match('/^http/', $notice->uri)) {
+ $noticeurl = $notice->uri;
+ }
+
+ $html =
+ '<li class="notice_single" id="' . $notice->id . '">'
+ .'<a href="' . $profile->profileurl . '">'
+ .'<img src="';
+
+ if ($avatar) {
+ $html .= common_avatar_display_url($avatar);
+ } else {
+ $html .= common_default_avatar(AVATAR_STREAM_SIZE);
+ }
+
+ $html .=
+ '" class="avatar stream" width="'
+ . AVATAR_STREAM_SIZE . '" height="' . AVATAR_STREAM_SIZE .'"'
+ .' alt="';
+
+ if ($profile->fullname) {
+ $html .= $profile->fullname;
+ } else {
+ $html .= $profile->nickname;
+ }
+
+ $html .=
+ '"></a>'
+ .'<a href="' . $profile->profileurl . '" class="nickname">' . $profile->nickname . '</a>'
+ .'<p class="content">' . $notice->rendered . '</p>'
+ .'<p class="time">'
+ .'<a class="permalink" href="' . $noticeurl . '" title="' . common_exact_date($notice->created) . '">' . common_date_string($notice->created) . '</a>';
+
+ if ($notice->source) {
+ $html .= _(' from ');
+ $html .= $this->source_link($notice->source);
+ }
+
+ if ($notice->reply_to) {
+ $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
+ $html .=
+ ' (<a class="inreplyto" href="' . $replyurl . '">' . _('in reply to...') . ')';
+ }
+
+ $html .= '</p></li>';
+
+ return $html;
+ }
+
+ function source_link($source) {
+ $source_name = _($source);
+
+ $html = '<span class="noticesource">';
+
+ switch ($source) {
+ case 'web':
+ case 'xmpp':
+ case 'mail':
+ case 'omb':
+ case 'api':
+ $html .= $source_name;
+ break;
+ default:
+ $ns = Notice_source::staticGet($source);
+ if ($ns) {
+ $html .= '<a href="' . $ns->url . '">' . $ns->name . '</a>';
+ } else {
+ $html .= $source_name;
+ }
+ break;
+ }
+
+ $html .= '</span>';
+
+ return $html;
+ }
+
+
+}