2fe7e360425b1c4b0d44deb10a3a28ea6a9210ab
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Tree / View / PagePositionMap.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\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Backend\Utility\IconUtility;
19 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
20 use TYPO3\CMS\Core\Utility\GeneralUtility;
21
22 /**
23 * Position map class - generating a page tree / content element list which links for inserting (copy/move) of records.
24 * Used for pages / tt_content element wizards of various kinds.
25 *
26 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
27 */
28 class PagePositionMap {
29
30 // EXTERNAL, static:
31 /**
32 * @var string
33 */
34 public $moveOrCopy = 'move';
35
36 /**
37 * @var int
38 */
39 public $dontPrintPageInsertIcons = 0;
40
41 /**
42 * @var string
43 */
44 public $backPath = '';
45
46 // How deep the position page tree will go.
47 /**
48 * @var int
49 */
50 public $depth = 2;
51
52 // Can be set to the sys_language uid to select content elements for.
53 /**
54 * @var string
55 */
56 public $cur_sys_language;
57
58 // INTERNAL, dynamic:
59 // Request uri
60 /**
61 * @var string
62 */
63 public $R_URI = '';
64
65 // Element id.
66 /**
67 * @var string
68 */
69 public $elUid = '';
70
71 // tt_content element uid to move.
72 /**
73 * @var string
74 */
75 public $moveUid = '';
76
77 // Caching arrays:
78 /**
79 * @var array
80 */
81 public $getModConfigCache = array();
82
83 /**
84 * @var array
85 */
86 public $checkNewPageCache = array();
87
88 // Label keys:
89 /**
90 * @var string
91 */
92 public $l_insertNewPageHere = 'insertNewPageHere';
93
94 /**
95 * @var string
96 */
97 public $l_insertNewRecordHere = 'insertNewRecordHere';
98
99 /**
100 * @var string
101 */
102 public $modConfigStr = 'mod.web_list.newPageWiz';
103
104 /**
105 * Page tree implementation class name
106 *
107 * @var string
108 */
109 protected $pageTreeClassName = ElementBrowserPageTreeView::class;
110
111 /**
112 * Constructor allowing to set pageTreeImplementation
113 *
114 * @param string $pageTreeClassName
115 */
116 public function __construct($pageTreeClassName = NULL) {
117 if ($pageTreeClassName !== NULL) {
118 $this->pageTreeClassName = $pageTreeClassName;
119 }
120 }
121
122 /*************************************
123 *
124 * Page position map:
125 *
126 **************************************/
127 /**
128 * Creates a "position tree" based on the page tree.
129 *
130 * @param int $id Current page id
131 * @param array $pageinfo Current page record.
132 * @param string $perms_clause Page selection permission clause.
133 * @param string $R_URI Current REQUEST_URI
134 * @return string HTML code for the tree.
135 */
136 public function positionTree($id, $pageinfo, $perms_clause, $R_URI) {
137 $code = '';
138 // Make page tree object:
139 /** @var \TYPO3\CMS\Backend\Tree\View\PageTreeView localPageTree */
140 $t3lib_pageTree = GeneralUtility::makeInstance($this->pageTreeClassName);
141 $t3lib_pageTree->init(' AND ' . $perms_clause);
142 $t3lib_pageTree->addField('pid');
143 // Initialize variables:
144 $this->R_URI = $R_URI;
145 $this->elUid = $id;
146 // Create page tree, in $this->depth levels.
147 $t3lib_pageTree->getTree($pageinfo['pid'], $this->depth);
148 if (!$this->dontPrintPageInsertIcons) {
149 $code .= $this->JSimgFunc();
150 }
151 // Initialize variables:
152 $saveBlankLineState = array();
153 $saveLatestUid = array();
154 $latestInvDepth = $this->depth;
155 // Traverse the tree:
156 foreach ($t3lib_pageTree->tree as $cc => $dat) {
157 // Make link + parameters.
158 $latestInvDepth = $dat['invertedDepth'];
159 $saveLatestUid[$latestInvDepth] = $dat;
160 if (isset($t3lib_pageTree->tree[$cc - 1])) {
161 $prev_dat = $t3lib_pageTree->tree[$cc - 1];
162 // If current page, subpage?
163 if ($prev_dat['row']['uid'] == $id) {
164 // 1) It must be allowed to create a new page and 2) If there are subpages there is no need to render a subpage icon here - it'll be done over the subpages...
165 if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id) && !($prev_dat['invertedDepth'] > $t3lib_pageTree->tree[$cc]['invertedDepth'])) {
166 $code .= '<span class="nobr">' . $this->insertQuadLines($dat['blankLineCode']) . '<img src="clear.gif" width="18" height="8" align="top" alt="" />' . '<a href="#" onclick="' . htmlspecialchars($this->onClickEvent($id, $id, 1)) . '" onmouseover="' . htmlspecialchars(('changeImg(\'mImgSubpage' . $cc . '\',0);')) . '" onmouseout="' . htmlspecialchars(('changeImg(\'mImgSubpage' . $cc . '\',1);')) . '">' . '<img' . IconUtility::skinImg($this->backPath, 'gfx/newrecord_marker_d.gif', 'width="281" height="8"') . ' name="mImgSubpage' . $cc . '" border="0" align="top" title="' . $this->insertlabel() . '" alt="" />' . '</a></span><br />';
167 }
168 }
169 // If going down
170 if ($prev_dat['invertedDepth'] > $t3lib_pageTree->tree[$cc]['invertedDepth']) {
171 $prevPid = $t3lib_pageTree->tree[$cc]['row']['pid'];
172 } elseif ($prev_dat['invertedDepth'] < $t3lib_pageTree->tree[$cc]['invertedDepth']) {
173 // If going up
174 // First of all the previous level should have an icon:
175 if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($prev_dat['row']['pid'])) {
176 $prevPid = -$prev_dat['row']['uid'];
177 $code .= '<span class="nobr">' . $this->insertQuadLines($dat['blankLineCode']) . '<img src="clear.gif" width="18" height="1" align="top" alt="" />' . '<a href="#" onclick="' . htmlspecialchars($this->onClickEvent($prevPid, $prev_dat['row']['pid'], 2)) . '" onmouseover="' . htmlspecialchars(('changeImg(\'mImgAfter' . $cc . '\',0);')) . '" onmouseout="' . htmlspecialchars(('changeImg(\'mImgAfter' . $cc . '\',1);')) . '">' . '<img' . IconUtility::skinImg($this->backPath, 'gfx/newrecord_marker_d.gif', 'width="281" height="8"') . ' name="mImgAfter' . $cc . '" border="0" align="top" title="' . $this->insertlabel() . '" alt="" />' . '</a></span><br />';
178 }
179 // Then set the current prevPid
180 $prevPid = -$prev_dat['row']['pid'];
181 } else {
182 // In on the same level
183 $prevPid = -$prev_dat['row']['uid'];
184 }
185 } else {
186 // First in the tree
187 $prevPid = $dat['row']['pid'];
188 }
189 if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($dat['row']['pid'])) {
190 $code .= '<span class="nobr">' . $this->insertQuadLines($dat['blankLineCode']) . '<a href="#" onclick="' . htmlspecialchars($this->onClickEvent($prevPid, $dat['row']['pid'], 3)) . '" onmouseover="' . htmlspecialchars(('changeImg(\'mImg' . $cc . '\',0);')) . '" onmouseout="' . htmlspecialchars(('changeImg(\'mImg' . $cc . '\',1);')) . '">' . '<img' . IconUtility::skinImg($this->backPath, 'gfx/newrecord_marker_d.gif', 'width="281" height="8"') . ' name="mImg' . $cc . '" border="0" align="top" title="' . $this->insertlabel() . '" alt="" />' . '</a></span><br />';
191 }
192 // The line with the icon and title:
193 $t_code = '<span class="nobr">' . $dat['HTML'] . $this->linkPageTitle($this->boldTitle(htmlspecialchars(GeneralUtility::fixed_lgd_cs($dat['row']['title'], $GLOBALS['BE_USER']->uc['titleLen'])), $dat, $id), $dat['row']) . '</span><br />';
194 $code .= $t_code;
195 }
196 // If the current page was the last in the tree:
197 $prev_dat = end($t3lib_pageTree->tree);
198 if ($prev_dat['row']['uid'] == $id) {
199 if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id)) {
200 $code .= '<span class="nobr">' . $this->insertQuadLines($saveLatestUid[$latestInvDepth]['blankLineCode'], 1) . '<img src="clear.gif" width="18" height="8" align="top" alt="" />' . '<a href="#" onclick="' . $this->onClickEvent($id, $id, 4) . '" onmouseover="' . htmlspecialchars(('changeImg(\'mImgSubpage' . $cc . '\',0);')) . '" onmouseout="' . htmlspecialchars(('changeImg(\'mImgSubpage' . $cc . '\',1);')) . '">' . '<img' . IconUtility::skinImg($this->backPath, 'gfx/newrecord_marker_d.gif', 'width="281" height="8"') . ' name="mImgSubpage' . $cc . '" border="0" align="top" title="' . $this->insertlabel() . '" alt="" />' . '</a></span><br />';
201 }
202 }
203 for ($a = $latestInvDepth; $a <= $this->depth; $a++) {
204 $dat = $saveLatestUid[$a];
205 $prevPid = -$dat['row']['uid'];
206 if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($dat['row']['pid'])) {
207 $code .= '<span class="nobr">' . $this->insertQuadLines($dat['blankLineCode'], 1) . '<a href="#" onclick="' . htmlspecialchars($this->onClickEvent($prevPid, $dat['row']['pid'], 5)) . '" onmouseover="' . htmlspecialchars(('changeImg(\'mImgEnd' . $a . '\',0);')) . '" onmouseout="' . htmlspecialchars(('changeImg(\'mImgEnd' . $a . '\',1);')) . '">' . '<img' . IconUtility::skinImg($this->backPath, 'gfx/newrecord_marker_d.gif', 'width="281" height="8"') . ' name="mImgEnd' . $a . '" border="0" align="top" title="' . $this->insertlabel() . '" alt="" />' . '</a></span><br />';
208 }
209 }
210 return $code;
211 }
212
213 /**
214 * Creates the JavaScritp for insert new-record rollover image
215 *
216 * @param string $prefix Insert record image prefix.
217 * @return string <script> section
218 */
219 public function JSimgFunc($prefix = '') {
220 $code = $GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
221
222 var img_newrecord_marker=new Image();
223 img_newrecord_marker.src = "' . IconUtility::skinImg($this->backPath, ('gfx/newrecord' . $prefix . '_marker.gif'), '', 1) . '";
224
225 var img_newrecord_marker_d=new Image();
226 img_newrecord_marker_d.src = "' . IconUtility::skinImg($this->backPath, ('gfx/newrecord' . $prefix . '_marker_d.gif'), '', 1) . '";
227
228 function changeImg(name,d) { //
229 if (document[name]) {
230 if (d) {
231 document[name].src = img_newrecord_marker_d.src;
232 } else {
233 document[name].src = img_newrecord_marker.src;
234 }
235 }
236 }
237 ');
238 return $code;
239 }
240
241 /**
242 * Wrap $t_code in bold IF the $dat uid matches $id
243 *
244 * @param string $t_code Title string
245 * @param array $dat Infomation array with record array inside.
246 * @param int $id The current id.
247 * @return string The title string.
248 */
249 public function boldTitle($t_code, $dat, $id) {
250 if ($dat['row']['uid'] == $id) {
251 $t_code = '<strong>' . $t_code . '</strong>';
252 }
253 return $t_code;
254 }
255
256 /**
257 * Creates the onclick event for the insert-icons.
258 *
259 * TSconfig mod.web_list.newPageWiz.overrideWithExtension may contain an extension which provides a module
260 * to be used instead of the normal create new page wizard.
261 *
262 * @param int $pid The pid.
263 * @param int $newPagePID New page id.
264 * @return string Onclick attribute content
265 */
266 public function onClickEvent($pid, $newPagePID) {
267 $TSconfigProp = $this->getModConfig($newPagePID);
268 if ($TSconfigProp['overrideWithExtension']) {
269 if (ExtensionManagementUtility::isLoaded($TSconfigProp['overrideWithExtension'])) {
270 $onclick = 'window.location.href=\'' . ExtensionManagementUtility::extRelPath($TSconfigProp['overrideWithExtension']) . 'mod1/index.php?cmd=crPage&positionPid=' . $pid . '\';';
271 return $onclick;
272 }
273 }
274 $params = '&edit[pages][' . $pid . ']=new&returnNewPageId=1';
275 return BackendUtility::editOnClick($params, '', $this->R_URI);
276 }
277
278 /**
279 * Get label, htmlspecialchars()'ed
280 *
281 * @return string The localized label for "insert new page here
282 */
283 public function insertlabel() {
284 return $GLOBALS['LANG']->getLL($this->l_insertNewPageHere, 1);
285 }
286
287 /**
288 * Wrapping page title.
289 *
290 * @param string $str Page title.
291 * @param array $rec Page record (?)
292 * @return string Wrapped title.
293 */
294 public function linkPageTitle($str, $rec) {
295 return $str;
296 }
297
298 /**
299 * Checks if the user has permission to created pages inside of the $pid page.
300 * Uses caching so only one regular lookup is made - hence you can call the function multiple times without worrying about performance.
301 *
302 * @param int $pid Page id for which to test.
303 * @return bool
304 */
305 public function checkNewPageInPid($pid) {
306 if (!isset($this->checkNewPageCache[$pid])) {
307 $pidInfo = BackendUtility::getRecord('pages', $pid);
308 $this->checkNewPageCache[$pid] = $GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->doesUserHaveAccess($pidInfo, 8);
309 }
310 return $this->checkNewPageCache[$pid];
311 }
312
313 /**
314 * Returns module configuration for a pid.
315 *
316 * @param int $pid Page id for which to get the module configuration.
317 * @return array The properties of teh module configuration for the page id.
318 * @see onClickEvent()
319 */
320 public function getModConfig($pid) {
321 if (!isset($this->getModConfigCache[$pid])) {
322 // Acquiring TSconfig for this PID:
323 $this->getModConfigCache[$pid] = BackendUtility::getModTSconfig($pid, $this->modConfigStr);
324 }
325 return $this->getModConfigCache[$pid]['properties'];
326 }
327
328 /**
329 * Insert half/quad lines.
330 *
331 * @param string $codes Keywords for which lines to insert.
332 * @param bool $allBlank If TRUE all lines are just blank clear.gifs
333 * @return string HTML content.
334 */
335 public function insertQuadLines($codes, $allBlank = FALSE) {
336 $codeA = GeneralUtility::trimExplode(',', $codes . ',line', TRUE);
337 $lines = array();
338 foreach ($codeA as $code) {
339 if ($code == 'blank' || $allBlank) {
340 $lines[] = '<img src="clear.gif" width="18" height="8" align="top" alt="" />';
341 } else {
342 $lines[] = '<img' . IconUtility::skinImg($this->backPath, 'gfx/ol/halfline.gif', 'width="18" height="8"') . ' align="top" alt="" />';
343 }
344 }
345 return implode('', $lines);
346 }
347
348 /*************************************
349 *
350 * Content element positioning:
351 *
352 **************************************/
353 /**
354 * Creates HTML for inserting/moving content elements.
355 *
356 * @param int $pid page id onto which to insert content element.
357 * @param int $moveUid Move-uid (tt_content element uid?)
358 * @param string $colPosList List of columns to show
359 * @param bool $showHidden If not set, then hidden/starttime/endtime records are filtered out.
360 * @param string $R_URI Request URI
361 * @return string HTML
362 */
363 public function printContentElementColumns($pid, $moveUid, $colPosList, $showHidden, $R_URI) {
364 $this->R_URI = $R_URI;
365 $this->moveUid = $moveUid;
366 $colPosArray = GeneralUtility::trimExplode(',', $colPosList, TRUE);
367 $lines = array();
368 foreach ($colPosArray as $kk => $vv) {
369 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . (int)$pid . ($showHidden ? '' : BackendUtility::BEenableFields('tt_content')) . ' AND colPos=' . (int)$vv . ((string)$this->cur_sys_language !== '' ? ' AND sys_language_uid=' . (int)$this->cur_sys_language : '') . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'sorting');
370 $lines[$vv] = array();
371 $lines[$vv][] = $this->insertPositionIcon('', $vv, $kk, $moveUid, $pid);
372 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
373 BackendUtility::workspaceOL('tt_content', $row);
374 if (is_array($row)) {
375 $lines[$vv][] = $this->wrapRecordHeader($this->getRecordHeader($row), $row);
376 $lines[$vv][] = $this->insertPositionIcon($row, $vv, $kk, $moveUid, $pid);
377 }
378 }
379 $GLOBALS['TYPO3_DB']->sql_free_result($res);
380 }
381 return $this->printRecordMap($lines, $colPosArray, $pid);
382 }
383
384 /**
385 * Creates the table with the content columns
386 *
387 * @param array $lines Array with arrays of lines for each column
388 * @param array $colPosArray Column position array
389 * @param int $pid The id of the page
390 * @return string HTML
391 */
392 public function printRecordMap($lines, $colPosArray, $pid = 0) {
393 $row1 = '';
394 $row2 = '';
395 $count = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(count($colPosArray), 1);
396 $backendLayout = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getSelectedBackendLayout', $pid, $this);
397 if (isset($backendLayout['__config']['backend_layout.'])) {
398 $table = '<div class="t3-gridContainer"><table border="0" cellspacing="0" cellpadding="0" id="typo3-ttContentList">';
399 $colCount = (int)$backendLayout['__config']['backend_layout.']['colCount'];
400 $rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount'];
401 $table .= '<colgroup>';
402 for ($i = 0; $i < $colCount; $i++) {
403 $table .= '<col style="width:' . 100 / $colCount . '%"></col>';
404 }
405 $table .= '</colgroup>';
406 $tcaItems = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getColPosListItemsParsed', $pid, $this);
407 // Cycle through rows
408 for ($row = 1; $row <= $rowCount; $row++) {
409 $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
410 if (!isset($rowConfig)) {
411 continue;
412 }
413 $table .= '<tr>';
414 for ($col = 1; $col <= $colCount; $col++) {
415 $columnConfig = $rowConfig['columns.'][$col . '.'];
416 if (!isset($columnConfig)) {
417 continue;
418 }
419 // Which tt_content colPos should be displayed inside this cell
420 $columnKey = (int)$columnConfig['colPos'];
421 $head = '';
422 foreach ($tcaItems as $item) {
423 if ($item[1] == $columnKey) {
424 $head = $GLOBALS['LANG']->sL($item[0], TRUE);
425 }
426 }
427 // Render the grid cell
428 $table .= '<td valign="top"' . (isset($columnConfig['colspan']) ? ' colspan="' . $columnConfig['colspan'] . '"' : '') . (isset($columnConfig['rowspan']) ? ' rowspan="' . $columnConfig['rowspan'] . '"' : '') . ' class="t3-gridCell t3-page-column t3-page-column-' . $columnKey . (!isset($columnConfig['colPos']) ? ' t3-gridCell-unassigned' : '') . (isset($columnConfig['colPos']) && !$head ? ' t3-gridCell-restricted' : '') . (isset($columnConfig['colspan']) ? ' t3-gridCell-width' . $columnConfig['colspan'] : '') . (isset($columnConfig['rowspan']) ? ' t3-gridCell-height' . $columnConfig['rowspan'] : '') . '">';
429 $table .= '<div class="t3-page-colHeader t3-row-header">';
430 if (isset($columnConfig['colPos']) && $head) {
431 $table .= $this->wrapColumnHeader($head, '', '') . '</div>' . implode('<br />', $lines[$columnKey]);
432 } elseif ($columnConfig['colPos']) {
433 $table .= $this->wrapColumnHeader($GLOBALS['LANG']->getLL('noAccess'), '', '') . '</div>';
434 } elseif ($columnConfig['name']) {
435 $table .= $this->wrapColumnHeader($columnConfig['name'], '', '') . '</div>';
436 } else {
437 $table .= $this->wrapColumnHeader($GLOBALS['LANG']->getLL('notAssigned'), '', '') . '</div>';
438 }
439 $table .= '</td>';
440 }
441 $table .= '</tr>';
442 }
443 $table .= '</table></div>';
444 } else {
445 // Traverse the columns here:
446 foreach ($colPosArray as $kk => $vv) {
447 $row1 .= '<td align="center" width="' . round(100 / $count) . '%"><div class="t3-page-colHeader t3-row-header">' . $this->wrapColumnHeader($GLOBALS['LANG']->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $vv, $pid), TRUE), $vv) . '</div></td>';
448 $row2 .= '<td valign="top" nowrap="nowrap">' . implode('<br />', $lines[$vv]) . '</td>';
449 }
450 $table = '
451
452 <!--
453 Map of records in columns:
454 -->
455 <table border="0" cellpadding="0" cellspacing="0" id="typo3-ttContentList">
456 <tr>' . $row1 . '</tr>
457 <tr>' . $row2 . '</tr>
458 </table>
459
460 ';
461 }
462 return $this->JSimgFunc('2') . $table;
463 }
464
465 /**
466 * Wrapping the column header
467 *
468 * @param string $str Header value
469 * @param string $vv Column info.
470 * @return string
471 * @see printRecordMap()
472 */
473 public function wrapColumnHeader($str, $vv) {
474 return $str;
475 }
476
477 /**
478 * Creates a linked position icon.
479 *
480 * @param mixed $row Element row. If this is an array the link will cause an insert after this content element, otherwise
481 * the link will insert at the first position in the column
482 * @param string $vv Column position value.
483 * @param int $kk Column key.
484 * @param int $moveUid Move uid
485 * @param int $pid PID value.
486 * @return string
487 */
488 public function insertPositionIcon($row, $vv, $kk, $moveUid, $pid) {
489 if (is_array($row) && !empty($row['uid'])) {
490 // Use record uid for the hash when inserting after this content element
491 $uid = $row['uid'];
492 } else {
493 // No uid means insert at first position in the column
494 $uid = '';
495 }
496 $cc = hexdec(substr(md5($uid . '-' . $vv . '-' . $kk), 0, 4));
497 return '<a href="#" onclick="' . htmlspecialchars($this->onClickInsertRecord($row, $vv, $moveUid, $pid, $this->cur_sys_language)) . '" onmouseover="' . htmlspecialchars(('changeImg(\'mImg' . $cc . '\',0);')) . '" onmouseout="' . htmlspecialchars(('changeImg(\'mImg' . $cc . '\',1);')) . '">' . '<img' . IconUtility::skinImg($this->backPath, 'gfx/newrecord2_marker_d.gif', 'width="100" height="8"') . ' name="mImg' . $cc . '" border="0" align="top" title="' . $GLOBALS['LANG']->getLL($this->l_insertNewRecordHere, 1) . '" alt="" />' . '</a>';
498 }
499
500 /**
501 * Create on-click event value.
502 *
503 * @param mixed $row The record. If this is not an array with the record data the insert will be for the first position
504 * in the column
505 * @param string $vv Column position value.
506 * @param int $moveUid Move uid
507 * @param int $pid PID value.
508 * @param int $sys_lang System language (not used currently)
509 * @return string
510 */
511 public function onClickInsertRecord($row, $vv, $moveUid, $pid, $sys_lang = 0) {
512 $table = 'tt_content';
513 if (is_array($row)) {
514 $location = BackendUtility::getModuleUrl('tce_db') . '&cmd[' . $table . '][' . $moveUid . '][' . $this->moveOrCopy . ']=-' . $row['uid'] . '&prErr=1&uPT=1&vC=' . $GLOBALS['BE_USER']->veriCode() . BackendUtility::getUrlToken('tceAction');
515 } else {
516 $location = BackendUtility::getModuleUrl('tce_db') . '&cmd[' . $table . '][' . $moveUid . '][' . $this->moveOrCopy . ']=' . $pid . '&data[' . $table . '][' . $moveUid . '][colPos]=' . $vv . '&prErr=1&vC=' . $GLOBALS['BE_USER']->veriCode() . BackendUtility::getUrlToken('tceAction');
517 }
518 $location .= '&redirect=' . rawurlencode($this->R_URI);
519 // returns to prev. page
520 return 'window.location.href=' . GeneralUtility::quoteJSvalue($location) . ';return false;';
521 }
522
523 /**
524 * Wrapping the record header (from getRecordHeader())
525 *
526 * @param string $str HTML content
527 * @param array $row Record array.
528 * @return string HTML content
529 */
530 public function wrapRecordHeader($str, $row) {
531 return $str;
532 }
533
534 /**
535 * Create record header (includes teh record icon, record title etc.)
536 *
537 * @param array $row Record row.
538 * @return string HTML
539 */
540 public function getRecordHeader($row) {
541 $line = IconUtility::getSpriteIconForRecord('tt_content', $row, array('title' => htmlspecialchars(BackendUtility::getRecordIconAltText($row, 'tt_content'))));
542 $line .= BackendUtility::getRecordTitle('tt_content', $row, TRUE);
543 return $this->wrapRecordTitle($line, $row);
544 }
545
546 /**
547 * Wrapping the title of the record.
548 *
549 * @param string $str The title value.
550 * @param array $row The record row.
551 * @return string Wrapped title string.
552 */
553 public function wrapRecordTitle($str, $row) {
554 return '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('uid' => (int)$row['uid'], 'moveUid' => ''))) . '">' . $str . '</a>';
555 }
556
557 }