|
1
|
|
|
<?php
|
|
2
|
|
|
/**
|
|
3
|
|
|
* Contao Open Source CMS
|
|
4
|
|
|
*
|
|
5
|
|
|
* Copyright (c) Jan Karai
|
|
6
|
|
|
*
|
|
7
|
|
|
* @license LGPL-3.0+
|
|
8
|
|
|
*/
|
|
9
|
|
|
|
|
10
|
|
|
/**
|
|
11
|
|
|
* Load tl_content language file
|
|
12
|
|
|
*/
|
|
13
|
|
|
System::loadLanguageFile('tl_content');
|
|
14
|
|
|
|
|
15
|
|
|
/**
|
|
16
|
|
|
* Table tl_belegungsplan_calender
|
|
17
|
|
|
*/
|
|
18
|
|
|
$GLOBALS['TL_DCA']['tl_belegungsplan_calender'] = array
|
|
19
|
|
|
(
|
|
20
|
|
|
// Config
|
|
21
|
|
|
'config' => array
|
|
22
|
|
|
(
|
|
23
|
|
|
'dataContainer' => 'Table',
|
|
24
|
|
|
'ptable' => 'tl_belegungsplan_objekte',
|
|
25
|
|
|
'ctable' => array('tl_content'),
|
|
26
|
|
|
'switchToEdit' => true,
|
|
27
|
|
|
'enableVersioning' => true,
|
|
28
|
|
|
'sql' => array
|
|
29
|
|
|
(
|
|
30
|
|
|
'keys' => array
|
|
31
|
|
|
(
|
|
32
|
|
|
'id' => 'primary',
|
|
33
|
|
|
'pid' => 'index'
|
|
34
|
|
|
)
|
|
35
|
|
|
)
|
|
36
|
|
|
),
|
|
37
|
|
|
// List
|
|
38
|
|
|
'list' => array
|
|
39
|
|
|
(
|
|
40
|
|
|
'sorting' => array
|
|
41
|
|
|
(
|
|
42
|
|
|
'mode' => 4,
|
|
43
|
|
|
'fields' => array('startDate DESC'),
|
|
44
|
|
|
'headerFields' => array('name', 'tstamp'),
|
|
45
|
|
|
'panelLayout' => 'filter;sort,search,limit',
|
|
46
|
|
|
'child_record_callback' => array('tl_belegungsplan_calender', 'listCalender')
|
|
47
|
|
|
),
|
|
48
|
|
|
'label' => array
|
|
49
|
|
|
(
|
|
50
|
|
|
'fields' => array('gast', 'startDate', 'endDate'),
|
|
51
|
|
|
'format' => '%s'
|
|
52
|
|
|
),
|
|
53
|
|
|
'global_operations' => array
|
|
54
|
|
|
(
|
|
55
|
|
|
'all' => array
|
|
56
|
|
|
(
|
|
57
|
|
|
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
|
|
58
|
|
|
'href' => 'act=select',
|
|
59
|
|
|
'class' => 'header_edit_all',
|
|
60
|
|
|
'attributes' => 'onclick="Backend.getScrollOffset()" accesskey="e"'
|
|
61
|
|
|
)
|
|
62
|
|
|
),
|
|
63
|
|
|
'operations' => array
|
|
64
|
|
|
(
|
|
65
|
|
|
'edit' => array
|
|
66
|
|
|
(
|
|
67
|
|
|
'label' => &$GLOBALS['TL_LANG']['tl_belegungsplan_calender']['edit'],
|
|
68
|
|
|
'href' => 'act=edit',
|
|
69
|
|
|
'icon' => 'edit.svg'
|
|
70
|
|
|
),
|
|
71
|
|
|
'delete' => array
|
|
72
|
|
|
(
|
|
73
|
|
|
'label' => &$GLOBALS['TL_LANG']['tl_belegungsplan_calender']['delete'],
|
|
74
|
|
|
'href' => 'act=delete',
|
|
75
|
|
|
'icon' => 'delete.svg',
|
|
76
|
|
|
'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'
|
|
77
|
|
|
)
|
|
78
|
|
|
)
|
|
79
|
|
|
),
|
|
80
|
|
|
// Palettes
|
|
81
|
|
|
'palettes' => array
|
|
82
|
|
|
(
|
|
83
|
|
|
'__selector__' => array(),
|
|
84
|
|
|
'default' => '{title_legend},gast,author;{date_legend},startDate,endDate'
|
|
85
|
|
|
),
|
|
86
|
|
|
// Subpalettes
|
|
87
|
|
|
'subpalettes' => array(
|
|
88
|
|
|
),
|
|
89
|
|
|
// Fields
|
|
90
|
|
|
'fields' => array
|
|
91
|
|
|
(
|
|
92
|
|
|
'id' => array
|
|
93
|
|
|
(
|
|
94
|
|
|
'sql' => "int(10) unsigned NOT NULL auto_increment"
|
|
95
|
|
|
),
|
|
96
|
|
|
'pid' => array
|
|
97
|
|
|
(
|
|
98
|
|
|
'foreignKey' => 'tl_belegungsplan_objekte.name',
|
|
99
|
|
|
'sql' => "int(10) unsigned NOT NULL default '0'",
|
|
100
|
|
|
'relation' => array('type'=>'belongsTo', 'load'=>'eager')
|
|
101
|
|
|
),
|
|
102
|
|
|
'tstamp' => array
|
|
103
|
|
|
(
|
|
104
|
|
|
'sql' => "int(10) unsigned NOT NULL default '0'"
|
|
105
|
|
|
),
|
|
106
|
|
|
'gast' => array
|
|
107
|
|
|
(
|
|
108
|
|
|
'label' => &$GLOBALS['TL_LANG']['tl_belegungsplan_calender']['gast'],
|
|
109
|
|
|
'exclude' => true,
|
|
110
|
|
|
'search' => true,
|
|
111
|
|
|
'filter' => true,
|
|
112
|
|
|
'inputType' => 'text',
|
|
113
|
|
|
'eval' => array('mandatory'=>true, 'maxlength'=>255, 'tl_class'=>'long'),
|
|
114
|
|
|
'sql' => "varchar(255) NOT NULL default ''"
|
|
115
|
|
|
),
|
|
116
|
|
|
'author' => array
|
|
117
|
|
|
(
|
|
118
|
|
|
'label' => &$GLOBALS['TL_LANG']['tl_belegungsplan_calender']['author'],
|
|
119
|
|
|
'default' => BackendUser::getInstance()->id,
|
|
120
|
|
|
'exclude' => true,
|
|
121
|
|
|
'search' => true,
|
|
122
|
|
|
'filter' => true,
|
|
123
|
|
|
'sorting' => true,
|
|
124
|
|
|
'flag' => 11,
|
|
125
|
|
|
'inputType' => 'select',
|
|
126
|
|
|
'foreignKey' => 'tl_user.name',
|
|
127
|
|
|
'eval' => array('doNotCopy'=>true, 'chosen'=>true, 'mandatory'=>true, 'includeBlankOption'=>true, 'tl_class'=>'w50'),
|
|
128
|
|
|
'sql' => "int(10) unsigned NOT NULL default '0'",
|
|
129
|
|
|
'relation' => array('type'=>'belongsTo', 'load'=>'eager')
|
|
130
|
|
|
),
|
|
131
|
|
|
'startDate' => array
|
|
132
|
|
|
(
|
|
133
|
|
|
'label' => &$GLOBALS['TL_LANG']['tl_belegungsplan_calender']['startDate'],
|
|
134
|
|
|
'exclude' => true,
|
|
135
|
|
|
'search' => true,
|
|
136
|
|
|
'filter' => true,
|
|
137
|
|
|
'sorting' => true,
|
|
138
|
|
|
'flag' => 8,
|
|
139
|
|
|
'inputType' => 'text',
|
|
140
|
|
|
'eval' => array('rgxp'=>'date', 'mandatory'=>true, 'doNotCopy'=>true, 'datepicker'=>true, 'tl_class'=>'w50 wizard'),
|
|
141
|
|
|
'sql' => "int(10) unsigned NULL"
|
|
142
|
|
|
),
|
|
143
|
|
|
'endDate' => array
|
|
144
|
|
|
(
|
|
145
|
|
|
'label' => &$GLOBALS['TL_LANG']['tl_belegungsplan_calender']['endDate'],
|
|
146
|
|
|
'exclude' => true,
|
|
147
|
|
|
'search' => true,
|
|
148
|
|
|
'filter' => true,
|
|
149
|
|
|
'sorting' => true,
|
|
150
|
|
|
'flag' => 8,
|
|
151
|
|
|
'inputType' => 'text',
|
|
152
|
|
|
'eval' => array('rgxp'=>'date', 'mandatory'=>true, 'doNotCopy'=>true, 'datepicker'=>true, 'tl_class'=>'w50 wizard'),
|
|
153
|
|
|
'sql' => "int(10) unsigned NULL"
|
|
154
|
|
|
)
|
|
155
|
|
|
)
|
|
156
|
|
|
);
|
|
157
|
|
|
|
|
158
|
|
|
/**
|
|
159
|
|
|
* Provide miscellaneous methods that are used by the data configuration array.
|
|
160
|
|
|
*
|
|
161
|
|
|
* @author Jan Karai <https://www.sachsen-it.de>
|
|
162
|
|
|
*/
|
|
163
|
|
View Code Duplication |
class tl_belegungsplan_calender extends Backend
|
|
|
|
|
|
|
164
|
|
|
{
|
|
165
|
|
|
/**
|
|
166
|
|
|
* Import the back end user object
|
|
167
|
|
|
*/
|
|
168
|
|
|
public function __construct() {
|
|
169
|
|
|
parent::__construct();
|
|
170
|
|
|
$this->import('BackendUser', 'User');
|
|
171
|
|
|
}
|
|
172
|
|
|
/**
|
|
173
|
|
|
* Add the type of input field
|
|
174
|
|
|
*
|
|
175
|
|
|
* @param array $arrRow
|
|
176
|
|
|
*
|
|
177
|
|
|
* @return string
|
|
178
|
|
|
*/
|
|
179
|
|
|
public function listCalender($arrRow)
|
|
180
|
|
|
{
|
|
181
|
|
|
return '<div class="tl_content_left">' . $arrRow['gast'] . ' <span style="color:#999;padding-left:3px">[' . Date::parse(Config::get('dateFormat'), $arrRow['startDate']) . $GLOBALS['TL_LANG']['MSC']['cal_timeSeparator'] . Date::parse(Config::get('dateFormat'), $arrRow['endDate']) . ']</span></div>';
|
|
182
|
|
|
}
|
|
183
|
|
|
}
|
|
184
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.