~oh-dev/openhealth/phit-tools

« back to all changes in this revision

Viewing changes to ihris-suite/lib/i2ce/modules/MooTools/modules/ColorPicker/I2CE_Module_ColorPicker.php

  • Committer: litlfred at ibiblio
  • Date: 2009-10-23 12:59:28 UTC
  • Revision ID: litlfred@ibiblio.org-20091023125928-u5lkafz0urm9t8eq
updated ihris-suite to 4.0.1-prerelease -- not debugged

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
/**
3
 
* © Copyright 2007 IntraHealth International, Inc.
4
 
5
 
* This File is part of I2CE 
6
 
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.
11
 
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.
16
 
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
 
5
 *
 
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.
 
10
 * 
 
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.
 
15
 * 
 
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/>.
19
18
*/
20
19
/**
21
20
*  I2CE_Module_ColorPicker
22
21
* @package I2CE
23
22
* @subpackage Core
24
23
* @author Carl Leitner <litlfred@ibiblio.org>
25
 
* @copyright Copyright &copy; 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/>.
32
24
* @version 2.1
33
25
* @access public
34
26
*/
38
30
 
39
31
    public static function getMethods() {
40
32
        return array(
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',
55
47
            );
56
48
    }
57
49
 
74
66
    }
75
67
 
76
68
 
77
 
    public function processValues_color_triple_hex_single($configurator,$args) {
78
 
        $ret = null;
79
 
        if (count($args) != 2) {
80
 
            return $ret;
81
 
        }
82
 
        list($value,$status)  = $args;
 
69
    public function processValues_color_triple_hex_single($configurator,$value,$status=array()) {
83
70
        return $this->ensureColorTripleHex($value);
84
71
    }          
85
72
 
86
 
    public function processValues_color_triple_rgb_single($configurator,$args) {
87
 
        $ret = null;
88
 
        if (count($args) != 2) {
89
 
            return $ret;
90
 
        }
91
 
        list($value,$status)  = $args;
 
73
    public function processValues_color_triple_rgb_single($configurator,$value,$status=array()) {
92
74
        return $this->ensureColorTripleRGB($value);
93
75
    }
94
76
 
95
 
    public function processValues_color_triple_hex_many($configurator,$args) {
96
 
        $ret = null;
97
 
        if (count($args) != 2) {
98
 
            return $ret;
99
 
        }
100
 
        list($valueList,$status)  = $args;
 
77
    public function processValues_color_triple_hex_many($configurator,$valueList,$status=array()) {
101
78
        $ret = array();
102
79
        foreach ($valueList as $value) {
103
80
            $ret[] = $this->ensureColorTripleHex($value);
108
85
        return $ret;
109
86
    }
110
87
 
111
 
    public function processValues_color_triple_rgb_many($configurator,$args) {
112
 
        $ret = null;
113
 
        if (count($args) != 2) {
114
 
            return $ret;
115
 
        }
116
 
        list($valueList,$status)  = $args;
 
88
    public function processValues_color_triple_rgb_many($configurator,$valueList,$status=array()) {
117
89
        $ret = array();
118
90
        foreach ($valueList as $value) {
119
91
            $ret[] = $this->ensureColorTripleHex($value);
129
101
 
130
102
    
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");
154
125
        }
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());
159
130
            return $node;
160
131
        }
161
132
        $path = $factory->getModule() . 
162
133
            $factory->getPath($swissConfig->getConfigPath(),   $valNode->getAttribute('name'));
163
134
        $colorId = 'value_color_triple_rgb_single' . '/'  . $path;
164
 
        $colors = null;
165
 
        if ($config->__checkType('','parent')) {
166
 
            $colors = $this->ensureColorTripleRGB($config->getAsArray());
167
 
        }
 
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]);
173
141
        }
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);
177
145
            return $node;
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);
190
158
            return $node;
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);
210
178
 
211
179
    
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");
235
202
        }
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());
240
207
            return $node;
241
208
        }
242
209
        $path = $factory->getModule() . 
243
210
            $factory->getPath($swissConfig->getConfigPath(),   $valNode->getAttribute('name'));
244
211
        $colorId = 'value_color_triple_hex_single' . '/'  . $path;
245
 
        $colors = null;
246
 
        if ($config->__checkType('','parent')) {
247
 
            $colors = $this->ensureColorTripleRGB($config->getAsArray());
248
 
        }
 
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]);
254
218
        }
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);
258
222
            return $node;
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);
271
235
            return $node;
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);
471
435
            return;
472
436
        }     
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');