[8241] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | FacebookPlug - a Piwigo Plugin | |
---|
[8425] | 4 | // | Copyright (C) 2010-2011 Ruben ARNAUD - rub@piwigo.org | |
---|
[8241] | 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 |
---|
[9795] | 30 | load_language('admin.lang', FBP_DIR.'/'); |
---|
[8241] | 31 | |
---|
| 32 | // Arguments |
---|
| 33 | $page['tab'] = (isset($_GET['tab']) ? $_GET['tab'] : 'social_plugin'); |
---|
| 34 | |
---|
| 35 | // Data |
---|
[9795] | 36 | //~ $base_url = get_admin_plugin_menu_link(__FILE__); |
---|
| 37 | $base_url = get_root_url().'admin.php?page=plugin-'.FBP_PLUGIN_NAME.'-'; |
---|
[8295] | 38 | $picture_url_type = array('page', 'image'); |
---|
| 39 | $picture_url_type_l10n = array_map('l10n', $picture_url_type); |
---|
[8241] | 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 | |
---|
[8331] | 47 | |
---|
[8241] | 48 | // Tabsheet |
---|
| 49 | $tabsheet = new tabsheet(); |
---|
| 50 | $tabsheet->add('social_plugin', |
---|
[8282] | 51 | l10n('Social plugins'), |
---|
[9795] | 52 | //add_url_params($base_url, array('tab' => 'social_plugin'))); |
---|
| 53 | $base_url.'social_plugin'); |
---|
[8440] | 54 | $tabsheet->add('button', |
---|
| 55 | l10n('Buttons'), |
---|
[9795] | 56 | //add_url_params($base_url, array('tab' => 'button'))); |
---|
| 57 | $base_url.'button'); |
---|
[8241] | 58 | $tabsheet->add('advanced', |
---|
| 59 | l10n('Advanced'), |
---|
[9795] | 60 | //add_url_params($base_url, array('tab' => 'advanced'))); |
---|
| 61 | $base_url.'advanced'); |
---|
[8386] | 62 | $tabsheet->add('activity', |
---|
| 63 | l10n('Activity'), |
---|
[9795] | 64 | //add_url_params($base_url, array('tab' => 'activity'))); |
---|
| 65 | $base_url.'activity'); |
---|
[8241] | 66 | $tabsheet->select($page['tab']); |
---|
| 67 | $tabsheet->assign(); |
---|
| 68 | |
---|
[8386] | 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 | |
---|
[8241] | 79 | // Update |
---|
| 80 | if (isset($_POST['submit'])) |
---|
| 81 | { |
---|
[8331] | 82 | $save_conf['fbp'] = $conf['fbp']; |
---|
| 83 | |
---|
[8241] | 84 | switch ($page['tab']) |
---|
| 85 | { |
---|
| 86 | case 'social_plugin' : |
---|
| 87 | { |
---|
[8250] | 88 | // Like button |
---|
[8386] | 89 | $conf['fbp']['social_plugin_like_button']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_ENABLED']); |
---|
[8241] | 90 | $conf['fbp']['social_plugin_like_button']['layout'] = $layout[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_LAYOUT']]; |
---|
[8386] | 91 | $conf['fbp']['social_plugin_like_button']['show_faces'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_SHOW_FACES']); |
---|
[8241] | 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']]; |
---|
[8282] | 94 | // Facepile |
---|
[8386] | 95 | $conf['fbp']['social_plugin_facepile']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_FACEPILE_ENABLED']); |
---|
[8282] | 96 | $conf['fbp']['social_plugin_facepile']['max_rows'] = intval($_POST['FBP_SOCIAL_PLUGIN_FACEPILE_MAX_ROWS']); |
---|
[8295] | 97 | // Comments |
---|
[8386] | 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']); |
---|
[8295] | 100 | $conf['fbp']['social_plugin_comments']['title'] = $_POST['FBP_SOCIAL_PLUGIN_COMMENTS_TITLE']; |
---|
[8386] | 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']); |
---|
[8250] | 110 | // Like box |
---|
[8386] | 111 | $conf['fbp']['social_plugin_like_box']['enabled'] = ! empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_ENABLED']); |
---|
[8275] | 112 | $conf['fbp']['social_plugin_like_box']['url'] = $_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_URL']; |
---|
[8250] | 113 | $conf['fbp']['social_plugin_like_box']['colorscheme'] = $colorscheme[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_COLORSCHEME']]; |
---|
[8386] | 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 | |
---|
[8331] | 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 | } |
---|
[8241] | 126 | break; |
---|
| 127 | } |
---|
| 128 | |
---|
[8440] | 129 | case 'button' : |
---|
[8436] | 130 | { |
---|
| 131 | $conf['fbp']['share_picture'] = ! empty($_POST['FBP_SHARE_PICTURE']); |
---|
| 132 | $conf['fbp']['share_album'] = ! empty($_POST['FBP_SHARE_ALBUM']); |
---|
[8440] | 133 | $conf['fbp']['upload_picture'] = ! empty($_POST['FBP_UPLOAD_PICTURE']); |
---|
[8436] | 134 | break; |
---|
| 135 | } |
---|
| 136 | |
---|
[8241] | 137 | case 'advanced' : |
---|
| 138 | { |
---|
[8298] | 139 | $conf['fbp']['facebook_app_id'] = $_POST['FBP_FACEBOOK_APP_ID']; |
---|
[8386] | 140 | $conf['fbp']['async_script'] = ! empty($_POST['FBP_ASYNC_SCRIPT']); |
---|
| 141 | $conf['fbp']['force_facebook_init'] = ! empty($_POST['FBP_FORCE_FACEBOOK_INIT']); |
---|
[8295] | 142 | $conf['fbp']['picture_url_type'] = $picture_url_type[$_POST['FBP_PICTURE_URL_TYPE']]; |
---|
[8386] | 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']); |
---|
[8241] | 147 | break; |
---|
| 148 | } |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | $query = ' |
---|
| 152 | update '.CONFIG_TABLE.' |
---|
| 153 | set |
---|
| 154 | value = \''.serialize($conf['fbp']).'\' |
---|
| 155 | where |
---|
| 156 | param = \'fbp\' |
---|
| 157 | ;'; |
---|
[8275] | 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 | } |
---|
[8375] | 166 | |
---|
| 167 | // Delete compiled templates |
---|
| 168 | $template->delete_compiled_templates(); |
---|
[8241] | 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 | ( |
---|
[8375] | 181 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/like/', |
---|
[8386] | 182 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_like_button']['enabled']), |
---|
[8241] | 183 | 'LAYOUT_OPTIONS' => $layout_l10n, |
---|
| 184 | 'LAYOUT_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['layout'], $layout), |
---|
[8386] | 185 | 'SHOW_FACES' => fbp_checked($conf['fbp']['social_plugin_like_button']['show_faces']), |
---|
[8241] | 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 | ), |
---|
[8282] | 191 | 'facepile' => array |
---|
| 192 | ( |
---|
[8375] | 193 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/facepile/', |
---|
[8386] | 194 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_facepile']['enabled']), |
---|
[8282] | 195 | 'MAX_ROWS' => $conf['fbp']['social_plugin_facepile']['max_rows'], |
---|
| 196 | ), |
---|
[8295] | 197 | 'comments' => array |
---|
| 198 | ( |
---|
[8375] | 199 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/comments/', |
---|
[8386] | 200 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_comments']['enabled']), |
---|
[8295] | 201 | 'NUMPOSTS' => $conf['fbp']['social_plugin_comments']['numposts'], |
---|
| 202 | 'TITLE' => $conf['fbp']['social_plugin_comments']['title'], |
---|
[8386] | 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']), |
---|
[8295] | 206 | ), |
---|
[8386] | 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 | ), |
---|
[8250] | 217 | 'like_box' => array |
---|
| 218 | ( |
---|
[8375] | 219 | 'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/like-box/', |
---|
[8386] | 220 | 'ENABLED' => fbp_checked($conf['fbp']['social_plugin_like_box']['enabled']), |
---|
[8275] | 221 | 'URL' => $conf['fbp']['social_plugin_like_box']['url'], |
---|
[8250] | 222 | 'COLORSCHEME_OPTIONS' => $colorscheme_l10n, |
---|
| 223 | 'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_box']['colorscheme'], $colorscheme), |
---|
[8386] | 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'], |
---|
[8250] | 228 | ), |
---|
[8241] | 229 | )); |
---|
| 230 | break; |
---|
| 231 | } |
---|
[8440] | 232 | case 'button' : |
---|
[8436] | 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']), |
---|
[8440] | 239 | 'FBP_UPLOAD_PICTURE' => fbp_checked($conf['fbp']['upload_picture']), |
---|
[8436] | 240 | )); |
---|
| 241 | break; |
---|
| 242 | } |
---|
[8241] | 243 | case 'advanced' : |
---|
| 244 | { |
---|
| 245 | $template->assign( |
---|
| 246 | $page['tab'], |
---|
| 247 | array( |
---|
[8298] | 248 | 'FBP_FACEBOOK_APP_ID' => $conf['fbp']['facebook_app_id'], |
---|
[8386] | 249 | 'FBP_ASYNC_SCRIPT' => fbp_checked($conf['fbp']['async_script']), |
---|
| 250 | 'FBP_FORCE_FACEBOOK_INIT' => fbp_checked($conf['fbp']['force_facebook_init']), |
---|
[8295] | 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), |
---|
[8386] | 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']), |
---|
[8241] | 257 | )); |
---|
| 258 | break; |
---|
| 259 | } |
---|
[8386] | 260 | case 'activity' : |
---|
| 261 | { |
---|
| 262 | $template->assign( |
---|
| 263 | $page['tab'], |
---|
| 264 | array( |
---|
| 265 | )); |
---|
| 266 | break; |
---|
| 267 | } |
---|
[8241] | 268 | } |
---|
| 269 | |
---|
[8331] | 270 | // Global value |
---|
[9795] | 271 | //~ $template->assign('FBP_ACTION', add_url_params($base_url, array('tab' => $page['tab']))); |
---|
| 272 | $template->assign('FBP_ACTION', $base_url.$page['tab']); |
---|
[8375] | 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', '<')); |
---|
[8241] | 277 | |
---|
[8331] | 278 | //Apply tpl |
---|
[9795] | 279 | $template->set_filename('fbp_plugin_admin_content', FBP_DIR.'/tpl/admin.tpl'); |
---|
[8436] | 280 | $template->assign_var_from_handle('ADMIN_CONTENT', 'fbp_plugin_admin_content'); |
---|
[8241] | 281 | |
---|
| 282 | ?> |
---|