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