Skip to content

Commit fb1d645

Browse files
committed
Code Style & CI chain
1 parent 5d11703 commit fb1d645

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1963
-1924
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
name: CI
22

3-
on: [push]
3+
on:
4+
push: ~
5+
pull_request: ~
6+
7+
permissions: read-all
48

59
jobs:
10+
ci:
11+
uses: 'terminal42/contao-build-tools/.github/workflows/build-tools.yml@main'
12+
613
tests:
714
name: 'PHP ${{ matrix.php }} (Composer Flags: ${{ matrix.composer }})'
815
runs-on: ubuntu-latest

.gitignore

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
# OS
2-
.DS_Store
3-
Thumbs.db
4-
5-
# IDEs
6-
.buildpath
7-
.project
8-
.settings/
9-
.build/
10-
.idea/
11-
nbproject/
12-
13-
# Composer
1+
/node_modules/
142
/vendor/
153
/composer.lock
16-
17-
# PHPUnit
18-
.phpunit.result.cache
4+
/.phpunit.result.cache

assets/ajax-reload.js

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1+
/* eslint-disable no-console */
2+
/* eslint-disable no-eval */
3+
14
(() => {
25
const elementsInProgress = {};
36
const eventsInProgress = {};
47

5-
function dispatchEvents() {
6-
if (arguments.length === 0) {
8+
function dispatchEvents(...args) {
9+
if (args.length === 0) {
710
console.error('Please provide at least one event');
811
}
912

1013
const els = {};
1114
const events = [];
1215
const listeners = [...document.querySelectorAll('[data-haste-ajax-listeners]')];
1316

14-
[...arguments].forEach(event => {
17+
args.forEach((event) => {
1518
let eventData = event;
1619

1720
if (typeof event === 'string') {
@@ -21,7 +24,7 @@
2124
let found = false;
2225

2326
// Find the elements that listen to particular event
24-
listeners.forEach(el => {
27+
listeners.forEach((el) => {
2528
if (el.dataset.hasteAjaxListeners.split(' ').indexOf(eventData.name) !== -1) {
2629
found = true;
2730
els[el.dataset.hasteAjaxId] = el;
@@ -34,7 +37,7 @@
3437
});
3538

3639
if (Object.keys(els).length > 0 && events.length > 0) {
37-
events.forEach(event => sendRequest(els, event));
40+
events.forEach((event) => sendRequest(els, event));
3841
}
3942
}
4043

@@ -44,13 +47,13 @@
4447
eventsInProgress[event.name].abort();
4548
}
4649

47-
for (const key in els) {
50+
Object.keys(els).forEach((key) => {
4851
// Mark the events to be updated by this event
4952
elementsInProgress[key] = event.name;
5053

5154
// Add the CSS class
5255
els[key].classList.add('haste-ajax-reloading');
53-
}
56+
});
5457

5558
const xhr = new XMLHttpRequest();
5659

@@ -61,16 +64,16 @@
6164
xhr.setRequestHeader('Haste-Ajax-Reload', event.name);
6265

6366
// Set the custom headers
64-
for (const header in event.headers || {}) {
65-
xhr.setRequestHeader(header, event.headers[header]);
66-
}
67+
Object.entries(event.headers || {}).forEach((v) => {
68+
xhr.setRequestHeader(...v);
69+
});
6770

6871
xhr.onload = () => {
6972
if (xhr.status === 200) {
7073
const newEls = {};
7174
const entries = JSON.parse(xhr.responseText);
7275

73-
Object.keys(entries).forEach(id => {
76+
Object.keys(entries).forEach((id) => {
7477
// Replace the entry only if it's marked to be updated by this event
7578
if (els[id] && elementsInProgress[id] === event.name) {
7679
els[id].outerHTML = entries[id];
@@ -80,22 +83,24 @@
8083
newEls[id] = document.querySelector(`[data-haste-ajax-id="${id}"]`);
8184

8285
// Execute the <script> tags inside the new element
83-
[...newEls[id].getElementsByTagName('script')].forEach(script => eval(script.innerHTML));
86+
[...newEls[id].getElementsByTagName('script')].forEach((script) => eval(script.innerHTML));
8487
}
8588
});
8689

8790
// Dispatch a global custom event
88-
document.dispatchEvent(new CustomEvent('HasteAjaxReloadComplete', {
89-
bubbles: false,
90-
cancelable: false,
91-
detail: {
92-
entries,
93-
event: event.name,
94-
eventData: event,
95-
oldElements: els,
96-
newElements: newEls
97-
}
98-
}));
91+
document.dispatchEvent(
92+
new CustomEvent('HasteAjaxReloadComplete', {
93+
bubbles: false,
94+
cancelable: false,
95+
detail: {
96+
entries,
97+
event: event.name,
98+
eventData: event,
99+
oldElements: els,
100+
newElements: newEls,
101+
},
102+
}),
103+
);
99104
} else {
100105
console.error(`The request for event "${event.name}" has failed`);
101106
console.error(xhr);

assets/dca-ajax-operations.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ window.Haste = window.Haste || {};
66
* @param {string} id The ID of the target element
77
* @returns {boolean}
88
*/
9-
window.Haste.toggleAjaxOperation = function(el, id) {
9+
window.Haste.toggleAjaxOperation = function (el, id) {
1010
el.blur();
1111

1212
function getUrlParameter(name, href) {
13-
const regex = new RegExp('[\\?&]' + name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]') + '=([^&#]*)');
13+
const regex = new RegExp(`[\\?&]${name.replace(/\[/, '\\[').replace(/]/, '\\]')}=([^&#]*)`);
1414
const results = regex.exec(href);
1515

1616
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
@@ -21,13 +21,13 @@ window.Haste.toggleAjaxOperation = function(el, id) {
2121
const value = el.getAttribute('data-haste-ajax-operation-value');
2222
const buttonHref = el.getAttribute('href');
2323
const urlTable = getUrlParameter('table', buttonHref);
24-
const urlAppend = (urlTable ? ('&table=' + urlTable) : '');
24+
const urlAppend = urlTable ? `&table=${urlTable}` : '';
2525

2626
// Send the request
2727
new Request.JSON({
2828
followRedirects: true,
2929
url: window.location.href + urlAppend,
30-
onComplete: function(json) {
30+
onComplete(json) {
3131
// Support Contao redirects
3232
if (this.getHeader('X-Ajax-Location')) {
3333
window.location.replace(this.getHeader('X-Ajax-Location'));
@@ -37,19 +37,19 @@ window.Haste.toggleAjaxOperation = function(el, id) {
3737
let iconPath = json.nextIcon;
3838

3939
if (iconPath.indexOf('/') === -1) {
40-
iconPath = Contao.script_url + 'system/themes/' + Contao.theme + '/icons/' + json.nextIcon;
40+
iconPath = `${window.Contao.script_url}system/themes/${window.Contao.theme}/icons/${json.nextIcon}`;
4141
}
4242

4343
image.src = iconPath;
4444

4545
el.setAttribute('data-haste-ajax-operation-value', json.nextValue);
46-
}
46+
},
4747
}).post({
48-
'action': 'hasteAjaxOperation',
49-
'operation': operation,
50-
'id': id,
51-
'value': value,
52-
'REQUEST_TOKEN': Contao.request_token
48+
action: 'hasteAjaxOperation',
49+
operation,
50+
id,
51+
value,
52+
REQUEST_TOKEN: window.Contao.request_token,
5353
});
5454

5555
return false;

composer-dependency-analyser.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
use Contao\CoreBundle\Twig\Runtime\BackendHelperRuntime;
4+
use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
5+
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;
6+
7+
return (new Configuration())
8+
9+
// Optional integrations
10+
->ignoreErrorsOnPackage('terminal42/dc_multilingual', [ErrorType::DEV_DEPENDENCY_IN_PROD])
11+
12+
->ignoreUnknownClasses([BackendHelperRuntime::class])
13+
;

composer.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,26 @@
2323
"php": "^8.1",
2424
"contao/core-bundle": "^4.13.41 || ^5.3.5",
2525
"symfony/mime": "^5.4 || ^6.0 || ^7.0",
26+
"symfony/security-core": "^5.4 || ^6.0 || ^7.0",
27+
"symfony/asset": "^5.4 || ^6.0 || ^7.0",
28+
"symfony/config": "^5.4 || ^6.0 || ^7.0",
29+
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
30+
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0",
31+
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0",
32+
"symfony/http-foundation": "^5.4 || ^6.0 || ^7.0",
33+
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
34+
"symfony/property-access": "^5.4 || ^6.0 || ^7.0",
35+
"symfony/routing": "^5.4 || ^6.0 || ^7.0",
36+
"symfony/string": "^5.4 || ^6.0 || ^7.0",
37+
"symfony/uid": "^5.4 || ^6.0 || ^7.0",
2638
"symfony/deprecation-contracts": "^2.1 || ^3.0",
27-
"symfony/security-core": "^5.4 || ^6.0 || ^7.0"
39+
"symfony/event-dispatcher-contracts": "^2.1 || ^3.0",
40+
"symfony/service-contracts": "^2.1 || ^3.0",
41+
"doctrine/dbal": "^3.3",
42+
"doctrine/doctrine-bundle": "^2.4",
43+
"doctrine/orm": "^2.10",
44+
"doctrine/persistence": "^2.0 || ^3.0",
45+
"twig/twig": "^3.8"
2846
},
2947
"require-dev": {
3048
"contao/manager-plugin": "^2.0",

contao/languages/de/default.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,6 @@
11
<?php
22

3-
/*
4-
* Errors
5-
*/
63
$GLOBALS['TL_LANG']['ERR']['numberInputNotAllowed'] = 'Bitte geben Sie eine valide Zahl ein (e.g. 5\'000, 5.00, 5,00, 5\'000.00)';
74

8-
/*
9-
* Miscellaneous
10-
*/
115
$GLOBALS['TL_LANG']['HST']['advanced_filter'] = 'Erweiterte Filter:';
126
$GLOBALS['TL_LANG']['HST']['advanced_search'] = 'Suche in "%s":';
13-
14-
/*
15-
* Weight Units
16-
* http://www.metric-conversions.org/weight/weight-conversions.htm
17-
*/
18-
$GLOBALS['TL_LANG']['WGT']['mg'] = ['Milligramm (mg)', 'Eine Masseinheit; entspricht 1 Tausendstel Gramm.'];
19-
$GLOBALS['TL_LANG']['WGT']['g'] = ['Gramm (g)', 'Eine Masseinheit; entspricht 1 Tausendstel Kilogramm.'];
20-
$GLOBALS['TL_LANG']['WGT']['kg'] = ['Kilogramm (kg)', 'Ein Kilogramm entspricht 1\'000 Gramm oder 2.2 Pfund; Entspricht dem Gewicht von einem Liter Wasser.'];
21-
$GLOBALS['TL_LANG']['WGT']['t'] = ['Tonne (t)', 'Eine Tonne entspricht 1\'000 Kilogramm, oder 2,204.6 Pfund.'];
22-
$GLOBALS['TL_LANG']['WGT']['ct'] = ['Karat (ct)', 'Das metrische Karat ist eine Masseinheit für die Masse von Edelsteinen. 1 metrisches Karat = 0,2 g = 2 · 10−4 kg.'];
23-
$GLOBALS['TL_LANG']['WGT']['oz'] = ['Unze (oz)', 'Entspricht einem Sechzehntel eines Pfunds oder 28.35 Gramm.'];
24-
$GLOBALS['TL_LANG']['WGT']['lb'] = ['Pfund (lb)', 'Eine Masseinheit; entspricht 16 Unzen'];
25-
$GLOBALS['TL_LANG']['WGT']['st'] = ['Stone (st)', 'Ein britische Masseinheit; Entspricht 14 Pfund.'];
26-
$GLOBALS['TL_LANG']['WGT']['grain'] = ['Grain', 'Eine Masseinheit; entspricht 1/7000 Pfund bzw. einem Troy Grain oder 64.799 Milligramm.'];

contao/languages/en/default.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,8 @@
11
<?php
22

3-
/*
4-
* Errors
5-
*/
63
$GLOBALS['TL_LANG']['ERR']['numberInputNotAllowed'] = 'Enter a valid number (e.g. 5\'000, 5.00, 5,00, 5\'000.00)';
74
$GLOBALS['TL_LANG']['ERR']['minFileSize'] = 'The minimum size for file uploads is %s';
85
$GLOBALS['TL_LANG']['ERR']['maxFileSize'] = 'The maximum size for file uploads is %s';
96

10-
/*
11-
* Miscellaneous
12-
*/
137
$GLOBALS['TL_LANG']['HST']['advanced_filter'] = 'Advanced filter:';
148
$GLOBALS['TL_LANG']['HST']['advanced_search'] = 'Search in "%s":';
15-
16-
/*
17-
* Weight Units
18-
* http://www.metric-conversions.org/weight/weight-conversions.htm
19-
*/
20-
$GLOBALS['TL_LANG']['WGT']['mg'] = ['Milligram (mg)', 'A unit of mass equal to one-thousandth of a gram.'];
21-
$GLOBALS['TL_LANG']['WGT']['g'] = ['Gram (g)', 'A metric unit of weight equal to one thousandth of a kilogram.'];
22-
$GLOBALS['TL_LANG']['WGT']['kg'] = ['Kilogram (kg)', 'One kilogram is equivalent to 1,000 grams or 2.2 pounds; the mass of a liter of water.'];
23-
$GLOBALS['TL_LANG']['WGT']['t'] = ['Metric Ton (t)', 'A unit of weight equal to 1,000 kilograms, or 2,204.6 pounds.'];
24-
$GLOBALS['TL_LANG']['WGT']['ct'] = ['Carats (ct)', 'A measure of weight used for gemstones. One carat is equal to 1/5 of a gram (200 milligrams). Note that karat with a "K" is a measure of the purity of a gold alloy.'];
25-
$GLOBALS['TL_LANG']['WGT']['oz'] = ['Ounce (oz)', 'A unit of weight equal to one sixteenth of a pound or 28.35 grams.'];
26-
$GLOBALS['TL_LANG']['WGT']['lb'] = ['Pound (lb)', 'A unit of mass equal to 16 ounces'];
27-
$GLOBALS['TL_LANG']['WGT']['st'] = ['Stone (st)', 'A British measurement of mass that equals fourteen pounds.'];
28-
$GLOBALS['TL_LANG']['WGT']['grain'] = ['Grain', '1/7000 pound; equals a troy grain or 64.799 milligrams.'];

contao/languages/pl/default.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
<?php
22

3-
/*
4-
* Miscellaneous
5-
*/
63
$GLOBALS['TL_LANG']['HST']['advanced_filter'] = 'Zaawansowany filtr:';

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
},
1212
"browserslist": [
1313
"defaults"
14-
]
14+
],
15+
"packageManager": "[email protected]+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
1516
}

0 commit comments

Comments
 (0)