From a8c4643d3a57d3f94a9a17a6880240fabeb41fed Mon Sep 17 00:00:00 2001 From: Tony Air Date: Mon, 22 Apr 2024 14:03:31 +0200 Subject: [PATCH 01/10] RM: MailerFix --- _config/base-extensions.yml | 2 - src/MailerFix.php | 127 ------------------------------------ 2 files changed, 129 deletions(-) delete mode 100644 src/MailerFix.php diff --git a/_config/base-extensions.yml b/_config/base-extensions.yml index 673a3c2..5733a5d 100755 --- a/_config/base-extensions.yml +++ b/_config/base-extensions.yml @@ -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: diff --git a/src/MailerFix.php b/src/MailerFix.php deleted file mode 100644 index d9108b7..0000000 --- a/src/MailerFix.php +++ /dev/null @@ -1,127 +0,0 @@ -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; - } -} From e8771b8adf880cdb59f1c4ddcbb31f68aaceda4e Mon Sep 17 00:00:00 2001 From: Tony Air Date: Mon, 22 Apr 2024 14:08:10 +0200 Subject: [PATCH 02/10] RM: EmbedObjectField --- src/Extensions/EmbedObjectField.php | 59 ----------------------------- 1 file changed, 59 deletions(-) delete mode 100755 src/Extensions/EmbedObjectField.php diff --git a/src/Extensions/EmbedObjectField.php b/src/Extensions/EmbedObjectField.php deleted file mode 100755 index b1d5196..0000000 --- a/src/Extensions/EmbedObjectField.php +++ /dev/null @@ -1,59 +0,0 @@ -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)); - } -} From 9f2a14afd2807592f8f882c7fead0674fa0530d8 Mon Sep 17 00:00:00 2001 From: Tony Air Date: Mon, 22 Apr 2024 14:09:51 +0200 Subject: [PATCH 03/10] FIX: composer.json --- composer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 37ecab8..c5f8c99 100644 --- a/composer.json +++ b/composer.json @@ -13,11 +13,10 @@ }], "minimum-stability": "dev", "require": { - "silverstripe/cms": "*", + "silverstripe/cms": "^5", "a2nt/silverstripe-elemental-basics": "*", "silverstripe/widgets": "*", - "gorriecoe/silverstripe-linkfield": "*", - "symfony/mailer": "^6" + "gorriecoe/silverstripe-linkfield": "*" }, "autoload": { "psr-4": { From cec20eebf9f89aa2052be005c97456e772f2c2c4 Mon Sep 17 00:00:00 2001 From: Tony Air Date: Mon, 22 Apr 2024 15:42:25 +0200 Subject: [PATCH 04/10] FIX: SS5 outdated element --- src/Extensions/SiteConfigExtension.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Extensions/SiteConfigExtension.php b/src/Extensions/SiteConfigExtension.php index 80864c8..8c65ce3 100755 --- a/src/Extensions/SiteConfigExtension.php +++ b/src/Extensions/SiteConfigExtension.php @@ -142,16 +142,18 @@ class SiteConfigExtension extends DataExtension $fields->addFieldsToTab('Root.Maps', $addrFields); - if (MapboxField::getAccessToken()) { - $fields->addFieldsToTab('Root.Maps', [ - //TextField::create('MapAPIKey'), - TextField::create('MapZoom'), - MapboxField::create('Map', 'Choose a location', 'Latitude', 'Longitude'), - ]); - } else { - $fields->addFieldsToTab('Root.Maps', [ - LiteralField::create('MapNotice', '

No Map API keys specified.

') - ]); + if (\class_exists(MapboxField::class)) { + if (MapboxField::getAccessToken()) { + $fields->addFieldsToTab('Root.Maps', [ + //TextField::create('MapAPIKey'), + TextField::create('MapZoom'), + MapboxField::create('Map', 'Choose a location', 'Latitude', 'Longitude'), + ]); + } else { + $fields->addFieldsToTab('Root.Maps', [ + LiteralField::create('MapNotice', '

No Map API keys specified.

') + ]); + } } /*GoogleMapField::create( From 382f0d493af28ae696a5d4dc5c4d6eb20bf6ede2 Mon Sep 17 00:00:00 2001 From: Tony Air Date: Mon, 22 Apr 2024 17:27:05 +0200 Subject: [PATCH 05/10] FIX: SS5 Login Forms --- src/Ajax/Ex/AjaxControllerEx.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Ajax/Ex/AjaxControllerEx.php b/src/Ajax/Ex/AjaxControllerEx.php index 4af4c2e..011ac0c 100755 --- a/src/Ajax/Ex/AjaxControllerEx.php +++ b/src/Ajax/Ex/AjaxControllerEx.php @@ -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'); From 8544814c02f1085196263de035bc7abe9dee6ab4 Mon Sep 17 00:00:00 2001 From: Tony Air Date: Mon, 22 Apr 2024 17:45:17 +0200 Subject: [PATCH 06/10] IMPR: no SVG for FontAwesome by default --- src/Templates/DeferredRequirements.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Templates/DeferredRequirements.php b/src/Templates/DeferredRequirements.php index 286881d..a7587b7 100755 --- a/src/Templates/DeferredRequirements.php +++ b/src/Templates/DeferredRequirements.php @@ -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 = []; /** From 39ec8095e301f387270f2c2c28784b5dca00078f Mon Sep 17 00:00:00 2001 From: Tony Air Date: Mon, 22 Apr 2024 17:49:46 +0200 Subject: [PATCH 07/10] IMPR: Move theme specific settings --- _config/templates-requirements.yml | 13 ------------- _config/templates-themes.yml | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/_config/templates-requirements.yml b/_config/templates-requirements.yml index 96c9c53..b2428d3 100755 --- a/_config/templates-requirements.yml +++ b/_config/templates-requirements.yml @@ -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: diff --git a/_config/templates-themes.yml b/_config/templates-themes.yml index 6f3a1d1..a0c58fb 100755 --- a/_config/templates-themes.yml +++ b/_config/templates-themes.yml @@ -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: From 6c7c2109194decf4d948318530365b30e81fce1f Mon Sep 17 00:00:00 2001 From: Tony Air Date: Wed, 24 Apr 2024 13:52:55 +0200 Subject: [PATCH 08/10] IMPR: Publish all files --- src/Tasks/PublishAllFiles.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 src/Tasks/PublishAllFiles.php diff --git a/src/Tasks/PublishAllFiles.php b/src/Tasks/PublishAllFiles.php new file mode 100755 index 0000000..ffbe6ec --- /dev/null +++ b/src/Tasks/PublishAllFiles.php @@ -0,0 +1,29 @@ +exists()) { + $file->publishFile(); + } + $i++; + } + + die('Done!'); + } +} From f4153e53f2f701c6fcbb51a8e317c814c3ed3da6 Mon Sep 17 00:00:00 2001 From: Tony Air Date: Wed, 24 Apr 2024 13:59:03 +0200 Subject: [PATCH 09/10] IMPR: Publish all files --- src/Tasks/PublishAllFiles.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Tasks/PublishAllFiles.php b/src/Tasks/PublishAllFiles.php index ffbe6ec..4aa8c7c 100755 --- a/src/Tasks/PublishAllFiles.php +++ b/src/Tasks/PublishAllFiles.php @@ -5,11 +5,11 @@ namespace A2nt\CMSNiceties\Tasks; use SilverStripe\Assets\File; use SilverStripe\Dev\BuildTask; -class PublishAllFiles extends BuildTask +class BrokenFilesTask extends BuildTask { - protected $title = 'Publish All Files Task'; + protected $title = 'Broken Files Task'; - protected $description = 'Publish All Files'; + protected $description = 'Broken files report'; protected $enabled = true; @@ -19,8 +19,10 @@ class PublishAllFiles extends BuildTask $i = 0; foreach ($files as $file) { if ($file->exists()) { - $file->publishFile(); + echo ''.$file->getField('Name').'
'; + $file->publishRecursive(); } + $i++; } From 626df59c38c90d9bfcb8d4b10b5f61897919d335 Mon Sep 17 00:00:00 2001 From: Tony Air Date: Wed, 24 Apr 2024 14:01:37 +0200 Subject: [PATCH 10/10] IMPR: Publish all files --- src/Tasks/PublishAllFiles.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tasks/PublishAllFiles.php b/src/Tasks/PublishAllFiles.php index 4aa8c7c..56e3969 100755 --- a/src/Tasks/PublishAllFiles.php +++ b/src/Tasks/PublishAllFiles.php @@ -5,11 +5,11 @@ namespace A2nt\CMSNiceties\Tasks; use SilverStripe\Assets\File; use SilverStripe\Dev\BuildTask; -class BrokenFilesTask extends BuildTask +class PublishAllFiles extends BuildTask { - protected $title = 'Broken Files Task'; + protected $title = 'Publish All Files'; - protected $description = 'Broken files report'; + protected $description = 'Publish All Files'; protected $enabled = true;