Added form to export styles
authorAlexander Ebert <ebert@woltlab.com>
Fri, 12 Oct 2012 01:29:47 +0000 (03:29 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 12 Oct 2012 01:29:47 +0000 (03:29 +0200)
acptemplates/styleExport.tpl [new file with mode: 0644]
files/lib/acp/form/StyleExportForm.class.php [new file with mode: 0644]
language/de.xml

diff --git a/acptemplates/styleExport.tpl b/acptemplates/styleExport.tpl
new file mode 100644 (file)
index 0000000..cc6ad03
--- /dev/null
@@ -0,0 +1,47 @@
+{include file='header'}
+
+<header class="boxHeadline">
+       <hgroup>
+               <h1>{lang}wcf.acp.style.exportStyle{/lang}</h1>
+       </hgroup>
+</header>
+
+<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='StyleExport'}{/link}">
+       <div class="container containerPadding marginTop shadow">
+               <fieldset>
+                       <legend>{lang}wcf.acp.style.exportStyle.components{/lang}</legend>
+                       <small>{lang}wcf.acp.style.exportStyle.components.description{/lang}</small>
+                       
+                       <dl>
+                               <dd>
+                                       <label><input type="checkbox" name="exportIcons" value="1"{if $exportIcons} checked="checked"{/if}{if !$canExportIcons} disabled="disabled"{/if} /> <span>{lang}wcf.acp.style.exportIcons{/lang}</span></label>
+                               </dd>
+                       </dl>
+                       <dl>
+                               <dd>
+                                       <label><input type="checkbox" name="exportImages" value="1"{if $exportImages} checked="checked"{/if}{if !$canExportImages} disabled="disabled"{/if} /> <span>{lang}wcf.acp.style.exportImages{/lang}</span></label>
+                               </dd>
+                       </dl>
+                       <dl>
+                               <dd>
+                                       <label><input type="checkbox" name="exportTemplates" value="1"{if $exportTemplates} checked="checked"{/if}{if !$canExportTemplates} disabled="disabled"{/if} /> <span>{lang}wcf.acp.style.exportTemplates{/lang}</span></label>
+                               </dd>
+                       </dl>
+               </fieldset>
+       </div>
+       
+       <div class="formSubmit">
+               <input type="submit" value="{lang}wcf.acp.style.button.exportStyle{/lang}" accesskey="s" />
+               <input type="hidden" name="id" value="{@$styleID}" />
+       </div>
+</form>
+
+{include file='footer'}
\ No newline at end of file
diff --git a/files/lib/acp/form/StyleExportForm.class.php b/files/lib/acp/form/StyleExportForm.class.php
new file mode 100644 (file)
index 0000000..3cdf15b
--- /dev/null
@@ -0,0 +1,142 @@
+<?php
+namespace wcf\acp\form;
+use wcf\data\style\Style;
+use wcf\data\style\StyleEditor;
+use wcf\form\AbstractForm;
+use wcf\system\exception\IllegalLinkException;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * Shows the style export 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 StyleExportForm extends AbstractForm {
+       /**
+        * true, if style has custom icons
+        * @var boolean
+        */
+       public $canExportIcons = false;
+       
+       /**
+        * true, if style has custom images
+        * @var boolean
+        */
+       public $canExportImages = false;
+       
+       /**
+        * true, if style has custom templates
+        * @var boolean
+        */
+       public $canExportTemplates = false;
+       
+       /**
+        * true, if icons should be exported
+        * @var boolean
+        */
+       public $exportIcons = false;
+       
+       /**
+        * true, if images should be exported
+        * @var boolean
+        */
+       public $exportImages = false;
+       
+       /**
+        * true, if templates should be exported
+        * @var boolean
+        */
+       public $exportTemplates = false;
+       
+       /**
+        * @see wcf\page\AbstractPage::$neededPermissions
+        */
+       public $neededPermissions = array('admin.style.canEditStyle');
+       
+       /**
+        * 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() {
+               parent::readParameters();
+               
+               if (isset($_REQUEST['id'])) $this->styleID = intval($_REQUEST['id']);
+               $this->style = new Style($this->styleID);
+               if (!$this->style->styleID) {
+                       throw new IllegalLinkException();
+               }
+               
+               if ($this->style->iconPath && $this->style->iconPath != 'icon/') $this->canExportIcons = true;
+               if ($this->style->imagePath && $this->style->imagePath != 'images/') $this->canExportImages = true;
+               if ($this->style->templateGroupID) $this->canExportTemplates = true;
+       }
+       
+       /**
+        * @see wcf\form\IForm::readFormParameters()
+        */
+       public function readFormParameters() {
+               parent::readFormParameters();
+               
+               if ($this->canExportIcons && isset($_POST['exportIcons'])) $this->exportIcons = true;
+               if ($this->canExportImages && isset($_POST['exportImages'])) $this->exportImages = true;
+               if ($this->canExportTemplates && isset($_POST['exportTemplates'])) $this->exportTemplates = true;
+       }
+       
+       /**
+        * @see wcf\form\IForm::save()
+        */
+       public function save() {
+               parent::save();
+               
+               // get style filename
+               $filename = str_replace(' ', '-', preg_replace('/[^a-z0-9 _-]/', '', StringUtil::toLowerCase($this->style->styleName)));
+               
+               // send headers
+               header('Content-Type: application/x-gzip; charset=utf-8');
+               header('Content-Disposition: attachment; filename="'.$filename.'-style.tgz"');
+               
+               // export style
+               $styleEditor = new StyleEditor($this->style);
+               $styleEditor->export($this->exportTemplates, $this->exportImages, $this->exportIcons);
+               
+               // call saved event
+               $this->saved();
+               
+               exit;
+       }
+       
+       /**
+        * @see wcf\form\IForm::assignVariables()
+        */
+       public function assignVariables() {
+               parent::assignVariables();
+               
+               WCF::getTPL()->assign(array(
+                       'canExportIcons' => $this->canExportIcons,
+                       'canExportImages' => $this->canExportImages,
+                       'canExportTemplates' => $this->canExportTemplates,
+                       'exportIcons' => $this->exportIcons,
+                       'exportImages' => $this->exportImages,
+                       'exportTemplates' => $this->exportTemplates,
+                       'style' => $this->style,
+                       'styleID' => $this->styleID
+               ));
+       }
+}
index 11df8064581411043f4d5d98b17419335594a5c5..250e3306aa4b75afed139b49650ba14274d7d9c5 100644 (file)
@@ -10,6 +10,7 @@
                <item name="wcf.acp.style.add"><![CDATA[Stil hinzufügen]]></item>
                <item name="wcf.acp.style.authorName"><![CDATA[Autor]]></item>
                <item name="wcf.acp.style.authorURL"><![CDATA[Website]]></item>
