Added TSconfig option (options.overridePageModule) for replacing the default Page...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tsfebeuserauth.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 * Class for TYPO3 backend user authentication in the TSFE frontend
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
32 * XHTML compliant
33 *
34 * @author Kasper Skaarhoj <kasper@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 101: class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth
42 * 127: function extInitFeAdmin()
43 * 147: function extPrintFeAdminDialog()
44 *
45 * SECTION: Creating sections of the Admin Panel
46 * 227: function extGetCategory_preview($out='')
47 * 258: function extGetCategory_cache($out='')
48 * 296: function extGetCategory_publish($out='')
49 * 331: function extGetCategory_edit($out='')
50 * 370: function extGetCategory_tsdebug($out='')
51 * 400: function extGetCategory_info($out='')
52 *
53 * SECTION: Admin Panel Layout Helper functions
54 * 473: function extGetHead($pre)
55 * 490: function extItemLink($pre,$str)
56 * 506: function extGetItem($pre,$element)
57 * 522: function extFw($str)
58 * 531: function ext_makeToolBar()
59 *
60 * SECTION: TSFE BE user Access Functions
61 * 586: function extPageReadAccess($pageRec)
62 * 597: function extAdmModuleEnabled($key)
63 * 613: function extSaveFeAdminConfig()
64 * 645: function extGetFeAdminValue($pre,$val='')
65 *
66 * SECTION: TSFE BE user Access Functions
67 * 703: function extGetTreeList($id,$depth,$begin=0,$perms_clause)
68 * 732: function extGetNumberOfCachedPages($page_id)
69 *
70 * SECTION: Localization handling
71 * 771: function extGetLL($key)
72 *
73 * SECTION: Frontend Editing
74 * 814: function extIsEditAction()
75 * 837: function extIsFormShown()
76 * 854: function extEditAction()
77 *
78 * TOTAL FUNCTIONS: 23
79 * (This index is automatically created/updated by the extension "extdeveval")
80 *
81 */
82
83
84
85
86
87
88
89
90
91
92
93 /**
94 * TYPO3 backend user authentication in the TSFE frontend.
95 * This includes mainly functions related to the Admin Panel
96 *
97 * @author Kasper Skaarhoj <kasper@typo3.com>
98 * @package TYPO3
99 * @subpackage t3lib
100 */
101 class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth {
102 var $formfield_uname = ''; // formfield with login-name
103 var $formfield_uident = ''; // formfield with password
104 var $formfield_chalvalue = ''; // formfield with a unique value which is used to encrypt the password and username
105 var $security_level = ''; // sets the level of security. *'normal' = clear-text. 'challenged' = hashed password/username from form in $formfield_uident. 'superchallenged' = hashed password hashed again with username.
106 var $writeStdLog = 0; // Decides if the writelog() function is called at login and logout
107 var $writeAttemptLog = 0; // If the writelog() functions is called if a login-attempt has be tried without success
108 var $auth_include = ''; // this is the name of the include-file containing the login form. If not set, login CAN be anonymous. If set login IS needed.
109
110 var $extNeedUpdate=0;
111 var $extPublishList='';
112 var $extPageInTreeInfo=array();
113 var $ext_forcePreview=0;
114 var $langSplitIndex=0;
115 var $extAdmEnabled = 0; // General flag which is set if the adminpanel should be displayed at all..
116
117
118
119
120 /**
121 * Initialize the usage of Admin Panel.
122 * Called from index_ts.php if a backend users is correctly logged in.
123 * Sets $this->extAdminConfig to the "admPanel" config for the user and $this->extAdmEnabled = 1 IF access is enabled.
124 *
125 * @return void
126 */
127 function extInitFeAdmin() {
128 $this->extAdminConfig = $this->getTSConfigProp('admPanel');
129 if (is_array($this->extAdminConfig['enable.'])) {
130 reset($this->extAdminConfig['enable.']);
131 while(list($k,$v)=each($this->extAdminConfig['enable.'])) {
132 if ($v) {
133 $this->extAdmEnabled=1;
134 break;
135 }
136 }
137 }
138 }
139
140 /**
141 * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
142 * Called from index_ts.php - in the end of the script
143 *
144 * @return string HTML for the Admin Panel
145 * @see index_ts.php
146 */
147 function extPrintFeAdminDialog() {
148 if ($this->uc['TSFE_adminConfig']['display_top']) {
149 if ($this->extAdmModuleEnabled('preview')) $out.= $this->extGetCategory_preview();
150 if ($this->extAdmModuleEnabled('cache')) $out.= $this->extGetCategory_cache();
151 if ($this->extAdmModuleEnabled('publish')) $out.= $this->extGetCategory_publish();
152 if ($this->extAdmModuleEnabled('edit')) $out.= $this->extGetCategory_edit();
153 if ($this->extAdmModuleEnabled('tsdebug')) $out.= $this->extGetCategory_tsdebug();
154 if ($this->extAdmModuleEnabled('info')) $out.= $this->extGetCategory_info();
155 }
156
157 $header.='<tr><td bgcolor="#9BA1A8" colspan="2" nowrap="nowrap">';
158 $header.=$this->extItemLink('top','<img src="t3lib/gfx/ol/'.($this->uc['TSFE_adminConfig']['display_top']?'minus':'plus').'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" />'.
159 $this->extFw('<strong>'.$this->extGetLL('adminOptions').'</strong>')).$this->extFw(': '.$this->user['username']).
160 '</td><td bgcolor="#9BA1A8"><img src="clear.gif" width="10" height="1" alt="" /></td><td bgcolor="#9BA1A8"><input type="hidden" name="TSFE_ADMIN_PANEL[display_top]" value="'.$this->uc['TSFE_adminConfig']['display_top'].'" />'.($this->extNeedUpdate?'<input type="submit" value="'.$this->extGetLL('update').'" />':'').'</td></tr>';
161
162 $out='<form name="TSFE_ADMIN_PANEL_FORM" action="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'#TSFE_ADMIN" method="post"><table border="0" cellpadding="0" cellspacing="0" bgcolor="#F6F2E6">'.$header.$out.'</table></form>';
163 $out='<a name="TSFE_ADMIN"></a><table border="0" cellpadding="1" cellspacing="0" bgcolor="black"><tr><td>'.$out.'</td></tr></table>';
164 if ($this->uc['TSFE_adminConfig']['display_top']) {
165 $out.='<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
166 $out.='
167 <script type="text/javascript">
168 /*<![CDATA[*/
169 var evalFunc = new evalFunc();
170 // TSFEtypo3FormFieldSet()
171 function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { //
172 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
173 var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
174 if (checkbox && theValue==checkboxValue) {
175 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
176 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
177 } else {
178 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
179 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
180 }
181 }
182 // TSFEtypo3FormFieldGet()
183 function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { //
184 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
185 if (checkbox_off) {
186 document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
187 }else{
188 document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
189 }
190 TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
191 }
192 /*]]>*/
193 </script>
194 <script language="javascript" type="text/javascript">'.$this->extJSCODE.'</script>';
195 }
196 return "\n\n\n\n".$out.'<br />';
197 }
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214 /*****************************************************
215 *
216 * Creating sections of the Admin Panel
217 *
218 ****************************************************/
219
220 /**
221 * Creates the content for the "preview" section ("module") of the Admin Panel
222 *
223 * @param string Optional start-value; The generated content is added to this variable.
224 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
225 * @see extPrintFeAdminDialog()
226 */
227 function extGetCategory_preview($out='') {
228 $out.=$this->extGetHead('preview');
229 if ($this->uc['TSFE_adminConfig']['display_preview']) {
230 $this->extNeedUpdate=1;
231 $out.=$this->extGetItem('preview_showHiddenPages', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="1"'.($this->uc['TSFE_adminConfig']['preview_showHiddenPages']?' checked="checked"':'').' />');
232 $out.=$this->extGetItem('preview_showHiddenRecords', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="1"'.($this->uc['TSFE_adminConfig']['preview_showHiddenRecords']?' checked="checked"':'').' />');
233
234 // Simulate data
235 $out.=$this->extGetItem('preview_simulateDate', '<input type="checkbox" name="TSFE_ADMIN_PANEL[preview_simulateDate]_cb" onclick="TSFEtypo3FormFieldGet(\'TSFE_ADMIN_PANEL[preview_simulateDate]\', \'datetime\', \'\',1,0,1);" /><input type="text" name="TSFE_ADMIN_PANEL[preview_simulateDate]_hr" onchange="TSFEtypo3FormFieldGet(\'TSFE_ADMIN_PANEL[preview_simulateDate]\', \'datetime\', \'\', 1,0);" /><input type="hidden" name="TSFE_ADMIN_PANEL[preview_simulateDate]" value="'.$this->uc['TSFE_adminConfig']['preview_simulateDate'].'" />');
236 $this->extJSCODE.='TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 1,0);';
237
238 // Simulate fe_user:
239 $query = 'SELECT fe_groups.uid, fe_groups.title FROM fe_groups,pages WHERE pages.uid=fe_groups.pid AND NOT pages.deleted '.t3lib_BEfunc::deleteClause('fe_groups').' AND '.$this->getPagePermsClause(1);
240 $res = mysql(TYPO3_db, $query);
241 echo mysql_error();
242 $options='<option value="0"></option>';
243 while($row=mysql_fetch_assoc($res)) {
244 $options.='<option value="'.$row['uid'].'"'.($this->uc['TSFE_adminConfig']['preview_simulateUserGroup']==$row['uid']?' selected="selected"':'').'>'.htmlspecialchars('['.$row['uid'].'] '.$row['title']).'</option>';
245 }
246 $out.=$this->extGetItem('preview_simulateUserGroup', '<select name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">'.$options.'</select>');
247 }
248 return $out;
249 }
250
251 /**
252 * Creates the content for the "cache" section ("module") of the Admin Panel
253 *
254 * @param string Optional start-value; The generated content is added to this variable.
255 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
256 * @see extPrintFeAdminDialog()
257 */
258 function extGetCategory_cache($out='') {
259 $out.=$this->extGetHead('cache');
260 if ($this->uc['TSFE_adminConfig']['display_cache']) {
261 $this->extNeedUpdate=1;
262 $out.=$this->extGetItem('cache_noCache', '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_noCache]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[cache_noCache]" value="1"'.($this->uc['TSFE_adminConfig']['cache_noCache']?' checked="checked"':'').' />');
263
264 $options='';
265 $options.='<option value="0"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==0?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_0').'</option>';
266 $options.='<option value="1"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==1?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_1').'</option>';
267 $options.='<option value="2"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==2?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_2').'</option>';
268 $out.=$this->extGetItem('cache_clearLevels', '<select name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">'.$options.'</select>'.
269 '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="'.$GLOBALS['TSFE']->id.'" /><input type="submit" value="'.$this->extGetLL('update').'" />');
270
271 // Generating tree:
272 $depth=$this->extGetFeAdminValue('cache','clearCacheLevels');
273 $outTable='';
274 $this->extPageInTreeInfo=array();
275 $this->extPageInTreeInfo[]=array($GLOBALS['TSFE']->page['uid'],$GLOBALS['TSFE']->page['title'],$depth+1);
276 $this->extGetTreeList($GLOBALS['TSFE']->id, $depth,0,$this->getPagePermsClause(1));
277 reset($this->extPageInTreeInfo);
278 while(list(,$row)=each($this->extPageInTreeInfo)) {
279 $outTable.='<tr><td nowrap="nowrap"><img src="clear.gif" width="'.(($depth+1-$row[2])*18).'" height="1" alt="" /><img src="t3lib/gfx/i/pages.gif" width="18" height="16" align="absmiddle" border="0" alt="" />'.$this->extFw($row[1]).'</td><td><img src="clear.gif" width="10" height="1" alt="" /></td><td>'.$this->extFw($this->extGetNumberOfCachedPages($row[0])).'</td></tr>';
280 }
281 $outTable='<br /><table border="0" cellpadding="0" cellspacing="0">'.$outTable.'</table>';
282 $outTable.='<input type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="'.$this->extGetLL('cache_doit').'" />';
283 $out.=$this->extGetItem('cache_cacheEntries', $outTable);
284
285 }
286 return $out;
287 }
288
289 /**
290 * Creates the content for the "publish" section ("module") of the Admin Panel
291 *
292 * @param string Optional start-value; The generated content is added to this variable.
293 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
294 * @see extPrintFeAdminDialog()
295 */
296 function extGetCategory_publish($out='') {
297 $out.=$this->extGetHead('publish');
298 if ($this->uc['TSFE_adminConfig']['display_publish']) {
299 $this->extNeedUpdate=1;
300 $options='';
301 $options.='<option value="0"'.($this->uc['TSFE_adminConfig']['publish_levels']==0?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_0').'</option>';
302 $options.='<option value="1"'.($this->uc['TSFE_adminConfig']['publish_levels']==1?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_1').'</option>';
303 $options.='<option value="2"'.($this->uc['TSFE_adminConfig']['publish_levels']==2?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_2').'</option>';
304 $out.=$this->extGetItem('publish_levels', '<select name="TSFE_ADMIN_PANEL[publish_levels]">'.$options.'</select>'.
305 '<input type="hidden" name="TSFE_ADMIN_PANEL[publish_id]" value="'.$GLOBALS['TSFE']->id.'" /><input type="submit" value="'.$this->extGetLL('update').'" />');
306
307 // Generating tree:
308 $depth=$this->extGetFeAdminValue('publish','levels');
309 $outTable='';
310 $this->extPageInTreeInfo=array();
311 $this->extPageInTreeInfo[]=array($GLOBALS['TSFE']->page['uid'],$GLOBALS['TSFE']->page['title'],$depth+1);
312 $this->extGetTreeList($GLOBALS['TSFE']->id, $depth,0,$this->getPagePermsClause(1));
313 reset($this->extPageInTreeInfo);
314 while(list(,$row)=each($this->extPageInTreeInfo)) {
315 $outTable.='<tr><td nowrap="nowrap"><img src="clear.gif" width="'.(($depth+1-$row[2])*18).'" height="1" alt="" /><img src="t3lib/gfx/i/pages.gif" width="18" height="16" align="absmiddle" border="0" alt="" />'.$this->extFw($row[1]).'</td><td><img src="clear.gif" width="10" height="1" alt="" /></td><td>'.$this->extFw('...').'</td></tr>';
316 }
317 $outTable='<br /><table border="0" cellpadding="0" cellspacing="0">'.$outTable.'</table>';
318 $outTable.='<input type="submit" name="TSFE_ADMIN_PANEL[action][publish]" value="'.$this->extGetLL('publish_doit').'" />';
319 $out.=$this->extGetItem('publish_tree', $outTable);
320 }
321 return $out;
322 }
323
324 /**
325 * Creates the content for the "edit" section ("module") of the Admin Panel
326 *
327 * @param string Optional start-value; The generated content is added to this variable.
328 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
329 * @see extPrintFeAdminDialog()
330 */
331 function extGetCategory_edit($out='') {
332 $out.=$this->extGetHead('edit');
333 if ($this->uc['TSFE_adminConfig']['display_edit']) {
334 // If another page module was specified, replace the default Page module with the new one
335 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
336 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
337
338 $this->extNeedUpdate=1;
339 $out.=$this->extGetItem('edit_displayFieldIcons', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="1"'.($this->uc['TSFE_adminConfig']['edit_displayFieldIcons']?' checked="checked"':'').' />');
340 $out.=$this->extGetItem('edit_displayIcons', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="1"'.($this->uc['TSFE_adminConfig']['edit_displayIcons']?' checked="checked"':'').' />');
341 $out.=$this->extGetItem('edit_editFormsOnPage', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_editFormsOnPage]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_editFormsOnPage]" value="1"'.($this->uc['TSFE_adminConfig']['edit_editFormsOnPage']?' checked="checked"':'').' />');
342 $out.=$this->extGetItem('edit_editNoPopup', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_editNoPopup]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_editNoPopup]" value="1"'.($this->uc['TSFE_adminConfig']['edit_editNoPopup']?' checked="checked"':'').' />');
343
344 $out.=$this->extGetItem('', $this->ext_makeToolBar());
345 if (!t3lib_div::GPvar('ADMCMD_view')) {
346 $out.=$this->extGetItem('', '<a href="#" onclick="'.
347 htmlspecialchars('
348 if (parent.opener && parent.opener.top && parent.opener.top.TS) {
349 parent.opener.top.fsMod.recentIds["web"]='.intval($GLOBALS['TSFE']->page['uid']).';
350 if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav) {
351 parent.opener.top.content.nav_frame.refresh_nav();
352 }
353 parent.opener.top.goToModule("'.$pageModule.'");
354 parent.opener.top.focus();
355 } else {
356 vHWin=window.open(\''.TYPO3_mainDir.'alt_main.php\',\''.md5('Typo3Backend-'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']).'\',\'status=1,menubar=1,scrollbars=1,resizable=1\');
357 vHWin.focus();
358 }
359 return false;
360 ').
361 '">'.$this->extFw($this->extGetLL('edit_openAB')).'</a>');
362 }
363 }
364 return $out;
365 }
366
367 /**
368 * Creates the content for the "tsdebug" section ("module") of the Admin Panel
369 *
370 * @param string Optional start-value; The generated content is added to this variable.
371 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
372 * @see extPrintFeAdminDialog()
373 */
374 function extGetCategory_tsdebug($out='') {
375 $out.=$this->extGetHead('tsdebug');
376 if ($this->uc['TSFE_adminConfig']['display_tsdebug']) {
377 $this->extNeedUpdate=1;
378 $out.=$this->extGetItem('tsdebug_tree', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_tree']?' checked="checked"':'').' />');
379 $out.=$this->extGetItem('tsdebug_displayTimes', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_displayTimes']?' checked="checked"':'').' />');
380 $out.=$this->extGetItem('tsdebug_displayMessages', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_displayMessages']?' checked="checked"':'').' />');
381 $out.=$this->extGetItem('tsdebug_LR', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_LR']?' checked="checked"':'').' />');
382 $out.=$this->extGetItem('tsdebug_displayContent', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_displayContent']?' checked="checked"':'').' />');
383 $out.=$this->extGetItem('tsdebug_displayQueries', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_displayQueries']?' checked="checked"':'').' />');
384
385 $out.=$this->extGetItem('tsdebug_forceTemplateParsing', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_forceTemplateParsing']?' checked="checked"':'').' />');
386
387 $GLOBALS['TT']->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug','tree');
388 $GLOBALS['TT']->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug','displayTimes');
389 $GLOBALS['TT']->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug','displayMessages');
390 $GLOBALS['TT']->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug','displayContent');
391 $GLOBALS['TT']->printConf['flag_queries'] = $this->extGetFeAdminValue('tsdebug','displayQueries');
392 $out.='<tr><td><img src="clear.gif" width="50" height="1" alt="" /></td><td colspan="3">'.$GLOBALS['TT']->printTSlog().'</td></tr>';
393 }
394 return $out;
395 }
396
397 /**
398 * Creates the content for the "info" section ("module") of the Admin Panel
399 *
400 * @param string Optional start-value; The generated content is added to this variable.
401 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
402 * @see extPrintFeAdminDialog()
403 */
404 function extGetCategory_info($out='') {
405 $out.=$this->extGetHead('info');
406 if ($this->uc['TSFE_adminConfig']['display_info']) {
407
408 if (is_array($GLOBALS['TSFE']->imagesOnPage) && $this->extGetFeAdminValue('cache','noCache')) {
409 reset($GLOBALS['TSFE']->imagesOnPage);
410 $theBytes=0;
411 $count=0;
412 $fileTable='';
413 while(list(,$file)=each($GLOBALS['TSFE']->imagesOnPage)) {
414 $fs=@filesize($file);
415 $fileTable.='<tr><td>'.$this->extFw($file).'</td><td align="right">'.$this->extFw(t3lib_div::formatSize($fs)).'</td></tr>';
416 $theBytes+=$fs;
417 $count++;
418 }
419 $fileTable.='<tr><td><strong>'.$this->extFw('Total number of images:').'</strong></td><td>'.$this->extFw($count).'</td></tr>';
420 $fileTable.='<tr><td><strong>'.$this->extFw('Total image file sizes:').'</strong></td><td align="right">'.$this->extFw(t3lib_div::formatSize($theBytes)).'</td></tr>';
421 $fileTable.='<tr><td><strong>'.$this->extFw('Document size:').'</strong></td><td align="right">'.$this->extFw(t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content))).'</td></tr>';
422 $fileTable.='<tr><td><strong>'.$this->extFw('Total page load:').'</strong></td><td align="right">'.$this->extFw(t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)+$theBytes)).'</td></tr>';
423 $fileTable.='<tr><td>&nbsp;</td></tr>';
424 }
425
426 $fileTable.='<tr><td>'.$this->extFw('id:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->id).'</td></tr>';
427 $fileTable.='<tr><td>'.$this->extFw('type:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->type).'</td></tr>';
428 $fileTable.='<tr><td>'.$this->extFw('gr_list:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->gr_list).'</td></tr>';
429 $fileTable.='<tr><td>'.$this->extFw('no_cache:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->no_cache).'</td></tr>';
430 $fileTable.='<tr><td>'.$this->extFw('fe_user, name:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->fe_user->user['username']).'</td></tr>';
431 $fileTable.='<tr><td>'.$this->extFw('fe_user, uid:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->fe_user->user['uid']).'</td></tr>';
432 $fileTable.='<tr><td>&nbsp;</td></tr>';
433
434 // parsetime:
435 $fileTable.='<tr><td>'.$this->extFw('Total parsetime:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->scriptParseTime.' ms').'</td></tr>';
436
437 $fileTable='<table border="0" cellpadding="0" cellspacing="0">'.$fileTable.'</table>';
438
439 $out.='<tr><td><img src="clear.gif" width="50" height="1" alt="" /></td><td colspan="3">'.$fileTable.'</td></tr>';
440 }
441 return $out;
442 }
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461 /*****************************************************
462 *
463 * Admin Panel Layout Helper functions
464 *
465 ****************************************************/
466
467 /**
468 * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
469 * It will have a plus/minus icon and a label which is linked so that it submits the form which surrounds the whole Admin Panel when clicked, alterting the TSFE_ADMIN_PANEL[display_'.$pre.'] value
470 * See the functions extGetCategory_*
471 *
472 * @param string The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
473 * @return string HTML table row.
474 * @access private
475 * @see extGetItem()
476 */
477 function extGetHead($pre) {
478 $out.='<img src="t3lib/gfx/ol/blank.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
479 $out.='<img src="t3lib/gfx/ol/'.($this->uc['TSFE_adminConfig']['display_'.$pre]?'minus':'plus').'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
480 $out.=$this->extFw($this->extGetLL($pre));
481 $out=$this->extItemLink($pre,$out);
482 return '<tr><td bgcolor="#ABBBB4" colspan="4" nowrap="nowrap">'.$out.'<input type="hidden" name="TSFE_ADMIN_PANEL[display_'.$pre.']" value="'.$this->uc['TSFE_adminConfig']['display_'.$pre].'" /></td></tr>';
483 }
484
485 /**
486 * Wraps a string in a link which will open/close a certain part of the Admin Panel
487 *
488 * @param string The code for the display_ label/key
489 * @param string Input string
490 * @return string Linked input string
491 * @access private
492 * @see extGetHead()
493 */
494 function extItemLink($pre,$str) {
495 return '<a href="#" onclick="'.
496 htmlspecialchars('document.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[display_'.$pre.']\'].value='.($this->uc['TSFE_adminConfig']['display_'.$pre]?'0':'1').'; document.TSFE_ADMIN_PANEL_FORM.submit(); return false;').
497 '">'.$str.'</a>';
498 }
499
500 /**
501 * Returns a row (with 4 columns) for content in a section of the Admin Panel.
502 * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
503 *
504 * @param string Key to label
505 * @param string The HTML content for the forth table cell.
506 * @return string HTML table row.
507 * @access private
508 * @see extGetHead()
509 */
510 function extGetItem($pre,$element) {
511 return '<tr>
512 <td><img src="clear.gif" width="50" height="1" alt="" /></td>
513 <td nowrap="nowrap">'.($pre ? $this->extFw($this->extGetLL($pre)) : '&nbsp;').'</td>
514 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
515 <td>'.$element.'</td>
516 </tr>';
517
518 }
519
520 /**
521 * Wraps a string in a font-tag with verdana, size 1 and black
522 *
523 * @param string The string to wrap
524 * @return string
525 */
526 function extFw($str) {
527 return '<font face="Verdana" size="1" color="black"'.($GLOBALS['CLIENT']['FORMSTYLE']?' style="color:black;"':'').'>'.$str.'</font>';
528 }
529
530 /**
531 * Creates the tool bar links for the "edit" section of the Admin Panel.
532 *
533 * @return string A string containing images wrapped in <a>-tags linking them to proper functions.
534 */
535 function ext_makeToolBar() {
536 $toolBar='';
537 $id = $GLOBALS['TSFE']->id;
538 $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'show_rechis.php?element='.rawurlencode('pages:'.$id).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'#latest">'.
539 '<img src="t3lib/gfx/history2.gif" width="13" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_recordHistory').'" alt="" /></a>';
540 $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'sysext/cms/layout/db_new_content_el.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
541 '<img src="t3lib/gfx/new_record.gif" width="16" height="12" hspace="1" border="0" align="top" title="'.$this->extGetLL('edit_newContentElement').'" alt="" /></a>';
542 $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'move_el.php?table=pages&uid='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
543 '<img src="t3lib/gfx/move_page.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_move_page').'" alt="" /></a>';
544 $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'db_new.php?id='.$id.'&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
545 '<img src="t3lib/gfx/new_page.gif" width="13" height="12" hspace="0" border="0" align="top" title="'.$this->extGetLL('edit_newPage').'" alt="" /></a>';
546
547 $params='&edit[pages]['.$id.']=edit';
548 $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'alt_doc.php?'.$params.'&noView=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
549 '<img src="t3lib/gfx/edit2.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_editPageHeader').'" alt="" /></a>';
550 if ($this->check('modules','web_list')) {
551 $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
552 '<img src="t3lib/gfx/list.gif" width="11" height="11" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_db_list').'" alt="" /></a>';
553 }
554 return $toolBar;
555 }
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575 /*****************************************************
576 *
577 * TSFE BE user Access Functions
578 *
579 ****************************************************/
580
581 /**
582 * Evaluates if the Backend User has read access to the input page record.
583 * The evaluation is based on both read-permission and whether the page is found in one of the users webmounts. Only if both conditions are true will the function return true.
584 * Read access means that previewing is allowed etc.
585 * Used in index_ts.php
586 *
587 * @param array The page record to evaluate for
588 * @return boolean True if read access
589 */
590 function extPageReadAccess($pageRec) {
591 return $this->isInWebMount($pageRec['uid']) && $this->doesUserHaveAccess($pageRec,1);
592 }
593
594 /**
595 * Checks if a Admin Panel section ("module") is available for the user. If so, true is returned.
596 *
597 * @param string The module key, eg. "edit", "preview", "info" etc.
598 * @return boolean
599 * @see extPrintFeAdminDialog()
600 */
601 function extAdmModuleEnabled($key) {
602 // Returns true if the module checked is "preview" and the forcePreview flag is set.
603 if ($key=="preview" && $this->ext_forcePreview) return true;
604 // If key is not set, only "all" is checked
605 if ($this->extAdminConfig['enable.']['all']) return true;
606 if ($this->extAdminConfig['enable.'][$key]) {
607 return true;
608 }
609 }
610
611 /**
612 * Saves any change in settings made in the Admin Panel.
613 * Called from index_ts.php right after access check for the Admin Panel
614 *
615 * @return void
616 */
617 function extSaveFeAdminConfig() {
618 if (is_array($GLOBALS['HTTP_POST_VARS']['TSFE_ADMIN_PANEL'])) {
619 // Setting
620 $input = $GLOBALS['HTTP_POST_VARS']['TSFE_ADMIN_PANEL'];
621 $this->uc['TSFE_adminConfig'] = array_merge(!is_array($this->uc['TSFE_adminConfig'])?array():$this->uc['TSFE_adminConfig'], $input); // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
622 unset($this->uc['TSFE_adminConfig']['action']);
623
624 // Actions:
625 if ($input['action']['clearCache'] && $this->extAdmModuleEnabled('cache')) {
626 $this->extPageInTreeInfo=array();
627 $theStartId = intval($input['cache_clearCacheId']);
628 $GLOBALS['TSFE']->clearPageCacheContent_pidList($this->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache','clearCacheLevels'),0,$this->getPagePermsClause(1)).$theStartId);
629 }
630 if ($input['action']['publish'] && $this->extAdmModuleEnabled('publish')) {
631 $theStartId = intval($input['publish_id']);
632 $this->extPublishList = $this->extGetTreeList($theStartId, $this->extGetFeAdminValue('publish','levels'),0,$this->getPagePermsClause(1)).$theStartId;
633 }
634
635 // Saving
636 $this->writeUC();
637 }
638 $GLOBALS['TT']->LR = $this->extGetFeAdminValue('tsdebug','LR');
639 if ($this->extGetFeAdminValue('cache','noCache')) {$GLOBALS['TSFE']->set_no_cache();}
640 }
641
642 /**
643 * Returns the value for a Admin Panel setting. You must specify both the module-key and the internal setting key.
644 *
645 * @param string Module key
646 * @param string Setting key
647 * @return string The setting value
648 */
649 function extGetFeAdminValue($pre,$val='') {
650 if ($this->extAdmModuleEnabled($pre)) { // Check if module is enabled.
651 // Exceptions where the values can be overridden from backend:
652 if ($pre.'_'.$val == 'edit_displayIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayIcons']) {
653 return true;
654 }
655 if ($pre.'_'.$val == 'edit_displayFieldIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons']) {
656 return true;
657 }
658
659 $retVal = $val ? $this->uc['TSFE_adminConfig'][$pre.'_'.$val] : 1;
660
661 if ($pre=='preview' && $this->ext_forcePreview) {
662 if (!$val) {
663 return true;
664 } else {
665 return $retVal;
666 }
667 }
668
669 // regular check:
670 if ($this->uc['TSFE_adminConfig']['display_top'] && $this->uc['TSFE_adminConfig']['display_'.$pre]) { // See if the menu is expanded!
671 return $retVal;
672 }
673 }
674 }
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691 /*****************************************************
692 *
693 * TSFE BE user Access Functions
694 *
695 ****************************************************/
696
697 /**
698 * Generates a list of Page-uid's from $id. List does not include $id itself
699 * The only pages excluded from the list are deleted pages.
700 *
701 * @param integer Start page id
702 * @param integer Depth to traverse down the page tree.
703 * @param integer $begin is an optional integer that determines at which level in the tree to start collecting uid's. Zero means 'start right away', 1 = 'next level and out'
704 * @param string Perms clause
705 * @return string Returns the list with a comma in the end (if any pages selected!)
706 */
707 function extGetTreeList($id,$depth,$begin=0,$perms_clause) {
708 $depth=intval($depth);
709 $begin=intval($begin);
710 $id=intval($id);
711 $theList='';
712
713 if ($id && $depth>0) {
714 $query = 'SELECT uid,title FROM pages WHERE pid='.$id.' AND doktype IN ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].') AND NOT deleted AND '.$perms_clause;
715 $res = mysql(TYPO3_db, $query);
716 echo mysql_error();
717 while ($row = mysql_fetch_assoc($res)) {
718 if ($begin<=0) {
719 $theList.=$row['uid'].',';
720 $this->extPageInTreeInfo[]=array($row['uid'],$row['title'],$depth);
721 }
722 if ($depth>1) {
723 $theList.=$this->extGetTreeList($row['uid'], $depth-1,$begin-1,$perms_clause);
724 }
725 }
726 }
727 return $theList;
728 }
729
730 /**
731 * Returns the number of cached pages for a page id.
732 *
733 * @param integer The page id.
734 * @return integer The number of pages for this page in the table "cache_pages"
735 */
736 function extGetNumberOfCachedPages($page_id) {
737 $res = mysql (TYPO3_db, 'SELECT count(*) FROM cache_pages WHERE page_id='.intval($page_id));
738 list($num) = mysql_fetch_row($res);
739 return $num;
740 }
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762 /*****************************************************
763 *
764 * Localization handling
765 *
766 ****************************************************/
767
768 /**
769 * Returns the label for key, $key. If a translation for the language set in $this->uc['lang'] is found that is returned, otherwise the default value.
770 * IF the global variable $LOCAL_LANG is NOT an array (yet) then this function loads the global $LOCAL_LANG array with the content of "sysext/lang/locallang_tsfe.php" so that the values therein can be used for labels in the Admin Panel
771 *
772 * @param string Key for a label in the $LOCAL_LANG array of "sysext/lang/locallang_tsfe.php"
773 * @return string The value for the $key
774 */
775 function extGetLL($key) {
776 global $LOCAL_LANG;
777 if (!is_array($LOCAL_LANG)) {
778 include('./'.TYPO3_mainDir.'sysext/lang/locallang_tsfe.php');
779 if (!is_array($LOCAL_LANG)) $LOCAL_LANG=array();
780 }
781
782 $labelStr = htmlspecialchars($GLOBALS['LANG']->getLL($key)); // Label string in the default backend output charset.
783
784 // Convert to utf-8, then to entities:
785 if ($GLOBALS['LANG']->charSet!='utf-8') {
786 $labelStr = $GLOBALS['LANG']->csConvObj->utf8_encode($labelStr,$GLOBALS['LANG']->charSet);
787 }
788 $labelStr = $GLOBALS['LANG']->csConvObj->utf8_to_entities($labelStr);
789
790 // Return the result:
791 return $labelStr;
792 }
793
794
795
796
797
798
799
800
801
802
803
804
805
806 /*****************************************************
807 *
808 * Frontend Editing
809 *
810 ****************************************************/
811
812 /**
813 * Returns true in an edit-action is sent from the Admin Panel
814 *
815 * @return boolean
816 * @see index_ts.php
817 */
818 function extIsEditAction() {
819 $TSFE_EDIT = $GLOBALS['HTTP_POST_VARS']['TSFE_EDIT'];
820 if (is_array($TSFE_EDIT)) {
821 /* $cmd=(string)$TSFE_EDIT['cmd'];
822 if ($cmd!="edit" && $cmd!='new') {
823 return true;
824 }*/
825 if ($TSFE_EDIT['cancel']) {
826 unset($TSFE_EDIT['cmd']);
827 } elseif (($cmd!='edit' || (is_array($TSFE_EDIT['data']) && ($TSFE_EDIT['update'] || $TSFE_EDIT['update_close']))) && $cmd!='new') {
828 // $cmd can be a command like "hide" or "move". If $cmd is "edit" or "new" it's an indication to show the formfields. But if data is sent with update-flag then $cmd = edit is accepted because edit may be sendt because of .keepGoing flag.
829 return true;
830 }
831 }
832 }
833
834 /**
835 * Returns true if an edit form is shown on the page.
836 * Used from index_ts.php where a true return-value will result in classes etc. being included.
837 *
838 * @return boolean
839 * @see index_ts.php
840 */
841 function extIsFormShown() {
842 $TSFE_EDIT = $GLOBALS['HTTP_POST_VARS']['TSFE_EDIT'];
843 if (is_array($TSFE_EDIT)) {
844 $cmd=(string)$TSFE_EDIT['cmd'];
845 if ($cmd=='edit' || $cmd=='new') {
846 return true;
847 }
848 }
849 }
850
851 /**
852 * Management of the on-page frontend editing forms and edit panels.
853 * Basically taking in the data and commands and passes them on to the proper classes as they should be.
854 *
855 * @return void
856 * @see index_ts.php
857 */
858 function extEditAction() {
859 global $TCA;
860 // Commands:
861 $TSFE_EDIT = $GLOBALS['HTTP_POST_VARS']['TSFE_EDIT'];
862
863 list($table,$uid) = explode(':',$TSFE_EDIT['record']);
864 if ($TSFE_EDIT['cmd'] && $table && $uid && isset($TCA[$table])) {
865 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
866 $recData=array();
867 $cmdData=array();
868 $cmd=$TSFE_EDIT['cmd'];
869 switch($cmd) {
870 case 'hide':
871 case 'unhide':
872 $hideField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
873 if ($hideField) {
874 $recData[$table][$uid][$hideField]=($cmd=='hide'?1:0);
875 $tce->start($recData,Array());
876 $tce->process_datamap();
877 }
878 break;
879 case 'up':
880 case 'down':
881 $sortField = $TCA[$table]['ctrl']['sortby'];
882 if ($sortField) {
883 if ($cmd=='up') {
884 $op= '<';
885 $desc=' DESC';
886 } else {
887 $op= '>';
888 $desc='';
889 }
890 // Get self:
891 $fields = array_unique(t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['copyAfterDuplFields'].',uid,pid,'.$sortField,1));
892 $query='SELECT '.implode(',',$fields).' FROM '.$table.' WHERE uid='.$uid;
893 $res = mysql(TYPO3_db,$query);
894 if ($row=mysql_fetch_assoc($res)) {
895 // record before or after
896 $preview = $this->extGetFeAdminValue('preview');
897 $copyAfterFieldsQuery = '';
898 if ($preview) {$ignore = array('starttime'=>1, 'endtime'=>1, 'disabled'=>1, 'fe_group'=>1);}
899 if ($TCA[$table]['ctrl']['copyAfterDuplFields']) {
900 $cAFields = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['copyAfterDuplFields'],1);
901 while(list(,$fN)=each($cAFields)) {
902 $copyAfterFieldsQuery.=' AND '.$fN.'="'.$row[$fN].'"';
903 }
904 }
905
906 $query='SELECT uid,pid FROM '.$table.' WHERE pid='.$row['pid'].
907 ' AND '.$sortField.$op.intval($row[$sortField]).
908 $copyAfterFieldsQuery.
909 t3lib_pageSelect::enableFields($table,'',$ignore).
910 ' ORDER BY '.$sortField.$desc.
911 ' LIMIT 2';
912
913 $res = mysql(TYPO3_db,$query);
914 if ($row2=mysql_fetch_assoc($res)) {
915 if($cmd=='down') {
916 $cmdData[$table][$uid]['move']= -$row2['uid'];
917 } elseif ($row3=mysql_fetch_assoc($res)) { // Must take the second record above...
918 $cmdData[$table][$uid]['move']= -$row3['uid'];
919 } else { // ... and if that does not exist, use pid
920 $cmdData[$table][$uid]['move']= $row['pid'];
921 }
922 } elseif ($cmd=='up') {
923 $cmdData[$table][$uid]['move']= $row['pid'];
924 }
925 }
926 if (count($cmdData)) {
927 $tce->start(Array(),$cmdData);
928 $tce->process_cmdmap();
929 }
930 }
931 break;
932 case 'delete':
933 $cmdData[$table][$uid]['delete']= 1;
934 if (count($cmdData)) {
935 $tce->start(Array(),$cmdData);
936 $tce->process_cmdmap();
937 }
938 break;
939 }
940 }
941 // Data:
942 if (($TSFE_EDIT['doSave'] || $TSFE_EDIT['update'] || $TSFE_EDIT['update_close']) && is_array($TSFE_EDIT['data'])) {
943 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
944 # $tce->stripslashes_values=0; // This line is NOT needed because $TSFE_EDIT['data'] is already slashed and needs slashes stripped.
945 $tce->start($TSFE_EDIT['data'],Array());
946 $tce->process_uploads($GLOBALS['HTTP_POST_FILES']);
947 $tce->process_datamap();
948 }
949 }
950 }
951
952
953 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsfebeuserauth.php']) {
954 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsfebeuserauth.php']);
955 }
956 ?>