Rev 635 | Rev 865 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
635 | daniel-mar | 1 | /* |
2 | * OIDplus 2.0 |
||
3 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
||
4 | * |
||
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
6 | * you may not use this file except in compliance with the License. |
||
7 | * You may obtain a copy of the License at |
||
8 | * |
||
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
10 | * |
||
11 | * Unless required by applicable law or agreed to in writing, software |
||
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
14 | * See the License for the specific language governing permissions and |
||
15 | * limitations under the License. |
||
16 | */ |
||
17 | |||
18 | plugin_combobox_change_callbacks.push(function(strPlugin) { |
||
19 | $("#DBPLUGIN_PARAMS_PDO")[0].style.display = (strPlugin == 'PDO') ? "Block" : "None"; |
||
20 | }); |
||
21 | |||
22 | rebuild_callbacks.push(function() { |
||
23 | var e = $("#db_plugin")[0]; |
||
24 | var strPlugin = e.options[e.selectedIndex].value; |
||
25 | if (strPlugin != 'PDO') return true; |
||
26 | |||
27 | $("#struct_cli_1")[0].innerHTML = ''; |
||
28 | $("#struct_cli_2")[0].innerHTML = ''; |
||
29 | $("#struct_1")[0].href = 'struct_empty.sql.php'; |
||
30 | $("#struct_2")[0].href = 'struct_with_examples.sql.php'; |
||
31 | |||
32 | error = false; |
||
33 | |||
34 | // Check 1: dsn must not be empty |
||
35 | if ($("#pdo_dsn")[0].value.length == 0) |
||
36 | { |
||
37 | $("#pdo_dsn_warn")[0].innerHTML = '<font color="red">'+_L('Please specify a DSN!')+'</font>'; |
||
38 | $("#config")[0].innerHTML = '<b><?php</b><br><br><i>// ERROR: Please specify a DSN!</i>'; // do not translate |
||
39 | error = true; |
||
40 | } else { |
||
41 | $("#pdo_dsn_warn")[0].innerHTML = ''; |
||
42 | } |
||
43 | |||
44 | // Check 2: Username must not be empty |
||
45 | if ($("#pdo_username")[0].value.length == 0) |
||
46 | { |
||
47 | $("#pdo_username_warn")[0].innerHTML = '<font color="red">'+_L('Please specify a username!')+'</font>'; |
||
48 | $("#config")[0].innerHTML = '<b><?php</b><br><br><i>// ERROR: Please specify a username!</i>'; // do not translate |
||
49 | error = true; |
||
50 | } else { |
||
51 | $("#pdo_username_warn")[0].innerHTML = ''; |
||
52 | } |
||
53 | |||
54 | $("#struct_1")[0].href = setupdir+'struct_empty.sql.php?plugin=pdo&prefix='+encodeURI($("#tablename_prefix")[0].value)+'&slang='+encodeURI($("#pdo_slang")[0].value); |
||
55 | $("#struct_2")[0].href = setupdir+'struct_with_examples.sql.php?plugin=pdo&prefix='+encodeURI($("#tablename_prefix")[0].value)+'&slang='+encodeURI($("#pdo_slang")[0].value); |
||
56 | if ($("#pdo_slang")[0].value == 'mysql') { |
||
57 | $("#struct_cli_1")[0].innerHTML = '<br>'+_L('or via command line:')+'<br><code>curl -s "'+$("#struct_1")[0].href+'" | mysql -u '+$("#pdo_username")[0].value+' -p</code>'; |
||
58 | $("#struct_cli_2")[0].innerHTML = '<br>'+_L('or via command line:')+'<br><code>curl -s "'+$("#struct_2")[0].href+'" | mysql -u '+$("#pdo_username")[0].value+' -p</code>'; |
||
59 | } else if ($("#pdo_slang")[0].value == 'pgsql') { |
||
60 | $("#struct_cli_1")[0].innerHTML = '<br>'+_L('or via command line:')+'<br><code>curl -s "'+$("#struct_1")[0].href+'" | psql -h <font color="red">localhost</font> -U '+$("#pdo_username")[0].value+' -d <font color="red">oidplus</font> -a</code>'; |
||
61 | $("#struct_cli_2")[0].innerHTML = '<br>'+_L('or via command line:')+'<br><code>curl -s "'+$("#struct_2")[0].href+'" | psql -h <font color="red">localhost</font> -U '+$("#pdo_username")[0].value+' -d <font color="red">oidplus</font> -a</code>'; |
||
62 | } else { |
||
63 | $("#struct_cli_1")[0].innerHTML = ''; |
||
64 | $("#struct_cli_2")[0].innerHTML = ''; |
||
65 | } |
||
66 | |||
67 | return !error; |
||
68 | }); |
||
69 | |||
70 | rebuild_config_callbacks.push(function() { |
||
71 | var e = $("#db_plugin")[0]; |
||
72 | var strPlugin = e.options[e.selectedIndex].value; |
||
73 | if (strPlugin != 'PDO') return ''; |
||
74 | |||
75 | return 'OIDplus::baseConfig()->setValue(\'PDO_DSN\', \''+$("#pdo_dsn")[0].value+'\');<br>' + |
||
76 | 'OIDplus::baseConfig()->setValue(\'PDO_USERNAME\', \''+$("#pdo_username")[0].value+'\');<br>' + |
||
77 | 'OIDplus::baseConfig()->setValue(\'PDO_PASSWORD\', base64_decode(\''+b64EncodeUnicode($("#pdo_password")[0].value)+'\'));<br>' + |
||
78 | 'OIDplus::baseConfig()->setValue(\'FORCE_DBMS_SLANG\', \''+$("#pdo_slang")[0].value+'\');<br>'; // optional |
||
79 | }); |