]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/facebookaction.php
trac750 Better workflow for asking user for status update permission
[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         common_element('link', array('rel' => 'stylesheet',
39                                      'type' => 'text/css',
40                                      'href' => getFacebookCSS()));
41
42         common_element('script', array('type' => 'text/javascript',
43                                        'src' => getFacebookJS()),
44                                        ' ');
45
46         common_element_start('a', array('class' => 'url home bookmark',
47                                             'href' => common_local_url('public')));
48         if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) {
49             common_element('img', array('class' => 'logo photo',
50                 'src' => (common_config('site', 'logo')) ?
51                     common_config('site', 'logo') : theme_path('logo.png'),
52                 'alt' => common_config('site', 'name')));
53         }
54
55         common_element('span', array('class' => 'fn org'), common_config('site', 'name'));
56         common_element_end('a');
57
58     }
59
60     function showHeader($selected = 'Home', $msg = null, $success = false)
61     {
62
63         start_fbml();
64
65         common_element_start('fb:if-section-not-added', array('section' => 'profile'));
66         common_element_start('span', array('id' => 'add_to_profile'));
67         common_element('fb:add-section-button', array('section' => 'profile'));
68         common_element_end('span');
69         common_element_end('fb:if-section-not-added');
70
71         $this->showLogo();
72
73         common_element_start('dl', array("id" => 'site_nav_local_views'));
74         common_element('dt', null, _('Local Views'));
75         common_element_start('dd');
76
77         common_element_start('ul', array('class' => 'nav'));
78
79         common_element_start('li', array('class' =>
80             ($selected == 'Home') ? 'current' : 'facebook_home'));
81         common_element('a',
82             array('href' => 'index.php', 'title' => _('Home')), _('Home'));
83         common_element_end('li');
84
85
86         common_element_start('li',
87             array('class' =>
88                 ($selected == 'Invite') ? 'current' : 'facebook_invite'));
89         common_element('a',
90             array('href' => 'invite.php', 'title' => _('Invite')), _('Invite'));
91         common_element_end('li');
92
93         common_element_start('li',
94             array('class' =>
95                 ($selected == 'Settings') ? 'current' : 'facebook_settings'));
96         common_element('a',
97             array('href' => 'settings.php',
98                 'title' => _('Settings')), _('Settings'));
99         common_element_end('li');
100
101         common_element_end('ul');
102
103         common_element_end('dd');
104         common_element_end('dl');
105
106
107         if ($msg) {
108             if ($success) {
109                 common_element('fb:success', array('message' => $msg));
110             } else {
111                 // XXX do an error message here
112             }
113         }
114
115         common_element_start('div', 'main_body');
116
117     }
118
119     function showFooter()
120     {
121         common_element_end('div');
122         common_end_xml();
123     }
124
125
126     function showInstructions()
127     {
128         global $xw;
129
130         common_element_start('dl', array('class' => 'system_notice'));
131         common_element('dt', null, 'Page Notice');
132
133         $loginmsg_part1 = _('To use the %s Facebook Application you need to login ' .
134             'with your username and password. Don\'t have a username yet? ');
135
136         $loginmsg_part2 = _(' a new account.');
137
138         common_element_start('dd');
139         common_element_start('p');
140         common_text(sprintf($loginmsg_part1, common_config('site', 'name')));
141         common_element('a',
142             array('href' => common_local_url('register')), _('Register'));
143         common_text($loginmsg_part2);
144         common_element_end('dd');
145         common_element_end('dl');
146     }
147
148     function showLoginForm($msg = null)
149     {
150         start_fbml();
151
152         common_element('link', array('rel' => 'stylesheet',
153                                      'type' => 'text/css',
154                                      'href' => getFacebookCSS()));
155
156         $this->showLogo();
157
158         common_element_start('div', array('class' => 'content'));
159         common_element('h1', null, _('Login'));
160
161         if ($msg) {
162              common_element('fb:error', array('message' => $msg));
163         }
164
165         $this->showInstructions();
166
167         common_element_start('div', array('id' => 'content_inner'));
168
169         common_element_start('form', array('method' => 'post',
170                                                'id' => 'login',
171                                                'action' => 'index.php'));
172
173         common_element_start('fieldset');
174         common_element('legend', null, _('Login to site'));
175
176         common_element_start('ul', array('class' => 'form_datas'));
177         common_element_start('li');
178         common_input('nickname', _('Nickname'));
179         common_element_end('li');
180         common_element_start('li');
181         common_password('password', _('Password'));
182         common_element_end('li');
183         common_element_end('ul');
184
185         common_submit('submit', _('Login'));
186         common_element_end('form');
187
188         common_element_start('p');
189         common_element('a', array('href' => common_local_url('recoverpassword')),
190                        _('Lost or forgotten password?'));
191         common_element_end('p');
192
193         common_element_end('div');
194
195         common_end_xml();
196
197     }
198
199
200 }