Added $Id$ keywords, cleaned up comment tags
[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 * @author Kasper Skaarhoj <kasper@typo3.com>
31 * @package TYPO3
32 * @subpackage core
33 *
34 */
35
36
37 $BACK_PATH="";
38 require ("init.php");
39 require ("template.php");
40 include ("sysext/lang/locallang_misc.php");
41 require_once (PATH_t3lib."class.t3lib_page.php");
42 require_once (PATH_t3lib."class.t3lib_positionmap.php");
43 require_once (PATH_t3lib."class.t3lib_pagetree.php");
44
45
46
47
48 // ***************************
49 // Script Classes
50 // ***************************
51 class localPageTree extends t3lib_pageTree {
52 function wrapIcon($icon,$row) {
53 return substr($icon,0,-1).' title="id='.htmlspecialchars($row["uid"]).'">';
54 }
55 }
56 class ext_posMap_pages extends t3lib_positionMap {
57 var $l_insertNewPageHere = "movePageToHere";
58
59 function onClickEvent($pid) {
60 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;';
61 }
62 function linkPageTitle($str,$rec) {
63 return '<a href="'.t3lib_div::linkThisScript(array("uid"=>intval($rec["uid"]),"moveUid"=>$GLOBALS["SOBE"]->moveUid)).'">'.$str.'</a>';
64 }
65 function boldTitle($t_code,$dat,$id) {
66 return parent::boldTitle($t_code,$dat,$GLOBALS["SOBE"]->moveUid);
67 }
68 }
69 class ext_posMap_tt_content extends t3lib_positionMap {
70 var $dontPrintPageInsertIcons = 1;
71
72 function linkPageTitle($str,$rec) {
73 $str = '<a href="'.t3lib_div::linkThisScript(array("uid"=>intval($rec["uid"]),"moveUid"=>$GLOBALS["SOBE"]->moveUid)).'">'.$str.'</a>';
74 return $str;
75 }
76
77 function wrapRecordTitle($str,$row) {
78 if ($GLOBALS["SOBE"]->moveUid==$row["uid"]) $str = '<b>'.$str.'</b>';
79 return parent::wrapRecordTitle($str,$row);
80 }
81 }
82 class SC_move_el {
83 var $content;
84 var $moveUid;
85 var $content;
86 var $perms_clause;
87 var $page_id;
88 var $table;
89 var $R_URI;
90 var $doc;
91 var $sys_language=0;
92
93 function init() {
94 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
95 //debug($HTTP_GET_VARS);
96 $this->sys_language = intval(t3lib_div::GPvar("sys_language"));
97 $this->perms_clause = $BE_USER->getPagePermsClause(1);
98
99
100 $this->doc = t3lib_div::makeInstance("mediumDoc");
101 $this->doc->backPath = $BACK_PATH;
102 $this->doc->JScode='';
103
104
105 // ***************************
106 // Creating content
107 // ***************************
108 $this->content="";
109 $this->content.=$this->doc->startPage($LANG->getLL("movingElement"));
110 $this->content.=$this->doc->header($LANG->getLL("movingElement"));
111 $this->content.=$this->doc->spacer(5);
112
113
114 $this->page_id=intval(t3lib_div::GPvar("uid"));
115 $this->table=t3lib_div::GPvar("table");
116 $this->R_URI=t3lib_div::GPvar("returnUrl");
117 $this->moveUid = t3lib_div::GPvar("moveUid") ? t3lib_div::GPvar("moveUid") : $this->page_id;
118 }
119 function main() {
120 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
121
122 if ($this->page_id) {
123
124 $elRow = t3lib_BEfunc::getRecord($this->table,$this->moveUid);
125 $hline = t3lib_iconWorks::getIconImage($this->table,$elRow,$BACK_PATH,t3lib_BEfunc::titleAttrib(t3lib_BEfunc::getRecordIconAltText($elRow,$this->table),1).' align=top');
126 $hline.= t3lib_BEfunc::getRecordTitle($this->table,$elRow,1);
127 $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");
128
129 $this->content.=$this->doc->section($LANG->getLL("moveElement").":",$hline,0,1);
130 $this->content.=$this->doc->spacer(20);
131
132
133 $code="";
134 if ((string)$this->table=="pages") {
135 $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id,$this->perms_clause);
136 if (is_array($pageinfo)) {
137
138
139 $posMap = t3lib_div::makeInstance("ext_posMap_pages");
140 $posMap->moveOrCopy = t3lib_div::GPvar("makeCopy")?"copy":"move";
141
142 $code="";
143 // $code.="<BR><strong>".$LANG->getLL("selectPositionOfElement").":</strong><BR><BR>";
144 if ($pageinfo["pid"]) {
145 $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo["pid"],$this->perms_clause);
146 if (is_array($pidPageInfo)) {
147 $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>';
148 }
149 }
150 $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI);
151 }
152 }
153
154 if ((string)$this->table=="tt_content") {
155 $tt_content_rec = t3lib_BEfunc::getRecord("tt_content",$this->moveUid);
156 if (!t3lib_div::GPvar("moveUid")) $this->page_id = $tt_content_rec["pid"];
157
158 // debug($tt_content_rec["uid"]);
159
160
161 $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id,$this->perms_clause);
162 if (is_array($pageinfo)) {
163 $posMap = t3lib_div::makeInstance("ext_posMap_tt_content");
164 $posMap->moveOrCopy = t3lib_div::GPvar("makeCopy")?"copy":"move";
165 $posMap->cur_sys_language = $this->sys_language;
166
167 $code="";
168
169 $hline = t3lib_iconWorks::getIconImage("pages",$pageinfo,$BACK_PATH,t3lib_BEfunc::titleAttrib(t3lib_BEfunc::getRecordIconAltText($pageinfo,"pages"),1).' align=top');
170 $hline.= t3lib_BEfunc::getRecordTitle("pages",$pageinfo,1);
171
172 // Find columns
173 $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->page_id,"mod.SHARED"); // SHARED page-TSconfig settings.
174 $colPosList = strcmp(trim($modTSconfig_SHARED["properties"]["colPos_list"]),"") ? trim($modTSconfig_SHARED["properties"]["colPos_list"]) : "1,0,2,3";
175
176 $code=$hline."<BR>";
177 $code.=$posMap->printContentElementColumns($this->page_id,$this->moveUid,$colPosList,1,$this->R_URI);
178
179 $code.= '<BR>';
180 $code.= '<BR>';
181 if ($pageinfo["pid"]) {
182 $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo["pid"],$this->perms_clause);
183 if (is_array($pidPageInfo)) {
184 $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>';
185 }
186 }
187 $code.= $posMap->positionTree($this->page_id,$pageinfo,$this->perms_clause,$this->R_URI);
188 }
189 }
190
191 if ($this->R_URI) {
192 $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>';
193 }
194 $this->content.=$this->doc->section($LANG->getLL("selectPositionOfElement").":",$code,0,1);
195 }
196 }
197 function printContent() {
198 global $SOBE;
199 $this->content.= $this->doc->middle();
200 $this->content.= $this->doc->endPage();
201 echo $this->content;
202 }
203 }
204
205 // Include extension?
206 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/move_el.php"]) {
207 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/move_el.php"]);
208 }
209
210
211
212
213
214
215
216
217
218
219
220
221 // Make instance:
222 $SOBE = t3lib_div::makeInstance("SC_move_el");
223 $SOBE->init();
224 $SOBE->main();
225 $SOBE->printContent();
226 ?>