Added style list page and fixed a few issues
authorAlexander Ebert <ebert@woltlab.com>
Thu, 11 Oct 2012 22:03:22 +0000 (00:03 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 11 Oct 2012 22:03:22 +0000 (00:03 +0200)
acptemplates/styleList.tpl [new file with mode: 0644]
files/acp/js/WCF.ACP.Style.js [new file with mode: 0644]
files/lib/acp/form/StyleAddForm.class.php
files/lib/acp/form/StyleEditForm.class.php
files/lib/acp/page/StyleListPage.class.php [new file with mode: 0644]
files/style/styleEditor.less
language/de.xml

diff --git a/acptemplates/styleList.tpl b/acptemplates/styleList.tpl
new file mode 100644 (file)
index 0000000..c88b7fd
--- /dev/null
@@ -0,0 +1,89 @@
+{include file='header'}
+
+<script type="text/javascript" src="{@$__wcf->getPath()}acp/js/WCF.ACP.Style.js"></script>
+<script type="text/javascript">
+       //<![CDATA[
+       $(function() {
+               new WCF.ACP.Style.List();
+       });
+       //]]>
+</script>
+
+<header class="boxHeadline">
+       <hgroup>
+               <h1>{lang}wcf.acp.style.list{/lang}</h1>
+       </hgroup>
+</header>
+
+<div class="contentNavigation">
+       {pages print=true assign=pagesLinks controller="StyleList" link="pageNo=%d"}
+       
+       {hascontent}
+               <nav>
+                       <ul>
+                               {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>
+                                       {/if}
+
+                                       {event name='largeButtons'}
+                               {/content}
+                       </ul>
+               </nav>
+       {/hascontent}
+</div>
+
+<div class="container marginTop shadow">
+       <ol class="containerList styleList">
+               {foreach from=$objects item=style}
+                       <li>
+                               <div class="previewImage framed"><img src="{@$style->getPreviewImage()}" alt="" /></div>
+                               <div class="styleInformation">
+                                       <hgroup class="containerHeadline">
+                                               <h1><a href="{link controller='StyleEdit' id=$style->styleID}{/link}">{$style->styleName}</a></h1>
+                                               {if $style->styleDescription}<h2>{$style->styleDescription}</h2>{/if}
+                                       </hgroup>
+                                       <ul class="buttonList" data-style-id="{@$style->styleID}">
+                                               <li><a href="{link controller='StyleEdit' id=$style->styleID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><img src="{@$__wcf->getPath()}icon/edit.svg" class="icon16" alt="" /></a></li>
+                                               {if !$style->isDefault}
+                                                       {if !$style->disabled}<li><a title="{lang}wcf.acp.style.button.setAsDefault{/lang}" class="jsSetAsDefault jsTooltip"><img src="{@$__wcf->getPath()}icon/default.svg" class="icon16" alt="" /></a></li>{/if}
+                                                       <li><a title="{lang}wcf.global.button.delete{/lang}" class="jsDelete jsTooltip" data-confirm-message="{lang}wcf.acp.style.delete.confirmMessage{/lang}"><img src="{@$__wcf->getPath()}icon/delete.svg" class="icon16" alt="" /></a></li>
+                                               {/if}
+                                       </ul>
+                                       <dl class="plain inlineDataList">
+                                               <dt>{lang}wcf.acp.style.users{/lang}</dt>
+                                               <dd>{#$style->users}</dd>
+                                       </dl>
+                                       <dl class="plain inlineDataList">
+                                               <dt>{lang}wcf.acp.style.styleVersion{/lang}</dt>
+                                               <dd>{$style->styleVersion} ({$style->styleDate})</dd>
+                                       </dl>
+                                       <dl class="plain inlineDataList">
+                                               <dt>{lang}wcf.acp.style.authorName{/lang}</dt>
+                                               <dd>{if $style->authorURL}<a href="{@$__wcf->getPath()}acp/dereferrer.php?url={$style->authorURL}">{$style->authorName}</a>{else}{$style->authorName}{/if}</dd>
+                                       </dl>
+                               </div>
+                       </li>
+               {/foreach}
+       </ol>
+</div>
+
+<div class="contentNavigation">
+       {@$pagesLinks}
+       
+       {hascontent}
+               <nav>
+                       <ul>
+                               {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>
+                                       {/if}
+
+                                       {event name='largeButtons'}
+                               {/content}
+                       </ul>
+               </nav>
+       {/hascontent}
+</div>
+
+{include file='footer'}
diff --git a/files/acp/js/WCF.ACP.Style.js b/files/acp/js/WCF.ACP.Style.js
new file mode 100644 (file)
index 0000000..9422ae7
--- /dev/null
@@ -0,0 +1,183 @@
+/**
+ * ACP Style related classes.
+ * 
+ * @author     Alexander Ebert
+ * @copyright  2001-2012 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ */
+WCF.ACP.Style = { };
+
+/**
+ * Handles the preview image upload.
+ * 
+ * @param      integer         styleID
+ * @param      string          tmpHash
+ */
+WCF.ACP.Style.ImageUpload = WCF.Upload.extend({
+       /**
+        * upload button
+        * @var jQuery
+        */
+       _button: null,
+       
+       /**
+        * preview image
+        * @var jQuery
+        */
+       _image: null,
+       
+       /**
+        * style id
+        * @var integer
+        */
+       _styleID: 0,
+       
+       /**
+        * tmp hash
+        * @var string
+        */
+       _tmpHash: '',
+       
+       /**
+        * @see WCF.Upload.init()
+        */
+       init: function(styleID, tmpHash) {
+               this._styleID = parseInt(styleID) || 0;
+               this._tmpHash = tmpHash;
+               
+               this._button = $('#uploadImage');
+               this._image = $('#styleImage');
+               
+               this._super(this._button, undefined, 'wcf\\data\\style\\StyleAction');
+       },
+       
+       /**
+        * @see WCF.Upload._initFile()
+        */
+       _initFile: function(file) {
+               return this._image;
+       },
+       
+       /**
+        * @see WCF.Upload._getParameters()
+        */
+       _getParameters: function() {
+               return {
+                       styleID: this._styleID,
+                       tmpHash: this._tmpHash
+               };
+       },
+       
+       /**
+        * @see WCF.Upload._success()
+        */
+       _success: function(uploadID, data) {
+               if (data.returnValues.url) {
+                       // show image
+                       this._image.attr('src', data.returnValues.url);
+                       
+                       // hide error
+                       this._button.next('.innerError').remove();
+                       
+                       // show success message
+                       var $notification = new WCF.System.Notification(WCF.Language.get('wcf.acp.style.image.success'));
+                       $notification.show();
+               }
+               else if (data.returnValues.errorType) {
+                       // show error
+                       this._getInnerErrorElement().text(WCF.Language.get('wcf.acp.style.image.error.' + data.returnValues.errorType));
+               }
+       },
+       
+       /**
+        * Returns error display element.
+        * 
+        * @return      jQuery
+        */
+       _getInnerErrorElement: function() {
+               var $span = this._button.next('.innerError');
+               if (!$span.length) {
+                       $span = $('<small class="innerError" />').insertAfter(this._button);
+               }
+               
+               return $span;
+       }
+});
+
+/**
+ * Handles style list management buttons.
+ */
+WCF.ACP.Style.List = Class.extend({
+       /**
+        * action proxy
+        * @var WCF.Action.Proxy
+        */
+       _proxy: null,
+       
+       /**
+        * Initializes the WCF.ACP.Style.List class.
+        */
+       init: function() {
+               this._proxy = new WCF.Action.Proxy({
+                       success: $.proxy(this._success, this)
+               });
+               
+               $('.styleList .buttonList').each($.proxy(function(index, list) {
+                       var $list = $(list);
+                       var $styleID = $list.data('styleID');
+                       
+                       var self = this;
+                       $list.find('.jsSetAsDefault').click(function() { self._click('setAsDefault', $styleID); });
+                       $list.find('.jsDelete').click(function(event) { self._delete(event, $styleID); });
+               }, this));
+       },
+       
+       /**
+        * Executes actions.
+        * 
+        * @param       string          actionName
+        * @param       integer         styleID
+        */
+       _click: function(actionName, styleID) {
+               this._proxy.setOption('data', {
+                       actionName: actionName,
+                       className: 'wcf\\data\\style\\StyleAction',
+                       objectIDs: [ styleID ]
+               });
+               this._proxy.sendRequest();
+       },
+       
+       /**
+        * Prepares to delete a style.
+        * 
+        * @param       object          event
+        * @param       integer         styleID
+        */
+       _delete: function(event, styleID) {
+               var $confirmMessage = $(event.currentTarget).data('confirmMessage');
+               if ($confirmMessage) {
+                       var self = this;
+                       WCF.System.Confirmation.show($confirmMessage, function(action) {
+                               if (action === 'confirm') {
+                                       self._click('delete', styleID);
+                               }
+                       });
+               }
+               else {
+                       // invoke action directly
+                       this._click('delete', styleID);
+               }
+       },
+       
+       /**
+        * Reloads the page after an action was executed successfully.
+        * 
+        * @param       object          data
+        * @param       string          textStatus
+        * @param       jQuery          jqXHR
+        */
+       _success: function (data, textStatus, jqXHR) {
+               // reload page
+               window.location.reload();
+       }
+});
index c2cbef40e103c77a3f8152b3604668d06cf60f6d..2e8dd98c460d7058d12b1545f8d021516771abe3 100644 (file)
@@ -115,6 +115,11 @@ class StyleAddForm extends ACPForm {
         */
        public $license = '';
        
+       /**
+        * @see wcf\page\AbstractPage::$neededPermissions
+        */
+       public $neededPermissions = array('admin.style.canAddStyle');
+       
        /**
         * last change date
         * @var string
index d715c688c2043f1e33f9f5be0b6c0ddd3a4cb294..35d0bdabd4f6b428f9f96ffe518b64559f2416c2 100644 (file)
@@ -17,6 +17,16 @@ use wcf\system\WCF;
  * @category   Community Framework
  */
 class StyleEditForm extends StyleAddForm {
+       /**
+        * @see wcf\acp\form\ACPForm::$activeMenuItem
+        */
+       public $activeMenuItem = 'wcf.acp.menu.link.style';
+       
+       /**
+        * @see wcf\page\AbstractPage::$neededPermissions
+        */
+       public $neededPermissions = array('admin.style.canEditStyle');
+       
        /**
         * style object
         * @var wcf\data\style\Style
diff --git a/files/lib/acp/page/StyleListPage.class.php b/files/lib/acp/page/StyleListPage.class.php
new file mode 100644 (file)
index 0000000..052367e
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+namespace wcf\acp\page;
+use wcf\page\MultipleLinkPage;
+use wcf\system\menu\acp\ACPMenu;
+
+/**
+ * Shows the style list page.
+ * 
+ * @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.page
+ * @category   Community Framework
+ */
+class StyleListPage extends MultipleLinkPage {
+       /**
+        * @see wcf\page\AbstractPage::$neededPermissions
+        */
+       public $neededPermissions = array('admin.style.canEditStyle', 'admin.style.canDeleteStyle');
+       
+       /**
+        * @see wcf\page\MultipleLinkPage::$objectListClassName
+        */
+       public $objectListClassName = 'wcf\data\style\StyleList';
+       
+       /**
+        * @see wcf\page\MultipleLinkPage::$sortField
+        */
+       public $sortField = 'style.styleName';
+       
+       /**
+        * @see wcf\page\MultipleLinkPage::$sortOrder
+        */
+       public $sortOrder = 'ASC';
+       
+       public function initObjectList() {
+               parent::initObjectList();
+               
+               $this->objectList->sqlSelects = "(SELECT COUNT(*) FROM wcf".WCF_N."_user WHERE styleID = style.styleID) AS users";
+       }
+       
+       /**
+        * @see wcf\page\IPage::show()
+        */
+       public function show() {
+               // set active menu item.
+               ACPMenu::getInstance()->setActiveMenuItem('wcf.acp.menu.link.style.list');
+       
+               parent::show();
+       }
+}
index 080f901172786412be18863a3694f17a57cf2b99..4d4a97df9b170a208c2420e5cafb9acf07198e82 100644 (file)
                content: "";
                display: block;
        }
-}
\ No newline at end of file
+}
+
+.styleList > li {
+       min-height: 150px;
+       
+       &:hover > .styleInformation > .buttonList {
+               opacity: 1;
+       }
+       
+       > .previewImage {
+               float: left;
+               text-align: center;
+               width: 230px;
+       }
+       
+       > .styleInformation {
+               margin-left: 250px;
+               position: relative;
+               
+               > .buttonList {
+                       opacity: 0;
+                       position: absolute;
+                       right: 0;
+                       top: 0;
+                       
+                       .transition(opacity, .1s);
+                       
+                       > li:not(:last-child) {
+                               margin-right: 7px;
+                       }
+               }
+       }
+} 
\ No newline at end of file
index dc939d64813cbdc7723facfcb2c6f94bf53c0ad7..bace34250b1678eb2d57190d4ebfd10175f95943 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.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.colors.backgroundColor"><![CDATA[Hintergrundfarbe]]></item>
@@ -31,6 +32,7 @@
                <item name="wcf.acp.style.colors.tabular"><![CDATA[Tabellarische Auflistungen]]></item>
                <item name="wcf.acp.style.colors.userPanel"><![CDATA[Benutzerleiste]]></item>
                <item name="wcf.acp.style.copyright"><![CDATA[Copyright]]></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.general"><![CDATA[Daten]]></item>
                <item name="wcf.acp.style.general.data"><![CDATA[Allgemein]]></item>
                <item name="wcf.acp.style.general.files"><![CDATA[Dateien]]></item>
                <item name="wcf.acp.style.globals.layout"><![CDATA[Layout]]></item>
                <item name="wcf.acp.style.globals.useFluidLayout"><![CDATA[Flexible Breite verwenden]]></item>
                <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 &laquo;icons&raquo; ablegen. Geben Sie hier den Pfad zu diesem Ordner an.]]></item>
+               <item name="wcf.acp.style.iconPath.description"><![CDATA[Wenn Ihr Stil eigene Icons benötigt, sollten diese in einem Unterordner des Ordners &bdquo;icons&ldquo; 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 &laquo;images&raquo; ablegen. Geben Sie hier den Pfad zu diesem Ordner an.]]></item>
+               <item name="wcf.acp.style.imagePath.description"><![CDATA[Wenn Ihr Stil eigene Grafiken benötigt, sollten diese in einem Unterordner des Ordners &bdquo;images&ldquo; ablegen. Geben Sie hier den Pfad zu diesem Ordner 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.styleDate"><![CDATA[Datum]]></item>
                <item name="wcf.acp.style.styleDescription"><![CDATA[Beschreibung]]></item>
                <item name="wcf.acp.style.styleName"><![CDATA[Name]]></item>
                <item name="wcf.acp.style.styleVersion"><![CDATA[Version]]></item>
                <item name="wcf.acp.style.templateGroupID"><![CDATA[Template-Gruppe]]></item>
+               <item name="wcf.acp.style.users"><![CDATA[Benutzer]]></item>
        </category>
 </language>