[API][!!!] Fix API compatibility break in tslib_pibase
[Packages/TYPO3.CMS.git] / typo3 / move_el.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 * Move element wizard:
29 * Moving pages or content elements (tt_content) around in the system via a page tree navigation.
30 *
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
32 * XHTML compatible.
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 */
36
37
38 $BACK_PATH='';
39 require('init.php');
40 require('template.php');
41
42 // Include local language labels:
43 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
44
45
46
47
48
49
50
51
52
53
54 /**
55 * Local extension of the page tree class
56 *
57 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
58 * @package TYPO3
59 * @subpackage core
60 */
61 class localPageTree extends t3lib_pageTree {
62
63 /**
64 * Inserting uid-information in title-text for an icon
65 *
66 * @param string Icon image
67 * @param array Item row
68 * @return string Wrapping icon image.
69 */
70 function wrapIcon($icon,$row) {
71 return $this->addTagAttributes($icon,' title="id='.htmlspecialchars($row['uid']).'"');
72 }
73 }
74
75
76
77
78
79
80
81
82
83
84
85 /**
86 * Extension of position map for pages
87 *
88 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
89 * @package TYPO3
90 * @subpackage core
91 */
92 class ext_posMap_pages extends t3lib_positionMap {
93 var $l_insertNewPageHere = 'movePageToHere';
94
95 /**
96 * Creates the onclick event for the insert-icons.
97 *
98 * @param integer The pid.
99 * @param integer New page id.
100 * @return string Onclick attribute content
101 */
102 function onClickEvent($pid,$newPagePID) {
103 return 'window.location.href=\'tce_db.php?cmd[pages][' . $GLOBALS['SOBE']->moveUid . '][' . $this->moveOrCopy . ']=' . $pid .
104 '&redirect=' . rawurlencode($this->R_URI) .
105 '&prErr=1&uPT=1&vC=' . $GLOBALS['BE_USER']->veriCode() .
106 t3lib_BEfunc::getUrlToken('tceAction') .
107 '\';return false;';
108 }
109
110 /**
111 * Wrapping page title.
112 *
113 * @param string Page title.
114 * @param array Page record (?)
115 * @return string Wrapped title.
116 */
117 function linkPageTitle($str,$rec) {
118 $url = t3lib_div::linkThisScript(array('uid'=>intval($rec['uid']),'moveUid'=>$GLOBALS['SOBE']->moveUid));
119 return '<a href="'.htmlspecialchars($url).'">'.$str.'</a>';
120 }
121
122 /**
123 * Wrap $t_code in bold IF the $dat uid matches $id
124 *
125 * @param string Title string
126 * @param array Infomation array with record array inside.
127 * @param integer The current id.
128 * @return string The title string.
129 */
130 function boldTitle($t_code,$dat,$id) {
131 return parent::boldTitle($t_code,$dat,$GLOBALS['SOBE']->moveUid);
132 }
133 }
134
135
136
137
138
139
140
141
142
143
144
145
146 /**
147 * Extension of position map for content elements
148 *
149 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
150 * @package TYPO3
151 * @subpackage core
152 */
153 class ext_posMap_tt_content extends t3lib_positionMap {
154 var $dontPrintPageInsertIcons = 1;
155
156 /**
157 * Wrapping page title.
158 *
159 * @param string Page title.
160 * @param array Page record (?)
161 * @return string Wrapped title.
162 */
163 function linkPageTitle($str,$rec) {
164 $url = t3lib_div::linkThisScript(array('uid'=>intval($rec['uid']),'moveUid'=>$GLOBALS['SOBE']->moveUid));
165 return '<a href="'.htmlspecialchars($url).'">'.$str.'</a>';
166 }
167
168 /**
169 * Wrapping the title of the record.
170 *
171 * @param string The title value.
172 * @param array The record row.
173 * @return string Wrapped title string.
174 */
175 function wrapRecordTitle($str,$row) {
176 if ($GLOBALS['SOBE']->moveUid==$row['uid']) $str = '<strong>'.$str.'</strong>';
177 return parent::wrapRecordTitle($str,$row);
178 }
179 }
180
181
182
183
184
185
186
187
188
189 /**
190 * Script Class for rendering the move-element wizard display
191 *
192 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
193 * @package TYPO3
194 * @subpackage core
195 */
196 class SC_move_el {
197
198 // Internal, static (eg. from GPvars):
199 var $sys_language=0;
200 var $page_id;
201 var $table;
202 var $R_URI;
203 var $input_moveUid;
204 var $moveUid;
205 var $makeCopy;
206
207 /**
208 * Document template object
209 *
210 * @var mediumDoc
211 */
212 var $doc;
213 var $perms_clause; // Pages-select clause
214
215 // Internal, dynamic:
216 var $content; // Content for module accumulated here.
217
218
219 /**
220 * Constructor, initializing internal variables.
221 *
222 * @return void
223 */
224 function init() {
225
226 // Setting internal vars:
227 $this->sys_language = intval(t3lib_div::_GP('sys_language'));
228 $this->page_id=intval(t3lib_div::_GP('uid'));
229 $this->table=t3lib_div::_GP('table');
230 $this->R_URI=t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
231 $this->input_moveUid = t3lib_div::_GP('moveUid');
232 $this->moveUid = $this->input_moveUid ? $this->input_moveUid : $this->page_id;
233 $this->makeCopy = t3lib_div::_GP('makeCopy');
234
235 // Select-pages where clause for read-access:
236 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
237
238 // Starting the document template object:
239 $this->doc = t3lib_div::makeInstance('template');
240 $this->doc->backPath = $GLOBALS['BACK_PATH'];
241 $this->doc->setModuleTemplate('templates/move_el.html');
242 $this->doc->JScode='';
243
244 // Starting document content (header):
245 $this->content='';
246 $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('movingElement'));
247 $this->content.=$this->doc->spacer(5);
248 }
249
250 /**
251 * Creating the module output.
252 *
253 * @return void
254 */
255 function main() {
256 if ($this->page_id) {
257
258 // Get record for element:
259 $elRow = t3lib_BEfunc::getRecordWSOL($this->table,$this->moveUid);
260
261 // Headerline: Icon, record title:
262 $hline = t3lib_iconWorks::getSpriteIconForRecord($this->table, $elRow, array('id' => "c-recIcon", 'title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($elRow,$this->table))));
263 $hline.= t3lib_BEfunc::getRecordTitle($this->table,$elRow,TRUE);
264
265 // Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently):
266 $onClick = 'window.location.href=\''.t3lib_div::linkThisScript(array('makeCopy'=>!$this->makeCopy)).'\';';
267 $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">'.
268 $GLOBALS['LANG']->getLL('makeCopy', 1) . '</label>';
269
270 // Add the header-content to the module content:
271 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('moveElement') . ':', $hline, 0, 1);
272 $this->content.=$this->doc->spacer(20);
273
274 // Reset variable to pick up the module content in:
275 $code='';
276
277 // IF the table is "pages":
278 if ((string)$this->table=='pages') {
279 // Get page record (if accessible):
280 $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id,$this->perms_clause);
281 if (is_array($pageinfo) && $GLOBALS['BE_USER']->isInWebMount($pageinfo['pid'],$this->perms_clause)) {
282
283 // Initialize the position map:
284 $posMap = t3lib_div::makeInstance('ext_posMap_pages');
285 $posMap->moveOrCopy = $this->makeCopy?'copy':'move';
286
287 // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
288 if ($pageinfo['pid']) {
289 $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'],$this->perms_clause);
290 if (is_array($pidPageInfo)) {
291 if ($GLOBALS['BE_USER']->isInWebMount($pidPageInfo['pid'],$this->perms_clause)) {
292 $code.= '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('uid'=>intval($pageinfo['pid']),'moveUid'=>$this->moveUid))).'">'.
293 t3lib_iconWorks::getSpriteIcon('actions-view-go-up') .
294 t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE).
295 '</a><br />';
296 } else {
297 $code.= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo) .
298 t3lib_BEfunc::getRecordTitle('pages',$pidPageInfo,TRUE).
299 '<br />';
300 }
301 }
302 }
303
304 // Create the position tree:
305 $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI);
306 }
307 }
308
309 // IF the table is "tt_content":
310 if ((string)$this->table=='tt_content') {
311
312 // First, get the record:
313 $tt_content_rec = t3lib_BEfunc::getRecord('tt_content',$this->moveUid);
314
315 // ?
316 if (!$this->input_moveUid) $this->page_id = $tt_content_rec['pid'];
317
318 // Checking if the parent page is readable:
319 $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id,$this->perms_clause);
320 if (is_array($pageinfo) && $GLOBALS['BE_USER']->isInWebMount($pageinfo['pid'],$this->perms_clause)) {
321
322 // Initialize the position map:
323 $posMap = t3lib_div::makeInstance('ext_posMap_tt_content');
324 $posMap->moveOrCopy = $this->makeCopy?'copy':'move';
325 $posMap->cur_sys_language = $this->sys_language;
326
327 // Headerline for the parent page: Icon, record title:
328 $hline = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageinfo, array('title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($pageinfo, 'pages'))));
329 $hline .= t3lib_BEfunc::getRecordTitle('pages', $pageinfo, TRUE);
330
331 // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable:
332 $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->page_id,'mod.SHARED'); // SHARED page-TSconfig settings.
333 $colPosArray = t3lib_div::callUserFunction('EXT:cms/classes/class.tx_cms_backendlayout.php:tx_cms_BackendLayout->getColPosListItemsParsed', $this->page_id, $this);
334 foreach ($colPosArray as $colPos) {
335 $colPosList .= $colPosList != '' ? ',' . $colPos[1] : $colPos[1];
336 }
337 $colPosList = implode(',', array_unique(t3lib_div::intExplode(',', $colPosList))); // Removing duplicates, if any
338
339 // Adding parent page-header and the content element columns from position-map:
340 $code = $hline . '<br />';
341 $code .= $posMap->printContentElementColumns($this->page_id, $this->moveUid, $colPosList, 1, $this->R_URI);
342
343 // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
344 $code .= '<br />';
345 $code .= '<br />';
346 if ($pageinfo['pid']) {
347 $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'], $this->perms_clause);
348 if (is_array($pidPageInfo)) {
349 if ($GLOBALS['BE_USER']->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
350 $code .= '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array(
351 'uid' => intval($pageinfo['pid']),
352 'moveUid' => $this->moveUid)
353 )) . '">'
354 . t3lib_iconWorks::getSpriteIcon('actions-view-go-up')
355 . t3lib_BEfunc::getRecordTitle('pages', $pidPageInfo, TRUE)
356 . '</a><br />';
357 } else {
358 $code.= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo)
359 . t3lib_BEfunc::getRecordTitle('pages', $pidPageInfo, TRUE)
360 . '<br />';
361 }
362 }
363 }
364
365 // Create the position tree (for pages):
366 $code.= $posMap->positionTree($this->page_id, $pageinfo, $this->perms_clause, $this->R_URI);
367 }
368 }
369
370 // Add the $code content as a new section to the module:
371 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('selectPositionOfElement') . ':', $code, 0, 1);
372 }
373
374 // Setting up the buttons and markers for docheader
375 $docHeaderButtons = $this->getButtons();
376 $markers['CSH'] = $docHeaderButtons['csh'];
377 $markers['CONTENT'] = $this->content;
378
379 // Build the <body> for the module
380 $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('movingElement'));
381 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
382 $this->content.= $this->doc->endPage();
383 $this->content = $this->doc->insertStylesAndJS($this->content);
384 }
385
386 /**
387 * Print out the accumulated content:
388 *
389 * @return void
390 */
391 function printContent() {
392 echo $this->content;
393 }
394
395 /**
396 * Create the panel of buttons for submitting the form or otherwise perform operations.
397 *
398 * @return array all available buttons as an assoc. array
399 */
400 protected function getButtons() {
401 $buttons = array(
402 'csh' => '',
403 'back' => ''
404 );
405
406 if ($this->page_id) {
407 if ((string)$this->table == 'pages') {
408 // CSH
409 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'move_el_pages', $GLOBALS['BACK_PATH'], '', TRUE);
410 } elseif((string)$this->table == 'tt_content') {
411 // CSH
412 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'move_el_cs', $GLOBALS['BACK_PATH'], '', TRUE);
413 }
414
415 if ($this->R_URI) {
416 // Back
417 $buttons['back'] ='<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack" title="' . $GLOBALS['LANG']->getLL('goBack', TRUE) .'">' .
418 t3lib_iconWorks::getSpriteIcon('actions-view-go-back') .
419 '</a>';
420 }
421 }
422
423 return $buttons;
424 }
425 }
426
427
428 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/move_el.php'])) {
429 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/move_el.php']);
430 }
431
432
433
434 // Make instance:
435 $SOBE = t3lib_div::makeInstance('SC_move_el');
436 $SOBE->init();
437 $SOBE->main();
438 $SOBE->printContent();
439
440 ?>