{/if}
<form method="post" action="{link controller='StyleGlobalValues'}{/link}">
- <div class="section">
+ <div class="section"{if $errorField == 'styles'} formError{/if}>
<dl>
<dt>{lang}wcf.acp.style.globalValues.input{/lang}</dt>
<dd>
<input class="codeMirrorScrollOffset" name="stylesScrollOffset" value="{$stylesScrollOffset}" type="hidden">
</div>
</dd>
+ {if $errorField == 'styles'}
+ <small class="innerError">
+ {lang}wcf.acp.style.globalValues.input.error{/lang}
+ </small>
+ {/if}
</dl>
{include file='codemirror' codemirrorMode='text/x-less' codemirrorSelector='#styles'}
</div>
<?php
namespace wcf\acp\form;
use wcf\form\AbstractForm;
+use wcf\system\exception\UserInputException;
use wcf\system\registry\RegistryHandler;
use wcf\system\style\StyleCompiler;
use wcf\system\style\StyleHandler;
use wcf\system\WCF;
+use wcf\util\FileUtil;
use wcf\util\StringUtil;
/**
}
}
+ /**
+ * @inheritDoc
+ */
+ public function validate() {
+ parent::validate();
+
+ $tmpFile = FileUtil::getTemporaryFilename('styleGlobalValues_', '.scss');
+ file_put_contents($tmpFile, $this->styles);
+
+ try {
+ // Due to performance issues we can only compile the default style and check,
+ // whether there are syntax issues.
+ $defaultStyle = StyleHandler::getInstance()->getDefaultStyle();
+ $errorMessage = StyleCompiler::getInstance()->testStyle($defaultStyle->apiVersion, $defaultStyle->imagePath, $defaultStyle->getVariables(), $tmpFile);
+
+ if ($errorMessage !== true) {
+ throw new UserInputException('styles', [
+ 'message' => $errorMessage,
+ ]);
+ }
+ }
+ finally {
+ unlink($tmpFile);
+ }
+
+ }
+
/**
* @inheritDoc
*/
* @param string $apiVersion
* @param string $imagePath
* @param string[] $variables
+ * @param string|null $customCustomSCSSFile
* @return bool|string
* @since 5.3
*/
- public function testStyle($apiVersion, $imagePath, array $variables) {
+ public function testStyle($apiVersion, $imagePath, array $variables, $customCustomSCSSFile = null) {
$individualScss = '';
if (isset($variables['individualScss'])) {
$individualScss = $variables['individualScss'];
$parameters = ['scss' => ''];
EventHandler::getInstance()->fireAction($this, 'compile', $parameters);
+ $files = $this->getFiles();
+
+ if ($customCustomSCSSFile !== null) {
+ if (($customSCSSFileKey = array_search(WCF_DIR . self::FILE_GLOBAL_VALUES, $files)) !== false) {
+ unset($files[$customSCSSFileKey]);
+ }
+
+ $files[] = $customCustomSCSSFile;
+ }
+
try {
$this->compileStylesheetToString(
- $this->getFiles(),
+ $files,
$variables,
$individualScss . (!empty($parameters['scss']) ? "\n" . $parameters['scss'] : ''),
function($content) {
<item name="wcf.acp.style.globalValues"><![CDATA[Stilunabhängiges CSS und SCSS]]></item>
<item name="wcf.acp.style.globalValues.description"><![CDATA[Das unten stehende CSS und SCSS wird auf alle Stile angewandt, die individuelle Anpassungen in den Stilen sind jedoch höherwertig.]]></item>
<item name="wcf.acp.style.globalValues.input"><![CDATA[Individuelles CSS und SCSS]]></item>
+ <item name="wcf.acp.style.globalValues.input.error"><![CDATA[Der SCSS-Code ist invalid: {$errorType.message}.]]></item>
<item name="wcf.acp.style.image"><![CDATA[Vorschaubild]]></item>
<item name="wcf.acp.style.image.description"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Lade{else}Laden Sie{/if} hier ein Vorschaubild dieses Stiles hoch, als Bildformate sind JPG und PNG zulässig. Es wird empfohlen Vorschaubilder immer mit der Größe 102×64 Pixel anzulegen, größere Grafiken werden automatisch skaliert.]]></item>
<item name="wcf.acp.style.image2x"><![CDATA[Vorschaubild (HD)]]></item>
<item name="wcf.acp.style.globalValues"><![CDATA[Global CSS and SCSS]]></item>
<item name="wcf.acp.style.globalValues.description"><![CDATA[The CSS and SCSS entered below is applied to all styles, but custom values in styles take precedence.]]></item>
<item name="wcf.acp.style.globalValues.input"><![CDATA[Individual CSS and SCSS]]></item>
+ <item name="wcf.acp.style.globalValues.input.error"><![CDATA[The SCSS code is invalid: {$errorType.message}.]]></item>
<item name="wcf.acp.style.image"><![CDATA[Preview Image]]></item>
<item name="wcf.acp.style.image.description"><![CDATA[Upload a preview image for this style, acceptable image types are JPG and PNG. Dimensions should be 102×64 pixels, exceeding images will be scaled.]]></item>
<item name="wcf.acp.style.image2x"><![CDATA[Preview Image (HD)]]></item>