{include file='header'}
+<script type="text/javascript" src="{@$__wcf->getPath()}acp/js/WCF.ACP.StyleEditor.js"></script>
<script type="text/javascript" src="{@$__wcf->getPath()}js/WCF.ColorPicker.js"></script>
<script type="text/javascript">
//<![CDATA[
}
$useFluidLayout.change(useFluidLayout);
useFluidLayout();
+
+ new WCF.ACP.StyleEditor.Upload(0, '{$tmpHash}');
});
//]]>
</script>
<dl{if $errorField == 'image'} class="formError"{/if}>
<dt><label for="image">{lang}wcf.acp.style.image{/lang}</label></dt>
- <dd>
- <input type="hidden" name="image" value="{$image}" readonly="readonly" class="long" /> TODO: Add upload here!
+ <dd class="framed">
+ <img src="{if $action == 'add'}{@$__wcf->getPath()}images/stylePreview.png{else}{@$style->getPreviewImage()}{/if}" alt="" id="styleImage" />
+ <div id="uploadImage" class="marginTop"></div>
+ {*<input type="hidden" name="image" value="{$image}" readonly="readonly" class="long" /> TODO: Add upload here!*}
{if $errorField == 'image'}
<small class="innerError">
{if $errorType == 'empty'}
<div class="formSubmit">
<input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
+ <input type="hidden" name="tmpHash" value="{$tmpHash}" />
{if $styleID|isset}<input type="hidden" name="id" value="{@$styleID}" />{/if}
</div>
</form>
*/
public $iconPath = 'icon/';
- /**
- * path to preview image
- * @var string
- */
- public $image = '';
-
/**
* image path
* @var string
*/
public $templateGroupID = 0;
+ /**
+ * temporary image hash
+ * @var string
+ */
+ public $tmpHash = '';
+
/**
* fluid or fixed layout
* @var boolean
$templateGroupList->sqlOrderBy = "template_group.templateGroupName ASC";
$templateGroupList->readObjects();
$this->availableTemplateGroups = $templateGroupList->getObjects();
+
+ if (isset($_REQUEST['tmpHash'])) {
+ $this->tmpHash = StringUtil::trim($_REQUEST['tmpHash']);
+ }
+ if (empty($this->tmpHash)) {
+ $this->tmpHash = StringUtil::getRandomID();
+ }
}
/**
if (isset($_POST['authorURL'])) $this->authorURL = StringUtil::trim($_POST['authorURL']);
if (isset($_POST['copyright'])) $this->copyright = StringUtil::trim($_POST['copyright']);
if (isset($_POST['iconPath'])) $this->iconPath = StringUtil::trim($_POST['iconPath']);
- if (isset($_POST['image'])) $this->image = StringUtil::trim($_POST['image']);
if (isset($_POST['imagePath'])) $this->imagePath = StringUtil::trim($_POST['imagePath']);
if (isset($_POST['license'])) $this->license = StringUtil::trim($_POST['license']);
if (isset($_POST['styleDate'])) $this->styleDate = StringUtil::trim($_POST['styleDate']);
'styleDescription' => ($this->styleDescription ? $this->styleDescription : null),
'styleVersion' => $this->styleVersion,
'styleDate' => $this->styleDate,
- 'image' => $this->image,
'imagePath' => $this->imagePath,
'copyright' => $this->copyright,
'license' => $this->license,
'authorURL' => $this->authorURL,
'iconPath' => $this->iconPath
),
+ 'tmpHash' => $this->tmpHash,
'variables' => $this->variables
));
$this->objectAction->executeAction();
$this->saved();
// reset variables
- $this->authorName = $this->authorURL = $this->copyright = $this->fontFamily = '';
- $this->image = $this->license = $this->styleDate = $this->styleDescription = '';
- $this->styleName = $this->styleVersion = 0;
+ $this->authorName = $this->authorURL = $this->copyright = $this->fontFamily = $this->image = '';
+ $this->license = $this->styleDate = $this->styleDescription = $this->styleName = $this->styleVersion = '';
$this->iconPath = 'icon/';
$this->imagePath = 'images/';
'copyright' => $this->copyright,
'fontFamily' => $this->fontFamily,
'iconPath' => $this->iconPath,
- 'image' => $this->image,
'imagePath' => $this->imagePath,
'license' => $this->license,
'styleDate' => $this->styleDate,
'styleName' => $this->styleName,
'styleVersion' => $this->styleVersion,
'templateGroupID' => $this->templateGroupID,
+ 'tmpHash' => $this->tmpHash,
'useFluidLayout' => $this->useFluidLayout,
'variables' => $this->variables
));
--- /dev/null
+<?php
+namespace wcf\acp\form;
+use wcf\data\style\Style;
+use wcf\data\style\StyleAction;
+use wcf\form\AbstractForm;
+use wcf\system\exception\IllegalLinkException;
+use wcf\system\WCF;
+
+/**
+ * Shows the style edit form.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2012 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf.acp.style
+ * @subpackage acp.form
+ * @category Community Framework
+ */
+class StyleEditForm extends StyleAddForm {
+ /**
+ * style object
+ * @var wcf\data\style\Style
+ */
+ public $style = null;
+
+ /**
+ * style id
+ * @var integer
+ */
+ public $styleID = 0;
+
+ /**
+ * @see wcf\page\IPage::readParameters()
+ */
+ public function readParameters() {
+ if (isset($_REQUEST['id'])) $this->styleID = intval($_REQUEST['id']);
+ $this->style = new Style($this->styleID);
+ if (!$this->style->styleID) {
+ throw new IllegalLinkException();
+ }
+
+ parent::readParameters();
+ }
+
+ /**
+ * @see wcf\acp\form\StyleAddForm::readStyleVariables()
+ */
+ protected function readStyleVariables() {
+ $this->variables = $this->style->getVariables();
+ }
+
+ /**
+ * @see wcf\page\IPage::readData()
+ */
+ public function readData() {
+ parent::readData();
+
+ if (empty($_POST)) {
+ $this->authorName = $this->style->authorName;
+ $this->authorURL = $this->style->authorURL;
+ $this->copyright = $this->style->copyright;
+ $this->iconPath = $this->style->iconPath;
+ $this->imagePath = $this->style->imagePath;
+ $this->license = $this->style->license;
+ $this->styleDate = $this->style->styleDate;
+ $this->styleDescription = $this->style->styleDescription;
+ $this->styleName = $this->style->styleName;
+ $this->styleVersion = $this->style->styleVersion;
+ $this->templateGroupID = $this->style->templateGroupID;
+ }
+ }
+
+ /**
+ * @see wcf\form\IForm::save()
+ */
+ public function save() {
+ AbstractForm::saved();
+
+ $this->objectAction = new StyleAction(array($this->style), 'update', array(
+ 'data' => array(
+ 'styleName' => $this->styleName,
+ 'templateGroupID' => $this->templateGroupID,
+ 'styleDescription' => ($this->styleDescription ? $this->styleDescription : null),
+ 'styleVersion' => $this->styleVersion,
+ 'styleDate' => $this->styleDate,
+ 'imagePath' => $this->imagePath,
+ 'copyright' => $this->copyright,
+ 'license' => $this->license,
+ 'authorName' => $this->authorName,
+ 'authorURL' => $this->authorURL,
+ 'iconPath' => $this->iconPath
+ ),
+ 'tmpHash' => $this->tmpHash,
+ 'variables' => $this->variables
+ ));
+ $this->objectAction->executeAction();
+
+ // call saved event
+ $this->saved();
+
+ // reload style object to update preview image
+ $this->style = new Style($this->style->styleID);
+
+ WCF::getTPL()->assign('success', true);
+ }
+
+ /**
+ * @see wcf\page\IPage::assignVariables()
+ */
+ public function assignVariables() {
+ parent::assignVariables();
+
+ WCF::getTPL()->assign(array(
+ 'action' => 'edit',
+ 'style' => $this->style,
+ 'styleID' => $this->styleID
+ ));
+ }
+}
<item name="wcf.acp.style.iconPath"><![CDATA[Icon-Pfad]]></item>
<item name="wcf.acp.style.iconPath.description"><![CDATA[Wenn Ihr Stil eigene Icons benötigt, sollten diese in einem Unterordner des Ordners «icons» ablegen. Geben Sie hier den Pfad zu diesem Ordner an.]]></item>
<item name="wcf.acp.style.image"><![CDATA[Vorschaubild]]></item>
+ <item name="wcf.acp.style.image.description"><![CDATA[Laden Sie hier ein Vorschaubild dieses Stiles hoch, als Bildformate sind JPG und PNG zulässig. Es wird empfohlen Vorschaubilder immer mit der Größe 225px x 140px anzulegen, größere Grafiken werden automatisch skaliert.]]></item>
<item name="wcf.acp.style.imagePath"><![CDATA[Bilder-Pfad]]></item>
<item name="wcf.acp.style.imagePath.description"><![CDATA[Wenn Ihr Stil eigene Grafiken benötigt, sollten diese in einem Unterordner des Ordners «images» ablegen. Geben Sie hier den Pfad zu diesem Ordner an.]]></item>
<item name="wcf.acp.style.license"><![CDATA[Lizenz]]></item>