From 02a8bacbb6f5407f31b75511d8841affddb80296 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 15 Jul 2020 11:28:31 +0200 Subject: [PATCH] Download Google Font in StyleAddForm see #3394 --- .../install/files/acp/templates/styleAdd.tpl | 12 +++++++++- .../files/lib/acp/form/StyleAddForm.class.php | 22 +++++++++++++++++++ wcfsetup/install/lang/de.xml | 3 +++ wcfsetup/install/lang/en.xml | 3 +++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/acp/templates/styleAdd.tpl b/wcfsetup/install/files/acp/templates/styleAdd.tpl index d848ffb462..a4778a18c7 100644 --- a/wcfsetup/install/files/acp/templates/styleAdd.tpl +++ b/wcfsetup/install/files/acp/templates/styleAdd.tpl @@ -539,10 +539,20 @@ {lang}wcf.acp.style.globals.useGoogleFont{/lang} -
+
+ {lang}wcf.acp.style.globals.fontFamilyGoogle.description{/lang} + {if $errorField == 'wcfFontFamilyGoogle'} + + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.style.globals.fontFamilyGoogle.error.{$errorType}{/lang} + {/if} + + {/if}
diff --git a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php index b26656fb43..de23403372 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php @@ -11,6 +11,8 @@ use wcf\system\exception\SystemException; use wcf\system\exception\UserInputException; use wcf\system\language\I18nHandler; use wcf\system\Regex; +use wcf\system\style\exception\FontDownloadFailed; +use wcf\system\style\FontManager; use wcf\system\WCF; use wcf\util\ArrayUtil; use wcf\util\DateUtil; @@ -293,6 +295,24 @@ class StyleAddForm extends AbstractForm { if (isset($_POST['scrollOffsets']) && is_array($_POST['scrollOffsets'])) $this->scrollOffsets = ArrayUtil::toIntegerArray($_POST['scrollOffsets']); } + /** + * @since 5.3 + */ + protected function downloadGoogleFont() { + $fontManager = FontManager::getInstance(); + $family = $this->variables['wcfFontFamilyGoogle']; + if ($family) { + if (!$fontManager->isFamilyDownloaded($family)) { + try { + $fontManager->downloadFamily($family); + } + catch (FontDownloadFailed $e) { + throw new UserInputException('wcfFontFamilyGoogle', 'downloadFailed'.($e->getReason() ? '.'.$e->getReason() : '')); + } + } + } + } + /** * @inheritDoc */ @@ -357,6 +377,8 @@ class StyleAddForm extends AbstractForm { } $this->validateApiVersion(); + + $this->downloadGoogleFont(); } /** diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index c29fe1b70e..7f735aabc8 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -2949,6 +2949,9 @@ Kein Abschnitt darf leer sein und alle Abschnitten dürfen nur folgende Zeichen + + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 6c7d81b8d8..00edddeb3b 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2877,6 +2877,9 @@ If you have already bought the licenses for the listed apps, th + + + -- 2.20.1