Add smileyPath to smiley administration
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 24 May 2013 19:54:38 +0000 (21:54 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 24 May 2013 19:54:38 +0000 (21:54 +0200)
Closes #1296

wcfsetup/install/files/acp/templates/smileyAdd.tpl
wcfsetup/install/files/lib/acp/form/SmileyAddForm.class.php
wcfsetup/install/files/lib/acp/form/SmileyEditForm.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index bc586a76066b9babaffd78daa2218f608e68382b..c8f5c5e3d7a0147dde2a13f5a8fc2ecb808b4188 100644 (file)
@@ -34,6 +34,7 @@
                                <dt><label for="smileyTitle">{lang}wcf.acp.smiley.title{/lang}</label></dt>
                                <dd>
                                        <input type="text" id="smileyTitle" name="smileyTitle" value="{$smileyTitle}" autofocus="autofocus" class="long" />
+                                       
                                        {if $errorField == 'smileyTitle'}
                                                <small class="innerError">
                                                        {if $errorType == 'empty'}
@@ -72,6 +73,7 @@
                                <dt><label for="smileyCode">{lang}wcf.acp.smiley.smileyCode{/lang}</label></dt>
                                <dd>
                                        <input type="text" id="smileyCode" name="smileyCode" value="{$smileyCode}" required="required" class="medium" />
+                                       
                                        {if $errorField == 'smileyCode'}
                                                <small class="innerError">
                                                        {if $errorType == 'empty'}
                                </dd>
                        </dl>
                        
+                       <dl{if $errorField == 'smileyPath'} class="formError"{/if}>
+                               <dt><label for="smileyPath">{lang}wcf.acp.smiley.smileyPath{/lang}</label></dt>
+                               <dd>
+                                       <input type="text" id="smileyPath" name="smileyPath" value="{$smileyPath}" required="required" class="long" />
+                                       
+                                       {if $errorField == 'smileyPath'}
+                                               <small class="innerError">
+                                                       {if $errorType == 'empty'}
+                                                               {lang}wcf.global.form.error.empty{/lang}
+                                                       {else}
+                                                               {lang}wcf.acp.smiley.smileyPath.error.{@$errorType}{/lang}
+                                                       {/if}
+                                               </small>
+                                       {/if}
+                                       <small>{lang}wcf.acp.smiley.smileyPath.description{/lang}</small>
+                               </dd>
+                       </dl>
+                       
                        <dl{if $errorField == 'showOrder'} class="formError"{/if}>
                                <dt><label for="showOrder">{lang}wcf.acp.smiley.showOrder{/lang}</label></dt>
                                <dd>
index 10a0dbd7000bddd3a86fb6b3110c35e87e586a27..31fbcf7ce5fea906a9b6871486e86d452d244d75 100644 (file)
@@ -10,6 +10,7 @@ use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\exception\UserInputException;
 use wcf\system\language\I18nHandler;
 use wcf\system\WCF;
+use wcf\util\FileUtil;
 use wcf\util\StringUtil;
 
 /**
@@ -68,6 +69,12 @@ class SmileyAddForm extends AbstractForm {
         */
        public $aliases = '';
        
+       /**
+        * smileyPath
+        * @var string
+        */
+       public $smileyPath = '';
+       
        /**
         * node tree with available smiley categories
         * @var wcf\data\category\CategoryNodeTree
@@ -89,6 +96,7 @@ class SmileyAddForm extends AbstractForm {
                        'categoryID' => $this->categoryID,
                        'smileyCode' => $this->smileyCode,
                        'aliases' => $this->aliases,
+                       'smileyPath' => $this->smileyPath,
                        'categoryNodeList' => $this->categoryNodeTree->getIterator()
                ));
        }
@@ -122,18 +130,11 @@ class SmileyAddForm extends AbstractForm {
                
                if (I18nHandler::getInstance()->isPlainValue('smileyTitle')) $this->smileyTitle = I18nHandler::getInstance()->getValue('smileyTitle');
                
-               if (isset($_POST['showOrder'])) {
-                       $this->showOrder = intval($_POST['showOrder']);
-               }
-               if (isset($_POST['smileyCode'])) {
-                       $this->smileyCode = StringUtil::trim($_POST['smileyCode']);
-               }
-               if (isset($_POST['categoryID'])) {
-                       $this->categoryID = intval($_POST['categoryID']);
-               }
-               if (isset($_POST['aliases'])) {
-                       $this->aliases = StringUtil::unifyNewlines(StringUtil::trim($_POST['aliases']));
-               }
+               if (isset($_POST['showOrder'])) $this->showOrder = intval($_POST['showOrder']);
+               if (isset($_POST['categoryID'])) $this->categoryID = intval($_POST['categoryID']);
+               if (isset($_POST['smileyCode'])) $this->smileyCode = StringUtil::trim($_POST['smileyCode']);
+               if (isset($_POST['aliases'])) $this->aliases = StringUtil::unifyNewlines(StringUtil::trim($_POST['aliases']));
+               if (isset($_POST['smileyPath'])) $this->smileyPath = FileUtil::removeLeadingSlash(StringUtil::trim($_POST['smileyPath']));
        }
        
        /**
@@ -146,10 +147,11 @@ class SmileyAddForm extends AbstractForm {
                        'data' => array(
                                'smileyTitle' => $this->smileyTitle,
                                'smileyCode' => $this->smileyCode,
+                               'aliases' => $this->aliases,
+                               'smileyPath' => $this->smileyPath,
                                'showOrder' => $this->showOrder,
                                'categoryID' => $this->categoryID ?: null,
-                               'packageID' => 1,
-                               'aliases' => $this->aliases
+                               'packageID' => 1
                        )
                ));
                $this->objectAction->executeAction();
@@ -201,6 +203,14 @@ class SmileyAddForm extends AbstractForm {
                        throw new UserInputException('smileyCode');
                }
                
+               if (empty($this->smileyPath)) {
+                       throw new UserInputException('smileyPath');
+               }
+               
+               if (!file_exists(WCF_DIR.$this->smileyPath)) {
+                       throw new UserInputException('smileyPath', 'notFound');
+               }
+               
                // validate smiley code and aliases against existing smilies
                $conditionBuilder = new PreparedStatementConditionBuilder();
                if (isset($this->smiley)) {
index 694fff843f6bb8c380fc2f8bb061c7c402b95f85..38bb5c8a3ce8c4505d8264538762de4d26dcd794 100644 (file)
@@ -73,9 +73,10 @@ class SmileyEditForm extends SmileyAddForm {
                $this->objectAction = new SmileyAction(array($this->smileyID), 'update', array('data' => array(
                        'smileyTitle' => $this->smileyTitle,
                        'smileyCode' => $this->smileyCode,
+                       'aliases' => $this->aliases,
+                       'smileyPath' => $this->smileyPath,
                        'showOrder' => $this->showOrder,
-                       'categoryID' => $this->categoryID ?: null,
-                       'aliases' => $this->aliases
+                       'categoryID' => $this->categoryID ?: null
                )));
                $this->objectAction->executeAction();
                
@@ -99,6 +100,7 @@ class SmileyEditForm extends SmileyAddForm {
                        
                        $this->smileyCode = $this->smiley->smileyCode;
                        $this->aliases = $this->smiley->aliases;
+                       $this->smileyPath = $this->smiley->smileyPath;
                        $this->showOrder = $this->smiley->showOrder;
                        $this->categoryID = $this->smiley->categoryID;
                }
index 3f92b63eca775aad72bcd303fbef3f56493624c4..f4da99d089c85bc45b1952a7ec211ed0dde8e47d 100644 (file)
                <item name="wcf.acp.smiley.category.list"><![CDATA[Smiley-Kategorien]]></item>
                <item name="wcf.acp.smiley.categoryID"><![CDATA[Kategorie]]></item>
                <item name="wcf.acp.smiley.categoryID.default"><![CDATA[Standard-Kategorie]]></item>
-               <item name="wcf.acp.smiley.categoryID.error.notValid"><![CDATA[Die gewählte Kategorie ist nicht gültig.]]></item>
+               <item name="wcf.acp.smiley.categoryID.error.notValid"><![CDATA[Die gewählte Kategorie ist nicht gültig]]></item>
                <item name="wcf.acp.smiley.smileyCode"><![CDATA[Primärer Smiley-Code]]></item>
                <item name="wcf.acp.smiley.smileyCode.error.notUnique"><![CDATA[Dieser Smiley-Code wird bereits von einem anderen Smiley verwendet]]></item>
                <item name="wcf.acp.smiley.aliases"><![CDATA[Alternative Smiley-Codes]]></item>
                <item name="wcf.acp.smiley.aliases.error.notUnique"><![CDATA[Mindestens ein alternativer Smiley-Code wird bereits von einem anderen Smiley verwendet]]></item>
+               <item name="wcf.acp.smiley.smileyPath"><![CDATA[Smiley-Pfad]]></item>
+               <item name="wcf.acp.smiley.smileyPath.description"><![CDATA[Der Smiley-Pfad wird relativ zu „{$__wcf->getPath()}“ interpretiert.]]></item>
+               <item name="wcf.acp.smiley.smileyPath.error.notFound"><![CDATA[Es wurde keine Datei unter dem angegebenen Pfad gefunden]]></item>
                <item name="wcf.acp.smiley.showOrder"><![CDATA[Position]]></item>
        </category>
        
index 310f46714c61a69e7036e937d6a413ce4927b90b..ef4f6f0deb6bf4249b4de589281adeb80ff69c9f 100644 (file)
@@ -941,11 +941,14 @@ Examples for medium ID detection:
                <item name="wcf.acp.smiley.category.list"><![CDATA[Smiley Categories]]></item>
                <item name="wcf.acp.smiley.categoryID"><![CDATA[Category]]></item>
                <item name="wcf.acp.smiley.categoryID.default"><![CDATA[Default Category]]></item>
-               <item name="wcf.acp.smiley.categoryID.error.notValid"><![CDATA[Chosen category is invalid.]]></item>
+               <item name="wcf.acp.smiley.categoryID.error.notValid"><![CDATA[Chosen category is invalid]]></item>
                <item name="wcf.acp.smiley.smileyCode"><![CDATA[Primary Smiley Code]]></item>
                <item name="wcf.acp.smiley.smileyCode.error.notUnique"><![CDATA[This smiley code is already in use by an other smiley]]></item>
                <item name="wcf.acp.smiley.aliases"><![CDATA[Alternative Smiley Codes]]></item>
                <item name="wcf.acp.smiley.aliases.error.notUnique"><![CDATA[At least one alternative smiley code is already in use by an other smiley]]></item>
+               <item name="wcf.acp.smiley.smileyPath"><![CDATA[Smiley Path]]></item>
+               <item name="wcf.acp.smiley.smileyPath.description"><![CDATA[TODO: Der Smiley-Pfad wird relativ zu „{$__wcf->getPath()}“ interpretiert.]]></item>
+               <item name="wcf.acp.smiley.smileyPath.error.notFound"><![CDATA[TODO: Es wurde keine Datei unter dem angegebenen Pfad gefunden]]></item>
                <item name="wcf.acp.smiley.showOrder"><![CDATA[Show Order]]></item>
        </category>