Merge branch '1' into 2

This commit is contained in:
github-actions 2024-03-02 14:24:38 +00:00
commit 938bfe6a72
8 changed files with 153 additions and 6 deletions

View File

@ -43,3 +43,20 @@ SilverStripe\FrameworkTest\Elemental\Model\ElementalBehatTestObject:
BasicElementalPage:
extensions:
- DNADesign\Elemental\Extensions\ElementalPageExtension
---
Only:
moduleexists: 'silverstripe/linkfield'
---
SilverStripe\FrameworkTest\LinkField\PageTypes\LinkFieldTestPage:
extensions:
- SilverStripe\FrameworkTest\LinkField\Extensions\LinkPageExtension
SilverStripe\FrameworkTest\Model\Company:
extensions:
- SilverStripe\FrameworkTest\LinkField\Extensions\CompanyExtension
SilverStripe\FrameworkTest\LinkField\Blocks\LinkFieldTestBlock:
extensions:
- SilverStripe\FrameworkTest\LinkField\Extensions\ElementContentExtension

View File

@ -0,0 +1,16 @@
<?php
namespace SilverStripe\FrameworkTest\LinkField\Blocks;
use DNADesign\Elemental\Models\BaseElement;
class LinkFieldTestBlock extends BaseElement
{
private static string $table_name = 'LinkFieldTestBlock';
private static string $icon = 'font-icon-block-file-list';
private static string $singular_name = 'Links List Block';
private static string $plural_name = 'Links List Blocks';
}

View File

@ -0,0 +1,50 @@
<?php
namespace SilverStripe\FrameworkTest\LinkField\Extensions;
use SilverStripe\Core\Extension;
use SilverStripe\Forms\FieldList;
use SilverStripe\LinkField\Models\Link;
use SilverStripe\LinkField\Form\LinkField;
use SilverStripe\LinkField\Form\MultiLinkField;
use SilverStripe\LinkField\Models\ExternalLink;
class CompanyExtension extends Extension
{
private static array $has_one = [
'CompanyWebSiteLink' => Link::class,
];
private static $has_many = [
'ManyCompanyWebSiteLink' => Link::class . '.Owner',
];
private static array $owns = [
'CompanyWebSiteLink',
'ManyCompanyWebSiteLink',
];
private static array $cascade_deletes = [
'CompanyWebSiteLink',
'ManyCompanyWebSiteLink',
];
private static array $cascade_duplicates = [
'CompanyWebSiteLink',
'ManyCompanyWebSiteLink',
];
public function updateCMSFields(FieldList $fields)
{
$fields->removeByName(['CompanyWebSiteLinkID', 'ManyCompanyWebSiteLinkID']);
$fields->addFieldsToTab(
'Root.Main',
[
LinkField::create('CompanyWebSiteLink', 'Company Website link')
->setAllowedTypes([ExternalLink::class]),
MultiLinkField::create('ManyCompanyWebSiteLink', 'Multiple Company Website link'),
]
);
}
}

View File

@ -12,7 +12,6 @@ use SilverStripe\LinkField\Models\SiteTreeLink;
class ElementContentExtension extends Extension
{
private static bool $inline_editable = true;
private static array $has_one = [
@ -44,13 +43,13 @@ class ElementContentExtension extends Extension
$fields->addFieldsToTab(
'Root.Main',
[
LinkField::create('OneLink')
LinkField::create('OneLink', 'Single Link')
->setAllowedTypes([
SiteTreeLink::class,
EmailLink::class,
PhoneLink::class
]),
MultiLinkField::create('ManyLinks'),
MultiLinkField::create('ManyLinks', 'Multiple Links'),
],
);
}

View File

@ -38,18 +38,18 @@ class LinkPageExtension extends Extension
public function updateCMSFields(FieldList $fields)
{
$fields->removeByName(['Content', 'HasOneLinkID', 'HasManyLinks']);
$fields->removeByName(['Content', 'HasOneLinkID', 'HasManyLinksID']);
$fields->addFieldsToTab(
'Root.Main',
[
LinkField::create('HasOneLink')
LinkField::create('HasOneLink', 'Single Link')
->setAllowedTypes([
SiteTreeLink::class,
EmailLink::class,
PhoneLink::class
]),
MultiLinkField::create('HasManyLinks'),
MultiLinkField::create('HasManyLinks', 'Multiple Links'),
],
);
}

View File

@ -0,0 +1,10 @@
<?php
namespace SilverStripe\FrameworkTest\LinkField\PageTypes;
use Page;
class LinkFieldTestPage extends Page
{
private static string $table_name = 'LinkFieldTestPage';
}

View File

@ -0,0 +1,21 @@
<% if $OneLink %>
<div class="mt-1">
<h4>Single Link</h4>
<% with $OneLink %>
<% if $exists %>
<a href="$URL" <% if $OpenInNew %>target="_blank" rel="noopener noreferrer"<% end_if %>>$Title</a>
<% end_if %>
<% end_with %>
</div>
<% end_if %>
<% if $ManyLinks %>
<div class="mt-1">
<h4>Multiple Link</h4>
<ul>
<% loop $ManyLinks %>
<li>$Me</li>
<% end_loop %>
</ul>
</div>
<% end_if %>

View File

@ -0,0 +1,34 @@
<div class="content search-results">
<div class="container">
<div class="row">
<section class="col-lg-8 offset-lg-2">
<div class="search-results__heading">
<h1>$Title.XML</h1>
<% if $HasOneLink %>
<div class="mt-1">
<h4>Single Link</h4>
<% with $HasOneLink %>
<% if $exists %>
<a href="$URL" <% if $OpenInNew %>target="_blank" rel="noopener noreferrer"<% end_if %>>$Title</a>
<% end_if %>
<% end_with %>
</div>
<% end_if %>
<% if $HasManyLinks %>
<div class="mt-1">
<h4>Multiple Link</h4>
<ul>
<% loop $HasManyLinks %>
<li>$Me</li>
<% end_loop %>
</ul>
</div>
<% end_if %>
</div>
</section>
</div>
</div>
</div>