diff --git a/client/lang/de.js b/client/lang/de.js new file mode 100644 index 00000000..d0782dad --- /dev/null +++ b/client/lang/de.js @@ -0,0 +1,20 @@ +// This file was generated by silverstripe/tx-translator from client/lang/src/de.json. +// See https://github.com/silverstripe/silverstripe-tx-translator for details +if (typeof(ss) === 'undefined' || typeof(ss.i18n) === 'undefined') { + if (typeof(console) !== 'undefined') { // eslint-disable-line no-console + console.error('Class ss.i18n not defined'); // eslint-disable-line no-console + } +} else { + ss.i18n.addDictionary('de', { + "LinkField.ADD_LINK": "Link hinzufügen", + "LinkField.ARCHIVE": "archivieren", + "LinkField.CANNOT_CREATE_LINK": "Link kann nicht erstellt werden", + "LinkField.DELETE": "Löschen", + "LinkField.EDIT_LINK": "Link bearbeiten", + "LinkField.LINK_DRAFT_LABEL": "Entwurf", + "LinkField.LINK_DRAFT_TITLE": "Link hat unveröffentlichte Änderungen", + "LinkField.LINK_MODIFIED_LABEL": "Bearbeitet", + "LinkField.LINK_MODIFIED_TITLE": "Link hat unveröffentlichte Änderungen", + "LinkField.SAVE_SUCCESS": "Link gespeichert" +}); +} \ No newline at end of file diff --git a/client/lang/src/de.json b/client/lang/src/de.json new file mode 100644 index 00000000..fd55e6f1 --- /dev/null +++ b/client/lang/src/de.json @@ -0,0 +1,12 @@ +{ + "LinkField.ADD_LINK": "Link hinzufügen", + "LinkField.ARCHIVE": "archivieren", + "LinkField.CANNOT_CREATE_LINK": "Link kann nicht erstellt werden", + "LinkField.DELETE": "Löschen", + "LinkField.EDIT_LINK": "Link bearbeiten", + "LinkField.LINK_DRAFT_LABEL": "Entwurf", + "LinkField.LINK_DRAFT_TITLE": "Link hat unveröffentlichte Änderungen", + "LinkField.LINK_MODIFIED_LABEL": "Bearbeitet", + "LinkField.LINK_MODIFIED_TITLE": "Link hat unveröffentlichte Änderungen", + "LinkField.SAVE_SUCCESS": "Link gespeichert" +} \ No newline at end of file diff --git a/client/lang/src/nl.json b/client/lang/src/nl.json index cbcab58b..ce329bd7 100644 --- a/client/lang/src/nl.json +++ b/client/lang/src/nl.json @@ -1,23 +1,23 @@ { - "LinkField.SAVE_SUCCESS": "Opgeslagen link", + "LinkField.ADD_LINK": "Link toevoegen", + "LinkField.ARCHIVE": "Archiveer", "LinkField.ARCHIVE_CONFIRM": "Weet je zeker dat je deze link wil archiveren?", - "LinkField.DELETE_CONFIRM": "Weet je zeker dat je deze link wil verwijderen?", - "LinkField.ARCHIVE_SUCCESS": "Gearchiveerde link", - "LinkField.DELETE_SUCCESS": "Verwijderde link", "LinkField.ARCHIVE_ERROR": "Link archiveren mislukt", + "LinkField.ARCHIVE_SUCCESS": "Gearchiveerde link", + "LinkField.CANNOT_CREATE_LINK": "Kan geen link aanmaken", + "LinkField.DELETE": "Verwijder", + "LinkField.DELETE_CONFIRM": "Weet je zeker dat je deze link wil verwijderen?", "LinkField.DELETE_ERROR": "Link verwijderen mislukt", + "LinkField.DELETE_SUCCESS": "Verwijderde link", "LinkField.EDIT_LINK": "Bewerk link", - "LinkField.ADD_LINK": "Link toevoegen", - "LinkField.ARCHIVE": "Archiveer", - "LinkField.DELETE": "Verwijder", - "LinkField.LINK_DRAFT_TITLE": "Link heeft conceptwijzigingen", - "LinkField.LINK_DRAFT_LABEL": "Concept", - "LinkField.LINK_MODIFIED_TITLE": "Link heeft niet-gepubliceerde wijzigingen", - "LinkField.LINK_MODIFIED_LABEL": "Aangepast", - "LinkField.CANNOT_CREATE_LINK": "Kan geen link aanmaken", "LinkField.FAILED_TO_LOAD_LINKS": "Link(s) laden mislukt", "LinkField.FAILED_TO_SAVE_LINK": "Link opslaan mislukt", + "LinkField.LINK_DRAFT_LABEL": "Concept", + "LinkField.LINK_DRAFT_TITLE": "Link heeft conceptwijzigingen", + "LinkField.LINK_MODIFIED_LABEL": "Aangepast", + "LinkField.LINK_MODIFIED_TITLE": "Link heeft niet-gepubliceerde wijzigingen", "LinkField.SAVE_RECORD_FIRST": "Links kunnen worden toegevoegd na het opslaan", - "LinkField.SORT_SUCCESS": "Linkvolgorde opgeslagen", - "LinkField.SORT_ERROR": "Links sorteren mislukt" -} + "LinkField.SAVE_SUCCESS": "Opgeslagen link", + "LinkField.SORT_ERROR": "Links sorteren mislukt", + "LinkField.SORT_SUCCESS": "Linkvolgorde opgeslagen" +} \ No newline at end of file diff --git a/client/lang/src/pl.json b/client/lang/src/pl.json index 851c8b5b..bbe99aa2 100644 --- a/client/lang/src/pl.json +++ b/client/lang/src/pl.json @@ -1,23 +1,23 @@ { - "LinkField.SAVE_SUCCESS": "Zapisano", + "LinkField.ADD_LINK": "Dodaj", + "LinkField.ARCHIVE": "Archiwizuj", "LinkField.ARCHIVE_CONFIRM": "Czy na pewno chcesz zarchiwizować ten link?", - "LinkField.DELETE_CONFIRM": "Czy na pewno chcesz usunąć ten link?", - "LinkField.ARCHIVE_SUCCESS": "Zarchiwizowany link", - "LinkField.DELETE_SUCCESS": "Skasowano link", "LinkField.ARCHIVE_ERROR": "Nie udało się połączyć z archiwum", + "LinkField.ARCHIVE_SUCCESS": "Zarchiwizowany link", + "LinkField.CANNOT_CREATE_LINK": "Nie można utworzyć linku", + "LinkField.DELETE": "Usuń", + "LinkField.DELETE_CONFIRM": "Czy na pewno chcesz usunąć ten link?", "LinkField.DELETE_ERROR": "Nie udało się usunąć linku", + "LinkField.DELETE_SUCCESS": "Skasowano link", "LinkField.EDIT_LINK": "Zmień", - "LinkField.ADD_LINK": "Dodaj", - "LinkField.ARCHIVE": "Archiwizuj", - "LinkField.DELETE": "Usuń", - "LinkField.LINK_DRAFT_TITLE": "Link ma zmiany w szkicu", - "LinkField.LINK_DRAFT_LABEL": "Szkic", - "LinkField.LINK_MODIFIED_TITLE": "Link ma niepublikowane zmiany", - "LinkField.LINK_MODIFIED_LABEL": "Zmodyfikowane", - "LinkField.CANNOT_CREATE_LINK": "Nie można utworzyć linku", "LinkField.FAILED_TO_LOAD_LINKS": "Nie udało się załadować link(ów)", "LinkField.FAILED_TO_SAVE_LINK": "Nie udało się zapisać linku", + "LinkField.LINK_DRAFT_LABEL": "Szkic", + "LinkField.LINK_DRAFT_TITLE": "Link ma zmiany w szkicu", + "LinkField.LINK_MODIFIED_LABEL": "Zmodyfikowane", + "LinkField.LINK_MODIFIED_TITLE": "Link ma niepublikowane zmiany", "LinkField.SAVE_RECORD_FIRST": "Nie można dodawać linków, dopóki rekord nie zostanie zapisany", - "LinkField.SORT_SUCCESS": "Zaktualizowana kolejność sortowania linków", - "LinkField.SORT_ERROR": "Nie można sortować linków" -} + "LinkField.SAVE_SUCCESS": "Zapisano", + "LinkField.SORT_ERROR": "Nie można sortować linków", + "LinkField.SORT_SUCCESS": "Zaktualizowana kolejność sortowania linków" +} \ No newline at end of file diff --git a/client/lang/src/pl_PL.json b/client/lang/src/pl_PL.json index 851c8b5b..bbe99aa2 100644 --- a/client/lang/src/pl_PL.json +++ b/client/lang/src/pl_PL.json @@ -1,23 +1,23 @@ { - "LinkField.SAVE_SUCCESS": "Zapisano", + "LinkField.ADD_LINK": "Dodaj", + "LinkField.ARCHIVE": "Archiwizuj", "LinkField.ARCHIVE_CONFIRM": "Czy na pewno chcesz zarchiwizować ten link?", - "LinkField.DELETE_CONFIRM": "Czy na pewno chcesz usunąć ten link?", - "LinkField.ARCHIVE_SUCCESS": "Zarchiwizowany link", - "LinkField.DELETE_SUCCESS": "Skasowano link", "LinkField.ARCHIVE_ERROR": "Nie udało się połączyć z archiwum", + "LinkField.ARCHIVE_SUCCESS": "Zarchiwizowany link", + "LinkField.CANNOT_CREATE_LINK": "Nie można utworzyć linku", + "LinkField.DELETE": "Usuń", + "LinkField.DELETE_CONFIRM": "Czy na pewno chcesz usunąć ten link?", "LinkField.DELETE_ERROR": "Nie udało się usunąć linku", + "LinkField.DELETE_SUCCESS": "Skasowano link", "LinkField.EDIT_LINK": "Zmień", - "LinkField.ADD_LINK": "Dodaj", - "LinkField.ARCHIVE": "Archiwizuj", - "LinkField.DELETE": "Usuń", - "LinkField.LINK_DRAFT_TITLE": "Link ma zmiany w szkicu", - "LinkField.LINK_DRAFT_LABEL": "Szkic", - "LinkField.LINK_MODIFIED_TITLE": "Link ma niepublikowane zmiany", - "LinkField.LINK_MODIFIED_LABEL": "Zmodyfikowane", - "LinkField.CANNOT_CREATE_LINK": "Nie można utworzyć linku", "LinkField.FAILED_TO_LOAD_LINKS": "Nie udało się załadować link(ów)", "LinkField.FAILED_TO_SAVE_LINK": "Nie udało się zapisać linku", + "LinkField.LINK_DRAFT_LABEL": "Szkic", + "LinkField.LINK_DRAFT_TITLE": "Link ma zmiany w szkicu", + "LinkField.LINK_MODIFIED_LABEL": "Zmodyfikowane", + "LinkField.LINK_MODIFIED_TITLE": "Link ma niepublikowane zmiany", "LinkField.SAVE_RECORD_FIRST": "Nie można dodawać linków, dopóki rekord nie zostanie zapisany", - "LinkField.SORT_SUCCESS": "Zaktualizowana kolejność sortowania linków", - "LinkField.SORT_ERROR": "Nie można sortować linków" -} + "LinkField.SAVE_SUCCESS": "Zapisano", + "LinkField.SORT_ERROR": "Nie można sortować linków", + "LinkField.SORT_SUCCESS": "Zaktualizowana kolejność sortowania linków" +} \ No newline at end of file diff --git a/lang/de.yml b/lang/de.yml new file mode 100644 index 00000000..4c2308c3 --- /dev/null +++ b/lang/de.yml @@ -0,0 +1,80 @@ +de: + SilverStripe\LinkField\Controllers\LinkFieldController: + CREATE_LINK: 'Link erstellen' + MENUTITLE: Link-Felder + UPDATE_LINK: 'Link aktualisieren' + SilverStripe\LinkField\Form\AbstractLinkField: + INVALID_TYPECLASS_EMPTY: '"{class}": Erlaubte Typen dürfen nicht leer sein' + SilverStripe\LinkField\Form\Traits\AllowedLinkClassesTrait: + INVALID_TYPECLASS: '"{class}": {typeclass} ist kein gültiger Link-Typ' + INVALID_TYPECLASS_EMPTY: '"{class}": Erlaubte Typen dürfen nicht leer sein' + SilverStripe\LinkField\Models\EmailLink: + EMAIL_FIELD: E-Mail-Adresse + LINKLABEL: 'Link zur E-Mail-Adresse' + PLURALNAME: E-Mail-Links + PLURALS: + one: 'Ein E-Mail-Link' + other: '{count} E-Mail-Links' + SINGULARNAME: E-Mail-Link + db_Email: E-Mail + SilverStripe\LinkField\Models\ExternalLink: + EXTERNAL_URL_FIELD: 'Externe URL' + EXTERNAL_URL_FIELD_DESCRIPTION: 'Die URL muss entweder mit http:// oder https:// beginnen' + LINKLABEL: 'Link externe URL' + PLURALNAME: 'Externe Links' + PLURALS: + one: 'Externer Link' + other: '{count} externe Links' + SINGULARNAME: 'Externer Link' + db_ExternalUrl: 'Externe URL' + SilverStripe\LinkField\Models\FileLink: + CANNOT_VIEW_FILE: 'Datei kann nicht angezeigt werden' + FILE_DOES_NOT_EXIST: 'Datei existiert nicht' + FILE_FIELD: Datei + LINKLABEL: 'Link zu einer Datei' + MISSING_DEFAULT_TITLE: '(Datei fehlt)' + PLURALS: + one: Datei-Link + other: '{count} Datei-Links' + SINGULARNAME: Datei-Link + has_one_File: Datei + SilverStripe\LinkField\Models\Link: + LINK_TEXT_TEXT_DESCRIPTION: 'Wenn leer gelassen, wird ein Standardwert im Frontend verwendet' + LINK_TEXT_TITLE: Linktext + OPEN_IN_NEW_TITLE: 'In neuem Fenster öffnen?' + PLURALS: + one: Telefon-Link + other: '{count} Telefon-Links' + db_LinkText: Linktext + db_OpenInNew: 'In neuem Fenster öffnen' + SilverStripe\LinkField\Models\MultiLinkField: + AddLink: 'Link hinzufügen' + EditLink: 'Link bearbeiten' + SilverStripe\LinkField\Models\PhoneLink: + LINKLABEL: Telefonnummer + PHONE_FIELD: Telefon + PLURALNAME: Telefon-Links + PLURALS: + one: Telefon-Link + other: '{count} Telefon-Links' + SINGULARNAME: Telefon-Link + db_Phone: Telefon + SilverStripe\LinkField\Models\SiteTreeLink: + ANCHOR_DESCRIPTION: 'Kein "#" voranstellen. Anker-Vorschläge werden angezeigt, sobald eine Seite gewählt ist.' + CANNOT_VIEW_PAGE: 'Seite kann nicht angezeigt werden' + LINKLABEL: 'Seite auf dieser Website' + MISSING_DEFAULT_TITLE: '(Seite fehlt)' + PAGE_DOES_NOT_EXIST: 'Seite existiert nicht' + PAGE_FIELD_TITLE: Seite + PLURALNAME: Site-Tree-Links + PLURALS: + one: 'Ein Site-Tree-Link' + other: '{count} Site-Tree-Links' + QUERY_STRING_DESCRIPTION: 'Kein "?" voranstellen. Z.B.: "option1=wert&option2=wert2' + SINGULARNAME: Site-Tree-Link + TITLE_DESCRIPTION: 'Automatisch generiert aus dem Seitentitel, wenn leer' + db_Anchor: Anker + db_QueryString: Abfragezeichenfolge + has_one_Page: Seite + SilverStripe\LinkField\Tasks\LinkableMigrationTask: + VERSIONED_STATUS_MISMATCH: 'Linkable und LinkField haben keine übereinstimmenden Versionierung. Stellen Sie sicher, dass beide entweder nicht versioniert oder versioniert sind' diff --git a/lang/nl.yml b/lang/nl.yml index 374e85b1..d37a0336 100644 --- a/lang/nl.yml +++ b/lang/nl.yml @@ -45,11 +45,9 @@ nl: LINK_TYPE_TITLE: Linktype MISSING_DEFAULT_TITLE: '(geen waarde opgegeven)' OPEN_IN_NEW_TITLE: 'Openen in nieuw venster?' - PLURALNAME: Links PLURALS: one: 'Een link' other: '{count} links' - SINGULARNAME: Link db_LinkText: 'Tekst van link' db_OpenInNew: 'Openen in nieuw' db_Sort: Sorteer diff --git a/src/Controllers/LinkFieldController.php b/src/Controllers/LinkFieldController.php index f540803e..2e5bb2bc 100644 --- a/src/Controllers/LinkFieldController.php +++ b/src/Controllers/LinkFieldController.php @@ -127,17 +127,20 @@ private function getLinkData(Link $link): array */ public function linkDelete(): HTTPResponse { - $link = $this->linkFromRequest(); - if (!$link->canDelete()) { - $this->jsonError(403); - } // Check security token on destructive operation if (!SecurityToken::inst()->checkRequest($this->getRequest())) { $this->jsonError(400); } + $link = $this->linkFromRequest(); if ($link->hasExtension(Versioned::class)) { + if (!$link->canArchive()) { + $this->jsonError(403); + } $link->doArchive(); } else { + if (!$link->canDelete()) { + $this->jsonError(403); + } $link->delete(); } // Send response diff --git a/tests/php/Controllers/LinkFieldControllerTest.php b/tests/php/Controllers/LinkFieldControllerTest.php index 57055d42..c806bfb8 100644 --- a/tests/php/Controllers/LinkFieldControllerTest.php +++ b/tests/php/Controllers/LinkFieldControllerTest.php @@ -11,6 +11,7 @@ use SilverStripe\LinkField\Controllers\LinkFieldController; use SilverStripe\LinkField\Tests\Models\LinkTest\LinkOwner; use SilverStripe\Versioned\Versioned; +use SilverStripe\LinkField\Models\Link; class LinkFieldControllerTest extends FunctionalTest { @@ -529,14 +530,20 @@ public function provideLinkData(): array } /** - * @dataProvider provideLinkDelete + * @dataProvider provideLinkArchive */ - public function testLinkDelete( + public function testLinkArchive( string $idType, string $fail, int $expectedCode ): void { TestPhoneLink::$fail = $fail; + if ($fail == 'can-delete') { + // Remove the Versioned extension because there's logic in LinkFieldController + // to use either canArchive() or canDelete() based on the presence of the Versioned extension + // Note that you must remove the extension on the base class rather than a TestOnly subclass + Link::remove_extension(Versioned::class); + } $owner = $this->getFixtureLinkOwner(); $ownerID = $owner->ID; $ownerClass = urlencode($owner->ClassName); @@ -561,9 +568,12 @@ public function testLinkDelete( } else { $this->assertNull(TestPhoneLink::get()->byID($fixtureID)); } + if ($fail == 'can-delete') { + Link::add_extension(Versioned::class); + } } - public function provideLinkDelete(): array + public function provideLinkArchive(): array { return [ 'Valid' => [ @@ -571,6 +581,11 @@ public function provideLinkDelete(): array 'fail' => '', 'expectedCode' => 204, ], + 'Reject fail canArchive()' => [ + 'idType' => 'existing', + 'fail' => 'can-archive', + 'expectedCode' => 403, + ], 'Reject fail canDelete()' => [ 'idType' => 'existing', 'fail' => 'can-delete', diff --git a/tests/php/Controllers/LinkFieldControllerTest/TestPhoneLink.php b/tests/php/Controllers/LinkFieldControllerTest/TestPhoneLink.php index c740e1e1..b1f39bfa 100644 --- a/tests/php/Controllers/LinkFieldControllerTest/TestPhoneLink.php +++ b/tests/php/Controllers/LinkFieldControllerTest/TestPhoneLink.php @@ -43,6 +43,11 @@ public function canDelete($member = null) return TestPhoneLink::$fail !== 'can-delete'; } + public function canArchive($member = null) + { + return TestPhoneLink::$fail !== 'can-archive'; + } + public function validate(): ValidationResult { $validationResult = parent::validate();