mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 11:05:46 +02:00
commit
bd35c4f8e1
@ -58,8 +58,6 @@ SilverStripe\Core\Injector\Injector:
|
||||
properties:
|
||||
Authenticators:
|
||||
default: '%$A2nt\CMSNiceties\Forms\Authenticator'
|
||||
SilverStripe\Control\Email\Email:
|
||||
class: A2nt\CMSNiceties\MailerFix
|
||||
|
||||
SilverStripe\UserForms\Form\UserForm:
|
||||
extensions:
|
||||
|
@ -1,19 +1,6 @@
|
||||
---
|
||||
Name: a2nt-cms-niceties-templates-requirements
|
||||
---
|
||||
A2nt\CMSNiceties\Templates\DeferredRequirements:
|
||||
nofontawesome: false
|
||||
version: false
|
||||
static_domain: false
|
||||
deferred: true
|
||||
noreact: false
|
||||
nojquery: true
|
||||
jquery_version: '3.4.1'
|
||||
fontawesome_svg: true
|
||||
|
||||
SilverStripe\FontAwesome\FontAwesomeField:
|
||||
version: '5.12.0'
|
||||
|
||||
SilverStripe\View\Requirements:
|
||||
disable_flush_combined: true
|
||||
SilverStripe\View\Requirements_Backend:
|
||||
|
@ -3,6 +3,20 @@ Name: a2nt-cms-niceties-templates-themes
|
||||
After:
|
||||
- a2nt-cms-niceties-options-elements
|
||||
---
|
||||
|
||||
A2nt\CMSNiceties\Templates\DeferredRequirements:
|
||||
nofontawesome: false
|
||||
version: false
|
||||
static_domain: false
|
||||
deferred: true
|
||||
noreact: false
|
||||
nojquery: true
|
||||
jquery_version: '3.4.1'
|
||||
fontawesome_svg: false
|
||||
|
||||
SilverStripe\FontAwesome\FontAwesomeField:
|
||||
version: '6.5.1'
|
||||
|
||||
SilverStripe\View\SSViewer:
|
||||
source_file_comments: false
|
||||
themes:
|
||||
|
@ -13,11 +13,10 @@
|
||||
}],
|
||||
"minimum-stability": "dev",
|
||||
"require": {
|
||||
"silverstripe/cms": "^4",
|
||||
"silverstripe/cms": "^5",
|
||||
"a2nt/silverstripe-elemental-basics": "*",
|
||||
"silverstripe/widgets": "*",
|
||||
"gorriecoe/silverstripe-linkfield": "*",
|
||||
"symfony/mailer": "^6"
|
||||
"gorriecoe/silverstripe-linkfield": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -75,8 +75,11 @@ class AjaxControllerEx extends Extension
|
||||
{
|
||||
$ctrl = Security::singleton();
|
||||
|
||||
$auth = $ctrl->getApplicableAuthenticators()['default'];
|
||||
$loginHandler = $auth->getLoginHandler('login');
|
||||
|
||||
/* @var Form $form */
|
||||
$form = $ctrl->getLoginForms()['default'][0];
|
||||
$form = $loginHandler->LoginForm();
|
||||
self::_processFields($form);
|
||||
|
||||
//$form->addExtraClass('ajax-form');
|
||||
|
@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace A2nt\CMSNiceties\Extensions;
|
||||
|
||||
use Sheadawson\Linkable\Forms\EmbeddedObjectField;
|
||||
use SilverStripe\Forms\CheckboxField;
|
||||
use SilverStripe\Forms\CompositeField;
|
||||
use SilverStripe\Forms\LiteralField;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
|
||||
class EmbedObjectField extends EmbeddedObjectField
|
||||
{
|
||||
/**
|
||||
* List the allowed included embed types. If null all are allowed.
|
||||
* @var array
|
||||
*/
|
||||
private static $allowed_embed_types = [
|
||||
'video',
|
||||
'photo'
|
||||
];
|
||||
|
||||
/**
|
||||
* Defines tab to insert the embed fields into.
|
||||
* @var string
|
||||
*/
|
||||
private static $embed_tab = 'Main';
|
||||
|
||||
/**
|
||||
* @param array $properties
|
||||
* @return mixed|DBHTMLText
|
||||
*/
|
||||
public function FieldHolder($properties = [])
|
||||
{
|
||||
$name = $this->getName();
|
||||
$fields = [
|
||||
CheckboxField::create(
|
||||
$name . '[autoplay]',
|
||||
_t(self::class.'AUTOPLAY', 'Autoplay video?')
|
||||
)->setValue($this->object->getField('Autoplay')),
|
||||
|
||||
CheckboxField::create(
|
||||
$name . '[loop]',
|
||||
_t(self::class.'LOOP', 'Loop video?')
|
||||
)->setValue($this->object->getField('Loop')),
|
||||
|
||||
CheckboxField::create(
|
||||
$name.'[controls]',
|
||||
_t(self::class.'CONTROLS', 'Show player controls?')
|
||||
)->setValue($this->object->getField('Controls'))
|
||||
];
|
||||
|
||||
return CompositeField::create(array_merge([
|
||||
LiteralField::create(
|
||||
$name.'Options',
|
||||
parent::FieldHolder($properties)
|
||||
)
|
||||
], $fields));
|
||||
}
|
||||
}
|
@ -142,6 +142,7 @@ class SiteConfigExtension extends DataExtension
|
||||
|
||||
$fields->addFieldsToTab('Root.Maps', $addrFields);
|
||||
|
||||
if (\class_exists(MapboxField::class)) {
|
||||
if (MapboxField::getAccessToken()) {
|
||||
$fields->addFieldsToTab('Root.Maps', [
|
||||
//TextField::create('MapAPIKey'),
|
||||
@ -153,6 +154,7 @@ class SiteConfigExtension extends DataExtension
|
||||
LiteralField::create('MapNotice', '<p class="alert alert-info">No Map API keys specified.</p>')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/*GoogleMapField::create(
|
||||
$this->owner,
|
||||
|
@ -1,127 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace A2nt\CMSNiceties;
|
||||
|
||||
use RuntimeException;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\Email\Email;
|
||||
use Symfony\Component\Mailer\Mailer;
|
||||
use Symfony\Component\Mailer\Transport;
|
||||
use Symfony\Component\Mime\Email as MimeEmail;
|
||||
|
||||
class MailerFix extends Email
|
||||
{
|
||||
private $args;
|
||||
|
||||
public function __construct(
|
||||
$from = null,
|
||||
$to = null,
|
||||
$subject = null,
|
||||
$body = null,
|
||||
$cc = null,
|
||||
$bcc = null,
|
||||
$returnPath = null
|
||||
) {
|
||||
$this->args = func_get_args();
|
||||
parent::__construct($from, $to, $subject, $body, $cc, $bcc, $returnPath);
|
||||
}
|
||||
|
||||
private static function convertVars($mails)
|
||||
{
|
||||
return is_array($mails) ? implode(',', $mails) : $mails;
|
||||
}
|
||||
|
||||
private function loadDetails()
|
||||
{
|
||||
$fields = [
|
||||
'From',
|
||||
'To',
|
||||
'Subject',
|
||||
'Body',
|
||||
'CC',
|
||||
'BCC',
|
||||
'ReturnPath',
|
||||
];
|
||||
|
||||
$i = 0;
|
||||
foreach ($fields as $f) {
|
||||
$func = 'get'.$f;
|
||||
|
||||
$v = $this->$func();
|
||||
|
||||
if ($v) {
|
||||
$this->args[$i] = is_array($v) ? array_keys($v) : $v;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
public function send()
|
||||
{
|
||||
$transport = Transport::fromDsn('native://default');//smtp://localhost
|
||||
$mailer = new Mailer($transport);
|
||||
|
||||
$this->loadDetails();
|
||||
$this->render();
|
||||
|
||||
$body = $this->getBody();
|
||||
$to = self::convertVars($this->args[1]);
|
||||
|
||||
$email = (new MimeEmail())
|
||||
->to($to)
|
||||
//->priority(Email::PRIORITY_HIGH)
|
||||
->subject($this->args[2])
|
||||
->text(strip_tags($body, []))
|
||||
->html($body);
|
||||
|
||||
$from = self::convertVars($this->args[0]);
|
||||
$from = $from ? $from : self::getDefaultFrom();
|
||||
if ($from) {
|
||||
$email->from($from);
|
||||
}
|
||||
|
||||
$cc = isset($this->args[4]) ? self::convertVars($this->args[4]) : null;
|
||||
if ($cc) {
|
||||
$email->cc($cc);
|
||||
}
|
||||
|
||||
$bcc = isset($this->args[5]) ? self::convertVars($this->args[5]) : null;
|
||||
if ($bcc) {
|
||||
$email->bcc($bcc);
|
||||
}
|
||||
|
||||
$reply = isset($this->args[6]) ? self::convertVars($this->args[6]) : null;
|
||||
if ($reply) {
|
||||
$email->replyTo($reply);
|
||||
}
|
||||
|
||||
return $mailer->send($email);
|
||||
//parent::send();
|
||||
}
|
||||
|
||||
private function getDefaultFrom(): string
|
||||
{
|
||||
// admin_email can have a string or an array config
|
||||
// https://docs.silverstripe.org/en/4/developer_guides/email/#administrator-emails
|
||||
$adminEmail = Email::config()->get('admin_email');
|
||||
if (is_array($adminEmail) && count($adminEmail ?? []) > 0) {
|
||||
$defaultFrom = array_keys($adminEmail)[0];
|
||||
} else {
|
||||
if (is_string($adminEmail)) {
|
||||
$defaultFrom = $adminEmail;
|
||||
} else {
|
||||
$defaultFrom = '';
|
||||
}
|
||||
}
|
||||
if (empty($defaultFrom)) {
|
||||
$host = Director::host();
|
||||
if (empty($host)) {
|
||||
throw new RuntimeException('Host not defined');
|
||||
}
|
||||
$defaultFrom = sprintf('noreply@%s', $host);
|
||||
}
|
||||
|
||||
return $defaultFrom;
|
||||
}
|
||||
}
|
31
src/Tasks/PublishAllFiles.php
Executable file
31
src/Tasks/PublishAllFiles.php
Executable file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace A2nt\CMSNiceties\Tasks;
|
||||
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Dev\BuildTask;
|
||||
|
||||
class PublishAllFiles extends BuildTask
|
||||
{
|
||||
protected $title = 'Publish All Files';
|
||||
|
||||
protected $description = 'Publish All Files';
|
||||
|
||||
protected $enabled = true;
|
||||
|
||||
public function run($request)
|
||||
{
|
||||
$files = File::get();
|
||||
$i = 0;
|
||||
foreach ($files as $file) {
|
||||
if ($file->exists()) {
|
||||
echo '<b>'.$file->getField('Name').'</b><br/>';
|
||||
$file->publishRecursive();
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
die('Done!');
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ class DeferredRequirements implements TemplateGlobalProvider
|
||||
private static $nojquery = false;
|
||||
private static $jquery_version = '3.4.1';
|
||||
private static $nofontawesome = false;
|
||||
private static $fontawesome_svg = true;
|
||||
private static $fontawesome_svg = false;
|
||||
private static $custom_requirements = [];
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user