Skip to content

Commit

Permalink
Add URL to tourist attraction (#87)
Browse files Browse the repository at this point in the history
The tourist attraction can have an URL to their own website.
This URL is now imported and provided to templates.

Relates: #10193
  • Loading branch information
DanielSiepmann committed Nov 29, 2022
1 parent 35398b4 commit 20dc696
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 24 deletions.
1 change: 1 addition & 0 deletions Classes/Domain/Import/Typo3Converter/GeneralConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ private function buildDataArrayFromEntity(
'opening_hours' => $entity instanceof Place ? $this->getOpeningHours($entity->getOpeningHoursSpecification()) : '',
'special_opening_hours' => $entity instanceof Place ? $this->getOpeningHours($entity->getSpecialOpeningHoursSpecification()) : '',
'address' => $entity instanceof Place ? $this->getAddress($entity) : '',
'url' => $entity->getUrls()[0] ?? '',
'offers' => $entity instanceof Place ? $this->getOffers($entity) : '',
'other_service' => method_exists($entity, 'getOtherServices') ? implode(',', $entity->getOtherServices()) : '',
'traffic_infrastructure' => method_exists($entity, 'getTrafficInfrastructures') ? implode(',', $entity->getTrafficInfrastructures()) : '',
Expand Down
10 changes: 10 additions & 0 deletions Classes/Domain/Model/Frontend/Place.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ abstract class Place extends Base
*/
protected $address = null;

/**
* @var string
*/
protected $url = '';

/**
* @var OpeningHours|null
*/
Expand Down Expand Up @@ -88,6 +93,11 @@ public function getAddress(): ?Address
return $this->address;
}

public function getUrl(): string
{
return $this->url;
}

public function getOpeningHours(): ?OpeningHours
{
return $this->openingHours;
Expand Down
10 changes: 9 additions & 1 deletion Configuration/TCA/tx_thuecat_tourist_attraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@
'readOnly' => true,
],
],
'url' => [
'label' => $languagePath . '.url',
'l10n_mode' => 'exclude',
'config' => [
'type' => 'input',
'readOnly' => true,
],
],
'media' => [
'label' => $languagePath . '.media',
'l10n_mode' => 'exclude',
Expand Down Expand Up @@ -311,7 +319,7 @@
],
'types' => [
'0' => [
'showitem' => '--palette--;;language, title, description, slogan, start_of_construction, sanitation, other_service, museum_service, architectural_style, traffic_infrastructure, payment_accepted, digital_offer, photography, pets_allowed, is_accessible_for_free, public_access, available_languages, distance_to_public_transport, opening_hours, special_opening_hours, offers, accessibility_specification, address, media, remote_id, --div--;' . $languagePath . '.tab.relations, town, managed_by, parking_facility_near_by',
'showitem' => '--palette--;;language, title, description, slogan, start_of_construction, sanitation, other_service, museum_service, architectural_style, traffic_infrastructure, payment_accepted, digital_offer, photography, pets_allowed, is_accessible_for_free, public_access, available_languages, distance_to_public_transport, opening_hours, special_opening_hours, offers, accessibility_specification, address, url, media, remote_id, --div--;' . $languagePath . '.tab.relations, town, managed_by, parking_facility_near_by',
],
],
];
Expand Down
2 changes: 2 additions & 0 deletions Documentation/Changelog/1.3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Features

* Allow to check if an opening hour is valid for a single day.

* The URL of attractions is now imported and provided to the template.

