<permissions>admin.style.canAddStyle</permissions>
<showorder>2</showorder>
</acpmenuitem>
+
+ <acpmenuitem name="wcf.acp.menu.link.style.import">
+ <link>index.php/StyleImport/</link>
+ <parent>wcf.acp.menu.link.style</parent>
+ <permissions>admin.style.canAddStyle</permissions>
+ <showorder>3</showorder>
+ </acpmenuitem>
<!-- /style -->
</import>
</data>
--- /dev/null
+{include file='header' pageTitle='wcf.acp.style.importStyle'}
+
+<header class="boxHeadline">
+ <hgroup>
+ <h1>{lang}wcf.acp.style.importStyle{/lang}</h1>
+ </hgroup>
+</header>
+
+{if $success|isset}
+ <p class="success">{lang}wcf.global.form.add.success{/lang}</p>
+{/if}
+
+<div class="contentNavigation">
+ <nav>
+ <ul>
+ <li><a href="{link controller='StyleList'}{/link}" title="{lang}wcf.acp.menu.link.style.list{/lang}" class="button"><img src="{@$__wcf->getPath()}icon/list.svg" alt="" class="icon24" /> <span>{lang}wcf.acp.menu.link.style.list{/lang}</span></a></li>
+ </ul>
+ </nav>
+</div>
+
+<form method="post" action="{link controller='StyleImport'}{/link}" enctype="multipart/form-data">
+ <div class="container containerPadding marginTop shadow">
+ <fieldset>
+ <legend>{lang}wcf.acp.style.import.source{/lang}</legend>
+
+ <dl{if $errorField == 'source'} class="formError"{/if}>
+ <dt><label for="source">{lang}wcf.acp.style.import.source.upload{/lang}</label></dt>
+ <dd>
+ <input type="file" id="source" name="source" value="" />
+ {if $errorField == 'source'}
+ <small class="innerError">
+ {if $errorType == 'empty'}
+ {lang}wcf.global.form.error.empty{/lang}
+ {else}
+ {lang}wcf.acp.style.import.source.error.{@$errorType}{/lang}
+ {/if}
+ </small>
+ {/if}
+ <small>{lang}wcf.acp.style.import.source.upload.description{/lang}</small>
+ </dd>
+ </dl>
+
+ {event name='sourceFields'}
+ </fieldset>
+
+ {event name='fieldsets'}
+ </div>
+
+ <div class="formSubmit">
+ <input type="submit" name="submitButton" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
+ </div>
+</form>
+
+{include file='footer'}
\ No newline at end of file
{content}
{if $__wcf->session->getPermission('admin.style.canAddStyle')}
<li><a href="{link controller='StyleAdd'}{/link}" title="{lang}wcf.acp.menu.link.style.add{/lang}" class="button"><img src="{@$__wcf->getPath()}icon/add.svg" alt="" class="icon24" /> <span>{lang}wcf.acp.menu.link.style.add{/lang}</span></a></li>
+ <li><a href="{link controller='StyleImport'}{/link}" title="{lang}wcf.acp.menu.link.style.import{/lang}" class="button"><img src="{@$__wcf->getPath()}icon/upload.svg" alt="" class="icon24" /> <span>{lang}wcf.acp.menu.link.style.import{/lang}</span></a></li>
{/if}
{event name='largeButtons'}
{content}
{if $__wcf->session->getPermission('admin.style.canAddStyle')}
<li><a href="{link controller='StyleAdd'}{/link}" title="{lang}wcf.acp.menu.link.style.add{/lang}" class="button"><img src="{@$__wcf->getPath()}icon/add.svg" alt="" class="icon24" /> <span>{lang}wcf.acp.menu.link.style.add{/lang}</span></a></li>
+ <li><a href="{link controller='StyleImport'}{/link}" title="{lang}wcf.acp.menu.link.style.import{/lang}" class="button"><img src="{@$__wcf->getPath()}icon/upload.svg" alt="" class="icon24" /> <span>{lang}wcf.acp.menu.link.style.import{/lang}</span></a></li>
{/if}
{event name='largeButtons'}
--- /dev/null
+<?php
+namespace wcf\acp\form;
+use wcf\data\style\StyleEditor;
+use wcf\system\exception\UserInputException;
+use wcf\system\WCF;
+use wcf\util\FileUtil;
+
+/**
+ * Shows the style import 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 StyleImportForm extends ACPForm {
+ /**
+ * @see wcf\acp\form\ACPForm::$activeMenuItem
+ */
+ public $activeMenuItem = 'wcf.acp.menu.link.style.import';
+
+ /**
+ * @see wcf\page\AbstractPage::$neededPermissions
+ */
+ public $neededPermissions = array('admin.style.canAddStyle');
+
+ /**
+ * upload data
+ * @var array<string>
+ */
+ public $source = array();
+
+ /**
+ * style editor object
+ * @var wcf\data\style\StyleEditor
+ */
+ public $style = null;
+
+ /**
+ * @see wcf\form\IForm::readFormParameters()
+ */
+ public function readFormParameters() {
+ parent::readFormParameters();
+
+ if (isset($_FILES['source'])) $this->source = $_FILES['source'];
+ }
+
+ /**
+ * @see wcf\form\IForm::validate()
+ */
+ public function validate() {
+ parent::validate();
+
+ if (empty($this->source['name'])) {
+ throw new UserInputException('source');
+ }
+
+ if (empty($this->source['tmp_name'])) {
+ throw new UserInputException('source', 'uploadFailed');
+ }
+
+ // get filename
+ $this->source['name'] = FileUtil::getTemporaryFilename('style_', preg_replace('!^.*(?=\.(?:tar\.gz|tgz|tar)$)!i', '', basename($this->source['name'])));
+
+ if (!@move_uploaded_file($this->source['tmp_name'], $this->source['name'])) {
+ throw new UserInputException('source', 'uploadFailed');
+ }
+
+
+ }
+
+ /**
+ * @see wcf\form\IForm::save()
+ */
+ public function save() {
+ parent::save();
+
+ try {
+ $this->style = StyleEditor::import($this->source['name']);
+ }
+ catch (\Exception $e) {
+ @unlink($this->source['name']);
+ }
+
+ @unlink($this->source['name']);
+ $this->saved();
+
+ WCF::getTPL()->assign('success', true);
+ }
+}
<category name="wcf.acp.menu">
<item name="wcf.acp.menu.link.style"><![CDATA[Stile]]></item>
<item name="wcf.acp.menu.link.style.add"><![CDATA[Stil hinzufügen]]></item>
+ <item name="wcf.acp.menu.link.style.import"><![CDATA[Stil importieren]]></item>
<item name="wcf.acp.menu.link.style.list"><![CDATA[Stile auflisten]]></item>
</category>
<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 102px × 64px 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.importStyle"><![CDATA[Stil importieren]]></item>
+ <item name="wcf.acp.style.import.source"><![CDATA[Datenquelle]]></item>
+ <item name="wcf.acp.style.import.source.upload"><![CDATA[Stil hochladen]]></item>
+ <item name="wcf.acp.style.import.source.upload.description"><![CDATA[Geben Sie eine Stil-Datei von Ihrem lokalen Rechner an.]]></item>
<item name="wcf.acp.style.license"><![CDATA[Lizenz]]></item>
<item name="wcf.acp.style.list"><![CDATA[Stile auflisten]]></item>
<item name="wcf.acp.style.packageName"><![CDATA[Paketbezeichner]]></item>