Sort list of masks
[misc/kostenrechnung] / masks / sys_mask.php
1 <?php
2
3 function discover_cmp($a, $b)
4 {
5   return strcmp($a['id'],$b['id']);
6 }
7
8 function discover_masks()
9 {
10   $info = array();
11
12   if (($d = opendir($_SESSION['sys']['basedir'].'masks')) === false)
13     return $info;
14
15   while (($file = readdir($d)) !== false)
16     if (substr($file,-4) == '.php') {
17       $fname = substr($file,0,-4);
18       $info[] = array('id' => $fname, 'text' => $fname);
19     }
20   closedir($d);
21
22   usort($info,discover_cmp);
23   return $info;
24 }
25
26 $mask = array(
27               'table' => 'sys_mask',
28               'title' => 'Liste der Menüpunkte',
29               'join' => array('sys_menu ON sys_mask.menu = sys_menu.id'),
30               'list' => array(
31                               'id' => array(
32                                             'name' => 'ID',
33                                             'visible' => false,
34                                             'sql' => 'sys_mask.id',
35                                             ),
36                               'fname' => array(
37                                             'name' => 'Dateiname',
38                                             'width' => 100,
39                                             ),
40                               'title' => array(
41                                             'name' => 'Beschreibung',
42                                             'width' => 150,
43                                             ),
44                               'menutitle' => array(
45                                             'name' => 'Menüpunkt',
46                                             'width' => 100,
47                                             ),
48                               'menu' => array(
49                                             'name' => 'Menü',
50                                             'sql' => 'sys_menu.name',
51                                             'width' => 100,
52                                             ),
53                               'edit' => array(
54                                             'name' => 'Edit',
55                                             'width' => 40,
56                                             'specs' => "ClassName: 'aligncenter'",
57                                             ),
58                               'priority' => array(
59                                             'name' => 'Priorität',
60                                             'width' => 60,
61                                             'type' => 'number',
62                                             'specs' => "ClassName: 'alignright'",
63                                             'sql' => 'sys_mask.priority',
64                                             ),
65                               'sys_user' => array(
66                                             'name' => 'Bearb.',
67                                             'width' => 50,
68                                             'visible' => false,
69                                             'sql' => 'sys_mask.sys_user',
70                                             ),
71                               'sys_edit' => array(
72                                             'name' => 'Geändert',
73                                             'width' => 80,
74                                             'type' => 'date',
75                                             'visible' => false,
76                                             'sql' => 'sys_mask.sys_edit',
77                                             ),
78                               ),
79               'rows' => 20,
80               'edit' => array(
81                               'fname' => array(
82                                             'name' => 'Dateiname',
83                                             'type' => 'select',
84                                             'options' => discover_masks(),
85                                             ),
86                               'title' => array(
87                                             'name' => 'Beschreibung',
88                                             'type' => 'text',
89                                             'size' => 25,
90                                             ),
91                               'menutitle' => array(
92                                             'name' => 'Menüpunkt',
93                                             'type' => 'text',
94                                             'size' => 25,
95                                             ),
96                               'menu' => array(
97                                             'name' => 'Menü',
98                                             'type' => 'select',
99                                             'options' => 'SELECT id,name AS text FROM sys_menu ORDER BY name',
100                                             'size' => 10,
101                                             ),
102                               'edit' => array(
103                                             'name' => 'Edit',
104                                             'type' => 'boolean',
105                                             'size' => 10,
106                                             ),
107                               'priority' => array(
108                                             'name' => 'Priorität',
109                                             'type' => 'number',
110                                             'size' => 10,
111                                             ),
112                               ),
113               );
114
115 ?>