1514103408c7fcf829f70181eaca267509a89868
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\message\embedded\object;
3 use wcf\system\cache\runtime\MediaRuntimeCache;
4 use wcf\system\html\input\HtmlInputProcessor;
5 use wcf\util\ArrayUtil;
6
7 /**
8 * IMessageEmbeddedObjectHandler implementation for shared media.
9 *
10 * @author Alexander Ebert
11 * @copyright 2001-2016 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package WoltLabSuite\Core\System\Message\Embedded\Object
14 */
15 class MediaMessageEmbeddedObjectHandler extends AbstractMessageEmbeddedObjectHandler {
16 /**
17 * @inheritDoc
18 */
19 public function parse(HtmlInputProcessor $htmlInputProcessor, array $embeddedData) {
20 $mediaIDs = [];
21 foreach (['wsm', 'wsmg'] as $name) {
22 if (empty($embeddedData[$name])) {
23 continue;
24 }
25
26 for ($i = 0, $length = count($embeddedData[$name]); $i < $length; $i++) {
27 $parsedIDs = ArrayUtil::toIntegerArray(explode(',', $embeddedData[$name][$i][0]));
28
29 $mediaIDs = array_merge($mediaIDs, $parsedIDs);
30 }
31 }
32
33 return $mediaIDs;
34 }
35
36 /**
37 * @inheritDoc
38 */
39 public function loadObjects(array $objectIDs) {
40 return MediaRuntimeCache::getInstance()->getObjects($objectIDs);
41 }
42 }