Removed the tree filter toggle
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tsfebeuserauth.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2007 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 * 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 <kasperYYYY@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 103: class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth
42 * 129: function extInitFeAdmin()
43 * 154: function extPrintFeAdminDialog()
44 *
45 * SECTION: Creating sections of the Admin Panel
46 * 250: function extGetCategory_preview($out='')
47 * 283: function extGetCategory_cache($out='')
48 * 321: function extGetCategory_publish($out='')
49 * 356: function extGetCategory_edit($out='')
50 * 400: function extGetCategory_tsdebug($out='')
51 * 433: function extGetCategory_info($out='')
52 *
53 * SECTION: Admin Panel Layout Helper functions
54 * 506: function extGetHead($pre)
55 * 526: function extItemLink($pre,$str)
56 * 542: function extGetItem($pre,$element)
57 * 559: function extFw($str)
58 * 568: function ext_makeToolBar()
59 *
60 * SECTION: TSFE BE user Access Functions
61 * 637: function checkBackendAccessSettingsFromInitPhp()
62 * 682: function extPageReadAccess($pageRec)
63 * 693: function extAdmModuleEnabled($key)
64 * 709: function extSaveFeAdminConfig()
65 * 741: function extGetFeAdminValue($pre,$val='')
66 * 783: function extIsAdmMenuOpen($pre)
67 *
68 * SECTION: TSFE BE user Access Functions
69 * 818: function extGetTreeList($id,$depth,$begin=0,$perms_clause)
70 * 849: function extGetNumberOfCachedPages($page_id)
71 *
72 * SECTION: Localization handling
73 * 888: function extGetLL($key)
74 *
75 * SECTION: Frontend Editing
76 * 932: function extIsEditAction()
77 * 954: function extIsFormShown()
78 * 970: function extEditAction()
79 *
80 * TOTAL FUNCTIONS: 25
81 * (This index is automatically created/updated by the extension "extdeveval")
82 *
83 */
84
85
86
87
88
89
90
91
92
93
94
95 /**
96 * TYPO3 backend user authentication in the TSFE frontend.
97 * This includes mainly functions related to the Admin Panel
98 *
99 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
100 * @package TYPO3
101 * @subpackage t3lib
102 */
103 class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth {
104 var $formfield_uname = ''; // formfield with login-name
105 var $formfield_uident = ''; // formfield with password
106 var $formfield_chalvalue = ''; // formfield with a unique value which is used to encrypt the password and username
107 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.
108 var $writeStdLog = 0; // Decides if the writelog() function is called at login and logout
109 var $writeAttemptLog = 0; // If the writelog() functions is called if a login-attempt has be tried without success
110 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.
111
112 var $extNeedUpdate=0;
113 var $extPublishList='';
114 var $extPageInTreeInfo=array();
115 var $ext_forcePreview=0;
116 var $langSplitIndex=0;
117 var $extAdmEnabled = 0; // General flag which is set if the adminpanel should be displayed at all..
118
119
120
121
122 /**
123 * Initialize the usage of Admin Panel.
124 * Called from index_ts.php if a backend users is correctly logged in.
125 * Sets $this->extAdminConfig to the "admPanel" config for the user and $this->extAdmEnabled = 1 IF access is enabled.
126 *
127 * @return void
128 */
129 function extInitFeAdmin() {
130 $this->extAdminConfig = $this->getTSConfigProp('admPanel');
131 if (is_array($this->extAdminConfig['enable.'])) {
132 reset($this->extAdminConfig['enable.']);
133 while(list($k,$v)=each($this->extAdminConfig['enable.'])) {
134 if ($v) {
135 $this->extAdmEnabled=1; // Enable panel
136 break;
137 }
138 }
139 }
140
141 // Init TSFE_EDIT variables if either the admPanel is enabled or if forceDisplayIcons is set
142 if($this->extAdmEnabled || $this->extGetFeAdminValue('edit', 'displayIcons')) {
143 $this->TSFE_EDIT = t3lib_div::_POST('TSFE_EDIT');
144 }
145 }
146
147 /**
148 * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
149 * Called from index_ts.php - in the end of the script
150 *
151 * @return string HTML for the Admin Panel
152 * @see index_ts.php
153 */
154 function extPrintFeAdminDialog() {
155 $out='';
156 if ($this->uc['TSFE_adminConfig']['display_top']) {
157 if ($this->extAdmModuleEnabled('preview')) $out.= $this->extGetCategory_preview();
158 if ($this->extAdmModuleEnabled('cache')) $out.= $this->extGetCategory_cache();
159 if ($this->extAdmModuleEnabled('publish')) $out.= $this->extGetCategory_publish();
160 if ($this->extAdmModuleEnabled('edit')) $out.= $this->extGetCategory_edit();
161 if ($this->extAdmModuleEnabled('tsdebug')) $out.= $this->extGetCategory_tsdebug();
162 if ($this->extAdmModuleEnabled('info')) $out.= $this->extGetCategory_info();
163 }
164
165 $row = '<img src="'.TYPO3_mainDir.'gfx/ol/blank.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
166 $row.= '<img src="'.TYPO3_mainDir.'gfx/ol/'.($this->uc['TSFE_adminConfig']['display_top']?'minus':'plus').'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
167 $row.= '<strong>'.$this->extFw($this->extGetLL('adminOptions')).'</strong>';
168 $row.= $this->extFw(': '.$this->user['username']);
169
170 $header = '
171 <tr class="typo3-adminPanel-hRow" style="background-color:#9ba1a8;">
172 <td colspan="4" style="text-align:left; white-space:nowrap;">'.
173 $this->extItemLink('top',$row).'
174 <img src="clear.gif" width="40" height="1" alt="" />
175 <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>
176 </tr>';
177
178 $query = !t3lib_div::_GET('id') ? ('<input type="hidden" name="id" value="'.$GLOBALS['TSFE']->id.'" />'.chr(10)) : '';
179 // the dummy field is needed for Firefox: to force a page reload on submit with must change the form value with JavaScript (see "onsubmit" attribute of the "form" element")
180 $query.= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="">';
181 foreach (t3lib_div::_GET() as $k => $v) {
182 if ($k != 'TSFE_ADMIN_PANEL') {
183 if (is_array($v)) {
184 $query.= $this->extPrintFeAdminDialogHiddenFields($k,$v);
185 } else {
186 $query.= '<input type="hidden" name="'.$k.'" value="'.htmlspecialchars($v).'">'.chr(10);
187 }
188 }
189 }
190
191 $out = '
192 <!--
193 ADMIN PANEL
194 -->
195 <a name="TSFE_ADMIN"></a>
196 <form name="TSFE_ADMIN_PANEL_FORM" action="'.htmlspecialchars(t3lib_div::getIndpEnv('SCRIPT_NAME')).'#TSFE_ADMIN" method="get" style="margin:0;" onsubmit="document.forms.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[DUMMY]\'].value=Math.random().toString().substring(2,8)">'.
197 $query.'
198 <table border="0" cellpadding="0" cellspacing="0" class="typo3-adminPanel" style="background-color:#f6f2e6; border: 1px solid black; z-index:0; position:absolute;" summary="">'.
199 $header.
200 $out.'
201 </table>
202 </form>';
203
204 if ($this->uc['TSFE_adminConfig']['display_top']) {
205 $out.= '<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
206 $out.= '
207 <script type="text/javascript">
208 /*<![CDATA[*/
209 var evalFunc = new evalFunc();
210 // TSFEtypo3FormFieldSet()
211 function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { //
212 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
213 var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
214 if (checkbox && theValue==checkboxValue) {
215 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
216 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
217 } else {
218 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
219 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
220 }
221 }
222 // TSFEtypo3FormFieldGet()
223 function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { //
224 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
225 if (checkbox_off) {
226 document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
227 }else{
228 document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
229 }
230 TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
231 }
232 /*]]>*/
233 </script>
234 <script language="javascript" type="text/javascript">'.$this->extJSCODE.'</script>';
235 }
236 return "\n\n\n\n".$out.'<br />';
237 }
238
239 /**
240 * Fetches recursively all GET parameters as hidden fields.
241 * Called from extPrintFeAdminDialog.
242 *
243 * @param string current key
244 * @param mixed current value
245 * @return string hidden fields
246 * @see extPrintFeAdminDialog()
247 */
248 function extPrintFeAdminDialogHiddenFields($key,&$val) {
249 $out = '';
250 foreach($val as $k => $v) {
251 if (is_array($v)) {
252 $out.= $this->extPrintFeAdminDialogHiddenFields($key.'['.$k.']',$v);
253 } else {
254 $out.= '<input type="hidden" name="'.$key.'['.$k.']" value="'.htmlspecialchars($v).'">'.chr(10);
255 }
256 }
257 return $out;
258 }
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275 /*****************************************************
276 *
277 * Creating sections of the Admin Panel
278 *
279 ****************************************************/
280
281 /**
282 * Creates the content for the "preview" section ("module") of the Admin Panel
283 *
284 * @param string Optional start-value; The generated content is added to this variable.
285 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
286 * @see extPrintFeAdminDialog()
287 */
288 function extGetCategory_preview($out='') {
289 $out.= $this->extGetHead('preview');
290 if ($this->uc['TSFE_adminConfig']['display_preview']) {
291 $this->extNeedUpdate = 1;
292 $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"':'').' />');
293 $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"':'').' />');
294
295 // Simulate date
296 $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'].'" />');
297 $this->extJSCODE.= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 1,0);';
298
299 // Simulate fe_user:
300 $options = '<option value="0">&nbsp;</option>';
301 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
302 'fe_groups.uid, fe_groups.title',
303 'fe_groups,pages',
304 'pages.uid=fe_groups.pid AND pages.deleted=0 '.t3lib_BEfunc::deleteClause('fe_groups').' AND '.$this->getPagePermsClause(1)
305 );
306 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
307 $options.= '<option value="'.$row['uid'].'"'.($this->uc['TSFE_adminConfig']['preview_simulateUserGroup']==$row['uid']?' selected="selected"':'').'>'.htmlspecialchars('['.$row['uid'].'] '.$row['title']).'</option>';
308 }
309 $out.= $this->extGetItem('preview_simulateUserGroup', '<select name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">'.$options.'</select>');
310 }
311 return $out;
312 }
313
314 /**
315 * Creates the content for the "cache" section ("module") of the Admin Panel
316 *
317 * @param string Optional start-value; The generated content is added to this variable.
318 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
319 * @see extPrintFeAdminDialog()
320 */
321 function extGetCategory_cache($out='') {
322 $out.= $this->extGetHead('cache');
323 if ($this->uc['TSFE_adminConfig']['display_cache']) {
324 $this->extNeedUpdate = 1;
325 $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"':'').' />');
326
327 $options = '';
328 $options.= '<option value="0"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==0?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_0').'</option>';
329 $options.= '<option value="1"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==1?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_1').'</option>';
330 $options.= '<option value="2"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==2?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_2').'</option>';
331
332 $out.= $this->extGetItem('cache_clearLevels', '<select name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">'.$options.'</select>'.
333 '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="'.$GLOBALS['TSFE']->id.'" /><input type="submit" value="'.$this->extGetLL('update').'" />');
334
335 // Generating tree:
336 $depth = $this->extGetFeAdminValue('cache','clearCacheLevels');
337 $outTable = '';
338 $this->extPageInTreeInfo = array();
339 $this->extPageInTreeInfo[] = array($GLOBALS['TSFE']->page['uid'],$GLOBALS['TSFE']->page['title'],$depth+1);
340 $this->extGetTreeList($GLOBALS['TSFE']->id, $depth,0,$this->getPagePermsClause(1));
341 reset($this->extPageInTreeInfo);
342 while(list(,$row)=each($this->extPageInTreeInfo)) {
343 $outTable.= '
344 <tr>
345 <td style="white-space:nowrap;"><img src="clear.gif" width="'.(($depth+1-$row[2])*18).'" height="1" alt="" /><img src="'.TYPO3_mainDir.'gfx/i/pages.gif" width="18" height="16" align="absmiddle" border="0" alt="" />'.$this->extFw($row[1]).'</td>
346 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
347 <td>'.$this->extFw($this->extGetNumberOfCachedPages($row[0])).'</td>
348 </tr>';
349 }
350 $outTable = '<br /><table border="0" cellpadding="0" cellspacing="0" summary="">'.$outTable.'</table>';
351 $outTable.= '<input type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="'.$this->extGetLL('cache_doit').'" />';
352
353 $out.= $this->extGetItem('cache_cacheEntries', $outTable);
354 }
355 return $out;
356 }
357
358 /**
359 * Creates the content for the "publish" section ("module") of the Admin Panel
360 *
361 * @param string Optional start-value; The generated content is added to this variable.
362 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
363 * @see extPrintFeAdminDialog()
364 */
365 function extGetCategory_publish($out='') {
366 $out.= $this->extGetHead('publish');
367 if ($this->uc['TSFE_adminConfig']['display_publish']) {
368 $this->extNeedUpdate = 1;
369 $options = '';
370 $options.= '<option value="0"'.($this->uc['TSFE_adminConfig']['publish_levels']==0?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_0').'</option>';
371 $options.= '<option value="1"'.($this->uc['TSFE_adminConfig']['publish_levels']==1?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_1').'</option>';
372 $options.= '<option value="2"'.($this->uc['TSFE_adminConfig']['publish_levels']==2?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_2').'</option>';
373 $out.= $this->extGetItem('publish_levels', '<select name="TSFE_ADMIN_PANEL[publish_levels]">'.$options.'</select>'.
374 '<input type="hidden" name="TSFE_ADMIN_PANEL[publish_id]" value="'.$GLOBALS['TSFE']->id.'" />&nbsp;<input type="submit" value="'.$this->extGetLL('update').'" />');
375
376 // Generating tree:
377 $depth = $this->extGetFeAdminValue('publish','levels');
378 $outTable = '';
379 $this->extPageInTreeInfo = array();
380 $this->extPageInTreeInfo[] = array($GLOBALS['TSFE']->page['uid'],$GLOBALS['TSFE']->page['title'],$depth+1);
381 $this->extGetTreeList($GLOBALS['TSFE']->id, $depth,0,$this->getPagePermsClause(1));
382 reset($this->extPageInTreeInfo);
383 while(list(,$row)=each($this->extPageInTreeInfo)) {
384 $outTable.= '
385 <tr>
386 <td style="white-space:nowrap;"><img src="clear.gif" width="'.(($depth+1-$row[2])*18).'" height="1" alt="" /><img src="'.TYPO3_mainDir.'gfx/i/pages.gif" width="18" height="16" align="absmiddle" border="0" alt="" />'.$this->extFw($row[1]).'</td>
387 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
388 <td>'.$this->extFw('...').'</td>
389 </tr>';
390 }
391 $outTable = '<br /><table border="0" cellpadding="0" cellspacing="0" summary="">'.$outTable.'</table>';
392 $outTable.= '<input type="submit" name="TSFE_ADMIN_PANEL[action][publish]" value="'.$this->extGetLL('publish_doit').'" />';
393
394 $out.= $this->extGetItem('publish_tree', $outTable);
395 }
396 return $out;
397 }
398
399 /**
400 * Creates the content for the "edit" section ("module") of the Admin Panel
401 *
402 * @param string Optional start-value; The generated content is added to this variable.
403 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
404 * @see extPrintFeAdminDialog()
405 */
406 function extGetCategory_edit($out='') {
407 $out.= $this->extGetHead('edit');
408 if ($this->uc['TSFE_adminConfig']['display_edit']) {
409
410 // If another page module was specified, replace the default Page module with the new one
411 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
412 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
413
414 $this->extNeedUpdate = 1;
415 $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"':'').' />');
416 $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"':'').' />');
417 $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"':'').' />');
418 $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"':'').' />');
419 $out.= $this->extGetItem('', $this->ext_makeToolBar());
420
421 if (!t3lib_div::_GP('ADMCMD_view')) {
422 $out.= $this->extGetItem('', '<a href="#" onclick="'.
423 htmlspecialchars('
424 if (parent.opener && parent.opener.top && parent.opener.top.TS) {
425 parent.opener.top.fsMod.recentIds["web"]='.intval($GLOBALS['TSFE']->page['uid']).';
426 if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav) {
427 parent.opener.top.content.nav_frame.refresh_nav();
428 }
429 parent.opener.top.goToModule("'.$pageModule.'");
430 parent.opener.top.focus();
431 } else {
432 vHWin=window.open(\''.TYPO3_mainDir.t3lib_BEfunc::getBackendScript().'\',\''.md5('Typo3Backend-'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']).'\',\'status=1,menubar=1,scrollbars=1,resizable=1\');
433 vHWin.focus();
434 }
435 return false;
436 ').
437 '">'.$this->extFw($this->extGetLL('edit_openAB')).'</a>');
438 }
439 }
440 return $out;
441 }
442
443 /**
444 * Creates the content for the "tsdebug" section ("module") of the Admin Panel
445 *
446 * @param string Optional start-value; The generated content is added to this variable.
447 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
448 * @see extPrintFeAdminDialog()
449 */
450 function extGetCategory_tsdebug($out='') {
451 $out.= $this->extGetHead('tsdebug');
452 if ($this->uc['TSFE_adminConfig']['display_tsdebug']) {
453 $this->extNeedUpdate = 1;
454
455 $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"':'').' />');
456 $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"':'').' />');
457 $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"':'').' />');
458 $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"':'').' />');
459 $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"':'').' />');
460 $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"':'').' />');
461 $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"':'').' />');
462
463 $GLOBALS['TT']->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug','tree');
464 $GLOBALS['TT']->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug','displayTimes');
465 $GLOBALS['TT']->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug','displayMessages');
466 $GLOBALS['TT']->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug','displayContent');
467 $GLOBALS['TT']->printConf['flag_queries'] = $this->extGetFeAdminValue('tsdebug','displayQueries');
468
469 $out.= '
470 <tr>
471 <td><img src="clear.gif" width="50" height="1" alt="" /></td>
472 <td colspan="3">'.$GLOBALS['TT']->printTSlog().'</td>
473 </tr>';
474 }
475 return $out;
476 }
477
478 /**
479 * Creates the content for the "info" section ("module") of the Admin Panel
480 *
481 * @param string Optional start-value; The generated content is added to this variable.
482 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
483 * @see extPrintFeAdminDialog()
484 */
485 function extGetCategory_info($out='') {
486 $out.= $this->extGetHead('info');
487 if ($this->uc['TSFE_adminConfig']['display_info']) {
488 $tableArr = array();
489
490 if ($this->extGetFeAdminValue('cache','noCache')) {
491 $theBytes = 0;
492 $count = 0;
493
494 if (count($GLOBALS['TSFE']->imagesOnPage)) {
495 $tableArr[] = array('*Images on this page:*', '');
496 foreach ($GLOBALS['TSFE']->imagesOnPage as $file) {
497 $fs = @filesize($file);
498 $tableArr[] = array('&ndash; '.$file, t3lib_div::formatSize($fs));
499 $theBytes+= $fs;
500 $count++;
501 }
502 }
503 $tableArr[] = array('', ''); // Add an empty line
504
505 $tableArr[] = array('*Total number of images:*', $count);
506 $tableArr[] = array('*Total image file sizes:*', t3lib_div::formatSize($theBytes));
507 $tableArr[] = array('*Document size:*', t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)));
508 $tableArr[] = array('*Total page load:*', t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)+$theBytes));
509 $tableArr[] = array('', '');
510 }
511
512 $tableArr[] = array('id:', $GLOBALS['TSFE']->id);
513 $tableArr[] = array('type:', $GLOBALS['TSFE']->type);
514 $tableArr[] = array('gr_list:', $GLOBALS['TSFE']->gr_list);
515 $tableArr[] = array('no_cache:', $GLOBALS['TSFE']->no_cache);
516 $tableArr[] = array('fe_user, name:', $GLOBALS['TSFE']->fe_user->user['username']);
517 $tableArr[] = array('fe_user, uid:', $GLOBALS['TSFE']->fe_user->user['uid']);
518 $tableArr[] = array('', ''); // Add an empty line
519
520 // parsetime:
521 $tableArr[] = array('*Total parsetime:*', $GLOBALS['TSFE']->scriptParseTime.' ms');
522
523 $table = '';
524 foreach ($tableArr as $arr) {
525 if (strlen($arr[0])) { // Put text wrapped by "*" between <strong> tags
526 $value1 = preg_replace('/^\*(.*)\*$/', '$1', $arr[0], -1, $count);
527 $value1 = ($count?'<strong>':'') . $this->extFw($value1) . ($count?'</strong>':'');
528 } else {
529 $value1 = $this->extFw('&nbsp;');
530 }
531
532 $value2 = strlen($arr[1]) ? $arr[1] : '&nbsp;';
533 $value2 = $this->extFw($value2);
534
535 $table.= '
536 <tr>
537 <td style="text-align:left">'.$value1.'</td>
538 <td style="text-align:right">'.$value2.'</td>
539 </tr>';
540 }
541
542 $table = '<table border="0" cellpadding="0" cellspacing="0" summary="">'.$table.'</table>';
543
544 $out.= '
545 <tr>
546 <td><img src="clear.gif" width="50" height="1" alt="" /></td>
547 <td colspan="3">'.$table.'</td>
548 </tr>';
549 }
550 return $out;
551 }
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570 /*****************************************************
571 *
572 * Admin Panel Layout Helper functions
573 *
574 ****************************************************/
575
576 /**
577 * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
578 * 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
579 * See the functions extGetCategory_*
580 *
581 * @param string The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
582 * @return string HTML table row.
583 * @access private
584 * @see extGetItem()
585 */
586 function extGetHead($pre) {
587 $out = '<img src="'.TYPO3_mainDir.'gfx/ol/blank.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
588 $out.= '<img src="'.TYPO3_mainDir.'gfx/ol/'.($this->uc['TSFE_adminConfig']['display_'.$pre]?'minus':'plus').'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
589 $out.= $this->extFw($this->extGetLL($pre));
590
591 $out = $this->extItemLink($pre,$out);
592 return '
593 <tr class="typo3-adminPanel-itemHRow" style="background-color:#abbbb4;">
594 <td colspan="4" style="text-align:left; border-top:dashed 1px #007a8c; white-space:nowrap;">'.$out.'<input type="hidden" name="TSFE_ADMIN_PANEL[display_'.$pre.']" value="'.$this->uc['TSFE_adminConfig']['display_'.$pre].'" /></td>
595 </tr>';
596 }
597
598 /**
599 * Wraps a string in a link which will open/close a certain part of the Admin Panel
600 *
601 * @param string The code for the display_ label/key
602 * @param string Input string
603 * @return string Linked input string
604 * @access private
605 * @see extGetHead()
606 */
607 function extItemLink($pre,$str) {
608 return '<a href="#" style="text-decoration:none;" onclick="'.
609 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;').
610 '">'.$str.'</a>';
611 }
612
613 /**
614 * Returns a row (with 4 columns) for content in a section of the Admin Panel.
615 * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
616 *
617 * @param string Key to label
618 * @param string The HTML content for the forth table cell.
619 * @return string HTML table row.
620 * @access private
621 * @see extGetHead()
622 */
623 function extGetItem($pre,$element) {
624 $out = '
625 <tr class="typo3-adminPanel-itemRow">
626 <td><img src="clear.gif" width="50" height="1" alt="" /></td>
627 <td style="text-align:left; white-space:nowrap;">'.($pre ? $this->extFw($this->extGetLL($pre)) : '&nbsp;').'</td>
628 <td><img src="clear.gif" width="30" height="1" alt="" /></td>
629 <td style="text-align:left; white-space:nowrap;">'.$element.'</td>
630 </tr>';
631
632 return $out;
633 }
634
635 /**
636 * Wraps a string in a span-tag with black verdana font
637 *
638 * @param string The string to wrap
639 * @return string
640 */
641 function extFw($str) {
642 return '<span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:0.6em; color:black;">'.$str.'</span>';
643 }
644
645 /**
646 * Creates the tool bar links for the "edit" section of the Admin Panel.
647 *
648 * @return string A string containing images wrapped in <a>-tags linking them to proper functions.
649 */
650 function ext_makeToolBar() {
651 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
652 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
653 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
654 $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : (TYPO3_mainDir.'sysext/cms/layout/db_new_content_el.php');
655
656 $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
657 $langAllowed = $GLOBALS['BE_USER']->checkLanguageAccess($GLOBALS['TSFE']->sys_language_uid);
658
659 $toolBar = '';
660 $id = $GLOBALS['TSFE']->id;
661 $toolBar.= '<a href="'.htmlspecialchars(TYPO3_mainDir.'show_rechis.php?element='.rawurlencode('pages:'.$id).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'#latest">'.
662 '<img src="'.TYPO3_mainDir.'gfx/history2.gif" width="13" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_recordHistory').'" alt="" /></a>';
663
664 if ($perms&16 && $langAllowed) {
665 $params = '';
666 if ($GLOBALS['TSFE']->sys_language_uid) $params = '&sys_language_uid='.$GLOBALS['TSFE']->sys_language_uid;
667 $toolBar.= '<a href="'.htmlspecialchars($newContentWizScriptPath.'?id='.$id.$params.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
668 '<img src="'.TYPO3_mainDir.'gfx/new_record.gif" width="16" height="12" hspace="1" border="0" align="top" title="'.$this->extGetLL('edit_newContentElement').'" alt="" /></a>';
669 }
670 if ($perms&2) {
671 $toolBar.= '<a href="'.htmlspecialchars(TYPO3_mainDir.'move_el.php?table=pages&uid='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
672 '<img src="'.TYPO3_mainDir.'gfx/move_page.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_move_page').'" alt="" /></a>';
673 }
674 if ($perms&8) {
675 $toolBar.= '<a href="'.htmlspecialchars(TYPO3_mainDir.'db_new.php?id='.$id.'&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
676 '<img src="'.TYPO3_mainDir.'gfx/new_page.gif" width="13" height="12" hspace="0" border="0" align="top" title="'.$this->extGetLL('edit_newPage').'" alt="" /></a>';
677 }
678 if ($perms&2) {
679 $params = '&edit[pages]['.$id.']=edit';
680 $toolBar.= '<a href="'.htmlspecialchars(TYPO3_mainDir.'alt_doc.php?'.$params.'&noView=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
681 '<img src="'.TYPO3_mainDir.'gfx/edit2.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_editPageProperties').'" alt="" /></a>';
682
683 if ($GLOBALS['TSFE']->sys_language_uid && $langAllowed) {
684 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
685 'uid,pid,t3ver_state', 'pages_language_overlay',
686 'pid='.intval($id).' AND sys_language_uid='.$GLOBALS['TSFE']->sys_language_uid.$GLOBALS['TSFE']->sys_page->enableFields('pages_language_overlay'),
687 '', '', '1');
688 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
689 $GLOBALS['TSFE']->sys_page->versionOL('pages_language_overlay',$row);
690 if (is_array($row)) {
691 $params='&edit[pages_language_overlay]['.$row['uid'].']=edit';
692 $toolBar.= '<a href="'.htmlspecialchars(TYPO3_mainDir.'alt_doc.php?'.$params.'&noView=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
693 '<img src="'.TYPO3_mainDir.'gfx/edit3.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_editPageOverlay').'" alt="" /></a>';
694 }
695 }
696 }
697 if ($this->check('modules','web_list')) {
698 $toolBar.= '<a href="'.htmlspecialchars(TYPO3_mainDir.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
699 '<img src="'.TYPO3_mainDir.'gfx/list.gif" width="11" height="11" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_db_list').'" alt="" /></a>';
700 }
701
702 return $toolBar;
703 }
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723 /*****************************************************
724 *
725 * TSFE BE user Access Functions
726 *
727 ****************************************************/
728
729 /**
730 * Implementing the access checks that the typo3/init.php script does before a user is ever logged in.
731 * Used in the frontend.
732 *
733 * @return boolean Returns true if access is OK
734 * @see typo3/init.php, t3lib_beuserauth::backendCheckLogin()
735 */
736 function checkBackendAccessSettingsFromInitPhp() {
737 global $TYPO3_CONF_VARS;
738
739 // **********************
740 // Check Hardcoded lock on BE:
741 // **********************
742 if ($TYPO3_CONF_VARS['BE']['adminOnly'] < 0) {
743 return FALSE;
744 }
745
746 // **********************
747 // Check IP
748 // **********************
749 if (trim($TYPO3_CONF_VARS['BE']['IPmaskList'])) {
750 if (!t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $TYPO3_CONF_VARS['BE']['IPmaskList'])) {
751 return FALSE;
752 }
753 }
754
755
756 // **********************
757 // Check SSL (https)
758 // **********************
759 if (intval($TYPO3_CONF_VARS['BE']['lockSSL']) && $TYPO3_CONF_VARS['BE']['lockSSL'] != 3) {
760 if (!t3lib_div::getIndpEnv('TYPO3_SSL')) {
761 return FALSE;
762 }
763 }
764
765 // Finally a check from t3lib_beuserauth::backendCheckLogin()
766 if (!$TYPO3_CONF_VARS['BE']['adminOnly'] || $this->isAdmin()) {
767 return TRUE;
768 } else return FALSE;
769 }
770
771
772 /**
773 * Evaluates if the Backend User has read access to the input page record.
774 * 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.
775 * Read access means that previewing is allowed etc.
776 * Used in index_ts.php
777 *
778 * @param array The page record to evaluate for
779 * @return boolean True if read access
780 */
781 function extPageReadAccess($pageRec) {
782 return $this->isInWebMount($pageRec['uid']) && $this->doesUserHaveAccess($pageRec,1);
783 }
784
785 /**
786 * Checks if a Admin Panel section ("module") is available for the user. If so, true is returned.
787 *
788 * @param string The module key, eg. "edit", "preview", "info" etc.
789 * @return boolean
790 * @see extPrintFeAdminDialog()
791 */
792 function extAdmModuleEnabled($key) {
793 // Returns true if the module checked is "preview" and the forcePreview flag is set.
794 if ($key=="preview" && $this->ext_forcePreview) return true;
795
796 // If key is not set, only "all" is checked
797 if ($this->extAdminConfig['enable.']['all']) return true;
798 if ($this->extAdminConfig['enable.'][$key]) {
799 return true;
800 }
801 }
802
803 /**
804 * Saves any change in settings made in the Admin Panel.
805 * Called from index_ts.php right after access check for the Admin Panel
806 *
807 * @return void
808 */
809 function extSaveFeAdminConfig() {
810 $input = t3lib_div::_GET('TSFE_ADMIN_PANEL');
811 if (is_array($input)) {
812 // Setting
813 $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...
814 unset($this->uc['TSFE_adminConfig']['action']);
815
816 // Actions:
817 if ($input['action']['clearCache'] && $this->extAdmModuleEnabled('cache')) {
818 $this->extPageInTreeInfo=array();
819 $theStartId = intval($input['cache_clearCacheId']);
820 $GLOBALS['TSFE']->clearPageCacheContent_pidList($this->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache','clearCacheLevels'),0,$this->getPagePermsClause(1)).$theStartId);
821 }
822 if ($input['action']['publish'] && $this->extAdmModuleEnabled('publish')) {
823 $theStartId = intval($input['publish_id']);
824 $this->extPublishList = $this->extGetTreeList($theStartId, $this->extGetFeAdminValue('publish','levels'),0,$this->getPagePermsClause(1)).$theStartId;
825 }
826
827 // Saving
828 $this->writeUC();
829 }
830 $GLOBALS['TT']->LR = $this->extGetFeAdminValue('tsdebug','LR');
831
832 if ($this->extGetFeAdminValue('cache','noCache')) {
833 $GLOBALS['TSFE']->set_no_cache();
834 }
835
836 // Hook for post processing the frontend admin configuration.
837 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extSaveFeAdminConfig-postProc'])) {
838 $_params = array('input' => &$input, 'pObj' => &$this);
839 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extSaveFeAdminConfig-postProc'] as $_funcRef) {
840 t3lib_div::callUserFunction($_funcRef,$_params,$this);
841 }
842 }
843 }
844
845 /**
846 * Returns the value for a Admin Panel setting. You must specify both the module-key and the internal setting key.
847 *
848 * @param string Module key
849 * @param string Setting key
850 * @return string The setting value
851 */
852 function extGetFeAdminValue($pre,$val='') {
853 if ($this->extAdmModuleEnabled($pre)) { // Check if module is enabled.
854 // Exceptions where the values can be overridden from backend:
855 // deprecated
856 if ($pre.'_'.$val == 'edit_displayIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayIcons']) {
857 return true;
858 }
859 if ($pre.'_'.$val == 'edit_displayFieldIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons']) {
860 return true;
861 }
862
863 // override all settings with user TSconfig
864 if ($this->extAdminConfig['override.'][$pre.'.'][$val] && $val) {
865 return $this->extAdminConfig['override.'][$pre.'.'][$val];
866 }
867 if ($this->extAdminConfig['override.'][$pre]) {
868 return $this->extAdminConfig['override.'][$pre];
869 }
870
871 $retVal = $val ? $this->uc['TSFE_adminConfig'][$pre.'_'.$val] : 1;
872
873 if ($pre=='preview' && $this->ext_forcePreview) {
874 if (!$val) {
875 return true;
876 } else {
877 return $retVal;
878 }
879 }
880
881 // regular check:
882 if ($this->extIsAdmMenuOpen($pre)) { // See if the menu is expanded!
883 return $retVal;
884 }
885
886 // Hook for post processing the frontend editing action.
887 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction-postProc'])) {
888 $_params = array('cmd' => &$cmd, 'tce' => &$tce, 'pObj' => &$this);
889 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction-postProc'] as $_funcRef) {
890 t3lib_div::callUserFunction($_funcRef,$_params,$this);
891 }
892 }
893 }
894 }
895
896 /**
897 * Returns true if admin panel module is open
898 *
899 * @param string Module key
900 * @return boolean True, if the admin panel is open for the specified admin panel module key.
901 */
902 function extIsAdmMenuOpen($pre) {
903 return $this->uc['TSFE_adminConfig']['display_top'] && $this->uc['TSFE_adminConfig']['display_'.$pre];
904 }
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921 /*****************************************************
922 *
923 * TSFE BE user Access Functions
924 *
925 ****************************************************/
926
927 /**
928 * Generates a list of Page-uid's from $id. List does not include $id itself
929 * The only pages excluded from the list are deleted pages.
930 *
931 * @param integer Start page id
932 * @param integer Depth to traverse down the page tree.
933 * @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'
934 * @param string Perms clause
935 * @return string Returns the list with a comma in the end (if any pages selected!)
936 */
937 function extGetTreeList($id,$depth,$begin=0,$perms_clause) {
938 $depth=intval($depth);
939 $begin=intval($begin);
940 $id=intval($id);
941 $theList='';
942
943 if ($id && $depth>0) {
944 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
945 'uid,title',
946 'pages',
947 'pid='.$id.' AND doktype IN ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].') AND deleted=0 AND '.$perms_clause
948 );
949 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
950 if ($begin<=0) {
951 $theList.= $row['uid'].',';
952 $this->extPageInTreeInfo[]=array($row['uid'],$row['title'],$depth);
953 }
954 if ($depth>1) {
955 $theList.= $this->extGetTreeList($row['uid'], $depth-1,$begin-1,$perms_clause);
956 }
957 }
958 }
959 return $theList;
960 }
961
962 /**
963 * Returns the number of cached pages for a page id.
964 *
965 * @param integer The page id.
966 * @return integer The number of pages for this page in the table "cache_pages"
967 */
968 function extGetNumberOfCachedPages($page_id) {
969 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_pages', 'page_id='.intval($page_id));
970 list($num) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
971 return $num;
972 }
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994 /*****************************************************
995 *
996 * Localization handling
997 *
998 ****************************************************/
999
1000 /**
1001 * 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.
1002 * 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
1003 *
1004 * @param string Key for a label in the $LOCAL_LANG array of "sysext/lang/locallang_tsfe.php"
1005 * @return string The value for the $key
1006 */
1007 function extGetLL($key) {
1008 global $LOCAL_LANG;
1009 if (!is_array($LOCAL_LANG)) {
1010 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_tsfe.php');
1011 #include('./'.TYPO3_mainDir.'sysext/lang/locallang_tsfe.php');
1012 if (!is_array($LOCAL_LANG)) {
1013 $LOCAL_LANG = array();
1014 }
1015 }
1016
1017 $labelStr = htmlspecialchars($GLOBALS['LANG']->getLL($key)); // Label string in the default backend output charset.
1018
1019 // Convert to utf-8, then to entities:
1020 if ($GLOBALS['LANG']->charSet!='utf-8') {
1021 $labelStr = $GLOBALS['LANG']->csConvObj->utf8_encode($labelStr,$GLOBALS['LANG']->charSet);
1022 }
1023 $labelStr = $GLOBALS['LANG']->csConvObj->utf8_to_entities($labelStr);
1024
1025 // Return the result:
1026 return $labelStr;
1027 }
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041 /*****************************************************
1042 *
1043 * Frontend Editing
1044 *
1045 ****************************************************/
1046
1047 /**
1048 * Returns true in an edit-action is sent from the Admin Panel
1049 *
1050 * @return boolean
1051 * @see index_ts.php
1052 */
1053 function extIsEditAction() {
1054 if (is_array($this->TSFE_EDIT)) {
1055 if ($this->TSFE_EDIT['cancel']) {
1056 unset($this->TSFE_EDIT['cmd']);
1057 } else {
1058 $cmd = (string)$this->TSFE_EDIT['cmd'];
1059 if (($cmd!='edit' || (is_array($this->TSFE_EDIT['data']) && ($this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']))) && $cmd!='new') {
1060 // $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.
1061 return true;
1062 }
1063 }
1064 }
1065 return false;
1066 }
1067
1068 /**
1069 * Returns true if an edit form is shown on the page.
1070 * Used from index_ts.php where a true return-value will result in classes etc. being included.
1071 *
1072 * @return boolean
1073 * @see index_ts.php
1074 */
1075 function extIsFormShown() {
1076 if (is_array($this->TSFE_EDIT)) {
1077 $cmd = (string)$this->TSFE_EDIT['cmd'];
1078 if ($cmd=='edit' || $cmd=='new') {
1079 return true;
1080 }
1081 }
1082 }
1083
1084 /**
1085 * Management of the on-page frontend editing forms and edit panels.
1086 * Basically taking in the data and commands and passes them on to the proper classes as they should be.
1087 *
1088 * @return void
1089 * @see index_ts.php
1090 */
1091 function extEditAction() {
1092 global $TCA, $TYPO3_CONF_VARS;
1093 // Commands:
1094 list($table,$uid) = explode(':',$this->TSFE_EDIT['record']);
1095 if ($this->TSFE_EDIT['cmd'] && $table && $uid && isset($TCA[$table])) {
1096 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
1097 $tce->stripslashes_values=0;
1098 $recData = array();
1099 $cmdData = array();
1100 $cmd = $this->TSFE_EDIT['cmd'];
1101
1102 // ****************
1103 // extEditAction HOOK
1104 // ****************
1105 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'])) {
1106 $_params = array();
1107 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'] as $_funcRef) {
1108 t3lib_div::callUserFunction($_funcRef,$_params,$this);
1109 }
1110 }
1111
1112 switch($cmd) {
1113 case 'hide':
1114 case 'unhide':
1115 $hideField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
1116 if ($hideField) {
1117 $recData[$table][$uid][$hideField] = ($cmd=='hide' ? 1 : 0);
1118 $tce->start($recData,Array());
1119 $tce->process_datamap();
1120 }
1121 break;
1122 case 'up':
1123 case 'down':
1124 $sortField = $TCA[$table]['ctrl']['sortby'];
1125 if ($sortField) {
1126 if ($cmd=='up') {
1127 $op= '<';
1128 $desc=' DESC';
1129 } else {
1130 $op= '>';
1131 $desc='';
1132 }
1133
1134 // Get self:
1135 $fields = array_unique(t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['copyAfterDuplFields'].',uid,pid,'.$sortField,1));
1136 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',',$fields), $table, 'uid='.$uid);
1137 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1138 // record before or after
1139 $preview = $this->extGetFeAdminValue('preview');
1140 $copyAfterFieldsQuery = '';
1141 if ($preview) {
1142 $ignore = array('starttime'=>1, 'endtime'=>1, 'disabled'=>1, 'fe_group'=>1);
1143 }
1144 if ($TCA[$table]['ctrl']['copyAfterDuplFields']) {
1145 $cAFields = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['copyAfterDuplFields'],1);
1146 while(list(,$fN)=each($cAFields)) {
1147 $copyAfterFieldsQuery.= ' AND '.$fN.'="'.$row[$fN].'"';
1148 }
1149 }
1150
1151 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1152 'uid,pid',
1153 $table,
1154 'pid='.intval($row['pid']).
1155 ' AND '.$sortField.$op.intval($row[$sortField]).
1156 $copyAfterFieldsQuery.
1157 $GLOBALS['TSFE']->sys_page->enableFields($table,'',$ignore),
1158 '',
1159 $sortField.$desc,
1160 '2'
1161 );
1162 if ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1163 if($cmd=='down') {
1164 $cmdData[$table][$uid]['move'] = -$row2['uid'];
1165 } elseif ($row3 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { // Must take the second record above...
1166 $cmdData[$table][$uid]['move'] = -$row3['uid'];
1167 } else { // ... and if that does not exist, use pid
1168 $cmdData[$table][$uid]['move'] = $row['pid'];
1169 }
1170 } elseif ($cmd=='up') {
1171 $cmdData[$table][$uid]['move'] = $row['pid'];
1172 }
1173 }
1174 if (count($cmdData)) {
1175 $tce->start(Array(),$cmdData);
1176 $tce->process_cmdmap();
1177 }
1178 }
1179 break;
1180 case 'delete':
1181 $cmdData[$table][$uid]['delete'] = 1;
1182 if (count($cmdData)) {
1183 $tce->start(Array(),$cmdData);
1184 $tce->process_cmdmap();
1185 }
1186 break;
1187 }
1188 }
1189 // Data:
1190 if (($this->TSFE_EDIT['doSave'] || $this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']) && is_array($this->TSFE_EDIT['data'])) {
1191 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
1192 $tce->stripslashes_values = 0;
1193 $tce->start($this->TSFE_EDIT['data'],Array());
1194 $tce->process_uploads($_FILES);
1195 $tce->process_datamap();
1196 }
1197 }
1198 }
1199
1200
1201 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsfebeuserauth.php']) {
1202 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsfebeuserauth.php']);
1203 }
1204
1205 ?>