‪TYPO3CMS  ‪main
ContentCreationPagePositionMap.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3\CMS\Backend\Utility\BackendUtility;
24 use TYPO3\CMS\Core\Imaging\IconSize;
26 
33 {
37  public array ‪$defVals = [];
38 
42  public bool ‪$saveAndClose = false;
43 
47  public string ‪$R_URI = '';
48 
51 
53  {
54  $this->iconFactory = ‪$iconFactory;
55  $this->uriBuilder = ‪$uriBuilder;
56  parent::__construct(‪$backendLayoutView);
57  }
58 
62  protected function ‪insertPositionIcon(?array $row, int $colPos, int $pid): string
63  {
64  if ($this->saveAndClose) {
65  $target = (string)$this->uriBuilder->buildUriFromRoute('tce_db', [
66  'data' => [
67  'tt_content' => [
68  ‪StringUtility::getUniqueId('NEW') => array_replace($this->defVals, [
69  'colPos' => $colPos,
70  'pid' => (is_array($row) ? -$row['uid'] : $pid),
71  'sys_language_uid' => $this->cur_sys_language,
72  ]),
73  ],
74  ],
75  'redirect' => ‪$this->R_URI,
76  ]);
77  } else {
78  $target = (string)$this->uriBuilder->buildUriFromRoute('record_edit', [
79  'edit' => [
80  'tt_content' => [
81  (is_array($row) ? -$row['uid'] : $pid) => 'new',
82  ],
83  ],
84  'returnUrl' => $this->R_URI,
85  'defVals' => [
86  'tt_content' => array_replace($this->defVals, [
87  'colPos' => $colPos,
88  'sys_language_uid' => $this->cur_sys_language,
89  ]),
90  ],
91  ]);
92  }
93 
94  return '
95  <button type="button" class="btn btn-link" data-target="' . htmlspecialchars($target) . '" title="' . htmlspecialchars($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_misc.xlf:insertNewRecordHere')) . '">
96  ' . $this->iconFactory->getIcon('actions-arrow-left-alt', IconSize::SMALL)->render() . '
97  </button>';
98  }
99 
103  protected function ‪getRecordHeader(array $row): string
104  {
105  return '
106  <span class="py-2" title="' . BackendUtility::getRecordIconAltText($row, 'tt_content') . '">
107  ' . $this->iconFactory->getIconForRecord('tt_content', $row, IconSize::SMALL)->render() . '
108  ' . BackendUtility::getRecordTitle('tt_content', $row, true) . '
109  </span>';
110  }
111 }
‪TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap\$uriBuilder
‪UriBuilder $uriBuilder
Definition: ContentCreationPagePositionMap.php:50
‪TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap\getRecordHeader
‪getRecordHeader(array $row)
Definition: ContentCreationPagePositionMap.php:103
‪TYPO3\CMS\Backend\Tree\View\AbstractContentPagePositionMap\$backendLayoutView
‪BackendLayoutView $backendLayoutView
Definition: AbstractContentPagePositionMap.php:42
‪TYPO3\CMS\Backend\Tree\View\AbstractContentPagePositionMap\getLanguageService
‪getLanguageService()
Definition: AbstractContentPagePositionMap.php:324
‪TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap\$defVals
‪array $defVals
Definition: ContentCreationPagePositionMap.php:37
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:34
‪TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap
Definition: ContentCreationPagePositionMap.php:33
‪TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap\__construct
‪__construct(IconFactory $iconFactory, UriBuilder $uriBuilder, BackendLayoutView $backendLayoutView)
Definition: ContentCreationPagePositionMap.php:52
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:44
‪TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap\$R_URI
‪string $R_URI
Definition: ContentCreationPagePositionMap.php:47
‪TYPO3\CMS\Backend\Tree\View
Definition: AbstractContentPagePositionMap.php:18
‪TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap\$iconFactory
‪IconFactory $iconFactory
Definition: ContentCreationPagePositionMap.php:49
‪TYPO3\CMS\Backend\Tree\View\AbstractContentPagePositionMap
Definition: AbstractContentPagePositionMap.php:36
‪TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap\insertPositionIcon
‪insertPositionIcon(?array $row, int $colPos, int $pid)
Definition: ContentCreationPagePositionMap.php:62
‪TYPO3\CMS\Backend\View\BackendLayoutView
Definition: BackendLayoutView.php:37
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:24
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static getUniqueId(string $prefix='')
Definition: StringUtility.php:57
‪TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap\$saveAndClose
‪bool $saveAndClose
Definition: ContentCreationPagePositionMap.php:42