source: extensions/pwgCumulus/admin.php @ 5201

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

Initial version

File size: 5.0 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | pwgCumulus  - a plugin for Piwigo                                     |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2009      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  if (!empty($_POST['pwg_cumulus_width']) && intval($_POST['pwg_cumulus_width'])!=$me->pwg_cumulus_width) {
35    $me->pwg_cumulus_width = intval($_POST['pwg_cumulus_width']);
36    array_push($GLOBALS['page']['infos'], $lang['pwg_cumulus_width_changed']);
37    $save_config = true;
38  }
39  if (!empty($_POST['pwg_cumulus_height']) && intval($_POST['pwg_cumulus_height'])!=$me->pwg_cumulus_height) {
40    $me->pwg_cumulus_height = intval($_POST['pwg_cumulus_height']);
41    array_push($GLOBALS['page']['infos'], $lang['pwg_cumulus_height_changed']);
42    $save_config = true;
43  }
44  if (!empty($_POST['pwg_cumulus_coeff']) && intval($_POST['pwg_cumulus_coeff'])!=$me->pwg_cumulus_coeff) {
45    $me->pwg_cumulus_coeff = intval($_POST['pwg_cumulus_coeff']);
46    array_push($GLOBALS['page']['infos'], $lang['pwg_cumulus_coeff_changed']);
47    $save_config = true;
48  }
49
50  if (!empty($_POST['pwg_cumulus_color1']) && trim($_POST['pwg_cumulus_color1'])!=$me->pwg_cumulus_color1) {
51    //    $me->pwg_cumulus_color1 = trim($_POST['pwg_cumulus_color1'], " /\n\t\r\0\x0B");
52    $me->pwg_cumulus_color1 = $_POST['pwg_cumulus_color1'];
53    array_push($GLOBALS['page']['infos'], $lang['pwg_cumulus_color1_changed']);
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 = trim($_POST['pwg_cumulus_color2'], " /\n\t\r\0\x0B");
58    $me->pwg_cumulus_color2 = $_POST['pwg_cumulus_color2'];
59    array_push($GLOBALS['page']['infos'], $lang['pwg_cumulus_color2_changed']);
60    $save_config = true;
61  }
62  if (!empty($_POST['pwg_cumulus_hicolor']) && trim($_POST['pwg_cumulus_hicolor'])!=$me->pwg_cumulus_hicolor) {
63    //    $me->pwg_cumulus_hicolor = trim($_POST['pwg_cumulus_hicolor'], " /\n\t\r\0\x0B");
64    $me->pwg_cumulus_hicolor = $_POST['pwg_cumulus_hicolor'];
65    array_push($GLOBALS['page']['infos'], $lang['pwg_cumulus_hicolor_changed']);
66    $save_config = true;
67  }
68
69  if ($save_config) {
70    $me->save_config();
71  }
72}
73
74$GLOBALS['template']->set_filenames(array('plugin_admin_content' => PWG_CUMULUS_PLUGIN_TEMPLATE . '/admin.tpl'));
75$GLOBALS['template']->assign('PWG_CUMULUS_WIDTH', $me->pwg_cumulus_width); 
76$GLOBALS['template']->assign('PWG_CUMULUS_HEIGHT', $me->pwg_cumulus_height); 
77$GLOBALS['template']->assign('PWG_CUMULUS_COEFF', $me->pwg_cumulus_coeff); 
78$GLOBALS['template']->assign('PWG_CUMULUS_COLOR1', $me->pwg_cumulus_color1);
79$GLOBALS['template']->assign('PWG_CUMULUS_COLOR2', $me->pwg_cumulus_color2);
80$GLOBALS['template']->assign('PWG_CUMULUS_HICOLOR', $me->pwg_cumulus_hicolor);
81$GLOBALS['template']->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
82
83function pwg_cumulus_addAssets() {
84  $css_format = '<link rel="stylesheet" type="text/css" href="%s/%s.css">'."\n";
85  $js_format = '<script type="text/javascript" src="%s"></script>'."\n";
86 
87  $GLOBALS['template']->append('head_elements', 
88                               sprintf($css_format,
89                                       PWG_CUMULUS_PLUGIN_CSS,
90                                       'admin'
91                                       )
92                               );
93  $GLOBALS['template']->append('head_elements', 
94                               sprintf($css_format,
95                                       PWG_CUMULUS_PLUGIN_CSS,
96                                       'farbtastic'
97                                       )
98                               );
99  $GLOBALS['template']->func_known_script(array('id' => 'farbtastic',
100                                                'src' => PWG_CUMULUS_PLUGIN_JS. '/farbtastic.js'
101                                                ),
102                                          $GLOBALS['template']->smarty
103                                          );
104
105
106}
107?>
Note: See TracBrowser for help on using the repository browser.