3
* © Copyright 2007 IntraHealth International, Inc.
5
* This File is part of I2CE
7
* I2CE 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; either version 3 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
3
* @copyright © 2007, 2009 Intrahealth International, Inc.
4
* This File is part of I2CE
6
* I2CE is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
20
* I2CE_Module_ColorPicker
24
23
* @author Carl Leitner <litlfred@ibiblio.org>
25
* @copyright Copyright © 2007 IntraHealth International, Inc.
26
* This file is part of I2CE. I2CE is free software; you can redistribute it and/or modify it under
27
* the terms of the GNU General Public License as published by the Free Software Foundation; either
28
* version 3 of the License, or (at your option) any later version. I2CE is distributed in the hope
29
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
30
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
31
* received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
39
31
public static function getMethods() {
41
'I2CE_SwissConfig_Default::displayValue_color_triple_rgb_single'=>'displayValue_color_triple_rgb_single',
42
'I2CE_SwissConfig_Default::displayValue_color_triple_rgb_many'=>'displayValue_color_triple_rgb_many',
43
'I2CE_SwissConfig_Default::displayValue_color_triple_hex_single'=>'displayValue_color_triple_hex_single',
44
'I2CE_SwissConfig_Default::displayValue_color_triple_hex_many'=>'displayValue_color_triple_hex_many',
45
'I2CE_SwissConfig_Default::displayValue_color_hex_single'=>'displayValue_color_hex_single',
46
'I2CE_SwissConfig_Default::displayValue_color_hex_many'=>'displayValue_color_hex_many',
47
'I2CE_MagicDataTemplate::processValues_color_triple_hex_single'=>'processValues_color_triple_hex_single',
48
'I2CE_MagicDataTemplate::processValues_color_triple_hex_many'=>'processValues_color_triple_hex_many',
49
'I2CE_MagicDataTemplate::processValues_color_triple_rgb_single'=>'processValues_color_triple_rgb_single',
50
'I2CE_MagicDataTemplate::processValues_color_triple_rgb_many'=>'processValues_color_triple_rgb_many',
51
'I2CE_MagicDataTemplate::processValues_color_hex_single'=>'processValues_color_hex_single',
52
'I2CE_MagicDataTemplate::processValues_color_hex_many'=>'processValues_color_hex_many',
53
'I2CE_Page::addColorPickerTriple'=>'addColorPickerTriple',
54
'I2CE_Template::addColorPickerTriple'=>'addColorPickerTriple',
33
'I2CE_SwissConfig_Default->displayValue_color_triple_rgb_single'=>'displayValue_color_triple_rgb_single',
34
'I2CE_SwissConfig_Default->displayValue_color_triple_rgb_many'=>'displayValue_color_triple_rgb_many',
35
'I2CE_SwissConfig_Default->displayValue_color_triple_hex_single'=>'displayValue_color_triple_hex_single',
36
'I2CE_SwissConfig_Default->displayValue_color_triple_hex_many'=>'displayValue_color_triple_hex_many',
37
'I2CE_SwissConfig_Default->displayValue_color_hex_single'=>'displayValue_color_hex_single',
38
'I2CE_SwissConfig_Default->displayValue_color_hex_many'=>'displayValue_color_hex_many',
39
'I2CE_MagicDataTemplate->processValues_color_triple_hex_single'=>'processValues_color_triple_hex_single',
40
'I2CE_MagicDataTemplate->processValues_color_triple_hex_many'=>'processValues_color_triple_hex_many',
41
'I2CE_MagicDataTemplate->processValues_color_triple_rgb_single'=>'processValues_color_triple_rgb_single',
42
'I2CE_MagicDataTemplate->processValues_color_triple_rgb_many'=>'processValues_color_triple_rgb_many',
43
'I2CE_MagicDataTemplate->processValues_color_hex_single'=>'processValues_color_hex_single',
44
'I2CE_MagicDataTemplate->processValues_color_hex_many'=>'processValues_color_hex_many',
45
'I2CE_Page->addColorPickerTriple'=>'addColorPickerTriple',
46
'I2CE_Template->addColorPickerTriple'=>'addColorPickerTriple',
77
public function processValues_color_triple_hex_single($configurator,$args) {
79
if (count($args) != 2) {
82
list($value,$status) = $args;
69
public function processValues_color_triple_hex_single($configurator,$value,$status=array()) {
83
70
return $this->ensureColorTripleHex($value);
86
public function processValues_color_triple_rgb_single($configurator,$args) {
88
if (count($args) != 2) {
91
list($value,$status) = $args;
73
public function processValues_color_triple_rgb_single($configurator,$value,$status=array()) {
92
74
return $this->ensureColorTripleRGB($value);
95
public function processValues_color_triple_hex_many($configurator,$args) {
97
if (count($args) != 2) {
100
list($valueList,$status) = $args;
77
public function processValues_color_triple_hex_many($configurator,$valueList,$status=array()) {
102
79
foreach ($valueList as $value) {
103
80
$ret[] = $this->ensureColorTripleHex($value);
111
public function processValues_color_triple_rgb_many($configurator,$args) {
113
if (count($args) != 2) {
116
list($valueList,$status) = $args;
88
public function processValues_color_triple_rgb_many($configurator,$valueList,$status=array()) {
118
90
foreach ($valueList as $value) {
119
91
$ret[] = $this->ensureColorTripleHex($value);
131
103
//decimal triple of colors
132
public function displayValue_color_triple_rgb_single($swissConfig,$args) {
104
public function displayValue_color_triple_rgb_single($swissConfig,$valNode,$status,$config) {
133
105
$template = $swissConfig->getPage()->getTemplate();
134
106
$factory = $swissConfig->getFactory();
135
list($valNode,$status,$config) = $args;
136
107
$node = $template->loadFile("configuration_color_triple_rgb_single.html",'li');
137
108
if (!$node instanceof DOMNode) {
138
109
I2CE::raiseError("Unable to load/invalid configuraiton_color_triple_single.html");
155
126
$template->setDisplayDataImmediate('description',$description, $node);
156
127
$template->setDisplayDataImmediate('configDefaultValue',$this->ensureRGBColor($factory->getTextContent('value',$valNode)),$node);
157
if ($config->__checkType('','value')) {
158
I2CE::raiseError("Warning: expecting to have a parent node. Instead got leaf node at ". $config->__getPath());
128
if (!$config->is_parent()) {
129
I2CE::raiseError("Warning: expecting to have a parent node. Instead got leaf node at ". $config->getPath());
161
132
$path = $factory->getModule() .
162
133
$factory->getPath($swissConfig->getConfigPath(), $valNode->getAttribute('name'));
163
134
$colorId = 'value_color_triple_rgb_single' . '/' . $path;
165
if ($config->__checkType('','parent')) {
166
$colors = $this->ensureColorTripleRGB($config->getAsArray());
135
$colors = $this->ensureColorTripleRGB($config->getAsArray());
168
136
for ($i=0; $i < 3; $i++) {
169
137
$input = $inputs->item($i);
170
$input->setAttribute('name', 'value_color_triple_rgb_single' . $config->__getPath(false). '[]');
138
$input->setAttribute('name', 'value_color_triple_rgb_single' . $config->getPath(false). '[]');
171
139
$input->setAttribute('id', $colorId );
172
140
$input->setAttribute('value',$colors[$i]);
174
$showColorPicker = $template->query(".//*[@id='showColorPickerBox']",$node);
142
$showColorPicker = $template->query("./descendant-or-self::node()[@id='showColorPickerBox']",$node);
175
143
if ($showColorPicker->length != 1) {
176
144
I2CE::raiseError("Got unexpected number of nodes with id 'showColorPickerBox':" . $showColorPicker->length);
184
152
$showNode = $template->createTextNode( $this->ensureRGBColor($colors));
185
153
$showColorPicker->setAttribute('style','background-color: ' . $this->ensureRGBColor($colors) . '' );
186
154
$showColorPicker->appendChild ($showNode);
187
$colorPicker = $template->query(".//*[@id='colorPickerBox']",$node);
155
$colorPicker = $template->query("./descendant-or-self::node()[@id='colorPickerBox']",$node);
188
156
if ($colorPicker->length != 1) {
189
157
I2CE::raiseError("Got unexpected number of nodes with id 'colorPickerBox':" . $colorPicker->length);
194
162
'colorPickerBox/' . $path,
195
163
'showColorPickerBox/' . $path,
196
164
$colorId,$colors);
197
$defaultColor = $template->query(".//*[@id='defaultColor']",$node);
165
$defaultColor = $template->query("./descendant-or-self::node()[@id='defaultColor']",$node);
198
166
if ($defaultColor->length == 1) {
199
167
$defaultColor = $defaultColor->item(0);
200
168
$defaultColor->setAttribute('id','defaultColor/' . $path);
212
180
//decimal triple of colors
213
public function displayValue_color_triple_hex_single($swissConfig,$args) {
181
public function displayValue_color_triple_hex_single($swissConfig,$valNode,$status,$config) {
214
182
$template = $swissConfig->getPage()->getTemplate();
215
183
$factory = $swissConfig->getFactory();
216
list($valNode,$status,$config) = $args;
217
184
$node = $template->loadFile("configuration_color_triple_hex_single.html",'li');
218
185
if (!$node instanceof DOMNode) {
219
186
I2CE::raiseError("Unable to load/invalid configuraiton_color_triple_single.html");
236
203
$template->setDisplayDataImmediate('description',$description, $node);
237
204
$template->setDisplayDataImmediate('configDefaultValue',$this->ensureHexColor($factory->getTextContent('value',$valNode)),$node);
238
if ($config->__checkType('','value')) {
239
I2CE::raiseError("Warning: expecting to have a parent node. Instead got leaf node at ". $config->__getPath());
205
if (!$config->is_parent()) {
206
I2CE::raiseError("Warning: expecting to have a parent node. Instead got leaf node at ". $config->getPath());
242
209
$path = $factory->getModule() .
243
210
$factory->getPath($swissConfig->getConfigPath(), $valNode->getAttribute('name'));
244
211
$colorId = 'value_color_triple_hex_single' . '/' . $path;
246
if ($config->__checkType('','parent')) {
247
$colors = $this->ensureColorTripleRGB($config->getAsArray());
212
$colors = $this->ensureColorTripleRGB($config->getAsArray());
249
213
for ($i=0; $i < 3; $i++) {
250
214
$input = $inputs->item($i);
251
$input->setAttribute('name', 'value_color_triple_hex_single' . $config->__getPath(false). '[]');
215
$input->setAttribute('name', 'value_color_triple_hex_single' . $config->getPath(false). '[]');
252
216
$input->setAttribute('id', $colorId );
253
217
$input->setAttribute('value',$colors[$i]);
255
$showColorPicker = $template->query(".//*[@id='showColorPickerBox']",$node);
219
$showColorPicker = $template->query("./descendant-or-self::node()[@id='showColorPickerBox']",$node);
256
220
if ($showColorPicker->length != 1) {
257
221
I2CE::raiseError("Got unexpected number of nodes with id 'showColorPickerBox':" . $showColorPicker->length);
265
229
$showNode = $template->createTextNode( $this->ensureHexColor($colors));
266
230
$showColorPicker->setAttribute('style','background-color: ' . $this->ensureHexColor($colors) . '' );
267
231
$showColorPicker->appendChild ($showNode);
268
$colorPicker = $template->query(".//*[@id='colorPickerBox']",$node);
232
$colorPicker = $template->query("./descendant-or-self::node()[@id='colorPickerBox']",$node);
269
233
if ($colorPicker->length != 1) {
270
234
I2CE::raiseError("Got unexpected number of nodes with id 'colorPickerBox':" . $colorPicker->length);
275
239
'colorPickerBox/' . $path,
276
240
'showColorPickerBox/' . $path,
277
241
$colorId,$colors);
278
$defaultColor = $template->query(".//*[@id='defaultColor']",$node);
242
$defaultColor = $template->query("./descendant-or-self::node()[@id='defaultColor']",$node);
279
243
if ($defaultColor->length == 1) {
280
244
$defaultColor = $defaultColor->item(0);
281
245
$defaultColor->setAttribute('id','defaultColor/' . $path);
473
437
$template = $args['template'];
474
$template->addHeaderLink('mootools.js');
438
$template->addHeaderLink('mootools-core.js');
475
439
$template->addHeaderLink('colorpicker.js');
476
440
$template->addHeaderLink('colorPicker_helper.js');
477
441
$template->addHeaderLink('colorpicker.css');