Browse code

Progress live

Benjamin Roth authored on12/12/2022 09:35:54
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,159 @@
1
+<?php
2
+/**
3
+ * TeamList for Contao
4
+ *
5
+ * Copyright (c) 2016 Benjamin Roth
6
+ *
7
+ * @license LGPL-3.0+
8
+ */
9
+
10
+/**
11
+ * Table tl_esm_team_group
12
+ */
13
+
14
+use Contao\DC_Table;
15
+use Contao\DataContainer;
16
+use Contao\System;
17
+use Contao\CoreBundle\Security\ContaoCorePermissions;
18
+
19
+$GLOBALS['TL_DCA']['tl_esm_team_group'] = array
20
+(
21
+
22
+	// Config
23
+	'config' => array
24
+	(
25
+		'dataContainer'               => DC_Table::class,
26
+        'ctable'                      => array('tl_esm_team'),
27
+        'switchToEdit'                => true,
28
+        'enableVersioning'            => true,
29
+		'sql' => array
30
+		(
31
+			'keys' => array
32
+			(
33
+				'id' => 'primary'
34
+			)
35
+		)
36
+	),
37
+
38
+	// List
39
+	'list' => array
40
+	(
41
+		'sorting' => array
42
+		(
43
+			'mode'                    => DataContainer::MODE_SORTED,
44
+			'fields'                  => array('title'),
45
+			'flag'                    => 1,
46
+			'panelLayout'             => 'filter,search;sort,limit',
47
+		),
48
+		'label' => array
49
+		(
50
+			'fields'                  => array('title'),
51
+			'format'                  => '%s'
52
+		),
53
+		'global_operations' => array
54
+		(
55
+			'all' => array
56
+			(
57
+				'href'                => 'act=select',
58
+				'class'               => 'header_edit_all',
59
+				'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
60
+			)
61
+		),
62
+		'operations' => array
63
+		(
64
+            'edit' => array
65
+            (
66
+                'href'                => 'table=tl_esm_team',
67
+                'icon'                => 'edit.svg'
68
+            ),
69
+            'editheader' => array
70
+            (
71
+                'href'                => 'act=edit',
72
+                'icon'                => 'header.svg',
73
+                'button_callback'     => array('tl_esm_team_group', 'editHeader')
74
+            ),
75
+			'copy' => array
76
+			(
77
+				'href'                => 'act=copy',
78
+				'icon'                => 'copy.svg'
79
+			),
80
+            'delete' => array
81
+            (
82
+                'href'                => 'act=delete',
83
+                'icon'                => 'delete.svg',
84
+                'attributes'          => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['MSC']['deleteConfirm'] ?? null) . '\'))return false;Backend.getScrollOffset()"'
85
+            ),
86
+            'show' => array
87
+            (
88
+                'href'                => 'act=show',
89
+                'icon'                => 'show.svg'
90
+            )
91
+		)
92
+	),
93
+
94
+	// Palettes
95
+	'palettes' => array
96
+	(
97
+		'default'                     => '{title_legend},title'
98
+	),
99
+
100
+	// Subpalettes
101
+	'subpalettes' => array
102
+	(
103
+	),
104
+
105
+	// Fields
106
+	'fields' => array
107
+	(
108
+		'id' => array
109
+		(
110
+			'sql'                     => "int(10) unsigned NOT NULL auto_increment"
111
+		),
112
+		'tstamp' => array
113
+		(
114
+			'sql'                     => "int(10) unsigned NOT NULL default '0'"
115
+		),
116
+		'title' => array
117
+		(
118
+			'label'                   => &$GLOBALS['TL_LANG']['tl_esm_team_group']['title'],
119
+			'exclude'                 => true,
120
+			'search'                  => true,
121
+			'inputType'               => 'text',
122
+			'eval'                    => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
123
+			'sql'                     => "varchar(128) NOT NULL default ''"
124
+		)
125
+	)
126
+);
127
+
128
+/**
129
+ * Provide miscellaneous methods that are used by the data configuration array.
130
+ */
131
+class tl_esm_team_group extends Backend
132
+{
133
+
134
+	/**
135
+	 * Import the back end user object
136
+	 */
137
+	public function __construct()
138
+	{
139
+		parent::__construct();
140
+		$this->import('BackendUser', 'User');
141
+	}
142
+
143
+  /**
144
+   * Return the edit header button
145
+   *
146
+   * @param array  $row
147
+   * @param string $href
148
+   * @param string $label
149
+   * @param string $title
150
+   * @param string $icon
151
+   * @param string $attributes
152
+   *
153
+   * @return string
154
+   */
155
+  public function editHeader($row, $href, $label, $title, $icon, $attributes)
156
+  {
157
+    return System::getContainer()->get('security.helper')->isGranted(ContaoCorePermissions::USER_CAN_EDIT_FIELDS_OF_TABLE, 'tl_esm_team') ? '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label).'</a> ' : Image::getHtml(preg_replace('/\.gif$/i', '_.gif', $icon)).' ';
158
+  }
159
+}