mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 11:05:46 +02:00
FIX: minor issues
This commit is contained in:
parent
cced355f31
commit
e9883d1d34
@ -62,6 +62,7 @@ class ObjectGraphQlEx extends Extension
|
|||||||
$curr = Controller::curr();
|
$curr = Controller::curr();
|
||||||
$req = $curr->getRequest();
|
$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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace A2nt\CMSNiceties\Widgets;
|
namespace A2nt\CMSNiceties\Widgets;
|
||||||
|
|
||||||
use gorriecoe\Link\Models\Link;
|
use gorriecoe\Link\Models\Link;
|
||||||
@ -31,12 +30,12 @@ class BannerWidget extends Widget
|
|||||||
|
|
||||||
private static $has_one = [
|
private static $has_one = [
|
||||||
'Image' => Image::class,
|
'Image' => Image::class,
|
||||||
'Link' => Link::class,
|
'Linked' => Link::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
private static $owns = [
|
private static $owns = [
|
||||||
'Image',
|
'Image',
|
||||||
'Link',
|
'Linked',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
@ -46,7 +45,7 @@ class BannerWidget extends Widget
|
|||||||
$fields->push(UploadField::create('Image', 'Image (minimal width 301px)')
|
$fields->push(UploadField::create('Image', 'Image (minimal width 301px)')
|
||||||
->setAllowedFileCategories(['image/supported']));
|
->setAllowedFileCategories(['image/supported']));
|
||||||
|
|
||||||
$fields->push(LinkField::create('Link', 'Link', $this));
|
$fields->push(LinkField::create('Linked', 'Link', $this));
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
@ -63,12 +62,12 @@ class BannerWidget extends Widget
|
|||||||
|
|
||||||
public function onBeforeWrite()
|
public function onBeforeWrite()
|
||||||
{
|
{
|
||||||
$title = $this->getField('Title');
|
$title = $this->getField('Title');
|
||||||
$img = $this->Image();
|
$img = $this->Image();
|
||||||
if(!$title && $img) {
|
if(!$title && $img) {
|
||||||
$this->setField('Title', $img->getTitle());
|
$this->setField('Title', $img->getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::onBeforeWrite();
|
parent::onBeforeWrite();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<img src="$Image.FocusFill(432,315).URL" alt="$Title" />
|
<img src="$Image.FocusFill(432,315).URL" alt="$Title" />
|
||||||
<% if $Link %>
|
<% if $Linked %>
|
||||||
<% with $Link %>
|
<% with $Linked %>
|
||||||
<a href="$URL"<% if $OpenInNewWindow %> target="_blank"<% end_if %> class="stretched-link">
|
<a href="$LinkURL"<% if $OpenInNewWindow %> target="_blank"<% end_if %> class="stretched-link">
|
||||||
<span class="visually-hidden">$Up.Title</span>
|
<span class="visually-hidden">$Title</span>
|
||||||
</a>
|
</a>
|
||||||
<% end_with %>
|
<% end_with %>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
Loading…
Reference in New Issue
Block a user