+               <item name="wcf.acp.style.button.exportStyle"><![CDATA[Export starten]]></item>
                <item name="wcf.acp.style.button.setAsDefault"><![CDATA[Zum Standard machen]]></item>
                <item name="wcf.acp.style.colors"><![CDATA[Farbpalette]]></item>
                <item name="wcf.acp.style.colors.accentBackgroundColor"><![CDATA[Hintergrundfarbe (Akzent)]]></item>
                <item name="wcf.acp.style.copyStyle.confirmMessage"><![CDATA[Möchten Sie den Stil &bdquo;{$style->styleName}&ldquo; wirklich duplizieren?]]></item>
                <item name="wcf.acp.style.delete.confirmMessage"><![CDATA[Möchten Sie den Stil &bdquo;{$style->styleName}&ldquo; wirklich löschen?]]></item>
                <item name="wcf.acp.style.edit"><![CDATA[Stil bearbeiten]]></item>
+               <item name="wcf.acp.style.exportIcons"><![CDATA[Icons exportieren ({$style->iconPath})]]></item>
+               <item name="wcf.acp.style.exportImages"><![CDATA[Grafiken exportieren ({$style->imagePath})]]></item>
+               <item name="wcf.acp.style.exportTemplates"><![CDATA[Templates exportieren]]></item>
                <item name="wcf.acp.style.exportStyle"><![CDATA[Stil exportieren]]></item>
+               <item name="wcf.acp.style.exportStyle.components"><![CDATA[Optionen]]></item>
+               <item name="wcf.acp.style.exportStyle.components.description"><![CDATA[Wählen Sie hier aus, welche Bestandteile des Stils &bdquo;{$style->styleName}&ldquo; mit exportiert werden sollen]]></item>
                <item name="wcf.acp.style.general"><![CDATA[Daten]]></item>
                <item name="wcf.acp.style.general.data"><![CDATA[Allgemein]]></item>
                <item name="wcf.acp.style.general.files"><![CDATA[Dateien]]></item>