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