1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | FacebookPlug - a Piwigo Plugin | |
---|
4 | // | Copyright (C) 2010-2011 Ruben ARNAUD - rub@piwigo.org | |
---|
5 | // +-----------------------------------------------------------------------+ |
---|
6 | // | This program is free software; you can redistribute it and/or modify | |
---|
7 | // | it under the terms of the GNU General Public License as published by | |
---|
8 | // | the Free Software Foundation | |
---|
9 | // | | |
---|
10 | // | This program is distributed in the hope that it will be useful, but | |
---|
11 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
12 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
13 | // | General Public License for more details. | |
---|
14 | // | | |
---|
15 | // | You should have received a copy of the GNU General Public License | |
---|
16 | // | along with this program; if not, write to the Free Software | |
---|
17 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
18 | // | USA. | |
---|
19 | // +-----------------------------------------------------------------------+ |
---|
20 | |
---|
21 | if (!defined('PHPWG_ROOT_PATH')) |
---|
22 | { |
---|
23 | die('Hacking attempt!'); |
---|
24 | } |
---|
25 | |
---|
26 | // include |
---|
27 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
28 | |
---|
29 | // Lingua |
---|
30 | load_language('admin.lang', FBP_DIR.'/'); |
---|
31 | |
---|
32 | // Arguments |
---|
33 | $page['tab'] = (isset($_GET['tab']) ? $_GET['tab'] : 'social_plugin'); |
---|
34 | |
---|
35 | // Data |
---|
36 | //~ $base_url = get_admin_plugin_menu_link(__FILE__); |
---|
37 | $base_url = get_root_url().'admin.php?page=plugin-'.FBP_PLUGIN_NAME.'-'; |
---|
38 | $picture_url_type = array('page', 'image'); |
---|
39 | $picture_url_type_l10n = array_map('l10n', $picture_url_type); |
---|
40 | $layout = array('standard', 'button_count', 'box_count'); |
---|
41 | $layout_l10n = array_map('l10n', $layout); |
---|
42 | $action = array('like', 'recommend'); |
---|
43 | $action_l10n = array_map('l10n', $action); |
---|
44 | $colorscheme = array('light', 'dark'); |
---|
45 | $colorscheme_l10n = array_map('l10n', $colorscheme); |
---|
46 | |
---|
47 | |
---|
48 | // Tabsheet |
---|
49 | $tabsheet = new tabsheet(); |
---|
50 | $tabsheet->add('social_plugin', |
---|
51 | l10n('Social plugins'), |
---|
52 | //add_url_params($base_url, array('tab' => 'social_plugin'))); |
---|
53 | $base_url.'social_plugin'); |
---|
54 | $tabsheet->add('button', |
---|
55 | l10n('Buttons'), |
---|
56 | //add_url_params($base_url, array('tab' => 'button'))); |
---|
57 | $base_url.'button'); |
---|
58 | $tabsheet->add('advanced', |
---|
59 | l10n('Advanced'), |
---|
60 | //add_url_params($base_url, array('tab' => 'advanced'))); |
---|
61 | $base_url.'advanced'); |
---|
62 | $tabsheet->add('activity', |
---|
63 | l10n('Activity'), |
---|
64 | //add_url_params($base_url, array('tab' => 'activity'))); |
---|
65 | $base_url.'activity'); |
---|
66 | $tabsheet->select($page['tab']); |
---|
67 | $tabsheet->assign(); |
---|
68 | |
---|
69 | function fbp_intval($n) |
---|
70 | { |
---|
71 | return (is_numeric($n) ? $n : null); |
---|
72 | } |
---|
73 | |
---|
74 | function fbp_checked($b) |
---|
75 | { |
---|
76 | return ($b ? 'checked="checked"' : ''); |
---|
77 | } |
---|
78 | |
---|
79 | // Update |
---|
80 | if (isset($_POST['submit'])) |
---|
81 | { |
---|
82 | $save_conf['fbp'] = $conf['fbp']; |
---|
83 | |
---|
84 | switch ($page['tab']) |
---|
85 | { |
---|
86 | case 'social_plugin' : |
---|
87 | { |
---|
88 | // Like button |
---|
89 | $conf['fbp']['social_plugin_like_button']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_ENABLED']); |
---|
90 | $conf['fbp']['social_plugin_like_button']['layout'] = $layout[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_LAYOUT']]; |
---|
91 | $conf['fbp']['social_plugin_like_button']['show_faces'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_SHOW_FACES']); |
---|
92 | $conf['fbp']['social_plugin_like_button']['action'] = $action[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_ACTION']]; |
---|
93 | $conf['fbp']['social_plugin_like_button']['colorscheme'] = $colorscheme[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_COLORSCHEME']]; |
---|
94 | // Facepile |
---|
95 | $conf['fbp']['social_plugin_facepile']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_FACEPILE_ENABLED']); |
---|
96 | $conf['fbp']['social_plugin_facepile']['max_rows'] = intval($_POST['FBP_SOCIAL_PLUGIN_FACEPILE_MAX_ROWS']); |
---|
97 | // Comments |
---|
98 | $conf['fbp']['social_plugin_comments']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_ENABLED']); |
---|
99 | $conf['fbp']['social_plugin_comments']['numposts'] = fbp_intval($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_NUMPOSTS']); |
---|
100 | $conf['fbp']['social_plugin_comments']['title'] = $_POST['FBP_SOCIAL_PLUGIN_COMMENTS_TITLE']; |
---|
101 | $conf['fbp']['social_plugin_comments']['simple'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_SIMPLE']); |
---|
102 | $conf['fbp']['social_plugin_comments']['reverse'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_REVERSE']); |
---|
103 | $conf['fbp']['social_plugin_comments']['publish_feed'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_PUBLISH_FEED']); |
---|
104 | // Actvity feed |
---|
105 | $conf['fbp']['social_plugin_activity_feed']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_ACTIVITY_FEED_ENABLED']); |
---|
106 | $conf['fbp']['social_plugin_activity_feed']['colorscheme'] = $colorscheme[$_POST['FBP_SOCIAL_PLUGIN_ACTIVITY_FEED_COLORSCHEME']]; |
---|
107 | $conf['fbp']['social_plugin_activity_feed']['recommendations'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_ACTIVITY_FEED_RECOMMENDATIONS']); |
---|
108 | $conf['fbp']['social_plugin_activity_feed']['header'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_ACTIVITY_FEED_HEADER']); |
---|
109 | $conf['fbp']['social_plugin_activity_feed']['height'] = fbp_intval($_POST['FBP_SOCIAL_PLUGIN_ACTIVITY_FEED_HEIGHT']); |
---|
110 | // Like box |
---|
111 | $conf['fbp']['social_plugin_like_box']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_ENABLED']); |
---|
112 | $conf['fbp']['social_plugin_like_box']['url'] = $_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_URL']; |
---|
113 | $conf['fbp']['social_plugin_like_box']['colorscheme'] = $colorscheme[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_COLORSCHEME']]; |
---|
114 | $conf['fbp']['social_plugin_like_box']['show_faces'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_SHOW_FACES']); |
---|
115 | $conf['fbp']['social_plugin_like_box']['stream'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_STREAM']); |
---|
116 | $conf['fbp']['social_plugin_like_box']['header'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_HEADER']); |
---|
117 | $conf['fbp']['social_plugin_like_box']['height'] = fbp_intval($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_HEIGHT']); |
---|
118 | |
---|
119 | // Check |
---|
120 | if ($conf['fbp']['social_plugin_like_button']['enabled'] and $conf['fbp']['social_plugin_comments']['enabled']) |
---|
121 | { |
---|
122 | $conf['fbp']['social_plugin_like_button']['enabled'] = $save_conf['fbp']['social_plugin_like_button']['enabled']; |
---|
123 | $conf['fbp']['social_plugin_comments']['enabled'] = $save_conf['fbp']['social_plugin_comments']['enabled']; |
---|
124 | array_push($page['infos'], l10n('Like button and comments cannot be enabled together').', '.l10n('enabled values are restored')); |
---|
125 | } |
---|
126 | break; |
---|
127 | } |
---|
128 | |
---|
129 | case 'button' : |
---|
130 | { |
---|
131 | $conf['fbp']['share_picture'] = ! empty($_POST['FBP_SHARE_PICTURE']); |
---|
132 | $conf['fbp']['share_album'] = ! empty($_POST['FBP_SHARE_ALBUM']); |
---|
133 | $conf['fbp']['upload_picture'] = ! empty($_POST['FBP_UPLOAD_PICTURE']); |
---|
134 | break; |
---|
135 | } |
---|
136 | |
---|
137 | case 'advanced' : |
---|
138 | { |
---|
139 | $conf['fbp']['facebook_app_id'] = $_POST['FBP_FACEBOOK_APP_ID']; |
---|
140 | $conf['fbp']['async_script'] = ! empty($_POST['FBP_ASYNC_SCRIPT']); |
---|
141 | $conf['fbp']['force_facebook_init'] = ! empty($_POST['FBP_FORCE_FACEBOOK_INIT']); |
---|
142 | $conf['fbp']['picture_url_type'] = $picture_url_type[$_POST['FBP_PICTURE_URL_TYPE']]; |
---|
143 | $conf['fbp']['allow_fb_access_private_page'] = ! empty($_POST['FBP_ALLOW_FB_ACCESS_PRIVATE_PAGE']); |
---|
144 | $conf['fbp']['add_about_informations'] = ! empty($_POST['FBP_ADD_ABOUT_INFORMATIONS']); |
---|
145 | $conf['fbp']['add_group_footer'] = ! empty($_POST['FBP_ADD_GROUP_FOOTER']); |
---|
146 | $conf['fbp']['add_application_footer'] = ! empty($_POST['FBP_ADD_APPLICATION_FOOTER']); |
---|
147 | break; |
---|
148 | } |
---|
149 | } |
---|
150 | |
---|
151 | $query = ' |
---|
152 | update '.CONFIG_TABLE.' |
---|
153 | set |
---|
154 | value = \''.serialize($conf['fbp']).'\' |
---|
155 | where |
---|
156 | param = \'fbp\' |
---|
157 | ;'; |
---|
158 | if (pwg_query($query)) |
---|
159 | { |
---|
160 | array_push($page['infos'], l10n('Data updated with success')); |
---|
161 | } |
---|
162 | else |
---|
163 | { |
---|
164 | array_push($page['errors'], l10n('Data updated with error')); |
---|
165 | } |
---|
166 | |
---|
167 | // Delete compiled templates |
---|
168 | $template->delete_compiled_templates(); |
---|
169 | } |
---|
170 | |
---|
171 | // Display |
---|
172 | switch ($page['tab']) |
---|
173 | { |
---|
174 | case 'social_plugin' : |
---|
175 | { |
---|
176 | $template->assign( |
---|
177 | $page['tab'], |
---|
178 | array( |
---|
179 | 'like_button' => array |
---|
180 | ( |
---|
181 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/like/', |
---|
182 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_like_button']['enabled']), |
---|
183 | 'LAYOUT_OPTIONS' => $layout_l10n, |
---|
184 | 'LAYOUT_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['layout'], $layout), |
---|
185 | 'SHOW_FACES' => fbp_checked($conf['fbp']['social_plugin_like_button']['show_faces']), |
---|
186 | 'ACTION_OPTIONS' => $action_l10n, |
---|
187 | 'ACTION_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['action'], $action), |
---|
188 | 'COLORSCHEME_OPTIONS' => $colorscheme_l10n, |
---|
189 | 'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['colorscheme'], $colorscheme), |
---|
190 | ), |
---|
191 | 'facepile' => array |
---|
192 | ( |
---|
193 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/facepile/', |
---|
194 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_facepile']['enabled']), |
---|
195 | 'MAX_ROWS' => $conf['fbp']['social_plugin_facepile']['max_rows'], |
---|
196 | ), |
---|
197 | 'comments' => array |
---|
198 | ( |
---|
199 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/comments/', |
---|
200 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_comments']['enabled']), |
---|
201 | 'NUMPOSTS' => $conf['fbp']['social_plugin_comments']['numposts'], |
---|
202 | 'TITLE' => $conf['fbp']['social_plugin_comments']['title'], |
---|
203 | 'SIMPLE' => fbp_checked($conf['fbp']['social_plugin_comments']['simple']), |
---|
204 | 'REVERSE' => fbp_checked($conf['fbp']['social_plugin_comments']['reverse']), |
---|
205 | 'PUBLISH_FEED' => fbp_checked($conf['fbp']['social_plugin_comments']['publish_feed']), |
---|
206 | ), |
---|
207 | 'activity_feed' => array |
---|
208 | ( |
---|
209 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/activity/', |
---|
210 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_activity_feed']['enabled']), |
---|
211 | 'COLORSCHEME_OPTIONS' => $colorscheme_l10n, |
---|
212 | 'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_activity_feed']['colorscheme'], $colorscheme), |
---|
213 | 'RECOMMENDATIONS' => fbp_checked($conf['fbp']['social_plugin_activity_feed']['recommendations']), |
---|
214 | 'HEADER' => fbp_checked($conf['fbp']['social_plugin_activity_feed']['header']), |
---|
215 | 'HEIGHT' => $conf['fbp']['social_plugin_activity_feed']['height'], |
---|
216 | ), |
---|
217 | 'like_box' => array |
---|
218 | ( |
---|
219 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/like-box/', |
---|
220 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_like_box']['enabled']), |
---|
221 | 'URL' => $conf['fbp']['social_plugin_like_box']['url'], |
---|
222 | 'COLORSCHEME_OPTIONS' => $colorscheme_l10n, |
---|
223 | 'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_box']['colorscheme'], $colorscheme), |
---|
224 | 'SHOW_FACES' => fbp_checked($conf['fbp']['social_plugin_like_box']['show_faces']), |
---|
225 | 'STREAM' => fbp_checked($conf['fbp']['social_plugin_like_box']['stream']), |
---|
226 | 'HEADER' => fbp_checked($conf['fbp']['social_plugin_like_box']['header']), |
---|
227 | 'HEIGHT' => $conf['fbp']['social_plugin_like_box']['height'], |
---|
228 | ), |
---|
229 | )); |
---|
230 | break; |
---|
231 | } |
---|
232 | case 'button' : |
---|
233 | { |
---|
234 | $template->assign( |
---|
235 | $page['tab'], |
---|
236 | array( |
---|
237 | 'FBP_SHARE_PICTURE' => fbp_checked($conf['fbp']['share_picture']), |
---|
238 | 'FBP_SHARE_ALBUM' => fbp_checked($conf['fbp']['share_album']), |
---|
239 | 'FBP_UPLOAD_PICTURE' => fbp_checked($conf['fbp']['upload_picture']), |
---|
240 | )); |
---|
241 | break; |
---|
242 | } |
---|
243 | case 'advanced' : |
---|
244 | { |
---|
245 | $template->assign( |
---|
246 | $page['tab'], |
---|
247 | array( |
---|
248 | 'FBP_FACEBOOK_APP_ID' => $conf['fbp']['facebook_app_id'], |
---|
249 | 'FBP_ASYNC_SCRIPT' => fbp_checked($conf['fbp']['async_script']), |
---|
250 | 'FBP_FORCE_FACEBOOK_INIT' => fbp_checked($conf['fbp']['force_facebook_init']), |
---|
251 | 'FBP_PICTURE_URL_TYPE_OPTIONS' => $picture_url_type_l10n, |
---|
252 | 'FBP_PICTURE_URL_TYPE_OPTIONS_SELECTED' => array_search($conf['fbp']['picture_url_type'], $picture_url_type), |
---|
253 | 'FBP_ALLOW_FB_ACCESS_PRIVATE_PAGE'=> fbp_checked($conf['fbp']['allow_fb_access_private_page']), |
---|
254 | 'FBP_ADD_ABOUT_INFORMATIONS' => fbp_checked($conf['fbp']['add_about_informations']), |
---|
255 | 'FBP_ADD_GROUP_FOOTER' => fbp_checked($conf['fbp']['add_group_footer']), |
---|
256 | 'FBP_ADD_APPLICATION_FOOTER' => fbp_checked($conf['fbp']['add_application_footer']), |
---|
257 | )); |
---|
258 | break; |
---|
259 | } |
---|
260 | case 'activity' : |
---|
261 | { |
---|
262 | $template->assign( |
---|
263 | $page['tab'], |
---|
264 | array( |
---|
265 | )); |
---|
266 | break; |
---|
267 | } |
---|
268 | } |
---|
269 | |
---|
270 | // Global value |
---|
271 | //~ $template->assign('FBP_ACTION', add_url_params($base_url, array('tab' => $page['tab']))); |
---|
272 | $template->assign('FBP_ACTION', $base_url.$page['tab']); |
---|
273 | $template->assign('FACEBOOK_PIWIGO_RUB_URL', FACEBOOK_PIWIGO_RUB_URL); |
---|
274 | $template->assign('FACEBOOK_PIWIGO_GROUP_URL', FACEBOOK_PIWIGO_GROUP_URL); |
---|
275 | $template->assign('FACEBOOK_PIWIGO_APPLICATION_URL', FACEBOOK_PIWIGO_APPLICATION_URL); |
---|
276 | $template->assign('FBP_OLD_VERSION', version_compare(PHPWG_VERSION, '2.2', '<')); |
---|
277 | |
---|
278 | //Apply tpl |
---|
279 | $template->set_filename('fbp_plugin_admin_content', FBP_DIR.'/tpl/admin.tpl'); |
---|
280 | $template->assign_var_from_handle('ADMIN_CONTENT', 'fbp_plugin_admin_content'); |
---|
281 | |
---|
282 | ?> |
---|