</dl>
{/if}
+ <dl{if $errorField == 'customAssets'} class="formError"{/if}>
+ <dt><label for="customAssets">{lang}wcf.acp.style.customAssets{/lang}</label></dt>
+ <dd>
+ {@$__wcf->getUploadHandler()->renderField('customAssets')}
+ {if $errorField == 'customAssets'}
+ <small class="innerError">
+ {if $errorType == 'empty'}
+ {lang}wcf.global.form.error.empty{/lang}
+ {else}
+ {lang}wcf.acp.style.customAssets.error.{$errorType}{/lang}
+ {/if}
+ </small>
+ {/if}
+ <small>{lang}wcf.acp.style.customAssets.description{/lang}</small>
+ </dd>
+ </dl>
+
{event name='fileFields'}
</section>
public $scrollOffsets = [];
/**
- * @var mixed[]
+ * @var (null|UploadFile)[]
* @since 5.3
*/
public $uploads = [];
+ /**
+ * @var UploadFile[]
+ * @since 5.3
+ */
+ public $customAssets = [];
+
/**
* @inheritDoc
*/
$field->maxFiles = 1;
$handler->registerUploadField($field);
}
+
+ // This field is special cased, because it may contain arbitrary data.
+ $field = new UploadField('customAssets');
+ $field->setImageOnly(true);
+ $field->setAllowSvgImage(true);
+ $field->maxFiles = null;
+ $handler->registerUploadField($field);
}
/**
$this->uploads[$field] = $files[0];
}
}
+
+ $this->customAssets = [
+ 'removed' => UploadHandler::getInstance()->getRemovedFiledByFieldId('customAssets'),
+ 'added' => UploadHandler::getInstance()->getFilesByFieldId('customAssets'),
+ ];
+
}
/**
'apiVersion' => $this->apiVersion
]),
'uploads' => $this->uploads,
+ 'customAssets' => $this->customAssets,
'tmpHash' => $this->tmpHash,
- 'variables' => $this->variables
+ 'variables' => $this->variables,
]);
$returnValues = $this->objectAction->executeAction();
$style = $returnValues['returnValues'];
break;
}
}
-
}
+
+ UploadHandler::getInstance()->registerFilesByField('customAssets', array_map(function ($filename) {
+ return new UploadFile($filename, basename($filename), false, true, true);
+ }, glob($this->style->getAssetPath().'custom/*')));
}
}
'apiVersion' => $this->apiVersion
]),
'uploads' => $this->uploads,
+ 'customAssets' => $this->customAssets,
'tmpHash' => $this->tmpHash,
- 'variables' => $this->variables
+ 'variables' => $this->variables,
]);
$this->objectAction->executeAction();
// handle the cover photo
$this->updateCoverPhoto($style);
-
+
+ // handle custom assets
+ $this->updateCustomAssets($style);
+
return $style;
}
// handle the cover photo
$this->updateCoverPhoto($style->getDecoratedObject());
+ // handle custom assets
+ $this->updateCustomAssets($style->getDecoratedObject());
+
// reset stylesheet
StyleHandler::getInstance()->resetStylesheet($style->getDecoratedObject());
}
}
}
+ /**
+ * @since 5.2
+ */
+ protected function updateCustomAssets(Style $style) {
+ $customAssetPath = $style->getAssetPath().'custom/';
+
+ if (!empty($this->parameters['customAssets']['removed'])) {
+ /** @var \wcf\system\file\upload\UploadFile $file */
+ foreach ($this->parameters['customAssets']['removed'] as $file) {
+ unlink($file->getLocation());
+ }
+ }
+ if (!empty($this->parameters['customAssets']['added'])) {
+ if (!is_dir($customAssetPath)) {
+ FileUtil::makePath($customAssetPath);
+ }
+
+ /** @var \wcf\system\file\upload\UploadFile $file */
+ foreach ($this->parameters['customAssets']['added'] as $file) {
+ rename($file->getLocation(), $customAssetPath.$file->getFilename());
+ $file->setProcessed($customAssetPath.$file->getFilename());
+ }
+ }
+ }
+
/**
* Validates parameters to assign a new default style.
*/
<item name="wcf.acp.style.coverPhoto"><![CDATA[Standard-Titelbild]]></item>
<item name="wcf.acp.style.coverPhoto.delete.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} das Standard-Titelbild dieses Stils wirklich löschen? Nach dem Löschen wird das allgemeine, Stil-unabhängige Standard-Titelbild verwendet.]]></item>
<item name="wcf.acp.style.coverPhoto.description"><![CDATA[Das Bild muss mindestens {$coverPhotoMinWidth}×{$coverPhotoMinHeight} Pixel groß sein, als Bildformate sind GIF, JPG, JPEG und PNG zulässig.]]></item>
+ <item name="wcf.acp.style.customAssets"><![CDATA[Zusätzliche Bilder]]></item>
+ <item name="wcf.acp.style.customAssets.description"><![CDATA[{literal}Die hochgeladenen Bilder werden im <kbd>custom/</kbd>-Ordner innerhalb des <kbd>#{$style_image_path}</kbd> gespeichert.{/literal}]]></item>
<item name="wcf.acp.style.delete.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} den Stil <span class="confirmationObject">{$style->styleName}</span> wirklich löschen?]]></item>
<item name="wcf.acp.style.edit"><![CDATA[Stil bearbeiten]]></item>
<item name="wcf.acp.style.exportAsPackage"><![CDATA[Als Paket exportieren]]></item>
<item name="wcf.acp.style.coverPhoto"><![CDATA[Default Cover Photo]]></item>
<item name="wcf.acp.style.coverPhoto.delete.confirmMessage"><![CDATA[Do you really want to delete the default cover photo? Once deleted, the global default photo will be used instead.]]></item>
<item name="wcf.acp.style.coverPhoto.description"><![CDATA[The image must be at least {$coverPhotoMinWidth}×{$coverPhotoMinHeight} pixels large, acceptable image types are GIF, JPG, JPEG and PNG.]]></item>
+ <item name="wcf.acp.style.customAssets"><![CDATA[Additional Images]]></item>
+ <item name="wcf.acp.style.customAssets.description"><![CDATA[{literal}The uploaded images will be stored within the <kbd>custom/</kbd> folder within the <kbd>#{$style_image_path}</kbd>.{/literal}]]></item>
<item name="wcf.acp.style.delete.confirmMessage"><![CDATA[Do you really want to delete the style <span class="confirmationObject">{$style->styleName}</span>?]]></item>
<item name="wcf.acp.style.edit"><![CDATA[Edit Style]]></item>
<item name="wcf.acp.style.exportAsPackage"><![CDATA[Export as package]]></item>