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.config.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 | $picture_url_type = array('page', 'image'); |
---|
38 | $picture_url_type_l10n = array_map('l10n', $picture_url_type); |
---|
39 | $layout = array('standard', 'button_count', 'box_count'); |
---|
40 | $layout_l10n = array_map('l10n', $layout); |
---|
41 | $action = array('like', 'recommend'); |
---|
42 | $action_l10n = array_map('l10n', $action); |
---|
43 | $colorscheme = array('light', 'dark'); |
---|
44 | $colorscheme_l10n = array_map('l10n', $colorscheme); |
---|
45 | |
---|
46 | |
---|
47 | // Tabsheet |
---|
48 | $tabsheet = new tabsheet(); |
---|
49 | $tabsheet->add('social_plugin', |
---|
50 | l10n('Social plugins'), |
---|
51 | add_url_params($base_url, array('tab' => 'social_plugin'))); |
---|
52 | $tabsheet->add('share', |
---|
53 | l10n('Share'), |
---|
54 | add_url_params($base_url, array('tab' => 'share'))); |
---|
55 | $tabsheet->add('advanced', |
---|
56 | l10n('Advanced'), |
---|
57 | add_url_params($base_url, array('tab' => 'advanced'))); |
---|
58 | $tabsheet->add('activity', |
---|
59 | l10n('Activity'), |
---|
60 | add_url_params($base_url, array('tab' => 'activity'))); |
---|
61 | $tabsheet->select($page['tab']); |
---|
62 | $tabsheet->assign(); |
---|
63 | |
---|
64 | function fbp_intval($n) |
---|
65 | { |
---|
66 | return (is_numeric($n) ? $n : null); |
---|
67 | } |
---|
68 | |
---|
69 | function fbp_checked($b) |
---|
70 | { |
---|
71 | return ($b ? 'checked="checked"' : ''); |
---|
72 | } |
---|
73 | |
---|
74 | // Update |
---|
75 | if (isset($_POST['submit'])) |
---|
76 | { |
---|
77 | $save_conf['fbp'] = $conf['fbp']; |
---|
78 | |
---|
79 | switch ($page['tab']) |
---|
80 | { |
---|
81 | case 'social_plugin' : |
---|
82 | { |
---|
83 | // Like button |
---|
84 | $conf['fbp']['social_plugin_like_button']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_ENABLED']); |
---|
85 | $conf['fbp']['social_plugin_like_button']['layout'] = $layout[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_LAYOUT']]; |
---|
86 | $conf['fbp']['social_plugin_like_button']['show_faces'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_SHOW_FACES']); |
---|
87 | $conf['fbp']['social_plugin_like_button']['action'] = $action[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_ACTION']]; |
---|
88 | $conf['fbp']['social_plugin_like_button']['colorscheme'] = $colorscheme[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_COLORSCHEME']]; |
---|
89 | // Facepile |
---|
90 | $conf['fbp']['social_plugin_facepile']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_FACEPILE_ENABLED']); |
---|
91 | $conf['fbp']['social_plugin_facepile']['max_rows'] = intval($_POST['FBP_SOCIAL_PLUGIN_FACEPILE_MAX_ROWS']); |
---|
92 | // Comments |
---|
93 | $conf['fbp']['social_plugin_comments']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_ENABLED']); |
---|
94 | $conf['fbp']['social_plugin_comments']['numposts'] = fbp_intval($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_NUMPOSTS']); |
---|
95 | $conf['fbp']['social_plugin_comments']['title'] = $_POST['FBP_SOCIAL_PLUGIN_COMMENTS_TITLE']; |
---|
96 | $conf['fbp']['social_plugin_comments']['simple'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_SIMPLE']); |
---|
97 | $conf['fbp']['social_plugin_comments']['reverse'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_REVERSE']); |
---|
98 | $conf['fbp']['social_plugin_comments']['publish_feed'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_PUBLISH_FEED']); |
---|
99 | // Actvity feed |
---|
100 | $conf['fbp']['social_plugin_activity_feed']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_ACTIVITY_FEED_ENABLED']); |
---|
101 | $conf['fbp']['social_plugin_activity_feed']['colorscheme'] = $colorscheme[$_POST['FBP_SOCIAL_PLUGIN_ACTIVITY_FEED_COLORSCHEME']]; |
---|
102 | $conf['fbp']['social_plugin_activity_feed']['recommendations'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_ACTIVITY_FEED_RECOMMENDATIONS']); |
---|
103 | $conf['fbp']['social_plugin_activity_feed']['header'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_ACTIVITY_FEED_HEADER']); |
---|
104 | $conf['fbp']['social_plugin_activity_feed']['height'] = fbp_intval($_POST['FBP_SOCIAL_PLUGIN_ACTIVITY_FEED_HEIGHT']); |
---|
105 | // Like box |
---|
106 | $conf['fbp']['social_plugin_like_box']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_ENABLED']); |
---|
107 | $conf['fbp']['social_plugin_like_box']['url'] = $_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_URL']; |
---|
108 | $conf['fbp']['social_plugin_like_box']['colorscheme'] = $colorscheme[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_COLORSCHEME']]; |
---|
109 | $conf['fbp']['social_plugin_like_box']['show_faces'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_SHOW_FACES']); |
---|
110 | $conf['fbp']['social_plugin_like_box']['stream'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_STREAM']); |
---|
111 | $conf['fbp']['social_plugin_like_box']['header'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_HEADER']); |
---|
112 | $conf['fbp']['social_plugin_like_box']['height'] = fbp_intval($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_HEIGHT']); |
---|
113 | |
---|
114 | // Check |
---|
115 | if ($conf['fbp']['social_plugin_like_button']['enabled'] and $conf['fbp']['social_plugin_comments']['enabled']) |
---|
116 | { |
---|
117 | $conf['fbp']['social_plugin_like_button']['enabled'] = $save_conf['fbp']['social_plugin_like_button']['enabled']; |
---|
118 | $conf['fbp']['social_plugin_comments']['enabled'] = $save_conf['fbp']['social_plugin_comments']['enabled']; |
---|
119 | array_push($page['infos'], l10n('Like button and comments cannot be enabled together').', '.l10n('enabled values are restored')); |
---|
120 | } |
---|
121 | break; |
---|
122 | } |
---|
123 | |
---|
124 | case 'share' : |
---|
125 | { |
---|
126 | $conf['fbp']['share_picture'] = ! empty($_POST['FBP_SHARE_PICTURE']); |
---|
127 | $conf['fbp']['share_album'] = ! empty($_POST['FBP_SHARE_ALBUM']); |
---|
128 | break; |
---|
129 | } |
---|
130 | |
---|
131 | case 'advanced' : |
---|
132 | { |
---|
133 | $conf['fbp']['facebook_app_id'] = $_POST['FBP_FACEBOOK_APP_ID']; |
---|
134 | $conf['fbp']['async_script'] = ! empty($_POST['FBP_ASYNC_SCRIPT']); |
---|
135 | $conf['fbp']['force_facebook_init'] = ! empty($_POST['FBP_FORCE_FACEBOOK_INIT']); |
---|
136 | $conf['fbp']['picture_url_type'] = $picture_url_type[$_POST['FBP_PICTURE_URL_TYPE']]; |
---|
137 | $conf['fbp']['allow_fb_access_private_page'] = ! empty($_POST['FBP_ALLOW_FB_ACCESS_PRIVATE_PAGE']); |
---|
138 | $conf['fbp']['add_about_informations'] = ! empty($_POST['FBP_ADD_ABOUT_INFORMATIONS']); |
---|
139 | $conf['fbp']['add_group_footer'] = ! empty($_POST['FBP_ADD_GROUP_FOOTER']); |
---|
140 | $conf['fbp']['add_application_footer'] = ! empty($_POST['FBP_ADD_APPLICATION_FOOTER']); |
---|
141 | break; |
---|
142 | } |
---|
143 | } |
---|
144 | |
---|
145 | $query = ' |
---|
146 | update '.CONFIG_TABLE.' |
---|
147 | set |
---|
148 | value = \''.serialize($conf['fbp']).'\' |
---|
149 | where |
---|
150 | param = \'fbp\' |
---|
151 | ;'; |
---|
152 | if (pwg_query($query)) |
---|
153 | { |
---|
154 | array_push($page['infos'], l10n('Data updated with success')); |
---|
155 | } |
---|
156 | else |
---|
157 | { |
---|
158 | array_push($page['errors'], l10n('Data updated with error')); |
---|
159 | } |
---|
160 | |
---|
161 | // Delete compiled templates |
---|
162 | $template->delete_compiled_templates(); |
---|
163 | } |
---|
164 | |
---|
165 | // Display |
---|
166 | switch ($page['tab']) |
---|
167 | { |
---|
168 | case 'social_plugin' : |
---|
169 | { |
---|
170 | $template->assign( |
---|
171 | $page['tab'], |
---|
172 | array( |
---|
173 | 'like_button' => array |
---|
174 | ( |
---|
175 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/like/', |
---|
176 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_like_button']['enabled']), |
---|
177 | 'LAYOUT_OPTIONS' => $layout_l10n, |
---|
178 | 'LAYOUT_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['layout'], $layout), |
---|
179 | 'SHOW_FACES' => fbp_checked($conf['fbp']['social_plugin_like_button']['show_faces']), |
---|
180 | 'ACTION_OPTIONS' => $action_l10n, |
---|
181 | 'ACTION_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['action'], $action), |
---|
182 | 'COLORSCHEME_OPTIONS' => $colorscheme_l10n, |
---|
183 | 'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['colorscheme'], $colorscheme), |
---|
184 | ), |
---|
185 | 'facepile' => array |
---|
186 | ( |
---|
187 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/facepile/', |
---|
188 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_facepile']['enabled']), |
---|
189 | 'MAX_ROWS' => $conf['fbp']['social_plugin_facepile']['max_rows'], |
---|
190 | ), |
---|
191 | 'comments' => array |
---|
192 | ( |
---|
193 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/comments/', |
---|
194 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_comments']['enabled']), |
---|
195 | 'NUMPOSTS' => $conf['fbp']['social_plugin_comments']['numposts'], |
---|
196 | 'TITLE' => $conf['fbp']['social_plugin_comments']['title'], |
---|
197 | 'SIMPLE' => fbp_checked($conf['fbp']['social_plugin_comments']['simple']), |
---|
198 | 'REVERSE' => fbp_checked($conf['fbp']['social_plugin_comments']['reverse']), |
---|
199 | 'PUBLISH_FEED' => fbp_checked($conf['fbp']['social_plugin_comments']['publish_feed']), |
---|
200 | ), |
---|
201 | 'activity_feed' => array |
---|
202 | ( |
---|
203 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/activity/', |
---|
204 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_activity_feed']['enabled']), |
---|
205 | 'COLORSCHEME_OPTIONS' => $colorscheme_l10n, |
---|
206 | 'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_activity_feed']['colorscheme'], $colorscheme), |
---|
207 | 'RECOMMENDATIONS' => fbp_checked($conf['fbp']['social_plugin_activity_feed']['recommendations']), |
---|
208 | 'HEADER' => fbp_checked($conf['fbp']['social_plugin_activity_feed']['header']), |
---|
209 | 'HEIGHT' => $conf['fbp']['social_plugin_activity_feed']['height'], |
---|
210 | ), |
---|
211 | 'like_box' => array |
---|
212 | ( |
---|
213 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/like-box/', |
---|
214 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_like_box']['enabled']), |
---|
215 | 'URL' => $conf['fbp']['social_plugin_like_box']['url'], |
---|
216 | 'COLORSCHEME_OPTIONS' => $colorscheme_l10n, |
---|
217 | 'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_box']['colorscheme'], $colorscheme), |
---|
218 | 'SHOW_FACES' => fbp_checked($conf['fbp']['social_plugin_like_box']['show_faces']), |
---|
219 | 'STREAM' => fbp_checked($conf['fbp']['social_plugin_like_box']['stream']), |
---|
220 | 'HEADER' => fbp_checked($conf['fbp']['social_plugin_like_box']['header']), |
---|
221 | 'HEIGHT' => $conf['fbp']['social_plugin_like_box']['height'], |
---|
222 | ), |
---|
223 | )); |
---|
224 | break; |
---|
225 | } |
---|
226 | case 'share' : |
---|
227 | { |
---|
228 | $template->assign( |
---|
229 | $page['tab'], |
---|
230 | array( |
---|
231 | 'FBP_SHARE_PICTURE' => fbp_checked($conf['fbp']['share_picture']), |
---|
232 | 'FBP_SHARE_ALBUM' => fbp_checked($conf['fbp']['share_album']), |
---|
233 | )); |
---|
234 | break; |
---|
235 | } |
---|
236 | case 'advanced' : |
---|
237 | { |
---|
238 | $template->assign( |
---|
239 | $page['tab'], |
---|
240 | array( |
---|
241 | 'FBP_FACEBOOK_APP_ID' => $conf['fbp']['facebook_app_id'], |
---|
242 | 'FBP_ASYNC_SCRIPT' => fbp_checked($conf['fbp']['async_script']), |
---|
243 | 'FBP_FORCE_FACEBOOK_INIT' => fbp_checked($conf['fbp']['force_facebook_init']), |
---|
244 | 'FBP_PICTURE_URL_TYPE_OPTIONS' => $picture_url_type_l10n, |
---|
245 | 'FBP_PICTURE_URL_TYPE_OPTIONS_SELECTED' => array_search($conf['fbp']['picture_url_type'], $picture_url_type), |
---|
246 | 'FBP_ALLOW_FB_ACCESS_PRIVATE_PAGE'=> fbp_checked($conf['fbp']['allow_fb_access_private_page']), |
---|
247 | 'FBP_ADD_ABOUT_INFORMATIONS' => fbp_checked($conf['fbp']['add_about_informations']), |
---|
248 | 'FBP_ADD_GROUP_FOOTER' => fbp_checked($conf['fbp']['add_group_footer']), |
---|
249 | 'FBP_ADD_APPLICATION_FOOTER' => fbp_checked($conf['fbp']['add_application_footer']), |
---|
250 | )); |
---|
251 | break; |
---|
252 | } |
---|
253 | case 'activity' : |
---|
254 | { |
---|
255 | $template->assign( |
---|
256 | $page['tab'], |
---|
257 | array( |
---|
258 | )); |
---|
259 | break; |
---|
260 | } |
---|
261 | } |
---|
262 | |
---|
263 | // Global value |
---|
264 | $template->assign('FBP_ACTION', add_url_params($base_url, array('tab' => $page['tab']))); |
---|
265 | //~ $template->block_html_head('', '<link rel="stylesheet" type="text/css" href="'.FBP_PATH.'/css/admin.config.css">', $smarty, $repeat); |
---|
266 | $template->assign('FACEBOOK_PIWIGO_RUB_URL', FACEBOOK_PIWIGO_RUB_URL); |
---|
267 | $template->assign('FACEBOOK_PIWIGO_GROUP_URL', FACEBOOK_PIWIGO_GROUP_URL); |
---|
268 | $template->assign('FACEBOOK_PIWIGO_APPLICATION_URL', FACEBOOK_PIWIGO_APPLICATION_URL); |
---|
269 | $template->assign('FBP_OLD_VERSION', version_compare(PHPWG_VERSION, '2.2', '<')); |
---|
270 | |
---|
271 | //Apply tpl |
---|
272 | $template->set_filename('fbp_plugin_admin_content', FBP_DIR.'/tpl/admin.config.tpl'); |
---|
273 | $template->assign_var_from_handle('ADMIN_CONTENT', 'fbp_plugin_admin_content'); |
---|
274 | |
---|
275 | ?> |
---|