Initial commit - Typo3 11.5.41

This commit is contained in:
Matteo Gallo
2026-07-03 17:53:31 +02:00
commit 5ca4743197
6811 changed files with 568848 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
function ttAddressGoogleMaps() {
var obj = {};
obj.map = null;
obj.markers = [];
obj.run = function () {
const mapOptions = {
center: new google.maps.LatLng(48.3057664, 14.2873126),
zoom: 11,
maxZoom: 15,
streetViewControl: false,
fullscreenControl: false
};
obj.map = new google.maps.Map(document.getElementById('ttaddress__map'), mapOptions);
infoWindow = new google.maps.InfoWindow();
var bounds = new google.maps.LatLngBounds();
var records = document.getElementById("ttaddress__records");
for (var i = 0; i < records.childNodes.length; i++) {
var item = records.childNodes[i];
var marker = new google.maps.Marker({
map: obj.map,
position: new google.maps.LatLng(item.getAttribute('data-lat'), item.getAttribute('data-lng')),
infowindow: infoWindow,
recordId: item.getAttribute('data-id')
});
google.maps.event.addListener(marker, 'click', function (e) {
infoWindow.setContent(document.getElementById('ttaddress__record-' + this.recordId).innerHTML);
infoWindow.open(obj.map, this);
var allLabels = document.querySelectorAll('.ttaddress__label');
for (var i = 0; i < allLabels.length; i++) {
allLabels[i].classList.remove('active')
}
document.getElementById('ttaddress__label-' + this.recordId).classList.add('active');
});
bounds.extend(marker.getPosition());
obj.markers.push(marker);
}
obj.map.fitBounds(bounds);
};
obj.openMarker = function (markerId) {
google.maps.event.trigger(obj.markers[markerId], 'click');
};
return obj;
}
document.addEventListener("DOMContentLoaded", function () {
var ttAddressMapInstance = ttAddressGoogleMaps();
ttAddressMapInstance.run();
document.addEventListener('click', function (event) {
if (!event.target.matches('.ttaddress__markerlink')) {
return;
}
event.preventDefault();
var element = event.target;
ttAddressMapInstance.openMarker(element.getAttribute('data-iteration-id'));
}, false);
});

View File

@@ -0,0 +1,68 @@
function ttAddressLeaflet() {
var obj = {};
obj.map = null;
obj.markers = [];
obj.run = function () {
obj.map = L.map('ttaddress__map').setView([51.505, -0.09], 13);
obj.map.scrollWheelZoom.disable();
var mapBounds = L.latLngBounds();
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
id: 'mapbox.streets'
}).addTo(obj.map);
var records = document.getElementById("ttaddress__records").children;
for (var i = 0; i < records.length; i++) {
var item = records[i];
var marker = L.marker([item.getAttribute('data-lat'), item.getAttribute('data-lng')]).addTo(obj.map)
.bindPopup(document.getElementById('ttaddress__record-' + item.getAttribute('data-id')).innerHTML);
obj.markers.push(marker);
}
var group = new L.featureGroup(obj.markers);
obj.map.fitBounds(group.getBounds());
// Zoom out if zoom level is too high
// var zoomLevel = obj.map.getZoom();
// if (zoomLevel >= 10) {
// obj.map.setZoom(8);
// }
};
obj.openMarker = function (markerId) {
obj.markers[markerId].openPopup();
};
return obj;
}
function ttAddressOnload() {
var ttAddressMapInstance = ttAddressLeaflet();
ttAddressMapInstance.run();
document.addEventListener('click', function (event) {
if (!event.target.matches('.ttaddress__markerlink')) {
return;
}
event.preventDefault();
var element = event.target;
ttAddressMapInstance.openMarker(parseInt(element.getAttribute('data-iteration-id')));
}, false);
}
/** event listener on DOMContentLoaded does not work with scripts which are loaded async.
* With TYPO3 this could e.g. happen with EXT:scriptmerger
* Thus we listen only if document.readyState is loading, otherwise we can already fire as DOM is loaded already.
**/
if (document.readyState === 'loading') {
document.addEventListener("DOMContentLoaded", function () {
ttAddressOnload();
});
} else {
ttAddressOnload();
}

