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