Fixes
-----

Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang_tca.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
<trans-unit id="tx_thuecat_tourist_attraction.address" xml:space="preserve">
<source>Address</source>
</trans-unit>
<trans-unit id="tx_thuecat_tourist_attraction.url" xml:space="preserve">
<source>Url</source>
</trans-unit>
<trans-unit id="tx_thuecat_tourist_attraction.media" xml:space="preserve">
<source>Media</source>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<f:if condition="{address.fax}">
{address.fax}
</f:if>
<f:if condition="{url}">
<a href="{url}" referrerpolicy="no-referrer" rel="noreferrer noopener">{url}</a>
</f:if>
</p>
</div>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>{entity.title} ({entity.town.title})</h1>
<f:if condition="{entity.address}">
<img src="{f:uri.resource(path:'Icons/icon-info.svg', extensionName:'Thuecat')}" width="30" class="svg-icon" alt="Address">
<h2>{f:translate(id: 'content.address', extensionName: 'Thuecat')}</h2>
{f:render(partial: 'Address', arguments: {address: entity.address})}
{f:render(partial: 'Address', arguments: {address: entity.address, url: entity.url})}
</f:if>
<f:if condition="{entity.distanceToPublicTransport}">
<div class="distance-transport mt-5">
Expand All @@ -48,7 +48,7 @@ <h2>{f:translate(id: 'content.parkingFacilitiesNearBy', extensionName: 'Thuecat'
<f:if condition="{entity.address}">
<img src="{f:uri.resource(path:'Icons/icon-info.svg', extensionName:'Thuecat')}" width="30" class="svg-icon" alt="Address">
<h2>{f:translate(id: 'content.address', extensionName: 'Thuecat')}</h2>
{f:render(partial: 'Address', arguments: {address: entity.address})}
{f:render(partial: 'Address', arguments: {address: entity.address, url: entity.url})}
</f:if>
</div>
<div class="col-md-4">
Expand Down
1 change: 1 addition & 0 deletions Tests/Functional/Fixtures/Frontend/TouristAttractions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<media>[{"mainImage":true,"type":"image","title":"Erfurt-Dom und Severikirche-beleuchtet.jpg","description":"","url":"https:\/\/cms.thuecat.org\/o\/adaptive-media\/image\/5159216\/Preview-1280x0\/image","copyrightYear":2016,"author":"Image Author","license":{"type":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/","author":""}},{"mainImage":false,"type":"image","title":"Erfurt-Dom-und-Severikirche.jpg","description":"Sicht auf Dom St. Marien, St. Severikirche sowie die davor liegenden Klostergeb\u00e4ude und einem Ausschnitt des Biergartens umgeben von einem d\u00e4mmerungsverf\u00e4rten Himmel","url":"https:\/\/cms.thuecat.org\/o\/adaptive-media\/image\/5159186\/Preview-1280x0\/image","copyrightYear":2020,"license":{"type":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/","author":""}},{"mainImage":false,"type":"image","title":"Erfurt-Dom und Severikirche-beleuchtet.jpg","description":"","url":"https:\/\/cms.thuecat.org\/o\/adaptive-media\/image\/5159216\/Preview-1280x0\/image","copyrightYear":2016,"license":{"type":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/","author":""}}]</media>
<opening_hours>[{"opens":"09:30:00","closes":"18:00:00","from":{"date":"2021-05-01 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"through":{"date":"2021-10-31 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"daysOfWeek":["Saturday","Friday","Thursday","Tuesday","Monday","Wednesday"]},{"opens":"13:00:00","closes":"18:00:00","from":{"date":"2021-05-01 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"through":{"date":"2021-10-31 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"daysOfWeek":["Sunday"]},{"opens":"09:30:00","closes":"17:00:00","from":{"date":"2021-11-01 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"through":{"date":"2022-04-30 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"daysOfWeek":["Saturday","Friday","Thursday","Tuesday","Monday","Wednesday"]},{"opens":"13:00:00","closes":"17:00:00","from":{"date":"2021-11-01 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"through":{"date":"2022-04-30 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"daysOfWeek":["Sunday","PublicHolidays"]}]</opening_hours>
<address>{"street":"Beispielstraße 1a","zip":"99084","city":"Beispielstadt","email":"example@example.com","phone":"(0)30 23125 000","fax":"","geo":{"latitude":50.975955358589545,"longitude":11.023667024961856}}</address>
<url>https://example.com/attraction</url>
<offers>[{"type":"GuidedTourOffer","title":"F\u00fchrungen","description":"Immer samstags, um 11:15 Uhr findet eine \u00f6ffentliche F\u00fchrung durch das Museum statt. Dauer etwa 90 Minuten","prices":[{"title":"Erwachsene","description":"","price":8,"currency":"EUR","rule":"PerPerson"},{"title":"Erm\u00e4\u00dfigt","description":"als erm\u00e4\u00dfigt gelten schulpflichtige Kinder, Auszubildende, Studierende, Rentner\/-innen, Menschen mit Behinderungen, Inhaber Sozialausweis der Landeshauptstadt Erfurt","price":5,"currency":"EUR","rule":"PerPerson"}]},{"type":"EntryOffer","title":"Eintritt","description":"Schulklassen und Kitagruppen im Rahmen des Unterrichts: Eintritt frei\nAn jedem ersten Dienstag im Monat: Eintritt frei","prices":[{"title":"Erm\u00e4\u00dfigt","description":"als erm\u00e4\u00dfigt gelten schulpflichtige Kinder, Auszubildende, Studierende, Rentner\/-innen, Menschen mit Behinderungen, Inhaber Sozialausweis der Landeshauptstadt Erfurt","price":5,"currency":"EUR","rule":"PerPerson"},{"title":"Familienkarte","description":"","price":17,"currency":"EUR","rule":"PerGroup"},{"title":"ErfurtCard","description":"","price":14.9,"currency":"EUR","rule":"PerPackage"},{"title":"Erwachsene","description":"","price":8,"currency":"EUR","rule":"PerPerson"}]}]</offers>
<slogan>Highlight</slogan>
<start_of_construction>11. Jh</start_of_construction>
Expand Down

0 comments on commit 20dc696

Please sign in to comment.