{js application='wcf' acp='true' file='WCF.ACP.Style'}
{js application='wcf' file='WCF.ColorPicker' bundle='WCF.Combined'}
<script data-relocate="true">
-- require([
- 'WoltLabSuite/Core/Acp/Ui/Style/CoverPhoto/Delete', 'WoltLabSuite/Core/Acp/Ui/Style/CoverPhoto/Upload', 'WoltLabSuite/Core/Acp/Ui/Style/Favicon/Upload', 'WoltLabSuite/Core/Acp/Ui/Style/Image/Upload',
-- 'WoltLabSuite/Core/Acp/Ui/Style/Editor', 'WoltLabSuite/Core/Ui/Toggle/Input', 'Language'
-- ], function(
- AcpUiStyleCoverPhotoDelete, AcpUiStyleCoverPhotoUpload, AcpUiStyleFaviconUpload, AcpUiStyleImageUpload,
-- AcpUiStyleEditor, UiToggleInput, Language
-- ) {
++ require(['WoltLabSuite/Core/Acp/Ui/Style/Editor'], function(AcpUiStyleEditor) {
AcpUiStyleEditor.setup({
isTainted: {if $isTainted}true{else}false{/if},
styleId: {if $action === 'edit'}{@$style->styleID}{else}0{/if},
styleRuleMap: styleRuleMap
});
--
- new UiToggleInput('input[name="useGoogleFont"]', {
- show: ['#wcfFontFamilyGoogleContainer']
- });
- new AcpUiStyleImageUpload({if $action == 'add'}0{else}{@$style->styleID}{/if}, '{$tmpHash}', false);
- new AcpUiStyleImageUpload({if $action == 'add'}0{else}{@$style->styleID}{/if}, '{$tmpHash}', true);
-
- {if $action === 'edit'}
- new AcpUiStyleFaviconUpload({@$style->styleID});
-
- {if MODULE_USER_COVER_PHOTO}
- Language.addObject({
- 'wcf.acp.style.coverPhoto.delete.confirmMessage': '{lang}wcf.acp.style.coverPhoto.delete.confirmMessage{/lang}',
- 'wcf.user.coverPhoto.upload.error.invalidExtension': '{lang}wcf.user.coverPhoto.upload.error.invalidExtension{/lang}',
- 'wcf.user.coverPhoto.upload.error.minHeight': '{lang}wcf.user.coverPhoto.upload.error.minHeight{/lang}',
- 'wcf.user.coverPhoto.upload.error.minWidth': '{lang}wcf.user.coverPhoto.upload.error.minWidth{/lang}',
- 'wcf.user.coverPhoto.upload.error.uploadFailed': '{lang}wcf.user.coverPhoto.upload.error.uploadFailed{/lang}'
- });
-
- AcpUiStyleCoverPhotoDelete.init({@$style->styleID});
- new AcpUiStyleCoverPhotoUpload({@$style->styleID});
- {/if}
- {/if}
});
$(function() {
use wcf\system\event\EventHandler;
use wcf\system\exception\SystemException;
use wcf\system\exception\UserInputException;
+use wcf\system\file\upload\UploadField;
+use wcf\system\file\upload\UploadHandler;
+use wcf\system\image\ImageHandler;
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;
// codemirror scroll offset
if (isset($_POST['scrollOffsets']) && is_array($_POST['scrollOffsets'])) $this->scrollOffsets = ArrayUtil::toIntegerArray($_POST['scrollOffsets']);
+
+ $this->uploads = [];
+ foreach (array_keys($this->getUploadFields()) as $field) {
+ $removedFiles = UploadHandler::getInstance()->getRemovedFiledByFieldId($field);
+ if (!empty($removedFiles)) {
+ $this->uploads[$field] = null;
+ }
+
+ $files = UploadHandler::getInstance()->getFilesByFieldId($field);
+ if (!empty($files)) {
+ $this->uploads[$field] = $files[0];
+ }
+ }
}
+ /**
+ * @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
*/
$this->validateApiVersion();
+ $this->validateUploads();
++
+ $this->downloadGoogleFont();
}
/**
$this->specialVariables = [
'individualScss',
'overrideScss',
- 'pageLogo',
'pageLogoWidth',
'pageLogoHeight',
- 'pageLogoMobile',
'useFluidLayout',
- 'useGoogleFont',
'wcfFontFamilyGoogle',
'wcfFontFamilyFallback'
];