2 namespace wcf\system\message\embedded\object;
3 use wcf\data\page\Page;
4 use wcf\data\page\PageCache;
5 use wcf\system\html\input\HtmlInputProcessor;
8 * Parses embedded pages and outputs their link or title.
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
15 class PageMessageEmbeddedObjectHandler extends AbstractSimpleMessageEmbeddedObjectHandler {
19 public function parse(HtmlInputProcessor $htmlInputProcessor, array $embeddedData) {
21 if (!empty($embeddedData['wsp'])) {
22 for ($i = 0, $length = count($embeddedData['wsp']); $i < $length; $i++) {
23 $pageIDs[] = intval($embeddedData['wsp'][$i][0]);
27 return array_unique($pageIDs);
33 public function loadObjects(array $objectIDs) {
36 foreach ($objectIDs as $objectID) {
37 $page = PageCache::getInstance()->getPage($objectID);
39 $pages[$objectID] = $page;
49 public function validateValues($objectType, $objectID, array $values) {
50 return array_filter($values, function($value) {
51 return (PageCache::getInstance()->getPage($value) !== null);
58 public function replaceSimple($objectType, $objectID, $value, array $attributes) {
59 /** @var Page $page */
60 $page = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.page', $value);
65 $return = (!empty($attributes['return'])) ? $attributes['return'] : 'link';
68 return $page->getTitle();
73 return $page->getLink();