1<?php
2namespace TYPO3\CMS\Recordlist\Tree\View;
3
4/*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17use TYPO3\CMS\Core\Imaging\Icon;
18use TYPO3\CMS\Core\Imaging\IconFactory;
19use TYPO3\CMS\Core\Utility\GeneralUtility;
20use TYPO3\CMS\Core\Utility\HttpUtility;
21
22/**
23 * Extension class for the TBE record browser
24 * @internal
25 */
26class ElementBrowserPageTreeView extends \TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView
27{
28    /**
29     * Returns TRUE if a doktype can be linked (which is always the case here).
30     *
31     * @param int $doktype Doktype value to test
32     * @param int $uid uid to test.
33     * @return bool
34     */
35    public function ext_isLinkable($doktype, $uid)
36    {
37        return true;
38    }
39
40    /**
41     * Wrapping the title in a link, if applicable.
42     *
43     * @param string $title Title, ready for output (already html-escaped)
44     * @param array $v The record
45     * @param bool $ext_pArrPages If set, pages clicked will return immediately, otherwise reload page.
46     * @return string Wrapped title string
47     */
48    public function wrapTitle($title, $v, $ext_pArrPages = false)
49    {
50        if ($ext_pArrPages && $v['uid']) {
51            $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
52            $ficon = $iconFactory->getIconForRecord('pages', $v, Icon::SIZE_SMALL)->render();
53            $out = '<span data-uid="' . htmlspecialchars($v['uid']) . '" data-table="pages" data-title="' . htmlspecialchars($v['title']) . '" data-icon="' . htmlspecialchars($ficon) . '">';
54            $out .= '<a href="#" data-close="1">' . $title . '</a>';
55            $out .= '</span>';
56            return $out;
57        }
58
59        $parameters = HttpUtility::buildQueryString($this->linkParameterProvider->getUrlParameters(['pid' => $v['uid']]));
60        return '<a href="#" onclick="return jumpToUrl(' . htmlspecialchars(GeneralUtility::quoteJSvalue($this->getThisScript() . $parameters)) . ');">' . $title . '</a>';
61    }
62}
63