source: extensions/FacebookPlug/Plugin/admin.config.php @ 8440

Last change on this file since 8440 was 8440, checked in by rub, 13 years ago

Add upload button on image page

  • Property svn:eol-style set to LF
File size: 13.1 KB
Line 
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
21if (!defined('PHPWG_ROOT_PATH'))
22{
23  die('Hacking attempt!');
24}
25
26// include
27include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
28
29// Lingua
30load_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('button',
53               l10n('Buttons'),
54               add_url_params($base_url, array('tab' => 'button')));
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
64function fbp_intval($n)
65{
66  return (is_numeric($n) ? $n : null);
67}
68
69function fbp_checked($b)
70{
71  return ($b ? 'checked="checked"' : '');
72}
73
74// Update
75if (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 'button' :
125    {
126      $conf['fbp']['share_picture'] = ! empty($_POST['FBP_SHARE_PICTURE']);
127      $conf['fbp']['share_album'] = ! empty($_POST['FBP_SHARE_ALBUM']);
128      $conf['fbp']['upload_picture'] = ! empty($_POST['FBP_UPLOAD_PICTURE']);
129      break;
130    }
131
132    case 'advanced' :
133    {
134      $conf['fbp']['facebook_app_id'] = $_POST['FBP_FACEBOOK_APP_ID'];
135      $conf['fbp']['async_script'] = ! empty($_POST['FBP_ASYNC_SCRIPT']);
136      $conf['fbp']['force_facebook_init'] = ! empty($_POST['FBP_FORCE_FACEBOOK_INIT']);
137      $conf['fbp']['picture_url_type'] = $picture_url_type[$_POST['FBP_PICTURE_URL_TYPE']];
138      $conf['fbp']['allow_fb_access_private_page'] = ! empty($_POST['FBP_ALLOW_FB_ACCESS_PRIVATE_PAGE']);
139      $conf['fbp']['add_about_informations'] = ! empty($_POST['FBP_ADD_ABOUT_INFORMATIONS']);
140      $conf['fbp']['add_group_footer'] = ! empty($_POST['FBP_ADD_GROUP_FOOTER']);
141      $conf['fbp']['add_application_footer'] = ! empty($_POST['FBP_ADD_APPLICATION_FOOTER']);
142      break;
143    }
144  }
145
146  $query = '
147update '.CONFIG_TABLE.'
148set
149  value = \''.serialize($conf['fbp']).'\'
150where
151  param = \'fbp\'
152;';
153  if (pwg_query($query))
154  {
155    array_push($page['infos'], l10n('Data updated with success'));
156  }
157  else
158  {
159    array_push($page['errors'], l10n('Data updated with error'));
160  }
161
162  // Delete compiled templates
163  $template->delete_compiled_templates();
164}
165
166// Display
167switch ($page['tab'])
168{
169  case 'social_plugin' :
170  {
171    $template->assign(
172      $page['tab'],
173      array(
174        'like_button' => array
175          (
176            'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/like/',
177            'ENABLED' => fbp_checked($conf['fbp']['social_plugin_like_button']['enabled']),
178            'LAYOUT_OPTIONS' => $layout_l10n,
179            'LAYOUT_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['layout'], $layout),
180            'SHOW_FACES' => fbp_checked($conf['fbp']['social_plugin_like_button']['show_faces']),
181            'ACTION_OPTIONS' => $action_l10n,
182            'ACTION_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['action'], $action),
183            'COLORSCHEME_OPTIONS' => $colorscheme_l10n,
184            'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['colorscheme'], $colorscheme),
185          ),
186       'facepile' => array
187          (
188            'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/facepile/',
189            'ENABLED' => fbp_checked($conf['fbp']['social_plugin_facepile']['enabled']),
190            'MAX_ROWS' => $conf['fbp']['social_plugin_facepile']['max_rows'],
191          ),
192       'comments' => array
193          (
194            'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/comments/',
195            'ENABLED' => fbp_checked($conf['fbp']['social_plugin_comments']['enabled']),
196            'NUMPOSTS' => $conf['fbp']['social_plugin_comments']['numposts'],
197            'TITLE' => $conf['fbp']['social_plugin_comments']['title'],
198            'SIMPLE' => fbp_checked($conf['fbp']['social_plugin_comments']['simple']),
199            'REVERSE' => fbp_checked($conf['fbp']['social_plugin_comments']['reverse']),
200            'PUBLISH_FEED' => fbp_checked($conf['fbp']['social_plugin_comments']['publish_feed']),
201          ),
202       'activity_feed' => array
203          (
204            'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/activity/',
205            'ENABLED' => fbp_checked($conf['fbp']['social_plugin_activity_feed']['enabled']),
206            'COLORSCHEME_OPTIONS' => $colorscheme_l10n,
207            'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_activity_feed']['colorscheme'], $colorscheme),
208            'RECOMMENDATIONS' => fbp_checked($conf['fbp']['social_plugin_activity_feed']['recommendations']),
209            'HEADER' => fbp_checked($conf['fbp']['social_plugin_activity_feed']['header']),
210            'HEIGHT' => $conf['fbp']['social_plugin_activity_feed']['height'],
211          ),
212       'like_box' => array
213          (
214            'FB_PAGE' => FACEBOOK_DOC_PLUGINS_URL.'/like-box/',
215            'ENABLED' => fbp_checked($conf['fbp']['social_plugin_like_box']['enabled']),
216            'URL' => $conf['fbp']['social_plugin_like_box']['url'],
217            'COLORSCHEME_OPTIONS' => $colorscheme_l10n,
218            'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_box']['colorscheme'], $colorscheme),
219            'SHOW_FACES' => fbp_checked($conf['fbp']['social_plugin_like_box']['show_faces']),
220            'STREAM' => fbp_checked($conf['fbp']['social_plugin_like_box']['stream']),
221            'HEADER' => fbp_checked($conf['fbp']['social_plugin_like_box']['header']),
222            'HEIGHT' => $conf['fbp']['social_plugin_like_box']['height'],
223          ),
224        ));
225    break;
226  }
227  case 'button' :
228  {
229    $template->assign(
230      $page['tab'],
231      array(
232        'FBP_SHARE_PICTURE' => fbp_checked($conf['fbp']['share_picture']),
233        'FBP_SHARE_ALBUM' => fbp_checked($conf['fbp']['share_album']),
234        'FBP_UPLOAD_PICTURE' => fbp_checked($conf['fbp']['upload_picture']),
235        ));
236    break;
237  }
238  case 'advanced' :
239  {
240    $template->assign(
241      $page['tab'],
242      array(
243        'FBP_FACEBOOK_APP_ID' => $conf['fbp']['facebook_app_id'],
244        'FBP_ASYNC_SCRIPT' => fbp_checked($conf['fbp']['async_script']),
245        'FBP_FORCE_FACEBOOK_INIT' => fbp_checked($conf['fbp']['force_facebook_init']),
246        'FBP_PICTURE_URL_TYPE_OPTIONS' => $picture_url_type_l10n,
247        'FBP_PICTURE_URL_TYPE_OPTIONS_SELECTED' => array_search($conf['fbp']['picture_url_type'], $picture_url_type),
248        'FBP_ALLOW_FB_ACCESS_PRIVATE_PAGE'=> fbp_checked($conf['fbp']['allow_fb_access_private_page']),
249        'FBP_ADD_ABOUT_INFORMATIONS' => fbp_checked($conf['fbp']['add_about_informations']),
250        'FBP_ADD_GROUP_FOOTER' => fbp_checked($conf['fbp']['add_group_footer']),
251        'FBP_ADD_APPLICATION_FOOTER' => fbp_checked($conf['fbp']['add_application_footer']),
252        ));
253    break;
254  }
255  case 'activity' :
256  {
257    $template->assign(
258      $page['tab'],
259      array(
260        ));
261    break;
262  }
263}
264
265// Global value
266$template->assign('FBP_ACTION', add_url_params($base_url, array('tab' => $page['tab'])));
267//~ $template->block_html_head('', '<link rel="stylesheet" type="text/css" href="'.FBP_PATH.'/css/admin.config.css">', $smarty, $repeat);
268$template->assign('FACEBOOK_PIWIGO_RUB_URL', FACEBOOK_PIWIGO_RUB_URL);
269$template->assign('FACEBOOK_PIWIGO_GROUP_URL', FACEBOOK_PIWIGO_GROUP_URL);
270$template->assign('FACEBOOK_PIWIGO_APPLICATION_URL', FACEBOOK_PIWIGO_APPLICATION_URL);
271$template->assign('FBP_OLD_VERSION', version_compare(PHPWG_VERSION, '2.2', '<'));
272
273//Apply tpl
274$template->set_filename('fbp_plugin_admin_content', FBP_DIR.'/tpl/admin.config.tpl');
275$template->assign_var_from_handle('ADMIN_CONTENT', 'fbp_plugin_admin_content');
276
277?>
Note: See TracBrowser for help on using the repository browser.