FIX: minor issues

This commit is contained in:
Tony Air 2023-10-31 02:06:10 +02:00
parent cced355f31
commit e9883d1d34
3 changed files with 15 additions and 15 deletions

View File

@ -62,6 +62,7 @@ class ObjectGraphQlEx extends Extension
$curr = Controller::curr();
$req = $curr->getRequest();
return $req->requestVar('SecurityID') || $req->httpMethod() === 'POST';
// TODO: GraphQL form response /element/*id*/action
return $req->requestVar('SecurityID') || $req->httpMethod() === 'POST' || preg_match('!element/([0-9]+)/([A-z]+)!', $req->getURL());
}
}

View File

@ -1,6 +1,5 @@
<?php
namespace A2nt\CMSNiceties\Widgets;
use gorriecoe\Link\Models\Link;
@ -31,12 +30,12 @@ class BannerWidget extends Widget
private static $has_one = [
'Image' => Image::class,
'Link' => Link::class,
'Linked' => Link::class,
];
private static $owns = [
'Image',
'Link',
'Linked',
];
public function getCMSFields()
@ -46,7 +45,7 @@ class BannerWidget extends Widget
$fields->push(UploadField::create('Image', 'Image (minimal width 301px)')
->setAllowedFileCategories(['image/supported']));
$fields->push(LinkField::create('Link', 'Link', $this));
$fields->push(LinkField::create('Linked', 'Link', $this));
return $fields;
}
@ -63,12 +62,12 @@ class BannerWidget extends Widget
public function onBeforeWrite()
{
$title = $this->getField('Title');
$img = $this->Image();
if(!$title && $img) {
$this->setField('Title', $img->getTitle());
}
$title = $this->getField('Title');
$img = $this->Image();
if(!$title && $img) {
$this->setField('Title', $img->getTitle());
}
parent::onBeforeWrite();
parent::onBeforeWrite();
}
}

View File

@ -1,8 +1,8 @@
<img src="$Image.FocusFill(432,315).URL" alt="$Title" />
<% if $Link %>
<% with $Link %>
<a href="$URL"<% if $OpenInNewWindow %> target="_blank"<% end_if %> class="stretched-link">
<span class="visually-hidden">$Up.Title</span>
<% if $Linked %>
<% with $Linked %>
<a href="$LinkURL"<% if $OpenInNewWindow %> target="_blank"<% end_if %> class="stretched-link">
<span class="visually-hidden">$Title</span>
</a>
<% end_with %>
<% end_if %>