Browse code

Progress

Benjamin Roth authored on14/11/2022 23:17:53
Showing11 changed files
... ...
@@ -12,13 +12,16 @@
12 12
  * Table tl_eSM_team
13 13
  */
14 14
 
15
+use Contao\DC_Table;
16
+use Contao\DataContainer;
17
+
15 18
 $GLOBALS['TL_DCA']['tl_eSM_team'] = array
16 19
 (
17 20
 
18 21
 	// Config
19 22
 	'config' => array
20 23
 	(
21
-		'dataContainer'               => 'Table',
24
+		'dataContainer'               => DC_Table::class,
22 25
         'ptable'                      => 'tl_eSM_team_group',
23 26
 		'enableVersioning'            => true,
24 27
 		'sql' => array
... ...
@@ -38,17 +41,20 @@ $GLOBALS['TL_DCA']['tl_eSM_team'] = array
38 41
 		'sorting' => array
39 42
 		(
40 43
 
41
-			'mode'                    => 4,
44
+			'mode'                    => DataContainer::MODE_PARENT,
42 45
 			'fields'                  => array('division', 'lastname'),
43 46
             'headerFields'            => array('title'),
44 47
             'panelLayout'             => 'filter,search;sort,limit',
45 48
             'child_record_callback'   => array('tl_eSM_team', 'listMembers')
46
-    ),
49
+        ),
50
+        'label' => array
51
+        (
52
+
53
+        ),
47 54
 		'global_operations' => array
48 55
 		(
49 56
 			'all' => array
50 57
 			(
51
-				'label'               => &$GLOBALS['TL_LANG']['MSC']['all'],
52 58
 				'href'                => 'act=select',
53 59
 				'class'               => 'header_edit_all',
54 60
 				'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
... ...
@@ -58,43 +64,45 @@ $GLOBALS['TL_DCA']['tl_eSM_team'] = array
58 64
 		(
59 65
 			'edit' => array
60 66
 			(
61
-				'label'               => &$GLOBALS['TL_LANG']['tl_eSM_team']['edit'],
62 67
 				'href'                => 'act=edit',
63
-				'icon'                => 'edit.gif'
68
+				'icon'                => 'edit.svg'
64 69
 			),
65 70
 			'copy' => array
66 71
 			(
67
-				'label'               => &$GLOBALS['TL_LANG']['tl_eSM_team']['copy'],
68
-				'href'                => 'act=copy',
69
-				'icon'                => 'copy.gif'
72
+				'href'                => 'act=paste&mode=copy',
73
+                'attributes'          => 'onclick="Backend.getScrollOffset()"',
74
+				'icon'                => 'copy.svg'
70 75
 			),
76
+            'cut' => array
77
+            (
78
+                'href'                => 'act=paste&mode=cut',
79
+                'icon'                => 'cut.svg',
80
+                'attributes'          => 'onclick="Backend.getScrollOffset()"'
81
+            ),
71 82
 			'delete' => array
72 83
 			(
73
-				'label'               => &$GLOBALS['TL_LANG']['tl_eSM_team']['delete'],
74 84
 				'href'                => 'act=delete',
75
-				'icon'                => 'delete.gif',
76
-				'attributes'          => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['tl_eSM_team']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'
85
+				'icon'                => 'delete.svg',
86
+				'attributes'          => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'
77 87
 			),
78 88
 			'toggle' => array
79 89
 			(
80
-				'label'               => &$GLOBALS['TL_LANG']['tl_eSM_team']['toggle'],
81
-				'icon'                => 'visible.gif',
82
-				'attributes'          => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"',
83
-				'button_callback'     => array('tl_eSM_team', 'toggleIcon')
90
+                'href'                => 'act=toggle&field=invisible',
91
+				'icon'                => 'visible.svg',
92
+//				'button_callback'     => array('tl_eSM_team', 'toggleIcon')
84 93
 			),
85
-			'show' => array
86
-			(
87
-				'label'               => &$GLOBALS['TL_LANG']['tl_eSM_team']['show'],
88
-				'href'                => 'act=show',
89
-				'icon'                => 'show.gif'
90
-			)
94
+            'show' => array
95
+            (
96
+                'href'                => 'act=show',
97
+                'icon'                => 'show.svg'
98
+            )
91 99
 		)
92 100
 	),
93 101
 
94 102
 	// Palettes
95 103
 	'palettes' => array
96 104
 	(
97
-		'default'                     => '{person_legend},firstname,lastname;{company_legend},position,division;{picture_legend},singleSRC;{publish_legend:hide},published'
105
+		'default'                     => '{person_legend},firstname,lastname,comment;{company_legend},position,division;{picture_legend},singleSRC;{publish_legend:hide},published'
98 106
 	),
99 107
 
100 108
 	// Subpalettes
... ...
@@ -146,6 +154,14 @@ $GLOBALS['TL_DCA']['tl_eSM_team'] = array
146 154
 			'eval'                    => array('mandatory'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
147 155
 			'sql'                     => "varchar(128) NOT NULL default ''"
148 156
 		),
157
+        'comment' => array
158
+        (
159
+            'label'                   => &$GLOBALS['TL_LANG']['tl_eSM_team']['comment'],
160
+            'exclude'                 => true,
161
+            'inputType'               => 'textarea',
162
+            'eval'                    => array('mandatory'=>false, 'maxlength'=>128, 'tl_class'=>'clr'),
163
+            'sql'                     => "varchar(128) NOT NULL default ''"
164
+        ),
149 165
 		'division' => array
150 166
 		(
151 167
 			'label'                   => &$GLOBALS['TL_LANG']['tl_eSM_team']['division'],
... ...
@@ -12,13 +12,18 @@
12 12
  * Table tl_eSM_team_group
13 13
  */
14 14
 
15
+use Contao\DC_Table;
16
+use Contao\DataContainer;
17
+use Contao\System;
18
+use Contao\CoreBundle\Security\ContaoCorePermissions;
19
+
15 20
 $GLOBALS['TL_DCA']['tl_eSM_team_group'] = array
16 21
 (
17 22
 
18 23
 	// Config
19 24
 	'config' => array
20 25
 	(
21
-		'dataContainer'               => 'Table',
26
+		'dataContainer'               => DC_Table::class,
22 27
         'ctable'                      => array('tl_eSM_team'),
23 28
         'switchToEdit'                => true,
24 29
         'enableVersioning'            => true,
... ...
@@ -36,7 +41,7 @@ $GLOBALS['TL_DCA']['tl_eSM_team_group'] = array
36 41
 	(
37 42
 		'sorting' => array
38 43
 		(
39
-			'mode'                    => 1,
44
+			'mode'                    => DataContainer::MODE_SORTED,
40 45
 			'fields'                  => array('title'),
41 46
 			'flag'                    => 1,
42 47
 			'panelLayout'             => 'filter,search;sort,limit',
... ...
@@ -50,7 +55,6 @@ $GLOBALS['TL_DCA']['tl_eSM_team_group'] = array
50 55
 		(
51 56
 			'all' => array
52 57
 			(
53
-				'label'               => &$GLOBALS['TL_LANG']['MSC']['all'],
54 58
 				'href'                => 'act=select',
55 59
 				'class'               => 'header_edit_all',
56 60
 				'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
... ...
@@ -60,36 +64,31 @@ $GLOBALS['TL_DCA']['tl_eSM_team_group'] = array
60 64
 		(
61 65
             'edit' => array
62 66
             (
63
-                'label'               => &$GLOBALS['TL_LANG']['tl_eSM_team_group']['edit'],
64 67
                 'href'                => 'table=tl_eSM_team',
65
-                'icon'                => 'edit.gif'
68
+                'icon'                => 'edit.svg'
66 69
             ),
67 70
             'editheader' => array
68 71
             (
69
-                'label'               => &$GLOBALS['TL_LANG']['tl_eSM_team_group']['editheader'],
70 72
                 'href'                => 'act=edit',
71
-                'icon'                => 'header.gif',
73
+                'icon'                => 'header.svg',
72 74
                 'button_callback'     => array('tl_eSM_team_group', 'editHeader')
73 75
             ),
74 76
 			'copy' => array
75 77
 			(
76
-				'label'               => &$GLOBALS['TL_LANG']['tl_eSM_team_group']['copy'],
77 78
 				'href'                => 'act=copy',
78
-				'icon'                => 'copy.gif'
79
-			),
80
-			'delete' => array
81
-			(
82
-				'label'               => &$GLOBALS['TL_LANG']['tl_eSM_team_group']['delete'],
83
-				'href'                => 'act=delete',
84
-				'icon'                => 'delete.gif',
85
-				'attributes'          => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['tl_eSM_team_group']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'
79
+				'icon'                => 'copy.svg'
86 80
 			),
87
-			'show' => array
88
-			(
89
-				'label'               => &$GLOBALS['TL_LANG']['tl_eSM_team_group']['show'],
90
-				'href'                => 'act=show',
91
-				'icon'                => 'show.gif'
92
-			)
81
+            'delete' => array
82
+            (
83
+                'href'                => 'act=delete',
84
+                'icon'                => 'delete.svg',
85
+                'attributes'          => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'
86
+            ),
87
+            'show' => array
88
+            (
89
+                'href'                => 'act=show',
90
+                'icon'                => 'show.svg'
91
+            )
93 92
 		)
94 93
 	),
95 94
 
... ...
@@ -156,6 +155,6 @@ class tl_eSM_team_group extends Backend
156 155
    */
157 156
   public function editHeader($row, $href, $label, $title, $icon, $attributes)
158 157
   {
159
-    return $this->User->canEditFieldsOf('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
+    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)).' ';
160 159
   }
161 160
 }
162 161
\ No newline at end of file
... ...
@@ -8,7 +8,15 @@
8 8
 * @license LGPL-3.0+
9 9
 */
10 10
 
11
-$GLOBALS['TL_DCA']['tl_module']['palettes']['teamlist'] = '{title_legend},name,headline,type;{team_legend},eSM_team_group,eSM_team_divisions;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space';
11
+$GLOBALS['TL_DCA']['tl_module']['palettes']['team_list'] = '
12
+    {title_legend},name,headline,type;
13
+    {team_legend},eSM_team_group,eSM_team_divisions;
14
+    {image_legend},imgSize;
15
+    {template_legend:hide},customTpl;
16
+    {protected_legend:hide},protected;
17
+    {expert_legend:hide},guests,cssID
18
+';
19
+
12 20
 
13 21
 $GLOBALS['TL_DCA']['tl_module']['fields']['eSM_team_group'] = array
14 22
 (
... ...
@@ -29,11 +37,4 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['eSM_team_divisions'] = array
29 37
 	'reference'               => &$GLOBALS['TL_LANG']['REF']['divisions'],
30 38
 	'eval'                    => array('mandatory'=>true, 'multiple'=>true),
31 39
 	'sql'                     => "blob NULL"
32
-);
33
-
34
-$GLOBALS['TL_DCA']['tl_module']['palettes']['team_list'] = '
35
-    {title_legend},name,headline,type;
36
-    {template_legend:hide},customTpl;
37
-    {protected_legend:hide},protected;
38
-    {expert_legend:hide},guests,cssID
39
-';
40
+);
40 41
\ No newline at end of file
41 42
new file mode 100644
... ...
@@ -0,0 +1,54 @@
1
+{% extends '@Contao/block_searchable' %}
2
+{% import "@ContaoCore/Image/Studio/_macros.html.twig" as studio %}
3
+
4
+{% block content %}
5
+  {% if teammembers is not empty %}
6
+    <div class="swiper-slider">
7
+      <div id="swiper-{{ id }}"class="swiper-container">
8
+        <ul class="swiper-wrapper">
9
+          {% for member in teammembers %}
10
+            <li class="swiper-slide">
11
+              {% if member.imageFigure %}
12
+                {{- studio.figure(member.imageFigure, { attr: { class: ('image_container ') }}) -}}
13
+              {% endif %}
14
+              <div class="name">{{ member.firstname }} {{ member.lastname }}</div>
15
+              <div class="position">{{ member.position }}</div>
16
+              <div class="comment">{{ member.comment }}</div>
17
+            </li>
18
+          {% endfor %}
19
+        </ul>
20
+        <div class="swiper-button-next"></div>
21
+        <div class="swiper-button-prev"></div>
22
+      </div>
23
+    </div>
24
+  {% endif %}
25
+
26
+  <script>
27
+    var swiperEl = document.getElementById('swiper-{{ id }}');
28
+    new Swiper(swiperEl, {
29
+      "loop": true,
30
+      "speed": 500,
31
+      "slidesPerView": 5,
32
+      "slidesPerGroup": 5,
33
+      "spaceBetween": 5,
34
+      "effect": "slide",
35
+      "navigation": {
36
+        "nextEl": swiperEl.querySelectorAll('.swiper-button-next')[0],
37
+        "prevEl": swiperEl.querySelectorAll('.swiper-button-prev')[0]
38
+      },
39
+      "breakpoints": {
40
+        900: {
41
+          "slidesPerView": 5,
42
+          "slidesPerGroup": 5,
43
+        },
44
+        599: {
45
+          "slidesPerView": 2,
46
+          "slidesPerGroup": 2,
47
+        },
48
+        0: {
49
+          "slidesPerView": 1,
50
+          "slidesPerGroup": 1,
51
+        }
52
+      }
53
+    })</script>
54
+{% endblock %}
0 55
deleted file mode 100644
... ...
@@ -1,5 +0,0 @@
1
-<?php $this->extend('block_unsearchable'); ?>
2
-
3
-<?php $this->block('content'); ?>
4
-  <p>Put your content here.</p>
5
-<?php $this->endblock(); ?>
... ...
@@ -6,16 +6,63 @@ namespace App\Controller\FrontendModule;
6 6
 
7 7
 use Contao\CoreBundle\Controller\FrontendModule\AbstractFrontendModuleController;
8 8
 use Contao\CoreBundle\DependencyInjection\Attribute\AsFrontendModule;
9
+use Contao\CoreBundle\Image\Studio\Studio;
9 10
 use Contao\ModuleModel;
11
+use Contao\StringUtil;
12
+use Contao\System;
10 13
 use Contao\Template;
14
+use Doctrine\DBAL\Connection;
11 15
 use Symfony\Component\HttpFoundation\Request;
12 16
 use Symfony\Component\HttpFoundation\Response;
13 17
 
14 18
 #[AsFrontendModule(category: "miscellaneous")]
15 19
 class TeamListController extends AbstractFrontendModuleController
16 20
 {
21
+    /**
22
+     * @var Connection
23
+     */
24
+    protected $db;
25
+
26
+    public function __invoke(Request $request, ModuleModel $model, string $section, array $classes = null): Response
27
+    {
28
+        $this->db = System::getContainer()->get('database_connection');
29
+        return parent::__invoke($request, $model, $section, $classes); // TODO: Change the autogenerated stub
30
+    }
31
+
17 32
     protected function getResponse(Template $template, ModuleModel $model, Request $request): Response
18 33
     {
34
+        $Team = $this->db->executeQuery(
35
+            "SELECT * FROM tl_eSM_team WHERE division IN (:division) AND pid = :group AND published = '1' ORDER BY division, lastname",
36
+            [
37
+                'division' => StringUtil::deserialize($model->eSM_team_divisions),
38
+                'group' => $model->eSM_team_group
39
+            ],
40
+            ['division' => Connection::PARAM_STR_ARRAY]
41
+        );
42
+
43
+        if ($Team->rowCount())
44
+        {
45
+            $arrTeam = [];
46
+            $figureBuilder = System::getContainer()
47
+                ->get(Studio::class)
48
+                ->createFigureBuilder()
49
+                ->enableLightbox();
50
+
51
+            foreach ($Team->fetchAllAssociative() as $member)
52
+            {
53
+                $arrTeam[] = array_merge($member,[
54
+                    'imageFigure' => $figureBuilder->fromUuid($member['singleSRC'])->setSize($model->imgSize)->build()
55
+                ]);
56
+            }
57
+
58
+            shuffle($arrTeam);
59
+
60
+            $template->teammembers = $arrTeam;
61
+
62
+            $GLOBALS['TL_CSS']['swiper'] = 'bundles/esalesmediacontaoswiper/css/swiper-custom.css';
63
+            $GLOBALS['TL_JAVASCRIPT']['swiper'] = 'bundles/esalesmediacontaoswiper/js/lib/swiper/6.5.0/swiper-bundle.min.js'; // load swiper
64
+        }
65
+
19 66
         return $template->getResponse();
20 67
     }
21 68
 }
22 69
deleted file mode 100644
23 70
Binary files a/var/backups/backup__20221104185318.sql.gz and /dev/null differ
24 71
deleted file mode 100644
25 72
Binary files a/var/backups/backup__20221107224149.sql.gz and /dev/null differ
26 73
deleted file mode 100644
27 74
Binary files a/var/backups/backup__20221108134126.sql.gz and /dev/null differ
28 75
new file mode 100644
29 76
Binary files /dev/null and b/var/backups/backup__20221114155623.sql.gz differ
30 77
new file mode 100644
31 78
Binary files /dev/null and b/var/backups/backup__20221114221623.sql.gz differ