[TASK] Update php-cs-fixer to 2.5.0
[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($this->linkToCurrentModule(['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($this->linkToCurrentModule(['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 $linkInformation = 'tt_content:new/-' . $row['uid'] . '/' . $row['colPos'];
77 } else {
78 $linkInformation = 'tt_content:new/' . $pid . '/' . $vv;
79 }
80 $location = $this->linkToCurrentModule(['edit_record' => $linkInformation]);
81 return 'jumpToUrl(' . GeneralUtility::quoteJSvalue($location) . ');return false;';
82 }
83
84 /**
85 * Wrapping the record header (from getRecordHeader())
86 *
87 * @param string $str HTML content
88 * @param array $row Record array.
89 * @return string HTML content
90 */
91 public function wrapRecordHeader($str, $row)
92 {
93 if ($row['uid'] == $this->moveUid) {
94 /** @var IconFactory $iconFactory */
95 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
96 return $iconFactory->getIcon('status-status-current', Icon::SIZE_SMALL)->render() . $str;
97 }
98 return $str;
99 }
100
101 /**
102 * Returns URL to the current script.
103 * In particular the "popView" and "new_unique_uid" Get vars are unset.
104 *
105 * @param array $params Parameters array, merged with global GET vars.
106 * @return string URL
107 */
108 protected function linkToCurrentModule($params)
109 {
110 unset($params['popView']);
111 unset($params['new_unique_uid']);
112 return GeneralUtility::linkThisScript($params);
113 }
114 }