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

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

Happy new year!

Change header of maintained extensions

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