]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/facebookaction.php
trac750 - Facebook app now uses XMLWriter for output (much cleaner!)
[quix0rs-gnu-social.git] / lib / facebookaction.php
1 <?php
2 /*
3  * Laconica - a distributed open-source microblogging tool
4  * Copyright (C) 2008, Controlez-Vous, Inc.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 if (!defined('LACONICA')) { exit(1); }
21
22 require_once(INSTALLDIR.'/lib/facebookutil.php');
23
24 class FacebookAction extends Action
25 {
26
27     function handle($args)
28     {
29         parent::handle($args);
30     }
31
32     function update_profile_box($facebook, $fbuid, $user)
33     {
34
35         $notice = $user->getCurrentNotice();
36
37         # Need to include inline CSS for styling the Profile box
38
39          $style = '<style>
40          #notices {
41          clear: both;
42          margin: 0 auto;
43          padding: 0;
44          list-style-type: none;
45          width: 600px;
46          border-top: 1px solid #dec5b5;
47          }
48          #notices a:hover {
49          text-decoration: underline;
50          }
51          .notice_single {
52          clear: both;
53          display: block;
54          margin: 0;
55          padding: 5px 5px 5px 0;
56          min-height: 48px;
57          font-family: Georgia, "Times New Roman", Times, serif;
58          font-size: 13px;
59          line-height: 16px;
60          border-bottom: 1px solid #dec5b5;
61          background-color:#FCFFF5;
62          opacity:1;
63          }
64          .notice_single:hover {
65          background-color: #f7ebcc;
66          }
67          .notice_single p {
68          display: inline;
69          margin: 0;
70          padding: 0;
71          }
72          </style>';
73
74         $html = Facebookaction::render_notice($notice);
75
76
77         $fbml = "<fb:wide>$style $html</fb:wide>";
78         $fbml .= "<fb:narrow>$style $html</fb:narrow>";
79
80         $fbml_main = "<fb:narrow>$style $html</fb:narrow>";
81
82         $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main);
83     }
84
85     # Display methods
86
87     function show_header($selected = 'Home', $msg = null, $success = false)
88     {
89
90         start_fbml();
91
92         # Add a timestamp to the CSS file so Facebook cache wont ignore our changes
93         $ts = filemtime(theme_file('facebookapp.css'));
94         $cssurl = theme_path('facebookapp.css') . "?ts=$ts";
95
96         common_element('link', array('rel' => 'stylesheet',
97                                      'type' => 'text/css',
98                                      'href' => $cssurl));
99
100         common_element('fb:dashboard');
101
102         common_element_start('fb:tabs');
103         common_element('fb:tab-item', array('title' => 'Home',
104                                             'href' => 'index.php',
105                                             'selected' => ($selected == 'Home')));
106         common_element('fb:tab-item', array('title' => 'Invite Friends',
107                                             'href' => 'invite.php',
108                                             'selected' => ($selected == 'Invite')));
109         common_element('fb:tab-item', array('title' => 'Settings',
110                                             'href' => 'settings.php',
111                                             'selected' => ($selected == 'Settings')));
112         common_element_end('fb:tabs');
113
114
115         if ($msg) {
116             if ($success) {
117                 common_element('fb:success', array('message' => $msg));
118             } else {
119                 // XXX do an error message here
120             }
121         }
122
123         common_element_start('div', 'main_body');
124
125     }
126
127     function show_footer()
128     {
129         common_element_end('div');
130         common_end_xml();
131     }
132
133     function showLoginForm($msg = null)
134     {
135         start_fbml();
136
137         common_element_start('a', array('href' => 'http://identi.ca'));
138         common_element('img', array('src' => 'http://theme.identi.ca/identica/logo.png',
139                                     'alt' => 'Identi.ca',
140                                     'id' => 'logo'));
141         common_element_end('a');
142
143         if ($msg) {
144              common_element('fb:error', array('message' => $msg));
145         }
146
147         common_element("h2", null,
148             _('To add the Identi.ca application, you need to log into your Identi.ca account.'));
149
150
151         common_element_start('div', array('class' => 'instructions'));
152         common_element_start('p');
153         common_raw('Login with your username and password. Don\'t have a username yet?'
154         .' <a href="http://identi.ca/main/register">Register</a> a new account.');
155         common_element_end('p');
156         common_element_end('div');
157
158         common_element_start('div', array('id' => 'content'));
159         common_element_start('form', array('method' => 'post',
160                                                'id' => 'login',
161                                                'action' => 'index.php'));
162         common_input('nickname', _('Nickname'));
163         common_password('password', _('Password'));
164
165         common_submit('submit', _('Login'));
166         common_element_end('form');
167
168         common_element_start('p');
169         common_element('a', array('href' => common_local_url('recoverpassword')),
170                        _('Lost or forgotten password?'));
171         common_element_end('p');
172         common_element_end('div');
173
174         common_end_xml();
175
176     }
177
178
179 }