source: extensions/pwgCumulus/admin.php @ 5323

Last change on this file since 5323 was 5323, checked in by nikrou, 14 years ago

Update translation keys (prepare for gettext)

File size: 4.8 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | pwgCumulus  - a plugin for Piwigo                                     |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2009-2010 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 as published by  |
9// | 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
19// | USA.                                                                  |
20// +-----------------------------------------------------------------------+
21
22if (!defined('PHPWG_ROOT_PATH')) {
23  die('Hacking attempt!');
24}
25
26add_event_handler('loc_end_page_header', 'pwg_cumulus_addAssets');
27
28load_language('plugin.lang', PWG_CUMULUS_PLUGIN_LANG);
29
30$me = get_plugin_data($plugin_id);
31$save_config = false;
32
33if (!empty($_POST['submit'])) {
34  Log::getInstance()->debug($_POST);
35  if (!empty($_POST['pwg_cumulus_width']) && intval($_POST['pwg_cumulus_width'])!=$me->pwg_cumulus_width) {
36    $me->pwg_cumulus_width = intval($_POST['pwg_cumulus_width']);
37    array_push($GLOBALS['page']['infos'], $lang['Width updated']);
38    $save_config = true;
39  }
40  if (!empty($_POST['pwg_cumulus_height']) && intval($_POST['pwg_cumulus_height'])!=$me->pwg_cumulus_height) {
41    $me->pwg_cumulus_height = intval($_POST['pwg_cumulus_height']);
42    array_push($GLOBALS['page']['infos'], $lang['Height updated']);
43    $save_config = true;
44  }
45  if (!empty($_POST['pwg_cumulus_coeff']) && intval($_POST['pwg_cumulus_coeff'])!=$me->pwg_cumulus_coeff) {
46    $me->pwg_cumulus_coeff = intval($_POST['pwg_cumulus_coeff']);
47    array_push($GLOBALS['page']['infos'], $lang['Coefficient for tags size updated']);
48    $save_config = true;
49  }
50
51  if (!empty($_POST['pwg_cumulus_color1']) && trim($_POST['pwg_cumulus_color1'])!=$me->pwg_cumulus_color1) {
52    $me->pwg_cumulus_color1 = $_POST['pwg_cumulus_color1'];
53    array_push($GLOBALS['page']['infos'], $lang['Color 1 updated']);
54    $save_config = true;
55  }
56  if (!empty($_POST['pwg_cumulus_color2']) && trim($_POST['pwg_cumulus_color2'])!=$me->pwg_cumulus_color2) {
57    $me->pwg_cumulus_color2 = $_POST['pwg_cumulus_color2'];
58    array_push($GLOBALS['page']['infos'], $lang['Color 2 updated']);
59    $save_config = true;
60  }
61  if (!empty($_POST['pwg_cumulus_hicolor']) && trim($_POST['pwg_cumulus_hicolor'])!=$me->pwg_cumulus_hicolor) {
62    $me->pwg_cumulus_hicolor = $_POST['pwg_cumulus_hicolor'];
63    array_push($GLOBALS['page']['infos'], $lang['Mouseover color updated']);
64    $save_config = true;
65  }
66
67  if ($save_config) {
68    $me->save_config();
69  }
70}
71
72$GLOBALS['template']->set_filenames(array('plugin_admin_content' => PWG_CUMULUS_PLUGIN_TEMPLATE . '/admin.tpl'));
73$GLOBALS['template']->assign('PWG_CUMULUS_WIDTH', $me->pwg_cumulus_width); 
74$GLOBALS['template']->assign('PWG_CUMULUS_HEIGHT', $me->pwg_cumulus_height); 
75$GLOBALS['template']->assign('PWG_CUMULUS_COEFF', $me->pwg_cumulus_coeff); 
76$GLOBALS['template']->assign('PWG_CUMULUS_COLOR1', $me->pwg_cumulus_color1);
77$GLOBALS['template']->assign('PWG_CUMULUS_COLOR2', $me->pwg_cumulus_color2);
78$GLOBALS['template']->assign('PWG_CUMULUS_HICOLOR', $me->pwg_cumulus_hicolor);
79$GLOBALS['template']->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
80
81function pwg_cumulus_addAssets() {
82  $css_format = '<link rel="stylesheet" type="text/css" href="%s/%s.css">'."\n";
83  $js_format = '<script type="text/javascript" src="%s"></script>'."\n";
84 
85  $GLOBALS['template']->append('head_elements', 
86                               sprintf($css_format,
87                                       PWG_CUMULUS_PLUGIN_CSS,
88                                       'admin'
89                                 )
90    );
91  $GLOBALS['template']->append('head_elements', 
92                               sprintf($css_format,
93                                       PWG_CUMULUS_PLUGIN_CSS,
94                                       'farbtastic'
95                                 )
96    );
97  $GLOBALS['template']->func_known_script(array('id' => 'farbtastic',
98                                                'src' => PWG_CUMULUS_PLUGIN_JS. '/farbtastic.js'
99                                            ),
100                                          $GLOBALS['template']->smarty
101    );
102
103
104}
105?>
Note: See TracBrowser for help on using the repository browser.