'wcf.acp.style.favicon.error.invalidExtension': '{lang}wcf.acp.style.favicon.error.invalidExtension{/lang}',
'wcf.acp.style.image.error.invalidExtension': '{lang}wcf.acp.style.image.error.invalidExtension{/lang}'
});
- new WCF.ACP.Style.LogoUpload('{$tmpHash}');
- new WCF.ACP.Style.LogoUploadMobile('{$tmpHash}');
{if $action == 'edit'}
new WCF.ACP.Style.CopyStyle({@$style->styleID});
<dl>
<dt><label for="pageLogo">{lang}wcf.acp.style.globals.pageLogo{/lang}</label></dt>
<dd>
- <div class="selectedImagePreview">
- <img src="" alt="" id="styleLogo" style="max-width: 100%">
- </div>
- <div id="uploadLogo"></div>
- </dd>
- <dd>
- <input type="text" name="pageLogo" id="pageLogo" value="{$variables[pageLogo]}" class="long">
+ {@$__wcf->getUploadHandler()->renderField('pageLogo')}
<small>{lang}wcf.acp.style.globals.pageLogo.description{/lang}</small>
+ <script data-relocate="true">
+ elBySel('#pageLogouploadFileList').addEventListener('change', function (ev) {
+ var img = elBySel('#pageLogouploadFileList img');
+ if (!img) return;
+
+ function updateSizes() {
+ elById('pageLogoWidth').value = img.width;
+ elById('pageLogoHeight').value = img.height;
+ }
+ img.addEventListener('load', updateSizes);
+ if (img.complete) {
+ updateSizes();
+ }
+ })
+ </script>
</dd>
</dl>
<dl>
<dt><label for="pageLogoMobile">{lang}wcf.acp.style.globals.pageLogoMobile{/lang}</label></dt>
<dd>
- <div class="selectedImagePreview">
- <img src="" alt="" id="styleLogoMobile" style="max-width: 100%">
- </div>
- <div id="uploadLogoMobile"></div>
- </dd>
- <dd>
- <input type="text" name="pageLogoMobile" id="pageLogoMobile" value="{$variables[pageLogoMobile]}" class="long">
+ {@$__wcf->getUploadHandler()->renderField('pageLogoMobile')}
<small>{lang}wcf.acp.style.globals.pageLogoMobile.description{/lang}</small>
</dd>
</dl>
I18nHandler::getInstance()->register('styleDescription');
$this->setVariables();
+
+ $this->rebuildUploadFields();
+
if (empty($_POST)) {
$this->readStyleVariables();
}
if (empty($this->tmpHash)) {
$this->tmpHash = StringUtil::getRandomID();
}
-
- $this->rebuildUploadFields();
}
protected function rebuildUploadFields() {
$field->setImageOnly(true);
$field->maxFiles = 1;
$handler->registerUploadField($field);
+
+ if ($handler->isRegisteredFieldId('pageLogo')) {
+ $handler->unregisterUploadField('pageLogo');
+ }
+ $field = new UploadField('pageLogo');
+ $field->setImageOnly(true);
+ $field->setAllowSvgImage(true);
+ $field->maxFiles = 1;
+ $handler->registerUploadField($field);
+
+ if ($handler->isRegisteredFieldId('pageLogoMobile')) {
+ $handler->unregisterUploadField('pageLogoMobile');
+ }
+ $field = new UploadField('pageLogoMobile');
+ $field->setImageOnly(true);
+ $field->setAllowSvgImage(true);
+ $field->maxFiles = 1;
+ $handler->registerUploadField($field);
}
/**
if (isset($_POST['scrollOffsets']) && is_array($_POST['scrollOffsets'])) $this->scrollOffsets = ArrayUtil::toIntegerArray($_POST['scrollOffsets']);
$this->uploads = [];
- foreach (['image', 'image2x'] as $field) {
+ foreach (['image', 'image2x', 'pageLogo', 'pageLogoMobile'] as $field) {
$removedFiles = UploadHandler::getInstance()->getRemovedFiledByFieldId($field);
if (!empty($removedFiles)) {
$this->uploads[$field] = null;
$adapter->writeImage($thumbnail, $fileLocation);
}
}
+
+ // pageLogo
+ $field = 'pageLogo';
+ $files = UploadHandler::getInstance()->getFilesByFieldId($field);
+ if (count($files) > 1) {
+ throw new UserInputException($field, 'invalid');
+ }
+
+ // pageLogoMobile
+ $field = 'pageLogoMobile';
+ $files = UploadHandler::getInstance()->getFilesByFieldId($field);
+ if (count($files) > 1) {
+ throw new UserInputException($field, 'invalid');
+ }
}
/**
$this->specialVariables = [
'individualScss',
'overrideScss',
- 'pageLogo',
'pageLogoWidth',
'pageLogoHeight',
- 'pageLogoMobile',
'useFluidLayout',
'useGoogleFont',
'wcfFontFamilyGoogle',
$this->variables['overrideScss'] = $tmp['preset'];
$this->variables['overrideScssCustom'] = $tmp['custom'];
}
+
+ if ($this->variables['pageLogo']) {
+ $file = new UploadFile($this->style->getAssetPath().$this->variables['pageLogo'], basename($this->variables['pageLogo']), true, true, true);
+ UploadHandler::getInstance()->registerFilesByField('pageLogo', [
+ $file,
+ ]);
+ }
+ if ($this->variables['pageLogoMobile']) {
+ $file = new UploadFile($this->style->getAssetPath().$this->variables['pageLogoMobile'], basename($this->variables['pageLogoMobile']), true, true, true);
+ UploadHandler::getInstance()->registerFilesByField('pageLogoMobile', [
+ $file,
+ ]);
+ }
}
/**
return;
}
+ foreach (['pageLogo', 'pageLogoMobile'] as $type) {
+ if (array_key_exists($type, $this->parameters['uploads'])) {
+ /** @var \wcf\system\file\upload\UploadFile $file */
+ $file = $this->parameters['uploads'][$type];
+
+ if ($file !== null) {
+ $fileLocation = $file->getLocation();
+ $extension = pathinfo($file->getFilename(), PATHINFO_EXTENSION);
+ $newName = $type.'.'.$extension;
+ $newLocation = $style->getAssetPath().$newName;
+ rename($fileLocation, $newLocation);
+ $this->parameters['variables'][$type] = $newName;
+ $file->setProcessed($newLocation);
+ }
+ else {
+ $this->parameters['variables'][$type] = '';
+ }
+ }
+ }
+
$sql = "SELECT variableID, variableName, defaultValue
FROM wcf".WCF_N."_style_variable";
$statement = WCF::getDB()->prepareStatement($sql);