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