Added HTML support for paid subscriptions
authorAlexander Ebert <ebert@woltlab.com>
Fri, 10 Mar 2017 13:20:43 +0000 (14:20 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 10 Mar 2017 13:20:43 +0000 (14:20 +0100)
See #2188

com.woltlab.wcf/objectType.xml
com.woltlab.wcf/templates/paidSubscriptionList.tpl
wcfsetup/install/files/acp/templates/paidSubscriptionAdd.tpl
wcfsetup/install/files/lib/data/paid/subscription/PaidSubscription.class.php

index 3994c310a3fd4341acfee518c4749f4590c59b3d..7d74a8cd2fdcaae2609229f1380a7751f11581e0 100644 (file)
                        <name>com.woltlab.wcf.comment</name>
                        <definitionname>com.woltlab.wcf.message</definitionname>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.paidSubscription</name>
+                       <definitionname>com.woltlab.wcf.message</definitionname>
+               </type>
                
                <type>
                        <name>com.woltlab.wcf.bbcode.smiley</name>
index dae7fa836dd11ee8df9ed37492e1442fc41f81e0..66d32e3127c248715db95c74955ffef928817e9a 100644 (file)
@@ -42,7 +42,7 @@
                                <li>
                                        <div class="containerHeadline">
                                                <h3>{$subscription->title|language} <span class="badge label">{lang}wcf.paidSubscription.formattedCost{/lang}</span></h3>
-                                               <p>{@$subscription->description|language|newlineToBreak}</p>
+                                               <p>{@$subscription->getFormattedDescription()}</p>
                                        </div>
                                        
                                        <div class="containerContent">
index 33e645c6f5ff78a7d8edd3cb49de3f8bd8844f2c..38ec67feba770edb25dd6e9ea18cd364a4740add 100644 (file)
                <dl{if $errorField == 'description'} class="formError"{/if}>
                        <dt><label for="description">{lang}wcf.global.description{/lang}</label></dt>
                        <dd>
-                               <textarea id="description" name="description" cols="40" rows="10">{$i18nPlainValues[description]}</textarea>
+                               <textarea id="description" name="description" class="wysiwygTextarea"
+                                         data-disable-attachments="true"
+                                         data-disable-media="true"
+                               >{$i18nPlainValues[description]}</textarea>
+                               {include file='wysiwyg' wysiwygSelector='description'}
                                {if $errorField == 'description'}
                                        <small class="innerError">
                                                {if $errorType == 'empty'}
index 24e8fac0cbb4566c2e34e750ba00b2a2765e5853..d6a257d25bec79d09f67a14813fb19560503eb02 100644 (file)
@@ -2,6 +2,7 @@
 namespace wcf\data\paid\subscription;
 use wcf\data\object\type\ObjectTypeCache;
 use wcf\data\DatabaseObject;
+use wcf\system\html\output\HtmlOutputProcessor;
 use wcf\system\payment\method\PaymentMethodHandler;
 use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
@@ -57,4 +58,34 @@ class PaidSubscription extends DatabaseObject {
        public function getDateInterval() {
                return new \DateInterval('P' . $this->subscriptionLength . $this->subscriptionLengthUnit);
        }
+       
+       /**
+        * Returns the formatted description, with support for legacy descriptions without HTML.
+        * 
+        * @return      string
+        */
+       public function getFormattedDescription() {
+               $description = $this->getDescription();
+               if (preg_match('~^<[a-z]+~', $description)) {
+                       $processor = new HtmlOutputProcessor();
+                       $processor->process($description, 'com.woltlab.wcf.paidSubscription', $this->subscriptionID);
+                       
+                       return $processor->getHtml();
+               }
+               
+               return nl2br($description, false);
+       }
+       
+       /**
+        * Returns the description with transparent handling of phrases.
+        * 
+        * @return      string
+        */
+       protected function getDescription() {
+               if (preg_match('~^wcf.paidSubscription.subscription\d+.description$~', $this->description)) {
+                       return WCF::getLanguage()->get($this->description);
+               }
+               
+               return $this->description;
+       }
 }