Added more comments, $Id$ keywords etc for the whole core of TYPO3.
[Packages/TYPO3.CMS.git] / typo3 / move_el.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skaarhoj (kasper@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 *
30 * $Id$
31 *
32 * @author Kasper Skaarhoj <kasper@typo3.com>
33 */
34 /**
35 * [CLASS/FUNCTION INDEX of SCRIPT]
36 *
37 *
38 *
39 * 89: class localPageTree extends t3lib_pageTree
40 * 96: function wrapIcon($icon,$row)
41 *
42 *
43 * 118: class ext_posMap_pages extends t3lib_positionMap
44 * 125: function onClickEvent($pid)
45 * 134: function linkPageTitle($str,$rec)
46 * 144: function boldTitle($t_code,$dat,$id)
47 *
48 *
49 * 167: class ext_posMap_tt_content extends t3lib_positionMap
50 * 175: function linkPageTitle($str,$rec)
51 * 185: function wrapRecordTitle($str,$row)
52 *
53 *
54 * 209: class SC_move_el
55 * 223: function init()
56 * 255: function main()
57 * 339: function printContent()
58 *
59 * TOTAL FUNCTIONS: 9
60 * (This index is automatically created/updated by the extension "extdeveval")
61 *
62 */
63
64
65 $BACK_PATH='';
66 require ('init.php');
67 require ('template.php');
68 include ('sysext/lang/locallang_misc.php');
69 require_once (PATH_t3lib.'class.t3lib_page.php');
70 require_once (PATH_t3lib.'class.t3lib_positionmap.php');
71 require_once (PATH_t3lib.'class.t3lib_pagetree.php');
72
73
74
75
76
77
78
79
80
81
82 /**
83 * Local extension of the page tree class
84 *
85 * @author Kasper Skaarhoj <kasper@typo3.com>
86 * @package TYPO3
87 * @subpackage core
88 */
89 class localPageTree extends t3lib_pageTree {
90
91 /**
92 * @param [type] $icon: ...
93 * @param [type] $row: ...
94 * @return [type] ...
95 */
96 function wrapIcon($icon,$row) {
97 return substr($icon,0,-1).' title="id='.htmlspecialchars($row['uid']).'">';
98 }
99 }
100
101
102
103
104
105
106
107
108
109
110
111 /**
112 * Extension of position map for pages
113 *
114 * @author Kasper Skaarhoj <kasper@typo3.com>
115 * @package TYPO3
116 * @subpackage core
117 */
118 class ext_posMap_pages extends t3lib_positionMap {
119 var $l_insertNewPageHere = "movePageToHere";
120
121 /**
122 * @param [type] $pid: ...
123 * @return [type] ...
124 */
125 function onClickEvent($pid) {
126 return 'document.location=\'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;';
127 }
128
129 /**
130 * @param [type] $str: ...
131 * @param [type] $rec: ...
132 * @return [type] ...
133 */
134 function linkPageTitle($str,$rec) {
135 return '<a href="'.t3lib_div::linkThisScript(array("uid"=>intval($rec["uid"]),"moveUid"=>$GLOBALS["SOBE"]->moveUid)).'">'.$str.'</a>';
136 }
137
138 /**
139 * @param [type] $t_code: ...
140 * @param [type] $dat: ...
141 * @param [type] $id: ...
142 * @return [type] ...
143 */
144 function boldTitle($t_code,$dat,$id) {
145 return parent::boldTitle($t_code,$dat,$GLOBALS["SOBE"]->moveUid);
146 }
147 }
148
149
150
151
152
153
154
155
156
157
158
159
160 /**
161 * Extension of position map for content elements
162 *
163 * @author Kasper Skaarhoj <kasper@typo3.com>
164 * @package TYPO3
165 * @subpackage core
166 */
167 class ext_posMap_tt_content extends t3lib_positionMap {
168 var $dontPrintPageInsertIcons = 1;
169
170 /**
171 * @param [type] $str: ...
172 * @param [type] $rec: ...
173 * @return [type] ...
174 */
175 function linkPageTitle($str,$rec) {
176 $str = '<a href="'.t3lib_div::linkThisScript(array("uid"=>intval($rec["uid"]),"moveUid"=>$GLOBALS["SOBE"]->moveUid)).'">'.$str.'</a>';
177 return $str;
178 }
179
180 /**
181 * @param [type] $str: ...
182 * @param [type] $row: ...
183 * @return [type] ...
184 */
185 function wrapRecordTitle($str,$row) {
186 if ($GLOBALS["SOBE"]->moveUid==$row["uid"]) $str = '<b>'.$str.'</b>';
187 return parent::wrapRecordTitle($str,$row);
188 }
189 }
190
191
192
193
194
195
196
197
198
199
200
201
202 /**
203 * Script Class
204 *
205 * @author Kasper Skaarhoj <kasper@typo3.com>
206 * @package TYPO3
207 * @subpackage core
208 */
209 class SC_move_el {
210 var $content;
211 var $moveUid;
212 var $content;
213 var $perms_clause;
214 var $page_id;
215 var $table;
216 var $R_URI;
217 var $doc;
218 var $sys_language=0;
219
220 /**
221 * @return [type] ...
222 */
223 function init() {
224 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
225 //debug($HTTP_GET_VARS);
226 $this->sys_language = intval(t3lib_div::GPvar("sys_language"));
227 $this->perms_clause = $BE_USER->getPagePermsClause(1);
228
229
230 $this->doc = t3lib_div::makeInstance("mediumDoc");
231 $this->doc->backPath = $BACK_PATH;
232 $this->doc->JScode='';
233
234
235 // ***************************
236 // Creating content
237 // ***************************
238 $this->content="";
239 $this->content.=$this->doc->startPage($LANG->getLL("movingElement"));
240 $this->content.=$this->doc->header($LANG->getLL("movingElement"));
241 $this->content.=$this->doc->spacer(5);
242
243
244 $this->page_id=intval(t3lib_div::GPvar("uid"));
245 $this->table=t3lib_div::GPvar("table");
246 $this->R_URI=t3lib_div::GPvar("returnUrl");
247 $this->moveUid = t3lib_div::GPvar("moveUid") ? t3lib_div::GPvar("moveUid") : $this->page_id;
248 }
249
250 /**
251 * [Describe function...]
252 *
253 * @return [type] ...
254 */
255 function main() {
256 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
257
258 if ($this->page_id) {
259
260 $elRow = t3lib_BEfunc::getRecord($this->table,$this->moveUid);
261 $hline = t3lib_iconWorks::getIconImage($this->table,$elRow,$BACK_PATH,t3lib_BEfunc::titleAttrib(t3lib_BEfunc::getRecordIconAltText($elRow,$this->table),1).' align=top');
262 $hline.= t3lib_BEfunc::getRecordTitle($this->table,$elRow,1);
263 $hline.= '<BR><input type="hidden" name="makeCopy" value="0"><input type="checkbox" name="makeCopy" value="1"'.(t3lib_div::GPvar("makeCopy")?" CHECKED":"").' onClick="document.location=\''.t3lib_div::linkThisScript(array("makeCopy"=>!t3lib_div::GPvar("makeCopy"))).'\'">'.$LANG->getLL("makeCopy");
264
265 $this->content.=$this->doc->section($LANG->getLL("moveElement").":",$hline,0,1);
266 $this->content.=$this->doc->spacer(20);
267
268
269 $code="";
270 if ((string)$this->table=="pages") {
271 $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id,$this->perms_clause);
272 if (is_array($pageinfo)) {
273
274
275 $posMap = t3lib_div::makeInstance("ext_posMap_pages");
276 $posMap->moveOrCopy = t3lib_div::GPvar("makeCopy")?"copy":"move";
277
278 $code="";
279 // $code.="<BR><strong>".$LANG->getLL("selectPositionOfElement").":</strong><BR><BR>";
280 if ($pageinfo["pid"]) {
281 $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo["pid"],$this->perms_clause);
282 if (is_array($pidPageInfo)) {
283 $code.='<a href="'.t3lib_div::linkThisScript(array("uid"=>intval($pageinfo["pid"]),"moveUid"=>$this->moveUid)).'"><img src="gfx/i/pages_up.gif" width="18" height="16" border="0" align=top>'.t3lib_BEfunc::getRecordTitle("pages",$pidPageInfo).'</a><BR>';
284 }
285 }
286 $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI);
287 }
288 }
289
290 if ((string)$this->table=="tt_content") {
291 $tt_content_rec = t3lib_BEfunc::getRecord("tt_content",$this->moveUid);
292 if (!t3lib_div::GPvar("moveUid")) $this->page_id = $tt_content_rec["pid"];
293
294 // debug($tt_content_rec["uid"]);
295
296
297 $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id,$this->perms_clause);
298 if (is_array($pageinfo)) {
299 $posMap = t3lib_div::makeInstance("ext_posMap_tt_content");
300 $posMap->moveOrCopy = t3lib_div::GPvar("makeCopy")?"copy":"move";
301 $posMap->cur_sys_language = $this->sys_language;
302
303 $code="";
304
305 $hline = t3lib_iconWorks::getIconImage("pages",$pageinfo,$BACK_PATH,t3lib_BEfunc::titleAttrib(t3lib_BEfunc::getRecordIconAltText($pageinfo,"pages"),1).' align=top');
306 $hline.= t3lib_BEfunc::getRecordTitle("pages",$pageinfo,1);
307
308 // Find columns
309 $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->page_id,"mod.SHARED"); // SHARED page-TSconfig settings.
310 $colPosList = strcmp(trim($modTSconfig_SHARED["properties"]["colPos_list"]),"") ? trim($modTSconfig_SHARED["properties"]["colPos_list"]) : "1,0,2,3";
311
312 $code=$hline."<BR>";
313 $code.=$posMap->printContentElementColumns($this->page_id,$this->moveUid,$colPosList,1,$this->R_URI);
314
315 $code.= '<BR>';
316 $code.= '<BR>';
317 if ($pageinfo["pid"]) {
318 $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo["pid"],$this->perms_clause);
319 if (is_array($pidPageInfo)) {
320 $code.='<a href="'.t3lib_div::linkThisScript(array("uid"=>intval($pageinfo["pid"]),"moveUid"=>$this->moveUid)).'"><img src="gfx/i/pages_up.gif" width="18" height="16" border="0" align=top>'.t3lib_BEfunc::getRecordTitle("pages",$pidPageInfo).'</a><BR>';
321 }
322 }
323 $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI);
324 }
325 }
326
327 if ($this->R_URI) {
328 $code.='<BR><BR><a href="'.$this->R_URI.'" class="typo3-goBack"><img src="gfx/goback.gif" width="14" height="14" hspace="2" border="0" align="top"><strong>'.$LANG->getLL("goBack").'</strong></a>';
329 }
330 $this->content.=$this->doc->section($LANG->getLL("selectPositionOfElement").":",$code,0,1);
331 }
332 }
333
334 /**
335 * [Describe function...]
336 *
337 * @return [type] ...
338 */
339 function printContent() {
340 global $SOBE;
341 $this->content.= $this->doc->middle();
342 $this->content.= $this->doc->endPage();
343 echo $this->content;
344 }
345 }
346
347 // Include extension?
348 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/move_el.php']) {
349 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/move_el.php']);
350 }
351
352
353
354
355
356
357
358
359
360
361
362
363 // Make instance:
364 $SOBE = t3lib_div::makeInstance('SC_move_el');
365 $SOBE->init();
366 $SOBE->main();
367 $SOBE->printContent();
368 ?>