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