Add html support for media caption
authorMatthias Schmidt <gravatronics@live.com>
Sun, 16 Sep 2018 16:32:36 +0000 (18:32 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 16 Sep 2018 16:32:36 +0000 (18:32 +0200)
Close #2722

com.woltlab.wcf/templates/mediaBBCodeTag.tpl
com.woltlab.wcf/templates/mediaEditor.tpl
wcfsetup/install/files/acp/templates/mediaBBCodeTag.tpl
wcfsetup/install/files/acp/templates/mediaEditor.tpl
wcfsetup/install/files/js/WoltLabSuite/Core/Media/Editor.js
wcfsetup/install/files/lib/data/media/Media.class.php
wcfsetup/install/files/lib/data/media/MediaAction.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml
wcfsetup/setup/db/install.sql

index e80ee2c1ed336c4cd524b29e88c840d40cb3294f..ac0fc85d2439b61515b242312329239a131b6377 100644 (file)
@@ -1,4 +1,4 @@
-<span class="mediaBBCode{if $float != 'none'} messageFloatObject{$float|ucfirst}{/if}">
+<div class="mediaBBCode{if $float != 'none'} messageFloatObject{$float|ucfirst}{/if}">
        {if $thumbnailSize != 'original'}
                <a href="{$media->getLink()}" class="embeddedAttachmentLink jsImageViewer"><img src="{$media->getThumbnailLink($thumbnailSize)}" alt="{$media->altText}" title="{$media->title}" data-width="{@$media->getThumbnailWidth($thumbnailSize)}" data-height="{@$media->getThumbnailHeight($thumbnailSize)}"></a>
        {else}
@@ -6,6 +6,12 @@
        {/if}
        
        {if $media->caption}
-               <span class="mediaBBCodeCaption">{$media->caption}</span>
+               <div class="mediaBBCodeCaption">
+                       {if $media->captionEnableHtml}
+                               {@$media->caption}
+                       {else}
+                               {$media->caption}
+                       {/if}
+               </div>
        {/if}
-</span>
+</div>
index 490dba173088ba4b122ce69bd5f276866f0f98ec..e6ffc7cfcbecfeb7262b1b2ab2b70d32d4192ddd 100644 (file)
                {if $availableLanguages|count > 1}
                        {include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true}
                {/if}
-       
+               
+               <dl>
+                       <dt></dt>
+                       <dd>
+                               <label>
+                                       <input type="checkbox" name="captionEnableHtml" value="1"{if $media->captionEnableHtml} checked{/if}>
+                                       <span>{lang}wcf.media.caption.enableHtml{/lang}</span>
+                               </label>
+                       </dd>
+               </dl>
+               
                <dl>
                        <dt><label for="altText_{@$media->mediaID}">{lang}wcf.media.altText{/lang}</label></dt>
                        <dd>
index e80ee2c1ed336c4cd524b29e88c840d40cb3294f..ac0fc85d2439b61515b242312329239a131b6377 100644 (file)
@@ -1,4 +1,4 @@
-<span class="mediaBBCode{if $float != 'none'} messageFloatObject{$float|ucfirst}{/if}">
+<div class="mediaBBCode{if $float != 'none'} messageFloatObject{$float|ucfirst}{/if}">
        {if $thumbnailSize != 'original'}
                <a href="{$media->getLink()}" class="embeddedAttachmentLink jsImageViewer"><img src="{$media->getThumbnailLink($thumbnailSize)}" alt="{$media->altText}" title="{$media->title}" data-width="{@$media->getThumbnailWidth($thumbnailSize)}" data-height="{@$media->getThumbnailHeight($thumbnailSize)}"></a>
        {else}
@@ -6,6 +6,12 @@
        {/if}
        
        {if $media->caption}
-               <span class="mediaBBCodeCaption">{$media->caption}</span>
+               <div class="mediaBBCodeCaption">
+                       {if $media->captionEnableHtml}
+                               {@$media->caption}
+                       {else}
+                               {$media->caption}
+                       {/if}
+               </div>
        {/if}
-</span>
+</div>
index e5ad67186f2860c6f006b82e6f22d578469541bd..e6ffc7cfcbecfeb7262b1b2ab2b70d32d4192ddd 100644 (file)
                        {include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true}
                {/if}
                
+               <dl>
+                       <dt></dt>
+                       <dd>
+                               <label>
+                                       <input type="checkbox" name="captionEnableHtml" value="1"{if $media->captionEnableHtml} checked{/if}>
+                                       <span>{lang}wcf.media.caption.enableHtml{/lang}</span>
+                               </label>
+                       </dd>
+               </dl>
+               
                <dl>
                        <dt><label for="altText_{@$media->mediaID}">{lang}wcf.media.altText{/lang}</label></dt>
                        <dd>
index a68e56715730e81a2db481ec424e33d785ce6964..0d8d629b9b4b851155993c91773a4e81839b24bf 100644 (file)
@@ -120,6 +120,7 @@ define(
                        var categoryId = elBySel('select[name=categoryID]', content);
                        var altText = elBySel('input[name=altText]', content);
                        var caption = elBySel('textarea[name=caption]', content);
+                       var captionEnableHtml = elBySel('input[name=captionEnableHtml]', content);
                        var title = elBySel('input[name=title]', content);
                        
                        var hasError = false;
@@ -190,6 +191,9 @@ define(
                                this._media.title[this._media.languageID] = title.value;
                        }
                        
+                       // captionEnableHtml
+                       this._media.captionEnableHtml = ~~elBySel('input[name=captionEnableHtml]', content).checked;
+                       
                        var aclValues = {
                                allowAll: ~~elById('mediaEditor_' + this._media.mediaID + '_aclAllowAll').checked,
                                group: [],
@@ -219,6 +223,7 @@ define(
                                                altText: this._media.altText,
                                                caption: this._media.caption,
                                                data: {
+                                                       captionEnableHtml: this._media.captionEnableHtml,
                                                        categoryID: this._media.categoryID,
                                                        isMultilingual: this._media.isMultilingual,
                                                        languageID: this._media.languageID
index 9ba7c42083d919d850502584d5092568a0efd35e..a622c2444b39b6aae62395e970b3f3e6c61a5e47 100644 (file)
@@ -28,6 +28,7 @@ use wcf\system\WCF;
  * @property-read      string          $username               name of the user who uploaded the media file
  * @property-read      integer|null    $languageID             id of the language associated with the media file or null if the media file is multilingual or if the language has been deleted
  * @property-read      integer         $isMultilingual         is `1` if the media file's title, description and altText is available in multiple languages, otherwise `0`
+ * @property-read      integer         $captionEnableHtml      is `1` if html code in caption is supported, otherwise `0`
  * @property-read      integer         $isImage                is `1` if the media file is an image, otherwise `0`
  * @property-read      integer         $width                  width of the media file if `$isImage` is `1`, otherwise `0`
  * @property-read      integer         $height                 height of the media file if `$isImage` is `1`, otherwise `0`
index a0090eaed0d162040ba303f1c7f9d4f5db01949a..d8b63d9209b478dc24359a417efda1380d3f3b7c 100644 (file)
@@ -145,6 +145,7 @@ class MediaAction extends AbstractDatabaseObjectAction implements ISearchAction,
                return [
                        'altText' => $media instanceof ViewableMedia ? $media->altText : [],
                        'caption' => $media instanceof ViewableMedia ? $media->caption : [],
+                       'captionEnableHtml' => $media->captionEnableHtml,
                        'categoryID' => $media->categoryID,
                        'fileHash' => $media->fileHash,
                        'filename' => $media->filename,
index 265cbff11afe4f2a95faad13ce3759106a114d9a..864924ea3db095ac2de3de1d821d99c77e8e0333 100644 (file)
@@ -3189,6 +3189,7 @@ E-Mail-Adresse: {@$emailAddress} {* this line ends with a space *}
                <item name="wcf.media.button.insert"><![CDATA[Einfügen]]></item>
                <item name="wcf.media.button.select"><![CDATA[Auswählen]]></item>
                <item name="wcf.media.caption"><![CDATA[Bildunterschrift]]></item>
+               <item name="wcf.media.caption.enableHtml"><![CDATA[HTML in der Bildunterschrift verwenden]]></item>
                <item name="wcf.media.category.choose"><![CDATA[Kategorien]]></item>
                <item name="wcf.media.categoryID"><![CDATA[Kategorie]]></item>
                <item name="wcf.media.chooseImage"><![CDATA[Bild auswählen]]></item>
index e61b8b15e50aade38c815adbad8c4cf65909e4f9..8c2d28da68dceef786280515b23ee8483c1d0837 100644 (file)
@@ -3136,6 +3136,7 @@ Email: {@$emailAddress} {* this line ends with a space *}
                <item name="wcf.media.button.insert"><![CDATA[Insert]]></item>
                <item name="wcf.media.button.select"><![CDATA[Select]]></item>
                <item name="wcf.media.caption"><![CDATA[Caption]]></item>
+               <item name="wcf.media.caption.enableHtml"><![CDATA[Enable HTML code in caption]]></item>
                <item name="wcf.media.category.choose"><![CDATA[Categories]]></item>
                <item name="wcf.media.categoryID"><![CDATA[Category]]></item>
                <item name="wcf.media.chooseImage"><![CDATA[Select Image]]></item>
index 37e19ac6a1938a7f8785185bd47e0d7880e5fba2..b8b6ed57861d89cc95a3ea127385b876ab4ecdfc 100644 (file)
@@ -667,6 +667,7 @@ CREATE TABLE wcf1_media (
        username VARCHAR(255) NOT NULL,
        languageID INT(10),
        isMultilingual TINYINT(1) NOT NULL DEFAULT 0,
+       captionEnableHtml TINYINT(1) NOT NULL DEFAULT 0,
        
        isImage TINYINT(1) NOT NULL DEFAULT 0,
        width SMALLINT(5) NOT NULL DEFAULT 0,