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