dd1527b56c57d0a2527b33a1743ae9289366f5e4
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Tree / View / ContentLayoutPagePositionMap.php
1 <?php
2 namespace TYPO3\CMS\Backend\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
17 use TYPO3\CMS\Core\Imaging\Icon;
18 use TYPO3\CMS\Core\Imaging\IconFactory;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20
21 /**
22 * Position map class for content elements within the page module
23 */
24 class ContentLayoutPagePositionMap extends PagePositionMap
25 {
26 /**
27 * @var bool
28 */
29 public $dontPrintPageInsertIcons = 1;
30
31 /**
32 * @var string
33 */
34 public $l_insertNewRecordHere = 'newContentElement';
35
36 /**
37 * Wrapping the title of the record.
38 *
39 * @param string $str The title value.
40 * @param array $row The record row.
41 * @return string Wrapped title string.
42 */
43 public function wrapRecordTitle($str, $row)
44 {
45 $aOnClick = 'jumpToUrl(' . GeneralUtility::quoteJSvalue($GLOBALS['SOBE']->local_linkThisScript(array('edit_record' => ('tt_content:' . $row['uid'])))) . ');return false;';
46 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $str . '</a>';
47 }
48
49 /**
50 * Wrapping the column header
51 *
52 * @param string $str Header value
53 * @param string $vv Column info.
54 * @return string
55 * @see printRecordMap()
56 */
57 public function wrapColumnHeader($str, $vv)
58 {
59 $aOnClick = 'jumpToUrl(' . GeneralUtility::quoteJSvalue($GLOBALS['SOBE']->local_linkThisScript(array('edit_record' => ('_EDIT_COL:' . $vv)))) . ');return false;';
60 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $str . '</a>';
61 }
62
63 /**
64 * Create on-click event value.
65 *
66 * @param array $row The record.
67 * @param string $vv Column position value.
68 * @param int $moveUid Move uid
69 * @param int $pid PID value.
70 * @param int $sys_lang System language
71 * @return string
72 */
73 public function onClickInsertRecord($row, $vv, $moveUid, $pid, $sys_lang = 0)
74 {
75 if (is_array($row)) {
76 $location = $GLOBALS['SOBE']->local_linkThisScript(array('edit_record' => 'tt_content:new/-' . $row['uid'] . '/' . $row['colPos']));
77 } else {
78 $location = $GLOBALS['SOBE']->local_linkThisScript(array('edit_record' => 'tt_content:new/' . $pid . '/' . $vv));
79 }
80 return 'jumpToUrl(' . GeneralUtility::quoteJSvalue($location) . ');return false;';
81 }
82
83 /**
84 * Wrapping the record header (from getRecordHeader())
85 *
86 * @param string $str HTML content
87 * @param array $row Record array.
88 * @return string HTML content
89 */
90 public function wrapRecordHeader($str, $row)
91 {
92 if ($row['uid'] == $this->moveUid) {
93 /** @var IconFactory $iconFactory */
94 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
95 return $iconFactory->getIcon('status-status-current', Icon::SIZE_SMALL)->render() . $str;
96 } else {
97 return $str;
98 }
99 }
100 }