source: extensions/photoWidget/admin.php @ 31505

Last change on this file since 31505 was 26116, checked in by nikrou, 11 years ago

Make plugin compatible with plugin 2.6

File size: 4.0 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | photoWidget  - a plugin for Piwigo                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2010-2013 Nicolas Roudaire        http://www.nikrou.net  |
6// +-----------------------------------------------------------------------+
7// | This program is free software; you can redistribute it and/or modify  |
8// | it under the terms of the GNU General Public License version 2 as     |
9// | published by the Free Software Foundation                             |
10// |                                                                       |
11// | This program is distributed in the hope that it will be useful, but   |
12// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
13// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
14// | General Public License for more details.                              |
15// |                                                                       |
16// | You should have received a copy of the GNU General Public License     |
17// | along with this program; if not, write to the Free Software           |
18// | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,            |
19// | MA 02110-1301 USA                                                     |
20// +-----------------------------------------------------------------------+
21
22if (!defined('PHPWG_ROOT_PATH')) {
23  die('Hacking attempt!');
24}
25
26load_language('plugin.lang', PW_PLUGIN_LANG);
27
28$me = get_plugin_data($plugin_id);
29$save_config = false;
30
31if (!empty($_POST['submit'])) {
32  if (isset($_POST['pw_all_categories'])) {
33    if ($_POST['pw_all_categories']==1) {
34      $page['infos'][] = l10n('You choose that mode for').' '.l10n('All categories');
35      $me->pw_all_categories = 1;
36      $me->pw_categories = array();
37      $save_config = true;
38    } else {
39      if (isset($_POST['pw_categories'])) {
40        if (count($_POST['pw_categories'])==1 && ($_POST['pw_categories'][0]=='__none__')) {
41          $page['errors'][] = l10n('You must choose at least one category');
42          $me->pw_categories = array();
43          $save_config = true;     
44        } else {
45          $page['infos'][] = l10n('You choose that mode for').' '.
46            l10n_dec('one category',
47                     'severals categories',
48                     count($_POST['pw_categories'])
49                     );
50          $me->pw_all_categories = 0;
51          $me->pw_categories = $_POST['pw_categories'];       
52          $save_config = true;     
53        }
54      } else {
55        $page['errors'][] = l10n('You must choose at least one category');
56      }
57    }
58  }
59
60  if (!empty($_POST['pw_width']) && intval($_POST['pw_width'])!=$me->pw_width) {
61    $me->pw_width = intval($_POST['pw_width']);
62    $page['infos'][] = l10n('Width has been updated');
63    $save_config = true;
64  }
65  if (!empty($_POST['pw_height']) && intval($_POST['pw_height'])!=$me->pw_height) {
66    $me->pw_height = intval($_POST['pw_height']);
67    $page['infos'][] = l10n('Height has been updated');
68    $save_config = true;
69  }
70  if (!empty($_POST['pw_bgcolor']) && trim($_POST['pw_bgcolor'])!=$me->pw_bgcolor) {
71    $me->pw_bgcolor = $_POST['pw_bgcolor'];
72    $page['infos'][] = l10n('Background color of animation has been updated');
73    $save_config = true;
74  }
75
76  if ($save_config) {
77    $me->save_config();
78  }
79}
80
81$query = '
82SELECT id,name,global_rank,uppercats
83  FROM '.CATEGORIES_TABLE;
84
85display_select_cat_wrapper($query, $me->pw_categories, 'all_categories');
86
87$template->set_filenames(array('plugin_admin_content' => PW_TEMPLATE . '/admin.tpl'));
88$template->assign('PW_CAT_CHOICES', array(1 => l10n('Yes'), 0 => l10n('No')));
89$template->assign('PW_ALL_CATEGORIES', $me->pw_all_categories);
90$template->assign('PWG_PHOTO_WIDGET_PLUGIN_CSS', PW_CSS);
91$template->assign('PWG_PHOTO_WIDGET_PLUGIN_JS', PW_JS);
92$template->assign('PW_BGCOLOR', $me->pw_bgcolor);
93$template->assign('PW_WIDTH', $me->pw_width); 
94$template->assign('PW_HEIGHT', $me->pw_height); 
95$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Note: See TracBrowser for help on using the repository browser.