Added more comments, $Id$ keywords etc for the whole core of TYPO3.
[Packages/TYPO3.CMS.git] / typo3 / db_list.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 * Module: Web>List
29 *
30 * Listing database records from the tables configured in $TCA as they are related to the current page or root.
31 *
32 * Notice: This module and Web>Page (db_layout.php) module has a special status since they
33 * are NOT located in their actual module directories (fx. mod/web/list/) but in the
34 * backend root directory. This has some historical and practical causes.
35 *
36 * $Id$
37 *
38 * @author Kasper Skaarhoj <kasper@typo3.com>
39 */
40 /**
41 * [CLASS/FUNCTION INDEX of SCRIPT]
42 *
43 *
44 *
45 * 87: class SC_db_list
46 * 107: function init()
47 * 128: function menuConfig()
48 * 151: function clearCache()
49 * 164: function main()
50 * 342: function printContent()
51 *
52 * TOTAL FUNCTIONS: 5
53 * (This index is automatically created/updated by the extension "extdeveval")
54 *
55 */
56
57
58 unset($MCONF);
59 require ('mod/web/list/conf.php');
60 require ('init.php');
61 require ('template.php');
62 $LANG->includeLLFile('EXT:lang/locallang_mod_web_list.php');
63 require_once (PATH_t3lib.'class.t3lib_page.php');
64 require_once (PATH_t3lib.'class.t3lib_pagetree.php');
65 require_once (PATH_t3lib.'class.t3lib_recordlist.php');
66 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
67 require_once ('class.db_list.inc');
68 require_once ('class.db_list_extra.inc');
69 $BE_USER->modAccess($MCONF,1);
70
71 t3lib_BEfunc::lockRecords();
72
73
74
75
76
77
78
79
80 /**
81 * Script Class
82 *
83 * @author Kasper Skaarhoj <kasper@typo3.com>
84 * @package TYPO3
85 * @subpackage core
86 */
87 class SC_db_list {
88 var $MCONF=array();
89 var $MOD_MENU=array();
90 var $MOD_SETTINGS=array();
91
92 var $include_once=array();
93 var $content;
94
95 var $perms_clause;
96 var $modTSconfig;
97 var $pointer;
98 var $pageinfo;
99 var $imagemode;
100 var $table;
101 var $id;
102 var $doc;
103
104 /**
105 * @return [type] ...
106 */
107 function init() {
108 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
109 $this->MCONF = $GLOBALS['MCONF'];
110 $this->id = t3lib_div::GPvar('id');
111
112 $this->perms_clause = $BE_USER->getPagePermsClause(1);
113 $this->pointer = t3lib_div::GPvar('pointer');
114 $this->imagemode = t3lib_div::GPvar('imagemode');
115 $this->table = t3lib_div::GPvar('table');
116 $this->menuConfig();
117
118 if (t3lib_div::GPvar('clear_cache') || t3lib_div::GPvar('cmd')=='delete') {
119 $this->include_once[]=PATH_t3lib.'class.t3lib_tcemain.php';
120 }
121 }
122
123 /**
124 * [Describe function...]
125 *
126 * @return [type] ...
127 */
128 function menuConfig() {
129 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
130
131 // MENU-ITEMS:
132 // If array, then it's a selector box menu
133 // If empty string it's just a variable, that'll be saved.
134 // Values NOT in this array will not be saved in the settings-array for the module.
135 $this->MOD_MENU = array(
136 "bigControlPanel" => "",
137 "clipBoard" => ""
138 );
139
140 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->id,"mod.".$this->MCONF["name"]);
141
142 // CLEANSE SETTINGS
143 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::GPvar("SET"), $this->MCONF["name"]);
144 }
145
146 /**
147 * [Describe function...]
148 *
149 * @return [type] ...
150 */
151 function clearCache() {
152 if (t3lib_div::GPvar("clear_cache")) {
153 $tce = t3lib_div::makeInstance("t3lib_TCEmain");
154 $tce->start(Array(),Array());
155 $tce->clear_cacheCmd($this->id);
156 }
157 }
158
159 /**
160 * [Describe function...]
161 *
162 * @return [type] ...
163 */
164 function main() {
165 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
166
167 $this->doc = t3lib_div::makeInstance("template");
168 $this->doc->backPath = $BACK_PATH;
169
170
171 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
172 $access = is_array($this->pageinfo) ? 1 : 0;
173
174 $dblist = t3lib_div::makeInstance("localRecordList");
175 $dblist->backPath = $BACK_PATH;
176 $dblist->calcPerms = $BE_USER->calcPerms($this->pageinfo);
177 $dblist->thumbs = $BE_USER->uc["thumbnailsByDefault"];
178 $dblist->returnUrl=t3lib_div::GPvar("returnUrl");
179 $dblist->allFields = ($this->MOD_SETTINGS["bigControlPanel"] || $this->table) ? 1 : 0;
180 $dblist->showClipboard = 1;
181 $dblist->disableSingleTableView = $this->modTSconfig["properties"]["disableSingleTableView"];
182 $dblist->alternateBgColors=$this->modTSconfig["properties"]["alternateBgColors"]?1:0;
183 $dblist->allowedNewTables = t3lib_div::trimExplode(",",$this->modTSconfig["properties"]["allowedNewTables"],1);
184 $dblist->newWizards=$this->modTSconfig["properties"]["newWizards"]?1:0;
185
186 // ***********************
187 // CLipboard things...
188 // ***********************
189 $dblist->clipObj = t3lib_div::makeInstance("t3lib_clipboard"); // Start clipboard
190 $dblist->clipObj->initializeClipboard(); // Initialize - reads the clipboard content from the user session
191
192 $CB = $HTTP_GET_VARS["CB"]; // CB is the clipboard command array
193 if (t3lib_div::GPvar("cmd")=="setCB") {
194 // CBH is all the fields selected for the clipboard, CBC is the checkbox fields which were checked. By merging we get a full array of checked/unchecked elements
195 // This is set to the "el" array of the CB after being parsed so only the table in question is registered.
196 $CB["el"] = $dblist->clipObj->cleanUpCBC(array_merge($HTTP_POST_VARS["CBH"],$HTTP_POST_VARS["CBC"]),t3lib_div::GPvar("cmd_table"));
197 }
198 if (!$this->MOD_SETTINGS["clipBoard"]) $CB["setP"]="normal"; // If the clipboard is NOT shown, set the pad to "normal".
199 $dblist->clipObj->setCmd($CB); // Execute commands.
200 $dblist->clipObj->cleanCurrent(); // Clean up pad
201 $dblist->clipObj->endClipboard(); // Save the clipboard content
202
203
204 // This flag will prevent the
205 // It is set, if the clickmenu-layer is active AND the extended view is not enabled.
206 $dblist->dontShowClipControlPanels = $CLIENT["FORMSTYLE"] && !$this->MOD_SETTINGS["bigControlPanel"] && $dblist->clipObj->current=="normal" && !$BE_USER->uc["disableCMlayers"] && !$this->modTSconfig["properties"]["showClipControlPanelsDespiteOfCMlayers"];
207
208
209
210 if ($access) {
211
212 // Has not to do with the clipboard but is simply the delete action. The clipboard object is used to clean up the submitted entries to only the selected table.
213 if (t3lib_div::GPvar("cmd")=="delete") {
214 $items = $dblist->clipObj->cleanUpCBC($HTTP_POST_VARS["CBC"],t3lib_div::GPvar("cmd_table"),1);
215 if (count($items)) {
216 $cmd=array();
217 reset($items);
218 while(list($iK)=each($items)) {
219 $iKParts = explode("|",$iK);
220 $cmd[$iKParts[0]][$iKParts[1]]["delete"]=1;
221 }
222 $tce = t3lib_div::makeInstance("t3lib_TCEmain");
223 $tce->start(array(),$cmd);
224 $tce->process_cmdmap();
225
226 if (isset($cmd["pages"])) {
227 t3lib_BEfunc::getSetUpdateSignal("updatePageTree");
228 }
229
230 $tce->printLogErrorMessages(t3lib_div::getIndpEnv("REQUEST_URI"));
231 }
232 }
233
234 $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
235 $dblist->start($this->id,$this->table,$this->pointer,
236 t3lib_div::GPvar("search_field"),
237 t3lib_div::GPvar("search_levels"),
238 t3lib_div::GPvar("showLimit")
239 );
240 $dblist->setDispFields();
241 $dblist->writeTop($this->pageinfo,t3lib_BEfunc::getRecordPath (intval($this->pageinfo["uid"]),$this->perms_clause,15));
242 $dblist->generateList($this->id,$this->table);
243 $dblist->writeBottom();
244
245 $this->doc->JScode='
246 <script language="javascript" type="text/javascript">
247 function jumpToUrl(URL) { //
248 // alert("jumpToUrl: "+URL);
249 document.location = URL;
250 return false;
251 }
252 function jumpExt(URL,anchor) { //
253 var anc = anchor?anchor:"";
254 // alert("jumpExt: "+URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc);
255 document.location = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc;
256 return false;
257 }
258 function jumpSelf(URL) { //
259 // alert("jumpSelf: "+URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:""));
260 document.location = URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:"");
261 return false;
262 }
263 '.$this->doc->redirectUrls($dblist->listURL()).'
264 '.$dblist->CBfunctions().'
265 function editRecords(table,idList,addParams,CBflag) { //
266 document.location="'.$backPath.'alt_doc.php?returnUrl='.rawurlencode(t3lib_div::getIndpEnv("REQUEST_URI")).
267 '&edit["+table+"]["+idList+"]=edit"+addParams;
268 }
269 function editList(table,idList) { //
270 var list="";
271
272 // Checking how many is checked, how many is not
273 var pointer=0;
274 var pos = idList.indexOf(",");
275 while (pos!=-1) {
276 if (cbValue(table+"|"+idList.substr(pointer,pos-pointer))) {
277 list+=idList.substr(pointer,pos-pointer)+",";
278 }
279 pointer=pos+1;
280 pos = idList.indexOf(",",pointer);
281 }
282 if (cbValue(table+"|"+idList.substr(pointer))) {
283 list+=idList.substr(pointer)+",";
284 }
285
286 return list ? list : idList;
287 }
288
289 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
290 </script>
291 ';
292
293 $CMparts=$this->doc->getContextMenuCode();
294 $this->doc->bodyTagAdditions = $CMparts[1];
295 $this->doc->JScode.=$CMparts[0];
296 $this->doc->postCode.= $CMparts[2];
297 } // access
298
299
300
301 $this->content="";
302 $this->content.=$this->doc->startPage("DB list");
303 $this->content.= '<form action="'.$dblist->listURL().'" method="POST" name="dblistForm">';
304 $this->content.= $dblist->HTMLcode;
305 $this->content.= '<input type="hidden" name="cmd_table"><input type="hidden" name="cmd"></form>';
306
307 if ($dblist->HTMLcode) { // Making search form:
308 if ($dblist->table) { // Making search form:
309 $sBoxPre = $dblist->spaceSearchBoxFromLeft;
310 $dblist->spaceSearchBoxFromLeft=$sBoxPre;
311 $this->content.=$dblist->fieldSelectBox($dblist->table);
312 $dblist->spaceSearchBoxFromLeft=$sBoxPre;
313 $this->content.="";
314 }
315
316 $this->content.='<form action="" method="POST">';
317 $this->content.=t3lib_BEfunc::getFuncCheck($this->id,"SET[bigControlPanel]",$this->MOD_SETTINGS["bigControlPanel"],"db_list.php","")." ".$LANG->getLL("largeControl")."<BR>";
318 if ($dblist->showClipboard) $this->content.=t3lib_BEfunc::getFuncCheck($this->id,"SET[clipBoard]",$this->MOD_SETTINGS["clipBoard"],"db_list.php","").' '.$LANG->getLL("showClipBoard");
319 $this->content.='</form>';
320
321 // Printing clipboard if selected for.
322 if ($this->MOD_SETTINGS["clipBoard"] && $dblist->showClipboard) $this->content.=$dblist->clipObj->printClipboard();
323
324
325 if (!$this->modTSconfig["properties"]["noCreateRecordsLink"]) $this->content.='<a href="db_new.php?id='.$this->id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv("REQUEST_URI")).'"><img src="gfx/new_el.gif" width="11" height="12" hspace=4 border="0" align=top><strong>'.$LANG->getLL("newRecordGeneral").'</strong></a><BR><BR>';
326 $this->content.=$dblist->getSearchBox();
327 $this->content.="<BR>".$dblist->showSysNotesForPage();
328
329
330 // ShortCut
331 if ($BE_USER->mayMakeShortcut()) {
332 $this->content.=$this->doc->makeShortcutIcon("id,imagemode,pointer,table,search_field,search_levels,showLimit,sortField,sortRev",implode(",",array_keys($this->MOD_MENU)),$this->MCONF["name"]);
333 }
334 }
335 }
336
337 /**
338 * [Describe function...]
339 *
340 * @return [type] ...
341 */
342 function printContent() {
343 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
344
345 $this->content.= $this->doc->endPage();
346 echo $this->content;
347 }
348 }
349
350 // Include extension?
351 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_list.php']) {
352 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/db_list.php']);
353 }
354
355
356
357
358
359
360
361
362
363
364
365
366 // Make instance:
367 $SOBE = t3lib_div::makeInstance('SC_db_list');
368 $SOBE->init();
369
370 // Include files?
371 reset($SOBE->include_once);
372 while(list(,$INC_FILE)=each($SOBE->include_once)) {include_once($INC_FILE);}
373
374 $SOBE->clearCache();
375 $SOBE->main();
376 $SOBE->printContent();
377 ?>