Skip to content

Commit

Permalink
Merge branch '4' into 5
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 7, 2024
2 parents ce3e12b + 36677ad commit a88066b
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 54 deletions.
20 changes: 20 additions & 0 deletions client/lang/de.js
Original file line number Diff line number Diff line change
@@ -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"
});
}
12 changes: 12 additions & 0 deletions client/lang/src/de.json
Original file line number Diff line number Diff line change
@@ -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"
}
30 changes: 15 additions & 15 deletions client/lang/src/nl.json
Original file line number Diff line number Diff line change
@@ -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"
}
30 changes: 15 additions & 15 deletions client/lang/src/pl.json
Original file line number Diff line number Diff line change
@@ -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"
}
30 changes: 15 additions & 15 deletions client/lang/src/pl_PL.json
Original file line number Diff line number Diff line change
@@ -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"
}
80 changes: 80 additions & 0 deletions lang/de.yml
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 0 additions & 2 deletions lang/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions src/Controllers/LinkFieldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 18 additions & 3 deletions tests/php/Controllers/LinkFieldControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
Expand All @@ -561,16 +568,24 @@ 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' => [
'idType' => 'existing',
'fail' => '',
'expectedCode' => 204,
],
'Reject fail canArchive()' => [
'idType' => 'existing',
'fail' => 'can-archive',
'expectedCode' => 403,
],
'Reject fail canDelete()' => [
'idType' => 'existing',
'fail' => 'can-delete',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a88066b

Please sign in to comment.