<definitionname>com.woltlab.wcf.message.embeddedObject</definitionname>
<classname><![CDATA[wcf\system\message\embedded\object\PageMessageEmbeddedObjectHandler]]></classname>
</type>
+ <type>
+ <name>com.woltlab.wcf.media</name>
+ <definitionname>com.woltlab.wcf.message.embeddedObject</definitionname>
+ <classname><![CDATA[wcf\system\message\embedded\object\MediaMessageEmbeddedObjectHandler]]></classname>
+ </type>
<!-- embedded object handlers -->
<type>
--- /dev/null
+<img src="{if $thumbnailSize == 'original'}{$media->getLink()}{else}{$media->getThumbnailLink($thumbnailSize)}{/if}" alt="{$media->getTitle()}"{if $float != 'none'} class="messageFloatObject{$float|ucfirst}"{/if}>
\ No newline at end of file
});
this._options.editor.buffer.set();
- this._options.editor.insert.text('[wsm]' + mediaIds.join(',') + '[/wsm]');
+ this._options.editor.insert.text("[wsmg='" + mediaIds.join(',') + "'][/wsmg]");
},
/**
this._options.editor.insert.html('<img src="' + item[thumbnailSize + 'ThumbnailLink'] + '" class="woltlabSuiteMedia" data-media-id="' + item.mediaID + '" data-media-size="' + thumbnailSize + '">');
}
else {
- this._options.editor.insert.text('[wsm]' + item.mediaID + '[/wsm]');
+ this._options.editor.insert.text("[wsm='" + item.mediaID + "'][/wsm]");
}
},
var buffer = '[' + name;
if (attributes.length) {
+ for (var i = 0, length = attributes.length; i < length; i++) {
+ if (!/^'.*'$/.test(attributes[i])) {
+ attributes[i] = "'" + attributes[i] + "'";
+ }
+ }
+
buffer += '=' + attributes.join(',');
}
* that can be safely passed through HTMLPurifier's validation mechanism.
*
* All though not exactly required for all bbcodes, the actual output of an bbcode
- * cannot be forseen and potentially conflict with HTMLPurifier's whitelist. Examples
+ * cannot be foreseen and potentially conflict with HTMLPurifier's whitelist. Examples
* are <iframe> or other embedded media that is allowed as a result of a bbcode, but
* not allowed to be directly provided by a user.
*
--- /dev/null
+<?php
+namespace wcf\system\bbcode;
+use wcf\data\media\Media;
+use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * Parses the [wsm] bbcode tag.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Bbcode
+ * @since 3.0
+ */
+class WoltLabSuiteMediaBBCode extends AbstractBBCode {
+ /**
+ * @inheritDoc
+ */
+ public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser) {
+ $mediaID = (!empty($openingTag['attributes'][0])) ? intval($openingTag['attributes'][0]) : 0;
+ if (!$mediaID) {
+ return '';
+ }
+
+ /** @var Media $media */
+ $media = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.media', $mediaID);
+
+ if ($media !== null) {
+ if ($media->isImage) {
+ $thumbnailSize = (!empty($openingTag['attributes'][1])) ? $openingTag['attributes'][1] : 'original';
+ $float = (!empty($openingTag['attributes'][2])) ? $openingTag['attributes'][2] : 'none';
+
+ WCF::getTPL()->assign([
+ 'float' => $float,
+ 'media' => $media,
+ 'thumbnailSize' => $thumbnailSize
+ ]);
+
+ return WCF::getTPL()->fetch('mediaBBCodeTag', 'wcf');
+ }
+
+ return StringUtil::getAnchorTag($media->getLink(), $media->getTitle());
+ }
+
+ return '';
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\bbcode;
+
+/**
+ * Parses the [wsmg] bbcode tag.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Bbcode
+ */
+class WoltLabSuiteMediaGalleryBBCode extends AbstractBBCode {
+ /**
+ * @inheritDoc
+ */
+ public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser) {
+ return '<p>TODO: WoltLabSuiteMediaGalleryBBCode</p>';
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\runtime;
+use wcf\data\media\Media;
+use wcf\data\media\MediaList;
+
+/**
+ * Runtime cache implementation for shared media.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Cache\Runtime
+ * @since 3.0
+ *
+ * @method Media[] getCachedObjects()
+ * @method Media getObject($objectID)
+ * @method Media[] getObjects(array $objectIDs)
+ */
+class MediaRuntimeCache extends AbstractRuntimeCache {
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = MediaList::class;
+}
// size
$definition->addElement('woltlab-size', 'Inline', 'Inline', '', ['class' => 'Text']);
+ // media
+ $definition->addAttribute('img', 'data-media-id', 'Number');
+ $definition->addAttribute('img', 'data-media-size', new \HTMLPurifier_AttrDef_Enum(['small', 'medium', 'large', 'original']));
+
// mention
$definition->addElement('woltlab-mention', 'Inline', 'Inline', '', [
'data-user-id' => 'Number',
--- /dev/null
+<?php
+namespace wcf\system\message\embedded\object;
+use wcf\system\cache\runtime\MediaRuntimeCache;
+use wcf\system\html\input\HtmlInputProcessor;
+use wcf\util\ArrayUtil;
+
+/**
+ * IMessageEmbeddedObjectHandler implementation for shared media.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Message\Embedded\Object
+ */
+class MediaMessageEmbeddedObjectHandler extends AbstractMessageEmbeddedObjectHandler {
+ /**
+ * @inheritDoc
+ */
+ public function parse(HtmlInputProcessor $htmlInputProcessor, array $embeddedData) {
+ $mediaIDs = [];
+ foreach (['wsm', 'wsmg'] as $name) {
+ if (empty($embeddedData[$name])) {
+ continue;
+ }
+
+ for ($i = 0, $length = count($embeddedData[$name]); $i < $length; $i++) {
+ $parsedIDs = ArrayUtil::toIntegerArray(explode(',', $embeddedData[$name][$i][0]));
+
+ $mediaIDs = array_merge($mediaIDs, $parsedIDs);
+ }
+ }
+
+ return $mediaIDs;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function loadObjects(array $objectIDs) {
+ return MediaRuntimeCache::getInstance()->getObjects($objectIDs);
+ }
+}