[8241] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | FacebookPlug - a Piwigo Plugin | |
---|
| 4 | // | Copyright (C) 2010 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('plugin.lang', FBP_DIR.'/'); |
---|
| 31 | |
---|
[8243] | 32 | // Delete compiled templates |
---|
| 33 | $template->delete_compiled_templates(); |
---|
| 34 | |
---|
[8241] | 35 | // Arguments |
---|
| 36 | $page['tab'] = (isset($_GET['tab']) ? $_GET['tab'] : 'social_plugin'); |
---|
| 37 | |
---|
| 38 | // Data |
---|
| 39 | $base_url = get_admin_plugin_menu_link(__FILE__); |
---|
[8295] | 40 | $picture_url_type = array('page', 'image'); |
---|
| 41 | $picture_url_type_l10n = array_map('l10n', $picture_url_type); |
---|
[8241] | 42 | $layout = array('standard', 'button_count', 'box_count'); |
---|
| 43 | $layout_l10n = array_map('l10n', $layout); |
---|
| 44 | $action = array('like', 'recommend'); |
---|
| 45 | $action_l10n = array_map('l10n', $action); |
---|
| 46 | $colorscheme = array('light', 'dark'); |
---|
| 47 | $colorscheme_l10n = array_map('l10n', $colorscheme); |
---|
| 48 | |
---|
| 49 | // Tabsheet |
---|
| 50 | $tabsheet = new tabsheet(); |
---|
| 51 | $tabsheet->add('social_plugin', |
---|
[8282] | 52 | l10n('Social plugins'), |
---|
[8241] | 53 | add_url_params($base_url, array('tab' => 'social_plugin'))); |
---|
| 54 | $tabsheet->add('advanced', |
---|
| 55 | l10n('Advanced'), |
---|
| 56 | add_url_params($base_url, array('tab' => 'advanced'))); |
---|
| 57 | $tabsheet->select($page['tab']); |
---|
| 58 | $tabsheet->assign(); |
---|
| 59 | |
---|
| 60 | // Update |
---|
| 61 | if (isset($_POST['submit'])) |
---|
| 62 | { |
---|
| 63 | switch ($page['tab']) |
---|
| 64 | { |
---|
| 65 | case 'social_plugin' : |
---|
| 66 | { |
---|
[8250] | 67 | // Like button |
---|
[8241] | 68 | $conf['fbp']['social_plugin_like_button']['enabled'] = empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_ENABLED']) ? false : true; |
---|
| 69 | $conf['fbp']['social_plugin_like_button']['layout'] = $layout[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_LAYOUT']]; |
---|
| 70 | $conf['fbp']['social_plugin_like_button']['show_faces'] = empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_SHOW_FACES']) ? false : true; |
---|
| 71 | $conf['fbp']['social_plugin_like_button']['action'] = $action[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_ACTION']]; |
---|
| 72 | $conf['fbp']['social_plugin_like_button']['colorscheme'] = $colorscheme[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_COLORSCHEME']]; |
---|
[8282] | 73 | // Facepile |
---|
| 74 | $conf['fbp']['social_plugin_facepile']['enabled'] = empty($_POST['FBP_SOCIAL_PLUGIN_FACEPILE_ENABLED']) ? false : true; |
---|
| 75 | $conf['fbp']['social_plugin_facepile']['max_rows'] = intval($_POST['FBP_SOCIAL_PLUGIN_FACEPILE_MAX_ROWS']); |
---|
[8295] | 76 | // Comments |
---|
| 77 | $conf['fbp']['social_plugin_comments']['enabled'] = empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_ENABLED']) ? false : true; |
---|
| 78 | $conf['fbp']['social_plugin_comments']['numposts'] = intval($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_NUMPOSTS']); |
---|
| 79 | $conf['fbp']['social_plugin_comments']['title'] = $_POST['FBP_SOCIAL_PLUGIN_COMMENTS_TITLE']; |
---|
| 80 | $conf['fbp']['social_plugin_comments']['simple'] = empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_SIMPLE']) ? false : true; |
---|
| 81 | $conf['fbp']['social_plugin_comments']['reverse'] = empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_REVERSE']) ? false : true; |
---|
| 82 | $conf['fbp']['social_plugin_comments']['publish_feed'] = empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_PUBLISH_FEED']) ? false : true; |
---|
[8250] | 83 | // Like box |
---|
| 84 | $conf['fbp']['social_plugin_like_box']['enabled'] = empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_ENABLED']) ? false : true; |
---|
[8275] | 85 | $conf['fbp']['social_plugin_like_box']['url'] = $_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_URL']; |
---|
[8250] | 86 | $conf['fbp']['social_plugin_like_box']['colorscheme'] = $colorscheme[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_COLORSCHEME']]; |
---|
| 87 | $conf['fbp']['social_plugin_like_box']['show_faces'] = empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_SHOW_FACES']) ? false : true; |
---|
| 88 | $conf['fbp']['social_plugin_like_box']['stream'] = empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_STREAM']) ? false : true; |
---|
| 89 | $conf['fbp']['social_plugin_like_box']['header'] = empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_HEADER']) ? false : true; |
---|
[8241] | 90 | break; |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | case 'advanced' : |
---|
| 94 | { |
---|
[8298] | 95 | $conf['fbp']['facebook_app_id'] = $_POST['FBP_FACEBOOK_APP_ID']; |
---|
[8241] | 96 | $conf['fbp']['async_script'] = empty($_POST['FBP_ASYNC_SCRIPT']) ? false : true; |
---|
[8295] | 97 | $conf['fbp']['picture_url_type'] = $picture_url_type[$_POST['FBP_PICTURE_URL_TYPE']]; |
---|
[8241] | 98 | $conf['fbp']['allow_fb_access_private_page'] = empty($_POST['FBP_ALLOW_FB_ACCESS_PRIVATE_PAGE']) ? false : true; |
---|
| 99 | break; |
---|
| 100 | } |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | $query = ' |
---|
| 104 | update '.CONFIG_TABLE.' |
---|
| 105 | set |
---|
| 106 | value = \''.serialize($conf['fbp']).'\' |
---|
| 107 | where |
---|
| 108 | param = \'fbp\' |
---|
| 109 | ;'; |
---|
[8275] | 110 | if (pwg_query($query)) |
---|
| 111 | { |
---|
| 112 | array_push($page['infos'], l10n('Data updated with success')); |
---|
| 113 | } |
---|
| 114 | else |
---|
| 115 | { |
---|
| 116 | array_push($page['errors'], l10n('Data updated with error')); |
---|
| 117 | } |
---|
[8241] | 118 | } |
---|
| 119 | |
---|
| 120 | // Display |
---|
| 121 | switch ($page['tab']) |
---|
| 122 | { |
---|
| 123 | case 'social_plugin' : |
---|
| 124 | { |
---|
| 125 | $template->assign( |
---|
| 126 | $page['tab'], |
---|
| 127 | array( |
---|
| 128 | 'like_button' => array |
---|
| 129 | ( |
---|
[8282] | 130 | 'FB_PAGE' => 'http://developers.facebook.com/docs/reference/plugins/like/', |
---|
[8241] | 131 | 'ENABLED' => ($conf['fbp']['social_plugin_like_button']['enabled'] ? 'checked="checked"' : ''), |
---|
| 132 | 'LAYOUT_OPTIONS' => $layout_l10n, |
---|
| 133 | 'LAYOUT_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['layout'], $layout), |
---|
| 134 | 'SHOW_FACES' => ($conf['fbp']['social_plugin_like_button']['show_faces'] ? 'checked="checked"' : ''), |
---|
| 135 | 'ACTION_OPTIONS' => $action_l10n, |
---|
| 136 | 'ACTION_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['action'], $action), |
---|
| 137 | 'COLORSCHEME_OPTIONS' => $colorscheme_l10n, |
---|
| 138 | 'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['colorscheme'], $colorscheme), |
---|
| 139 | ), |
---|
[8282] | 140 | 'facepile' => array |
---|
| 141 | ( |
---|
| 142 | 'FB_PAGE' => 'http://developers.facebook.com/docs/reference/plugins/facepile/', |
---|
| 143 | 'ENABLED' => ($conf['fbp']['social_plugin_facepile']['enabled'] ? 'checked="checked"' : ''), |
---|
| 144 | 'MAX_ROWS' => $conf['fbp']['social_plugin_facepile']['max_rows'], |
---|
| 145 | ), |
---|
[8295] | 146 | 'comments' => array |
---|
| 147 | ( |
---|
| 148 | 'FB_PAGE' => 'http://developers.facebook.com/docs/reference/plugins/comments/', |
---|
| 149 | 'ENABLED' => ($conf['fbp']['social_plugin_comments']['enabled'] ? 'checked="checked"' : ''), |
---|
| 150 | 'NUMPOSTS' => $conf['fbp']['social_plugin_comments']['numposts'], |
---|
| 151 | 'TITLE' => $conf['fbp']['social_plugin_comments']['title'], |
---|
| 152 | 'SIMPLE' => ($conf['fbp']['social_plugin_comments']['simple'] ? 'checked="checked"' : ''), |
---|
| 153 | 'REVERSE' => ($conf['fbp']['social_plugin_comments']['reverse'] ? 'checked="checked"' : ''), |
---|
| 154 | 'PUBLISH_FEED' => ($conf['fbp']['social_plugin_comments']['publish_feed'] ? 'checked="checked"' : ''), |
---|
| 155 | ), |
---|
[8250] | 156 | 'like_box' => array |
---|
| 157 | ( |
---|
[8282] | 158 | 'FB_PAGE' => 'http://developers.facebook.com/docs/reference/plugins/like-box/', |
---|
[8250] | 159 | 'ENABLED' => ($conf['fbp']['social_plugin_like_box']['enabled'] ? 'checked="checked"' : ''), |
---|
[8275] | 160 | 'URL' => $conf['fbp']['social_plugin_like_box']['url'], |
---|
[8250] | 161 | 'COLORSCHEME_OPTIONS' => $colorscheme_l10n, |
---|
| 162 | 'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_box']['colorscheme'], $colorscheme), |
---|
| 163 | 'SHOW_FACES' => ($conf['fbp']['social_plugin_like_box']['show_faces'] ? 'checked="checked"' : ''), |
---|
| 164 | 'STREAM' => ($conf['fbp']['social_plugin_like_box']['stream'] ? 'checked="checked"' : ''), |
---|
| 165 | 'HEADER' => ($conf['fbp']['social_plugin_like_box']['header'] ? 'checked="checked"' : ''), |
---|
| 166 | ), |
---|
[8241] | 167 | )); |
---|
| 168 | break; |
---|
| 169 | } |
---|
| 170 | case 'advanced' : |
---|
| 171 | { |
---|
| 172 | $template->assign( |
---|
| 173 | $page['tab'], |
---|
| 174 | array( |
---|
[8298] | 175 | 'FBP_FACEBOOK_APP_ID' => $conf['fbp']['facebook_app_id'], |
---|
| 176 | 'FBP_ASYNC_SCRIPT' => ($conf['fbp']['async_script'] ? 'checked="checked"' : ''), |
---|
[8295] | 177 | 'FBP_PICTURE_URL_TYPE_OPTIONS' => $picture_url_type_l10n, |
---|
| 178 | 'FBP_PICTURE_URL_TYPE_OPTIONS_SELECTED' => array_search($conf['fbp']['picture_url_type'], $picture_url_type), |
---|
[8241] | 179 | 'FBP_ALLOW_FB_ACCESS_PRIVATE_PAGE'=> ($conf['fbp']['allow_fb_access_private_page'] ? 'checked="checked"' : ''), |
---|
| 180 | )); |
---|
| 181 | break; |
---|
| 182 | } |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | /*$template->assign( |
---|
| 186 | array( |
---|
| 187 | 'FBP_ALLOW_FB_ACCESS_PRIVATE_PAGE'=> ($conf['fbp']['allow_fb_access_private_page'] ? 'checked="checked"' : ''), |
---|
| 188 | //~ 'FBP_DAY_NUMBER'=> $conf['fbp']['day_number'], |
---|
| 189 | ));*/ |
---|
| 190 | |
---|
| 191 | $template->set_filename('plugin_admin_content', FBP_DIR.'/tpl/admin.config.tpl'); |
---|
| 192 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | ?> |
---|