1 | <?php |
---|
2 | /* ----------------------------------------------------------------------------- |
---|
3 | Plugin : Histogram |
---|
4 | Author : Grum |
---|
5 | email : grum@piwigo.org |
---|
6 | website : http://photos.grum.fr |
---|
7 | |
---|
8 | << May the Little SpaceFrog be with you ! >> |
---|
9 | ------------------------------------------------------------------------------ |
---|
10 | See main.inc.php for release information |
---|
11 | |
---|
12 | HGram_AIP : classe to manage plugin admin pages |
---|
13 | |
---|
14 | --------------------------------------------------------------------------- */ |
---|
15 | |
---|
16 | if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
17 | |
---|
18 | include_once('hgram_root.class.inc.php'); |
---|
19 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php'); |
---|
20 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTabSheet.class.inc.php'); |
---|
21 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
22 | |
---|
23 | class HGram_AIP extends HGram_root |
---|
24 | { |
---|
25 | protected $tabsheet; |
---|
26 | |
---|
27 | public function __construct($prefixeTable, $filelocation) |
---|
28 | { |
---|
29 | parent::__construct($prefixeTable, $filelocation); |
---|
30 | $this->checkRequest(); |
---|
31 | |
---|
32 | $this->loadConfig(); |
---|
33 | $this->initEvents(); |
---|
34 | |
---|
35 | $this->tabsheet = new tabsheet(); |
---|
36 | /* $this->tabsheet->add('database', |
---|
37 | l10n('hgram_database'), |
---|
38 | $this->getAdminLink()."&f_tabsheet=database");*/ |
---|
39 | $this->tabsheet->add('config', |
---|
40 | l10n('hgram_config'), |
---|
41 | $this->getAdminLink()."-config"); |
---|
42 | } |
---|
43 | |
---|
44 | public function __destruct() |
---|
45 | { |
---|
46 | unset($this->tabsheet); |
---|
47 | parent::__destruct(); |
---|
48 | } |
---|
49 | |
---|
50 | /* |
---|
51 | initialize events call for the plugin |
---|
52 | */ |
---|
53 | public function initEvents() |
---|
54 | { |
---|
55 | parent::initEvents(); |
---|
56 | if($_GET['tab']=='search') |
---|
57 | { |
---|
58 | // load request builder JS only on the search page |
---|
59 | GPCRequestBuilder::loadJSandCSS(); |
---|
60 | } |
---|
61 | add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS')); |
---|
62 | GPCCss::applyGpcCss(); |
---|
63 | } |
---|
64 | |
---|
65 | /* |
---|
66 | display administration page |
---|
67 | */ |
---|
68 | public function manage() |
---|
69 | { |
---|
70 | global $template; |
---|
71 | |
---|
72 | $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/hgram_admin.tpl"); |
---|
73 | |
---|
74 | switch($_GET['tab']) |
---|
75 | { |
---|
76 | case 'config': |
---|
77 | $this->displayConfigPage(); |
---|
78 | break; |
---|
79 | } |
---|
80 | |
---|
81 | $this->tabsheet->select($_GET['tab']); |
---|
82 | $this->tabsheet->assign(); |
---|
83 | $selected_tab=$this->tabsheet->get_selected(); |
---|
84 | $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]"); |
---|
85 | |
---|
86 | $template_plugin["HGRAM_VERSION"] = "<i>".$this->getPluginName()."</i> ".l10n('hgram_release').HGRAM_VERSION; |
---|
87 | |
---|
88 | $template->assign('plugin', $template_plugin); |
---|
89 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
90 | } |
---|
91 | |
---|
92 | |
---|
93 | /** |
---|
94 | * check the $_REQUEST values and set default values |
---|
95 | * |
---|
96 | */ |
---|
97 | protected function checkRequest() |
---|
98 | { |
---|
99 | if(!isset($_GET['tab'])) $_GET['tab']='config'; |
---|
100 | |
---|
101 | if(!($_GET['tab']=='config')) $_GET['tab']='config'; |
---|
102 | } |
---|
103 | |
---|
104 | /** |
---|
105 | * manage display of config page & save config |
---|
106 | */ |
---|
107 | protected function displayConfigPage() |
---|
108 | { |
---|
109 | $cfg=$this->config; |
---|
110 | |
---|
111 | if(isset($_POST['submit_save_config'])) |
---|
112 | { |
---|
113 | foreach($cfg as $key => $val) |
---|
114 | { |
---|
115 | if(isset($_REQUEST['f_'.$key])) |
---|
116 | { |
---|
117 | $cfg[$key] = $_REQUEST['f_'.$key]; |
---|
118 | } |
---|
119 | } |
---|
120 | |
---|
121 | if($cfg['color_r']=='') |
---|
122 | { |
---|
123 | $cfg['mode_r']='none'; |
---|
124 | } |
---|
125 | else |
---|
126 | { |
---|
127 | $cfg['mode_r']='line'; |
---|
128 | } |
---|
129 | |
---|
130 | if($cfg['color_g']=='') |
---|
131 | { |
---|
132 | $cfg['mode_g']='none'; |
---|
133 | } |
---|
134 | else |
---|
135 | { |
---|
136 | $cfg['mode_g']='line'; |
---|
137 | } |
---|
138 | |
---|
139 | if($cfg['color_b']=='') |
---|
140 | { |
---|
141 | $cfg['mode_b']='none'; |
---|
142 | } |
---|
143 | else |
---|
144 | { |
---|
145 | $cfg['mode_b']='line'; |
---|
146 | } |
---|
147 | |
---|
148 | $cfg['color_bg'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_bg'])); |
---|
149 | $cfg['color_v'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_v'])); |
---|
150 | $cfg['color_r'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_r'])); |
---|
151 | $cfg['color_g'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_g'])); |
---|
152 | $cfg['color_b'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_b'])); |
---|
153 | |
---|
154 | |
---|
155 | $this->config=$cfg; |
---|
156 | $this->purgeHistoCache(); |
---|
157 | |
---|
158 | $this->displayResult(l10n('hgram_save_config'), $this->saveConfig()); |
---|
159 | } |
---|
160 | |
---|
161 | $this->displayConfig(); |
---|
162 | } |
---|
163 | |
---|
164 | /** |
---|
165 | * display config page |
---|
166 | */ |
---|
167 | protected function displayConfig() |
---|
168 | { |
---|
169 | global $template, $lang; |
---|
170 | |
---|
171 | $template->set_filename('body_page', |
---|
172 | dirname($this->getFileLocation()).'/admin/hgram_config.tpl'); |
---|
173 | |
---|
174 | |
---|
175 | $cfg=$this->config; |
---|
176 | |
---|
177 | $cfg['color_bg'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_bg'])); |
---|
178 | $cfg['color_v'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_v'])); |
---|
179 | $cfg['color_r'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_r'])); |
---|
180 | $cfg['color_g'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_g'])); |
---|
181 | $cfg['color_b'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_b'])); |
---|
182 | if($cfg['mode_r']=='none') $cfg['color_r']=''; |
---|
183 | if($cfg['mode_g']=='none') $cfg['color_g']=''; |
---|
184 | if($cfg['mode_b']=='none') $cfg['color_b']=''; |
---|
185 | |
---|
186 | |
---|
187 | $template->assign('hgramConfig', $cfg); |
---|
188 | |
---|
189 | $template->assign_var_from_handle('HGRAM_BODY_PAGE', 'body_page'); |
---|
190 | |
---|
191 | } //displayConfig |
---|
192 | |
---|
193 | |
---|
194 | |
---|
195 | } //class |
---|
196 | |
---|
197 | |
---|
198 | ?> |
---|