-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditCat.inc.php
More file actions
95 lines (91 loc) · 2.19 KB
/
Copy patheditCat.inc.php
File metadata and controls
95 lines (91 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
$values = array();
$thiscat = array();
$field = $_GET['field'];
if (isset($_GET['id'])) {
$id = (int) $_GET['id'];
$thiscat['id'] = $id;
if ($id === 0) {
$title = "Create $field";
$canDelete = false;
$thiscat['name'] = '';
$thiscat['description'] = '';
$thiscat['type'] = 'a';
} else {
$title = "Edit $field";
$canDelete = true;
}
} else {
$id = 0;
$thiscat['id'] = false;
$title = "$field List";
$canDelete = false;
}
$keys = array('id','name','description');
switch ($field) {
case 'instance':
$query = 'instanceselectbox';
$showTypes = false;
break;
case 'category':
$query = 'categoryselectbox';
$showTypes = false;
break;
case 'trade-condition':
$query = 'tradeconditionselectbox';
$showTypes = false;
break;
case 'context':
$query = 'spacecontextselectbox';
$showTypes = false;
break;
case 'time-context':
$query = 'timecontextselectbox' ;
$values['timefilterquery'] = '';
$keys[] = 'type';
$showTypes = $config['useTypesForTimeContexts'];
break;
default:
$query = '';
$showTypes = false;
break;
}
$result = query($query, $config, $values, $sort);
$catlist = array();
$count = 0;
$thiscat = false;
if ($result) {
$firstcat = 0;
$nextcat = -1;
foreach ($result as $checkcat) {
$newcat = array();
$i = 0;
foreach ($checkcat as $item) {
$newcat[$keys[$i++]] = $item;
}
if (!$firstcat) {
$firstcat = $newcat['id'];
}
if (!$nextcat) {
$nextcat = $newcat['id'];
}
if ($newcat['id'] == $id) {
$thiscat = $newcat;
$nextcat = 0;
} else {
$catlist[] = $newcat;
}
$count++;
}
if (!$nextcat) {
$nextcat = $firstcat;
} elseif ($nextcat === -1) {
$nextcat = 0;
}
}
if (!$thiscat && $id) {
$title = makeClean("Failed to find $field with id=$id");
}
if ($config['debug'] & _GTD_DEBUG) {
echo "<pre>catlist:",print_r($catlist, true),'</pre>';
}