]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/facebookaction.php
Update facebook stuff to use new methods
[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')) {
21     exit(1);
22 }
23
24 require_once INSTALLDIR.'/lib/facebookutil.php';
25
26 class FacebookAction extends Action
27 {
28
29     function handle($args)
30     {
31         parent::handle($args);
32     }
33
34     function showLogo(){
35
36         global $xw;
37
38         $this->showStylesheets();
39         $this->showScripts();
40
41         $this->elementStart('a', array('class' => 'url home bookmark',
42                                             'href' => common_local_url('public')));
43         if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) {
44             $this->element('img', array('class' => 'logo photo',
45                 'src' => (common_config('site', 'logo')) ?
46                     common_config('site', 'logo') : theme_path('logo.png'),
47                 'alt' => common_config('site', 'name')));
48         }
49
50         $this->element('span', array('class' => 'fn org'), common_config('site', 'name'));
51         $this->elementEnd('a');
52
53     }
54
55     function showHeader($msg = null, $success = false)
56     {
57         startFBML();
58
59         $this->elementStart('fb:if-section-not-added', array('section' => 'profile'));
60         $this->elementStart('span', array('id' => 'add_to_profile'));
61         $this->element('fb:add-section-button', array('section' => 'profile'));
62         $this->elementEnd('span');
63         $this->elementEnd('fb:if-section-not-added');
64
65         $this->showLogo();
66
67         if ($msg) {
68             if ($success) {
69                 $this->element('fb:success', array('message' => $msg));
70             } else {
71                 // XXX do an error message here
72             }
73         }
74
75         $this->elementStart('div', 'main_body');
76
77     }
78
79     function showNav($selected = 'Home')
80     {
81
82         $this->elementStart('dl', array("id" => 'site_nav_local_views'));
83         $this->element('dt', null, _('Local Views'));
84         $this->elementStart('dd');
85
86         $this->elementStart('ul', array('class' => 'nav'));
87
88         $this->elementStart('li', array('class' =>
89             ($selected == 'Home') ? 'current' : 'facebook_home'));
90         $this->element('a',
91             array('href' => 'index.php', 'title' => _('Home')), _('Home'));
92         $this->elementEnd('li');
93
94         $this->elementStart('li',
95             array('class' =>
96                 ($selected == 'Invite') ? 'current' : 'facebook_invite'));
97         $this->element('a',
98             array('href' => 'invite.php', 'title' => _('Invite')), _('Invite'));
99         $this->elementEnd('li');
100
101         $this->elementStart('li',
102             array('class' =>
103                 ($selected == 'Settings') ? 'current' : 'facebook_settings'));
104         $this->element('a',
105             array('href' => 'settings.php',
106                 'title' => _('Settings')), _('Settings'));
107         $this->elementEnd('li');
108
109         $this->elementEnd('ul');
110
111         $this->elementEnd('dd');
112         $this->elementEnd('dl');
113
114     }
115
116     function showFooter()
117     {
118         $this->elementEnd('div');
119         $this->endXml();
120     }
121
122     function showInstructions()
123     {
124         global $xw;
125
126         $this->elementStart('dl', array('class' => 'system_notice'));
127         $this->element('dt', null, 'Page Notice');
128
129         $loginmsg_part1 = _('To use the %s Facebook Application you need to login ' .
130             'with your username and password. Don\'t have a username yet? ');
131
132         $loginmsg_part2 = _(' a new account.');
133
134         $this->elementStart('dd');
135         $this->elementStart('p');
136         $this->text(sprintf($loginmsg_part1, common_config('site', 'name')));
137         $this->element('a',
138             array('href' => common_local_url('register')), _('Register'));
139         $this->text($loginmsg_part2);
140         $this->elementEnd('dd');
141         $this->elementEnd('dl');
142     }
143
144     function showStylesheets()
145     {
146         global $xw;
147
148         $this->element('link', array('rel' => 'stylesheet',
149                                      'type' => 'text/css',
150                                      'href' => getFacebookBaseCSS()));
151
152         $this->element('link', array('rel' => 'stylesheet',
153                                      'type' => 'text/css',
154                                      'href' => getFacebookThemeCSS()));
155     }
156
157     function showScripts()
158     {
159         global $xw;
160
161         $this->element('script', array('type' => 'text/javascript',
162                                        'src' => getFacebookJS()));
163
164     }
165
166     function showLoginForm($msg = null)
167     {
168         startFBML();
169
170         $this->showStylesheets();
171         $this->showScripts();
172
173         $this->showLogo();
174
175         $this->elementStart('div', array('class' => 'content'));
176         $this->element('h1', null, _('Login'));
177
178         if ($msg) {
179              $this->element('fb:error', array('message' => $msg));
180         }
181
182         $this->showInstructions();
183
184         $this->elementStart('div', array('id' => 'content_inner'));
185
186         $this->elementStart('form', array('method' => 'post',
187                                                'class' => 'form_settings',
188                                                'id' => 'login',
189                                                'action' => 'index.php'));
190
191         $this->elementStart('fieldset');
192         $this->element('legend', null, _('Login to site'));
193
194         $this->elementStart('ul', array('class' => 'form_datas'));
195         $this->elementStart('li');
196         $this->input('nickname', _('Nickname'));
197         $this->elementEnd('li');
198         $this->elementStart('li');
199         $this->password('password', _('Password'));
200         $this->elementEnd('li');
201         $this->elementEnd('ul');
202
203         $this->submit('submit', _('Login'));
204         $this->elementEnd('form');
205
206         $this->elementStart('p');
207         $this->element('a', array('href' => common_local_url('recoverpassword')),
208                        _('Lost or forgotten password?'));
209         $this->elementEnd('p');
210
211         $this->elementEnd('div');
212
213         $this->endXml();
214
215     }
216
217     function showNoticeForm($user)
218     {
219
220         global $xw;
221
222         $this->elementStart('form', array('id' => 'form_notice',
223                                            'method' => 'post',
224                                            'action' => 'index.php'));
225
226         $this->elementStart('fieldset');
227         $this->element('legend', null, 'Send a notice');
228
229         $this->elementStart('ul', 'form_datas');
230         $this->elementStart('li', array('id' => 'noticcommon_elemente_text'));
231         $this->element('label', array('for' => 'notice_data-text'),
232                             sprintf(_('What\'s up, %s?'), $user->nickname));
233
234         $this->element('textarea', array('id' => 'notice_data-text',
235                                               'cols' => 35,
236                                               'rows' => 4,
237                                               'name' => 'status_textarea'));
238         $this->elementEnd('li');
239         $this->elementEnd('ul');
240
241         $this->elementStart('dl', 'form_note');
242         $this->element('dt', null, _('Available characters'));
243         $this->element('dd', array('id' => 'notice_text-count'),
244                             '140');
245         $this->elementEnd('dl');
246
247         $this->elementStart('ul', array('class' => 'form_actions'));
248
249         $this->elementStart('li', array('id' => 'notice_submit'));
250
251         $this->submit('submit', _('Send'));
252
253         /*
254         $this->element('input', array('id' => 'notice_action-submit',
255                                            'class' => 'submit',
256                                            'name' => 'status_submit',
257                                            'type' => 'submit',
258                                            'value' => _('Send')));
259         */
260         $this->elementEnd('li');
261         $this->elementEnd('ul');
262         $this->elementEnd('fieldset');
263         $this->elementEnd('form');
264     }
265
266 }