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