1 |
6daefa8c
|
Petr Lukašík
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* Manage operators in a database
|
5 |
|
|
*
|
6 |
|
|
* $Id: operators.php,v 1.20 2005/10/18 03:45:16 chriskl Exp $
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
|
|
// Include application functions
|
10 |
|
|
include_once('./libraries/lib.inc.php');
|
11 |
|
|
|
12 |
|
|
$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
|
13 |
|
|
if (!isset($msg)) $msg = '';
|
14 |
|
|
$PHP_SELF = $_SERVER['PHP_SELF'];
|
15 |
|
|
|
16 |
|
|
/**
|
17 |
|
|
* Show read only properties for an operator
|
18 |
|
|
*/
|
19 |
|
|
function doProperties($msg = '') {
|
20 |
|
|
global $data, $misc;
|
21 |
|
|
global $PHP_SELF, $lang;
|
22 |
|
|
|
23 |
|
|
$misc->printTrail('operator');
|
24 |
|
|
$misc->printTitle($lang['strproperties'],'pg.operator');
|
25 |
|
|
$misc->printMsg($msg);
|
26 |
|
|
|
27 |
|
|
$oprdata = $data->getOperator($_REQUEST['operator_oid']);
|
28 |
|
|
$oprdata->f['oprcanhash'] = $data->phpBool($oprdata->f['oprcanhash']);
|
29 |
|
|
|
30 |
|
|
if ($oprdata->recordCount() > 0) {
|
31 |
|
|
echo "<table>\n";
|
32 |
|
|
echo "<tr><th class=\"data left\">{$lang['strname']}</th>\n";
|
33 |
|
|
echo "<td class=\"data1\">", $misc->printVal($oprdata->f['oprname']), "</td></tr>\n";
|
34 |
|
|
echo "<tr><th class=\"data left\">{$lang['strleftarg']}</th>\n";
|
35 |
|
|
echo "<td class=\"data1\">", $misc->printVal($oprdata->f['oprleftname']), "</td></tr>\n";
|
36 |
|
|
echo "<tr><th class=\"data left\">{$lang['strrightarg']}</th>\n";
|
37 |
|
|
echo "<td class=\"data1\">", $misc->printVal($oprdata->f['oprrightname']), "</td></tr>\n";
|
38 |
|
|
echo "<tr><th class=\"data left\">{$lang['strcommutator']}</th>\n";
|
39 |
|
|
echo "<td class=\"data1\">", $misc->printVal($oprdata->f['oprcom']), "</td></tr>\n";
|
40 |
|
|
echo "<tr><th class=\"data left\">{$lang['strnegator']}</th>\n";
|
41 |
|
|
echo "<td class=\"data1\">", $misc->printVal($oprdata->f['oprnegate']), "</td></tr>\n";
|
42 |
|
|
echo "<tr><th class=\"data left\">{$lang['strjoin']}</th>\n";
|
43 |
|
|
echo "<td class=\"data1\">", $misc->printVal($oprdata->f['oprjoin']), "</td></tr>\n";
|
44 |
|
|
echo "<tr><th class=\"data left\">{$lang['strhashes']}</th>\n";
|
45 |
|
|
echo "<td class=\"data1\">", ($oprdata->f['oprcanhash']) ? $lang['stryes'] : $lang['strno'], "</td></tr>\n";
|
46 |
|
|
echo "<tr><th class=\"data left\">{$lang['strmerges']}</th>\n";
|
47 |
|
|
echo "<td class=\"data1\">", ($oprdata->f['oprlsortop'] !== '0' && $oprdata->f['oprrsortop'] !== '0') ? $lang['stryes'] : $lang['strno'], "</td></tr>\n";
|
48 |
|
|
echo "<tr><th class=\"data left\">{$lang['strrestrict']}</th>\n";
|
49 |
|
|
echo "<td class=\"data1\">", $misc->printVal($oprdata->f['oprrest']), "</td></tr>\n";
|
50 |
|
|
echo "<tr><th class=\"data left\">{$lang['strleftsort']}</th>\n";
|
51 |
|
|
echo "<td class=\"data1\">", $misc->printVal($oprdata->f['oprlsortop']), "</td></tr>\n";
|
52 |
|
|
echo "<tr><th class=\"data left\">{$lang['strrightsort']}</th>\n";
|
53 |
|
|
echo "<td class=\"data1\">", $misc->printVal($oprdata->f['oprrsortop']), "</td></tr>\n";
|
54 |
|
|
echo "<tr><th class=\"data left\">{$lang['strlessthan']}</th>\n";
|
55 |
|
|
echo "<td class=\"data1\">", $misc->printVal($oprdata->f['oprltcmpop']), "</td></tr>\n";
|
56 |
|
|
echo "<tr><th class=\"data left\">{$lang['strgreaterthan']}</th>\n";
|
57 |
|
|
echo "<td class=\"data1\">", $misc->printVal($oprdata->f['oprgtcmpop']), "</td></tr>\n";
|
58 |
|
|
echo "</table>\n";
|
59 |
|
|
|
60 |
|
|
echo "<p><a class=\"navlink\" href=\"$PHP_SELF?{$misc->href}\">{$lang['strshowalloperators']}</a></p>\n";
|
61 |
|
|
}
|
62 |
|
|
else
|
63 |
|
|
doDefault($lang['strinvalidparam']);
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
/**
|
67 |
|
|
* Show confirmation of drop and perform actual drop
|
68 |
|
|
*/
|
69 |
|
|
function doDrop($confirm) {
|
70 |
|
|
global $data, $misc;
|
71 |
|
|
global $PHP_SELF, $lang;
|
72 |
|
|
|
73 |
|
|
if ($confirm) {
|
74 |
|
|
$misc->printTrail('operator');
|
75 |
|
|
$misc->printTitle($lang['strdrop'], 'pg.operator.drop');
|
76 |
|
|
|
77 |
|
|
echo "<p>", sprintf($lang['strconfdropoperator'], $misc->printVal($_REQUEST['operator'])), "</p>\n";
|
78 |
|
|
|
79 |
|
|
echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
|
80 |
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"drop\" />\n";
|
81 |
|
|
echo "<input type=\"hidden\" name=\"operator\" value=\"", htmlspecialchars($_REQUEST['operator']), "\" />\n";
|
82 |
|
|
echo "<input type=\"hidden\" name=\"operator_oid\" value=\"", htmlspecialchars($_REQUEST['operator_oid']), "\" />\n";
|
83 |
|
|
echo $misc->form;
|
84 |
|
|
// Show cascade drop option if supportd
|
85 |
|
|
if ($data->hasDropBehavior()) {
|
86 |
|
|
echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
|
87 |
|
|
}
|
88 |
|
|
echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
|
89 |
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
|
90 |
|
|
echo "</form>\n";
|
91 |
|
|
}
|
92 |
|
|
else {
|
93 |
|
|
$status = $data->dropOperator($_POST['operator_oid'], isset($_POST['cascade']));
|
94 |
|
|
if ($status == 0)
|
95 |
|
|
doDefault($lang['stroperatordropped']);
|
96 |
|
|
else
|
97 |
|
|
doDefault($lang['stroperatordroppedbad']);
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
/**
|
103 |
|
|
* Show default list of operators in the database
|
104 |
|
|
*/
|
105 |
|
|
function doDefault($msg = '') {
|
106 |
|
|
global $data, $conf, $misc;
|
107 |
|
|
global $PHP_SELF, $lang;
|
108 |
|
|
|
109 |
|
|
$misc->printTrail('schema');
|
110 |
|
|
$misc->printTabs('schema','operators');
|
111 |
|
|
$misc->printMsg($msg);
|
112 |
|
|
|
113 |
|
|
$operators = $data->getOperators();
|
114 |
|
|
|
115 |
|
|
$columns = array(
|
116 |
|
|
'operator' => array(
|
117 |
|
|
'title' => $lang['stroperator'],
|
118 |
|
|
'field' => 'oprname',
|
119 |
|
|
),
|
120 |
|
|
'leftarg' => array(
|
121 |
|
|
'title' => $lang['strleftarg'],
|
122 |
|
|
'field' => 'oprleftname',
|
123 |
|
|
),
|
124 |
|
|
'rightarg' => array(
|
125 |
|
|
'title' => $lang['strrightarg'],
|
126 |
|
|
'field' => 'oprrightname',
|
127 |
|
|
),
|
128 |
|
|
'returns' => array(
|
129 |
|
|
'title' => $lang['strreturns'],
|
130 |
|
|
'field' => 'resultname',
|
131 |
|
|
),
|
132 |
|
|
'actions' => array(
|
133 |
|
|
'title' => $lang['stractions'],
|
134 |
|
|
),
|
135 |
|
|
'comment' => array(
|
136 |
|
|
'title' => $lang['strcomment'],
|
137 |
|
|
'field' => 'oprcomment',
|
138 |
|
|
),
|
139 |
|
|
);
|
140 |
|
|
|
141 |
|
|
$actions = array(
|
142 |
|
|
'properties' => array(
|
143 |
|
|
'title' => $lang['strproperties'],
|
144 |
|
|
'url' => "{$PHP_SELF}?action=properties&{$misc->href}&",
|
145 |
|
|
'vars' => array('operator' => 'oprname', 'operator_oid' => 'oid'),
|
146 |
|
|
),
|
147 |
|
|
'drop' => array(
|
148 |
|
|
'title' => $lang['strdrop'],
|
149 |
|
|
'url' => "{$PHP_SELF}?action=confirm_drop&{$misc->href}&",
|
150 |
|
|
'vars' => array('operator' => 'oprname', 'operator_oid' => 'oid'),
|
151 |
|
|
),
|
152 |
|
|
);
|
153 |
|
|
|
154 |
|
|
$misc->printTable($operators, $columns, $actions, $lang['strnooperators']);
|
155 |
|
|
|
156 |
|
|
// echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=create&{$misc->href}\">{$lang['strcreateoperator']}</a></p>\n";
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
/**
|
160 |
|
|
* Generate XML for the browser tree.
|
161 |
|
|
*/
|
162 |
|
|
function doTree() {
|
163 |
|
|
global $misc, $data, $PHP_SELF;
|
164 |
|
|
|
165 |
|
|
$operators = $data->getOperators();
|
166 |
|
|
|
167 |
|
|
// Operator prototype: "type operator type"
|
168 |
|
|
$proto = concat(field('oprleftname'), ' ', field('oprname'), ' ', field('oprrightname'));
|
169 |
|
|
|
170 |
|
|
$reqvars = $misc->getRequestVars('operator');
|
171 |
|
|
|
172 |
|
|
$attrs = array(
|
173 |
|
|
'text' => $proto,
|
174 |
|
|
'icon' => 'operators',
|
175 |
|
|
'toolTip'=> field('oprcomment'),
|
176 |
|
|
'action' => url('operators.php',
|
177 |
|
|
$reqvars,
|
178 |
|
|
array(
|
179 |
|
|
'action' => 'properties',
|
180 |
|
|
'operator' => $proto,
|
181 |
|
|
'operator_oid' => field('oid')
|
182 |
|
|
)
|
183 |
|
|
)
|
184 |
|
|
);
|
185 |
|
|
|
186 |
|
|
$misc->printTreeXML($operators, $attrs);
|
187 |
|
|
exit;
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
if ($action == 'tree') doTree();
|
191 |
|
|
|
192 |
|
|
$misc->printHeader($lang['stroperators']);
|
193 |
|
|
$misc->printBody();
|
194 |
|
|
|
195 |
|
|
switch ($action) {
|
196 |
|
|
case 'save_create':
|
197 |
|
|
if (isset($_POST['cancel'])) doDefault();
|
198 |
|
|
else doSaveCreate();
|
199 |
|
|
break;
|
200 |
|
|
case 'create':
|
201 |
|
|
doCreate();
|
202 |
|
|
break;
|
203 |
|
|
case 'drop':
|
204 |
|
|
if (isset($_POST['cancel'])) doDefault();
|
205 |
|
|
else doDrop(false);
|
206 |
|
|
break;
|
207 |
|
|
case 'confirm_drop':
|
208 |
|
|
doDrop(true);
|
209 |
|
|
break;
|
210 |
|
|
case 'properties':
|
211 |
|
|
doProperties();
|
212 |
|
|
break;
|
213 |
|
|
default:
|
214 |
|
|
doDefault();
|
215 |
|
|
break;
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
$misc->printFooter();
|
219 |
|
|
|
220 |
|
|
?>
|