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

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

Admin configuration page:

o Fix cancel Button
o Change layout
o Like Button and comments cannot be enabled together (php and JQuery test)

  • Property svn:eol-style set to LF
File size: 10.1 KB
Line 
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
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('plugin.lang', FBP_DIR.'/');
31
32// Delete compiled templates
33$template->delete_compiled_templates();
34
35// Arguments
36$page['tab'] = (isset($_GET['tab']) ? $_GET['tab'] : 'social_plugin');
37
38// Data
39$base_url = get_admin_plugin_menu_link(__FILE__);
40$picture_url_type = array('page', 'image');
41$picture_url_type_l10n = array_map('l10n', $picture_url_type);
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
50// Tabsheet
51$tabsheet = new tabsheet();
52$tabsheet->add('social_plugin',
53               l10n('Social plugins'),
54               add_url_params($base_url, array('tab' => 'social_plugin')));
55$tabsheet->add('advanced',
56               l10n('Advanced'),
57               add_url_params($base_url, array('tab' => 'advanced')));
58$tabsheet->select($page['tab']);
59$tabsheet->assign();
60
61// Update
62if (isset($_POST['submit']))
63{
64  $save_conf['fbp'] = $conf['fbp'];
65
66  switch ($page['tab'])
67  {
68    case 'social_plugin' :
69    {
70      // Like button
71      $conf['fbp']['social_plugin_like_button']['enabled'] = empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_ENABLED']) ? false : true;
72      $conf['fbp']['social_plugin_like_button']['layout'] = $layout[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_LAYOUT']];
73      $conf['fbp']['social_plugin_like_button']['show_faces'] = empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_SHOW_FACES']) ? false : true;
74      $conf['fbp']['social_plugin_like_button']['action'] = $action[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_ACTION']];
75      $conf['fbp']['social_plugin_like_button']['colorscheme'] = $colorscheme[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BUTTON_COLORSCHEME']];
76      // Facepile
77      $conf['fbp']['social_plugin_facepile']['enabled'] = empty($_POST['FBP_SOCIAL_PLUGIN_FACEPILE_ENABLED']) ? false : true;
78      $conf['fbp']['social_plugin_facepile']['max_rows'] = intval($_POST['FBP_SOCIAL_PLUGIN_FACEPILE_MAX_ROWS']);
79      // Comments
80      $conf['fbp']['social_plugin_comments']['enabled'] = empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_ENABLED']) ? false : true;
81      $conf['fbp']['social_plugin_comments']['numposts'] = intval($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_NUMPOSTS']);
82      $conf['fbp']['social_plugin_comments']['title'] = $_POST['FBP_SOCIAL_PLUGIN_COMMENTS_TITLE'];
83      $conf['fbp']['social_plugin_comments']['simple'] = empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_SIMPLE']) ? false : true;
84      $conf['fbp']['social_plugin_comments']['reverse'] = empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_REVERSE']) ? false : true;
85      $conf['fbp']['social_plugin_comments']['publish_feed'] = empty($_POST['FBP_SOCIAL_PLUGIN_COMMENTS_PUBLISH_FEED']) ? false : true;
86      // Like box
87      $conf['fbp']['social_plugin_like_box']['enabled'] = empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_ENABLED']) ? false : true;
88      $conf['fbp']['social_plugin_like_box']['url'] = $_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_URL'];
89      $conf['fbp']['social_plugin_like_box']['colorscheme'] = $colorscheme[$_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_COLORSCHEME']];
90      $conf['fbp']['social_plugin_like_box']['show_faces'] = empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_SHOW_FACES']) ? false : true;
91      $conf['fbp']['social_plugin_like_box']['stream'] = empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_STREAM']) ? false : true;
92      $conf['fbp']['social_plugin_like_box']['header'] = empty($_POST['FBP_SOCIAL_PLUGIN_LIKE_BOX_HEADER']) ? false : true;
93     
94      // Check
95      if ($conf['fbp']['social_plugin_like_button']['enabled'] and $conf['fbp']['social_plugin_comments']['enabled'])
96      {
97        $conf['fbp']['social_plugin_like_button']['enabled'] = $save_conf['fbp']['social_plugin_like_button']['enabled'];
98        $conf['fbp']['social_plugin_comments']['enabled'] = $save_conf['fbp']['social_plugin_comments']['enabled'];
99        array_push($page['infos'], l10n('Like button and comments cannot be enabled together').', '.l10n('enabled values are restored'));
100      }
101      break;
102    }
103
104    case 'advanced' :
105    {
106      $conf['fbp']['facebook_app_id'] = $_POST['FBP_FACEBOOK_APP_ID'];
107      $conf['fbp']['async_script'] = empty($_POST['FBP_ASYNC_SCRIPT']) ? false : true;
108      $conf['fbp']['picture_url_type'] = $picture_url_type[$_POST['FBP_PICTURE_URL_TYPE']];
109      $conf['fbp']['allow_fb_access_private_page'] = empty($_POST['FBP_ALLOW_FB_ACCESS_PRIVATE_PAGE']) ? false : true;
110      break;
111    }
112  }
113
114  $query = '
115update '.CONFIG_TABLE.'
116set
117  value = \''.serialize($conf['fbp']).'\'
118where
119  param = \'fbp\'
120;';
121  if (pwg_query($query))
122  {
123    array_push($page['infos'], l10n('Data updated with success'));
124  }
125  else
126  {
127    array_push($page['errors'], l10n('Data updated with error'));
128  }
129}
130
131// Display
132switch ($page['tab'])
133{
134  case 'social_plugin' :
135  {
136    $template->assign(
137      $page['tab'],
138      array(
139        'like_button' => array
140          (
141            'FB_PAGE' => 'http://developers.facebook.com/docs/reference/plugins/like/',
142            'ENABLED' => ($conf['fbp']['social_plugin_like_button']['enabled'] ? 'checked="checked"' : ''),
143            'LAYOUT_OPTIONS' => $layout_l10n,
144            'LAYOUT_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['layout'], $layout),
145            'SHOW_FACES' => ($conf['fbp']['social_plugin_like_button']['show_faces'] ? 'checked="checked"' : ''),
146            'ACTION_OPTIONS' => $action_l10n,
147            'ACTION_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['action'], $action),
148            'COLORSCHEME_OPTIONS' => $colorscheme_l10n,
149            'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_button']['colorscheme'], $colorscheme),
150          ),
151       'facepile' => array
152          (
153            'FB_PAGE' => 'http://developers.facebook.com/docs/reference/plugins/facepile/',
154            'ENABLED' => ($conf['fbp']['social_plugin_facepile']['enabled'] ? 'checked="checked"' : ''),
155            'MAX_ROWS' => $conf['fbp']['social_plugin_facepile']['max_rows'],
156          ),
157       'comments' => array
158          (
159            'FB_PAGE' => 'http://developers.facebook.com/docs/reference/plugins/comments/',
160            'ENABLED' => ($conf['fbp']['social_plugin_comments']['enabled'] ? 'checked="checked"' : ''),
161            'NUMPOSTS' => $conf['fbp']['social_plugin_comments']['numposts'],
162            'TITLE' => $conf['fbp']['social_plugin_comments']['title'],
163            'SIMPLE' => ($conf['fbp']['social_plugin_comments']['simple'] ? 'checked="checked"' : ''),
164            'REVERSE' => ($conf['fbp']['social_plugin_comments']['reverse'] ? 'checked="checked"' : ''),
165            'PUBLISH_FEED' => ($conf['fbp']['social_plugin_comments']['publish_feed'] ? 'checked="checked"' : ''),
166          ),
167       'like_box' => array
168          (
169            'FB_PAGE' => 'http://developers.facebook.com/docs/reference/plugins/like-box/',
170            'ENABLED' => ($conf['fbp']['social_plugin_like_box']['enabled'] ? 'checked="checked"' : ''),
171            'URL' => $conf['fbp']['social_plugin_like_box']['url'],
172            'COLORSCHEME_OPTIONS' => $colorscheme_l10n,
173            'COLORSCHEME_OPTIONS_SELECTED' => array_search($conf['fbp']['social_plugin_like_box']['colorscheme'], $colorscheme),
174            'SHOW_FACES' => ($conf['fbp']['social_plugin_like_box']['show_faces'] ? 'checked="checked"' : ''),
175            'STREAM' => ($conf['fbp']['social_plugin_like_box']['stream'] ? 'checked="checked"' : ''),
176            'HEADER' => ($conf['fbp']['social_plugin_like_box']['header'] ? 'checked="checked"' : ''),
177          ),
178        ));
179    break;
180  }
181  case 'advanced' :
182  {
183    $template->assign(
184      $page['tab'],
185      array(
186        'FBP_FACEBOOK_APP_ID' => $conf['fbp']['facebook_app_id'],
187        'FBP_ASYNC_SCRIPT' => ($conf['fbp']['async_script'] ? 'checked="checked"' : ''),
188        'FBP_PICTURE_URL_TYPE_OPTIONS' => $picture_url_type_l10n,
189        'FBP_PICTURE_URL_TYPE_OPTIONS_SELECTED' => array_search($conf['fbp']['picture_url_type'], $picture_url_type),
190        'FBP_ALLOW_FB_ACCESS_PRIVATE_PAGE'=> ($conf['fbp']['allow_fb_access_private_page'] ? 'checked="checked"' : ''),
191        ));
192    break;
193  }
194}
195
196// Global value
197//~ $template->assign('FBP_PATH', FBP_PATH);
198$template->assign('FBP_ACTION', add_url_params($base_url, array('tab' => $page['tab'])));
199$template->block_html_head('', '<link rel="stylesheet" type="text/css" href="'.FBP_PATH.'/css/admin.config.css">', $smarty, $repeat);
200
201//Apply tpl
202$template->set_filename('plugin_admin_content', FBP_DIR.'/tpl/admin.config.tpl');
203$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
204
205
206?>
Note: See TracBrowser for help on using the repository browser.