2 /***************************************************************
5 * (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Move element wizard:
29 * Moving pages or content elements (tt_content) around in the system via a page tree navigation.
32 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
35 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
38 * [CLASS/FUNCTION INDEX of SCRIPT]
42 * 96: class localPageTree extends t3lib_pageTree
43 * 105: function wrapIcon($icon,$row)
46 * 127: class ext_posMap_pages extends t3lib_positionMap
47 * 137: function onClickEvent($pid,$newPagePID)
48 * 148: function linkPageTitle($str,$rec)
49 * 161: function boldTitle($t_code,$dat,$id)
52 * 184: class ext_posMap_tt_content extends t3lib_positionMap
53 * 194: function linkPageTitle($str,$rec)
54 * 206: function wrapRecordTitle($str,$row)
57 * 227: class SC_move_el
58 * 250: function init()
59 * 284: function main()
60 * 416: function printContent()
63 * (This index is automatically created/updated by the extension "extdeveval")
70 require('template.php');
72 // Include local language labels:
73 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
85 * Local extension of the page tree class
87 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
91 class localPageTree
extends t3lib_pageTree
{
94 * Inserting uid-information in title-text for an icon
96 * @param string Icon image
97 * @param array Item row
98 * @return string Wrapping icon image.
100 function wrapIcon($icon,$row) {
101 return $this->addTagAttributes($icon,' title="id='.htmlspecialchars($row['uid']).'"');
116 * Extension of position map for pages
118 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
122 class ext_posMap_pages
extends t3lib_positionMap
{
123 var $l_insertNewPageHere = 'movePageToHere';
126 * Creates the onclick event for the insert-icons.
128 * @param integer The pid.
129 * @param integer New page id.
130 * @return string Onclick attribute content
132 function onClickEvent($pid,$newPagePID) {
133 return 'window.location.href=\'tce_db.php?cmd[pages]['.$GLOBALS['SOBE']->moveUid
.']['.$this->moveOrCopy
.']='.$pid.'&redirect='.rawurlencode($this->R_URI
).'&prErr=1&uPT=1&vC='.$GLOBALS['BE_USER']->veriCode().'\';return false;';
137 * Wrapping page title.
139 * @param string Page title.
140 * @param array Page record (?)
141 * @return string Wrapped title.
143 function linkPageTitle($str,$rec) {
144 $url = t3lib_div
::linkThisScript(array('uid'=>intval($rec['uid']),'moveUid'=>$GLOBALS['SOBE']->moveUid
));
145 return '<a href="'.htmlspecialchars($url).'">'.$str.'</a>';
149 * Wrap $t_code in bold IF the $dat uid matches $id
151 * @param string Title string
152 * @param array Infomation array with record array inside.
153 * @param integer The current id.
154 * @return string The title string.
156 function boldTitle($t_code,$dat,$id) {
157 return parent
::boldTitle($t_code,$dat,$GLOBALS['SOBE']->moveUid
);
173 * Extension of position map for content elements
175 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
179 class ext_posMap_tt_content
extends t3lib_positionMap
{
180 var $dontPrintPageInsertIcons = 1;
183 * Wrapping page title.
185 * @param string Page title.
186 * @param array Page record (?)
187 * @return string Wrapped title.
189 function linkPageTitle($str,$rec) {
190 $url = t3lib_div
::linkThisScript(array('uid'=>intval($rec['uid']),'moveUid'=>$GLOBALS['SOBE']->moveUid
));
191 return '<a href="'.htmlspecialchars($url).'">'.$str.'</a>';
195 * Wrapping the title of the record.
197 * @param string The title value.
198 * @param array The record row.
199 * @return string Wrapped title string.
201 function wrapRecordTitle($str,$row) {
202 if ($GLOBALS['SOBE']->moveUid
==$row['uid']) $str = '<b>'.$str.'</b>';
203 return parent
::wrapRecordTitle($str,$row);
216 * Script Class for rendering the move-element wizard display
218 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
224 // Internal, static (eg. from GPvars):
234 * Document template object
239 var $perms_clause; // Pages-select clause
241 // Internal, dynamic:
242 var $content; // Content for module accumulated here.
246 * Constructor, initializing internal variables.
251 global $BE_USER,$LANG,$BACK_PATH;
254 // Setting internal vars:
255 $this->sys_language
= intval(t3lib_div
::_GP('sys_language'));
256 $this->page_id
=intval(t3lib_div
::_GP('uid'));
257 $this->table
=t3lib_div
::_GP('table');
258 $this->R_URI
=t3lib_div
::_GP('returnUrl');
259 $this->input_moveUid
= t3lib_div
::_GP('moveUid');
260 $this->moveUid
= $this->input_moveUid ?
$this->input_moveUid
: $this->page_id
;
261 $this->makeCopy
= t3lib_div
::_GP('makeCopy');
263 // Select-pages where clause for read-access:
264 $this->perms_clause
= $BE_USER->getPagePermsClause(1);
266 // Starting the document template object:
267 $this->doc
= t3lib_div
::makeInstance('template');
268 $this->doc
->backPath
= $BACK_PATH;
269 $this->doc
->setModuleTemplate('templates/move_el.html');
270 $this->doc
->JScode
='';
272 // Starting document content (header):
274 $this->content
.=$this->doc
->header($LANG->getLL('movingElement'));
275 $this->content
.=$this->doc
->spacer(5);
279 * Creating the module output.
284 global $LANG,$BACK_PATH,$BE_USER;
286 if ($this->page_id
) {
288 // Get record for element:
289 $elRow = t3lib_BEfunc
::getRecordWSOL($this->table
,$this->moveUid
);
291 // Headerline: Icon, record title:
292 $hline = t3lib_iconWorks
::getIconImage($this->table
,$elRow,$BACK_PATH,' id="c-recIcon" title="'.htmlspecialchars(t3lib_BEfunc
::getRecordIconAltText($elRow,$this->table
)).'"');
293 $hline.= t3lib_BEfunc
::getRecordTitle($this->table
,$elRow,TRUE);
295 // Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently):
296 $onClick = 'window.location.href=\''.t3lib_div
::linkThisScript(array('makeCopy'=>!$this->makeCopy
)).'\';';
297 $hline.= '<br /><input type="hidden" name="makeCopy" value="0" /><input type="checkbox" name="makeCopy" id="makeCopy" value="1"'.($this->makeCopy?
' checked="checked"':'').' onclick="'.htmlspecialchars($onClick).'" /> <label for="makeCopy">'.
298 $LANG->getLL('makeCopy',1).'</label>';
300 // Add the header-content to the module content:
301 $this->content
.=$this->doc
->section($LANG->getLL('moveElement').':',$hline,0,1);
302 $this->content
.=$this->doc
->spacer(20);
304 // Reset variable to pick up the module content in:
307 // IF the table is "pages":
308 if ((string)$this->table
=='pages') {
309 // Get page record (if accessible):
310 $pageinfo = t3lib_BEfunc
::readPageAccess($this->page_id
,$this->perms_clause
);
311 if (is_array($pageinfo) && $BE_USER->isInWebMount($pageinfo['pid'],$this->perms_clause
)) {
313 // Initialize the position map:
314 $posMap = t3lib_div
::makeInstance('ext_posMap_pages');
315 $posMap->moveOrCopy
= $this->makeCopy?
'copy':'move';
317 // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
318 if ($pageinfo['pid']) {
319 $pidPageInfo = t3lib_BEfunc
::readPageAccess($pageinfo['pid'],$this->perms_clause
);
320 if (is_array($pidPageInfo)) {
321 if ($BE_USER->isInWebMount($pidPageInfo['pid'],$this->perms_clause
)) {
322 $code.= '<a href="'.htmlspecialchars(t3lib_div
::linkThisScript(array('uid'=>intval($pageinfo['pid']),'moveUid'=>$this->moveUid
))).'">'.
323 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/i/pages_up.gif','width="18" height="16"').' alt="" />'.
324 t3lib_BEfunc
::getRecordTitle('pages',$pidPageInfo,TRUE).
327 $code.= t3lib_iconWorks
::getIconImage('pages',$pidPageInfo,$BACK_PATH,'').
328 t3lib_BEfunc
::getRecordTitle('pages',$pidPageInfo,TRUE).
334 // Create the position tree:
335 $code.= $posMap->positionTree($this->page_id
,$pageinfo,$this->perms_clause
,$this->R_URI
);
339 // IF the table is "tt_content":
340 if ((string)$this->table
=='tt_content') {
342 // First, get the record:
343 $tt_content_rec = t3lib_BEfunc
::getRecord('tt_content',$this->moveUid
);
346 if (!$this->input_moveUid
) $this->page_id
= $tt_content_rec['pid'];
348 // Checking if the parent page is readable:
349 $pageinfo = t3lib_BEfunc
::readPageAccess($this->page_id
,$this->perms_clause
);
350 if (is_array($pageinfo) && $BE_USER->isInWebMount($pageinfo['pid'],$this->perms_clause
)) {
352 // Initialize the position map:
353 $posMap = t3lib_div
::makeInstance('ext_posMap_tt_content');
354 $posMap->moveOrCopy
= $this->makeCopy?
'copy':'move';
355 $posMap->cur_sys_language
= $this->sys_language
;
357 // Headerline for the parent page: Icon, record title:
358 $hline = t3lib_iconWorks
::getIconImage('pages',$pageinfo,$BACK_PATH,' title="'.htmlspecialchars(t3lib_BEfunc
::getRecordIconAltText($pageinfo,'pages')).'"');
359 $hline.= t3lib_BEfunc
::getRecordTitle('pages',$pageinfo,TRUE);
361 // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable:
362 $modTSconfig_SHARED = t3lib_BEfunc
::getModTSconfig($this->page_id
,'mod.SHARED'); // SHARED page-TSconfig settings.
363 $colPosList = strcmp(trim($modTSconfig_SHARED['properties']['colPos_list']),'') ?
trim($modTSconfig_SHARED['properties']['colPos_list']) : '1,0,2,3';
364 $colPosList = implode(',',array_unique(t3lib_div
::intExplode(',',$colPosList))); // Removing duplicates, if any
366 // Adding parent page-header and the content element columns from position-map:
367 $code=$hline.'<br />';
368 $code.=$posMap->printContentElementColumns($this->page_id
,$this->moveUid
,$colPosList,1,$this->R_URI
);
370 // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
373 if ($pageinfo['pid']) {
374 $pidPageInfo = t3lib_BEfunc
::readPageAccess($pageinfo['pid'],$this->perms_clause
);
375 if (is_array($pidPageInfo)) {
376 if ($BE_USER->isInWebMount($pidPageInfo['pid'],$this->perms_clause
)) {
377 $code.= '<a href="'.htmlspecialchars(t3lib_div
::linkThisScript(array('uid'=>intval($pageinfo['pid']),'moveUid'=>$this->moveUid
))).'">'.
378 '<img'.t3lib_iconWorks
::skinImg($this->doc
->backPath
,'gfx/i/pages_up.gif','width="18" height="16"').' alt="" />'.
379 t3lib_BEfunc
::getRecordTitle('pages',$pidPageInfo,TRUE).
382 $code.= t3lib_iconWorks
::getIconImage('pages',$pidPageInfo,$BACK_PATH,'').
383 t3lib_BEfunc
::getRecordTitle('pages',$pidPageInfo,TRUE).
389 // Create the position tree (for pages):
390 $code.= $posMap->positionTree($this->page_id
,$pageinfo,$this->perms_clause
,$this->R_URI
);
394 // Add the $code content as a new section to the module:
395 $this->content
.=$this->doc
->section($LANG->getLL('selectPositionOfElement').':',$code,0,1);
398 // Setting up the buttons and markers for docheader
399 $docHeaderButtons = $this->getButtons();
400 $markers['CSH'] = $docHeaderButtons['csh'];
401 $markers['CONTENT'] = $this->content
;
403 // Build the <body> for the module
404 $this->content
= $this->doc
->startPage($LANG->getLL('movingElement'));
405 $this->content
.= $this->doc
->moduleBody($this->pageinfo
, $docHeaderButtons, $markers);
406 $this->content
.= $this->doc
->endPage();
407 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
411 * Print out the accumulated content:
415 function printContent() {
420 * Create the panel of buttons for submitting the form or otherwise perform operations.
422 * @return array all available buttons as an assoc. array
424 protected function getButtons() {
425 global $LANG, $BACK_PATH;
432 if ($this->page_id
) {
433 if ((string)$this->table
== 'pages') {
435 $buttons['csh'] = t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'move_el_pages', $GLOBALS['BACK_PATH'], '', TRUE);
436 } elseif((string)$this->table
== 'tt_content') {
438 $buttons['csh'] = t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'move_el_cs', $GLOBALS['BACK_PATH'], '', TRUE);
443 $buttons['back'] ='<a href="' . htmlspecialchars($this->R_URI
) . '" class="typo3-goBack"><img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/goback.gif') . ' alt="" title="' . $LANG->getLL('goBack', 1) .'" /></a>';
452 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/move_el.php']) {
453 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/move_el.php']);
459 $SOBE = t3lib_div
::makeInstance('SC_move_el');
462 $SOBE->printContent();