1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* Manage casts in a database
|
5
|
*
|
6
|
* $Id: casts.php,v 1.11 2005/10/18 03:45:15 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 default list of casts in the database
|
18
|
*/
|
19
|
function doDefault($msg = '') {
|
20
|
global $data, $misc, $database;
|
21
|
global $PHP_SELF, $lang;
|
22
|
|
23
|
function renderCastContext($val) {
|
24
|
global $lang;
|
25
|
switch ($val) {
|
26
|
case 'e': return $lang['strno'];
|
27
|
case 'a': return $lang['strinassignment'];
|
28
|
default: return $lang['stryes'];
|
29
|
}
|
30
|
}
|
31
|
|
32
|
$misc->printTrail('database');
|
33
|
$misc->printTabs('database','casts');
|
34
|
$misc->printMsg($msg);
|
35
|
|
36
|
$casts = $data->getCasts();
|
37
|
|
38
|
$columns = array(
|
39
|
'source_type' => array(
|
40
|
'title' => $lang['strsourcetype'],
|
41
|
'field' => 'castsource',
|
42
|
),
|
43
|
'target_type' => array(
|
44
|
'title' => $lang['strtargettype'],
|
45
|
'field' => 'casttarget',
|
46
|
),
|
47
|
'function' => array(
|
48
|
'title' => $lang['strfunction'],
|
49
|
'field' => 'castfunc',
|
50
|
'params'=> array('null' => $lang['strbinarycompat']),
|
51
|
),
|
52
|
'implicit' => array(
|
53
|
'title' => $lang['strimplicit'],
|
54
|
'field' => 'castcontext',
|
55
|
'type' => 'callback',
|
56
|
'params'=> array('function' => 'renderCastContext', 'align' => 'center'),
|
57
|
),
|
58
|
);
|
59
|
|
60
|
$actions = array();
|
61
|
|
62
|
$misc->printTable($casts, $columns, $actions, $lang['strnocasts']);
|
63
|
}
|
64
|
|
65
|
/**
|
66
|
* Generate XML for the browser tree.
|
67
|
*/
|
68
|
function doTree() {
|
69
|
global $misc, $data;
|
70
|
|
71
|
$casts = $data->getCasts();
|
72
|
|
73
|
$proto = concat(field('castsource'), ' AS ', field('casttarget'));
|
74
|
|
75
|
$attrs = array(
|
76
|
'text' => $proto,
|
77
|
'icon' => 'casts'
|
78
|
);
|
79
|
|
80
|
$misc->printTreeXML($casts, $attrs);
|
81
|
exit;
|
82
|
}
|
83
|
|
84
|
if ($action == 'tree') doTree();
|
85
|
|
86
|
$misc->printHeader($lang['strcasts']);
|
87
|
$misc->printBody();
|
88
|
|
89
|
switch ($action) {
|
90
|
case 'tree':
|
91
|
doTree();
|
92
|
break;
|
93
|
default:
|
94
|
doDefault();
|
95
|
break;
|
96
|
}
|
97
|
|
98
|
$misc->printFooter();
|
99
|
|
100
|
?>
|