View File

@@ -0,0 +1,195 @@
define(['jquery', 'TYPO3/CMS/Backend/Icons', 'TYPO3/CMS/Backend/FormEngine', 'TYPO3/CMS/TtAddress/leaflet-core-1.4.0'], function ($, Icons, FormEngine) {
'use strict';
let LeafBE = {
$element: null,
$gLatitude: null,
$gLongitude: null,
$latitude: null,
$longitude: null,
$fieldLat: null,
$fieldLon: null,
$fieldLatActive: null,
$geoCodeUrl: null,
$geoCodeUrlShort: null,
$tilesUrl: null,
$tilesCopy: null,
$zoomLevel: 13,
$marker: null,
$map: null,
$iconClose: null
};
// Load icon via TYPO3 Icon-API and requireJS
Icons.getIcon('actions-close', Icons.sizes.small, null, null).then(function(markup) {
LeafBE['$iconClose']= markup;
});
LeafBE.init = function (element) {
// basic variable initialisation, uses data vars on the trigger button
LeafBE.$element = element;
LeafBE.$labelTitle = LeafBE.$element.attr('data-label-title');
LeafBE.$labelClose = LeafBE.$element.attr('data-label-close');
LeafBE.$labelImport = LeafBE.$element.attr('data-label-import');
LeafBE.$latitude = LeafBE.$element.attr('data-lat');
LeafBE.$longitude = LeafBE.$element.attr('data-lon');
LeafBE.$gLatitude = LeafBE.$element.attr('data-glat');
LeafBE.$gLongitude = LeafBE.$element.attr('data-glon');
LeafBE.$tilesUrl = LeafBE.$element.attr('data-tiles');
LeafBE.$tilesCopy = LeafBE.$element.attr('data-copy');
LeafBE.$geoCodeUrl = LeafBE.$element.attr('data-geocodeurl');
LeafBE.$geoCodeUrlShort = LeafBE.$element.attr('data-geocodeurlshort');
LeafBE.$fieldLat = LeafBE.$element.attr('data-namelat');
LeafBE.$fieldLon = LeafBE.$element.attr('data-namelon');
LeafBE.$fieldLatActive = LeafBE.$element.attr('data-namelat-active');
// add the container to display the map as a nice overlay
if (!$('#t3js-location-map-wrap').length) {
LeafBE.addMapMarkup();
}
};
LeafBE.addMapMarkup = function () {
$('body').append(
'<div id="t3js-location-map-wrap">' +
'<div class="t3js-location-map-title">' +
'<div class="btn-group"><a href="#" class="btn btn-icon btn-default" title="' + LeafBE.$labelClose + '" id="t3js-ttaddress-close-map">' +
LeafBE.$iconClose +
'</a>' +
'<a class="btn btn-default" href="#" title="Import marker position to form" id="t3js-ttaddress-import-position">' +
LeafBE.$labelImport +
'</a></div>' +
LeafBE.$labelTitle +
'</div>' +
'<div class="t3js-location-map-container" id="t3js-location-map-container">' +
'</div>' +
'</div>'
);
};
LeafBE.createMap = function () {
if (((!LeafBE.$latitude || !LeafBE.$longitude) || (LeafBE.$latitude == 0 && LeafBE.$longitude == 0)) && LeafBE.$geoCodeUrl != null) {
LeafBE.geocode();
}
// The ultimate fallback: if one of the coordinates is empty, fallback to Kopenhagen.
// Thank you Kaspar for TYPO3 and its great community! ;)
if (LeafBE.$latitude == null || LeafBE.$longitude == null) {
LeafBE.$latitude = LeafBE.$gLatitude;
LeafBE.$longitude = LeafBE.$gLongitude;
// set zoomlevel lower for faster navigation
LeafBE.$zoomLevel = 4;
}
LeafBE.$map = L.map('t3js-location-map-container', {
center: [LeafBE.$latitude, LeafBE.$longitude],
zoom: LeafBE.$zoomLevel
});
L.tileLayer(LeafBE.$tilesUrl, {
attribution: LeafBE.$tilesCopy
}).addTo(LeafBE.$map);
LeafBE.$marker = L.marker([LeafBE.$latitude, LeafBE.$longitude], {
draggable: true
}).addTo(LeafBE.$map);
let position = LeafBE.$marker.getLatLng();
LeafBE.$marker.on('dragend', function (event) {
LeafBE.$marker = event.target;
position = LeafBE.$marker.getLatLng();
});
LeafBE.$map.on('click', function (event) {
LeafBE.$marker.setLatLng(event.latlng);
});
// import coordinates and close overlay
$('#t3js-ttaddress-import-position').on('click', function () {
// set visual coordinates
$('input[data-formengine-input-name="' + LeafBE.$fieldLat + '"]').val(LeafBE.$marker.getLatLng().lat);
$('input[data-formengine-input-name="' + LeafBE.$fieldLon + '"]').val(LeafBE.$marker.getLatLng().lng);
// set hidden fields values
$('input[name="' + LeafBE.$fieldLat + '"]').val(LeafBE.$marker.getLatLng().lat);
$('input[name="' + LeafBE.$fieldLon + '"]').val(LeafBE.$marker.getLatLng().lng);
// enable also latitude, if not already done by user.
$('input[id="' + LeafBE.$fieldLatActive + '"]').parentsUntil('.form-group').removeClass('disabled');
$('input[id="' + LeafBE.$fieldLatActive + '"]').prop('checked', true);
// mark fields as changed for re-evaluation and revalidate the form,
// this is e.g. needed when this wizard is used on inline elements
FormEngine.Validation.markFieldAsChanged($('input[name="' + LeafBE.$fieldLat + '"]'));
FormEngine.Validation.markFieldAsChanged($('input[name="' + LeafBE.$fieldLon + '"]'));
FormEngine.Validation.validate();
// close map after import of coordinates.
$('#t3js-location-map-wrap').removeClass('active');
});
// close overlay without any further action
$('#t3js-ttaddress-close-map').on('click', function () {
$('#t3js-location-map-wrap').removeClass('active');
});
};
LeafBE.geocode = function () {
$.ajax({
type: 'GET',
url: LeafBE.$geoCodeUrl,
async: false,
dataType: 'json',
success: function (data) {
if (data.length == 0) {
$.ajax({
type: 'GET',
url: LeafBE.$geoCodeUrlShort,
async: false,
dataType: 'json',
success: function (data) {
if (data.length != 0) {
$.each(data[0], function (key, value) {
if (key == "lat") {
LeafBE.$latitude = value;
}
if (key == "lon") {
LeafBE.$longitude = value;
}
});
}
}
});
} else {
$.each(data[0], function (key, value) {
if (key == "lat") {
LeafBE.$latitude = value;
}
if (key == "lon") {
LeafBE.$longitude = value;
}
});
}
}
});
};
LeafBE.initializeEvents = function (element) {
$(element).on('click', function () {
if (LeafBE.$map !== null) {
LeafBE.$map.remove();
LeafBE.$map = null;
}
LeafBE.init($(this));
LeafBE.createMap();
$('#t3js-location-map-wrap').addClass('active');
});
};
// reinit when form has changes, e.g. inline relations loaded using ajax
LeafBE.reinitialize = FormEngine.reinitialize;
FormEngine.reinitialize = function () {
LeafBE.reinitialize();
if ($('.locationMapWizard').length) {
LeafBE.initializeEvents('.locationMapWizard');
}
};
//LeafBE.addMapMarkup();
LeafBE.initializeEvents('.locationMapWizard');
return LeafBE;
});

View File

@@ -0,0 +1,17 @@
import FormEngineValidation from '@typo3/backend/form-engine-validation.js';
export class TelephoneEvaluation {
static registerCustomEvaluation(name) {
FormEngineValidation.registerCustomEvaluation(name, TelephoneEvaluation.applyTelephoneValidationPattern);
}
static applyTelephoneValidationPattern(value) {
const items = TYPO3.settings.TtAddress.Evaluation.telephoneValidationPattern.split('/');
// fetch RegExp modifier and remove it
const modifier = items.pop();
// remove first item
items.shift();
const expression = new RegExp(items.join('/'), modifier);
return value.replace(expression, '');
}
}

File diff suppressed because one or more lines are too long