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