2 declare(strict_types=1);
3 namespace wcf\system\message\embedded\object;
4 use wcf\data\page\Page;
5 use wcf\data\page\PageCache;
6 use wcf\system\html\input\HtmlInputProcessor;
9 * Parses embedded pages and outputs their link or title.
11 * @author Alexander Ebert
12 * @copyright 2001-2018 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package WoltLabSuite\Core\System\Message\Embedded\Object
16 class PageMessageEmbeddedObjectHandler extends AbstractSimpleMessageEmbeddedObjectHandler {
20 public function parse(HtmlInputProcessor $htmlInputProcessor, array $embeddedData) {
22 if (!empty($embeddedData['wsp'])) {
23 for ($i = 0, $length = count($embeddedData['wsp']); $i < $length; $i++) {
24 $pageIDs[] = intval($embeddedData['wsp'][$i][0]);
28 return array_unique($pageIDs);
34 public function loadObjects(array $objectIDs) {
37 foreach ($objectIDs as $objectID) {
38 $page = PageCache::getInstance()->getPage($objectID);
40 $pages[$objectID] = $page;
50 public function validateValues($objectType, $objectID, array $values) {
51 return array_filter($values, function($value) {
52 return (PageCache::getInstance()->getPage($value) !== null);
59 public function replaceSimple($objectType, $objectID, $value, array $attributes) {
60 /** @var Page $page */
61 $page = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.page', $value);
66 $return = (!empty($attributes['return'])) ? $attributes['return'] : 'link';
69 return $page->getTitle();
74 return $page->getLink();