Cleanup: Updated NEWS.txt
[Packages/TYPO3.CMS.git] / typo3 / sysext / fe_edit / view / class.tx_feedit_adminpanel.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2008-2009 Jeff Segars <jeff@webempoweredchurch.org>
6 * (c) 2008-2009 David Slayback <dave@webempoweredchurch.org>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
19 *
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 /**
29 * View class for the admin panel in frontend editing.
30 *
31 * $Id$
32 *
33 * @author Jeff Segars <jeff@webempoweredchurch.org>
34 * @author David Slayback <dave@webempoweredchurch.org>
35 * @package TYPO3
36 * @subpackage fe_edit
37 */
38 class tx_feedit_adminpanel {
39
40 /**
41 * Determines whether the update button should be shown.
42 *
43 * @var boolean
44 */
45 protected $extNeedUpdate = false;
46
47 /**
48 * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
49 *
50 * @return string HTML for the Admin Panel
51 */
52 public function display() {
53 $out = '<script type="text/javascript" src="t3lib/js/adminpanel.js"></script>';
54 //CSS
55 $GLOBALS['TSFE']->additionalHeaderData['admPanelCSS'] = '<link rel="stylesheet" type="text/css" href="' . t3lib_extMgm::extRelPath('fe_edit') . 'admpanel.css' . '" />';
56 if(!empty($GLOBALS['TBE_STYLES']['stylesheets']['admPanel'])) {
57 $GLOBALS['TSFE']->additionalHeaderData['admPanelCSS-Skin'] = '
58 <link rel="stylesheet" type="text/css" href="' . $GLOBALS['TBE_STYLES']['stylesheets']['admPanel'].'" />
59 ';
60 }
61
62 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']) {
63 if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('preview')) {
64 $out .= $this->getPreviewModule();
65 }
66 if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('cache')) {
67 $out .= $this->getCacheModule();
68 }
69 if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('publish')) {
70 $out .= $this->getPublishModule();
71 }
72 if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('edit')){
73 $out .= $this->getEditModule();
74 }
75 if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('tsdebug')) {
76 $out .= $this->getTSDebugModule();
77 }
78 if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('info')) {
79 $out .= $this->getInfoModule();
80 }
81 }
82
83 $row = '<img src="' . TYPO3_mainDir . 'gfx/ol/blank.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
84 $row .= '<img src="' . TYPO3_mainDir . 'gfx/ol/' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']?'minus':'plus') . 'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
85 $row .= '<strong>' . $this->extFw($this->extGetLL('adminOptions')) . '</strong>';
86 $row .= $this->extFw(': ' . $GLOBALS['BE_USER']->user['username']);
87
88 $header = '
89 <tr class="typo3-adminPanel-hRow" style="background-color: #9ba1a8; cursor: move;">
90 <td colspan="4" style="text-align:left; white-space:nowrap;">' .
91 $this->extItemLink('top',$row) . '
92 <img src="clear.gif" width="40" height="1" alt="" />
93 <input type="hidden" name="TSFE_ADMIN_PANEL[display_top]" value="' . $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top'] . '" />' . ($this->extNeedUpdate ? '<input type="submit" value="' . $this->extGetLL('update') . '" />' : '') . '</td>
94 </tr>';
95
96 $query = !t3lib_div::_GET('id') ? ('<input type="hidden" name="id" value="' . $GLOBALS['TSFE']->id . '" />' . chr(10)) : '';
97 // 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")
98 $query .= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="">';
99 foreach (t3lib_div::_GET() as $key => $value) {
100 if ($key != 'TSFE_ADMIN_PANEL') {
101 if (is_array($value)) {
102 $query .= $this->getHiddenFields($key, $value);
103 } else {
104 $query .= '<input type="hidden" name="' . $key . '" value="' . htmlspecialchars($value) . '">' . chr(10);
105 }
106 }
107 }
108
109 $out = '
110 <!--
111 ADMIN PANEL
112 -->
113 <a name="TSFE_ADMIN"></a>
114 <form name="TSFE_ADMIN_PANEL_FORM" action="' . htmlspecialchars(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')) . '#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)">' .
115 $query . '
116 <table border="0" cellpadding="0" cellspacing="0" class="typo3-adminPanel" style="background-color:#f6f2e6; border: 1px solid black; z-index:0; position:absolute;" summary="">' .
117 $header .
118 $out . '
119 </table>
120 </form>';
121
122 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']) {
123 $out .= '<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
124 $out .= '
125 <script type="text/javascript">
126 /*<![CDATA[*/
127 var evalFunc = new evalFunc();
128 // TSFEtypo3FormFieldSet()
129 function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { //
130 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
131 var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
132 if (checkbox && theValue==checkboxValue) {
133 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
134 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
135 } else {
136 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
137 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
138 }
139 }
140 // TSFEtypo3FormFieldGet()
141 function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { //
142 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
143 if (checkbox_off) {
144 document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
145 }else{
146 document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
147 }
148 TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
149 }
150 /*]]>*/
151 </script>
152 <script language="javascript" type="text/javascript">' . $this->extJSCODE . '</script>';
153 }
154
155 $out = '
156 <div onmousedown="TYPO3AdminPanel.dragStart(this)" onmouseup="TYPO3AdminPanel.savePosition(this)" id="admPanel" style="position:absolute; z-index: 10000;">
157 ' . $out . '
158 <br /></div>
159 <script type="text/javascript">
160 TYPO3AdminPanel.dragInit();
161 TYPO3AdminPanel.restorePosition();
162 </script>';
163
164 return $out;
165 }
166
167 /**
168 * Fetches recursively all GET parameters as hidden fields.
169 * Called from display()
170 *
171 * @param string current key
172 * @param mixed current value
173 * @return string hidden fields
174 * @see display()
175 */
176 protected function getHiddenFields($key, &$val) {
177 $out = '';
178 foreach ($val as $k => $v) {
179 if (is_array($v)) {
180 $out .= $this->getHiddenFields($key . '[' . $k . ']', $v);
181 } else {
182 $out .= '<input type="hidden" name="' . $key . '[' . $k . ']" value="' . htmlspecialchars($v) . '">' . chr(10);
183 }
184 }
185 return $out;
186 }
187
188 /*****************************************************
189 *
190 * Creating sections of the Admin Panel
191 *
192 ****************************************************/
193
194 /**
195 * Creates the content for the "preview" section ("module") of the Admin Panel
196 *
197 * @param string Optional start-value; The generated content is added to this variable.
198 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
199 * @see display()
200 */
201 protected function getPreviewModule($out = '') {
202 $out .= $this->extGetHead('preview');
203 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_preview']) {
204 $this->extNeedUpdate = true;
205 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_showHiddenPages'] ? ' checked="checked"' : '') . ' />');
206 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_showHiddenRecords'] ? ' checked="checked"' : '') . ' />');
207
208 // Simulate date
209 $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="' . $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateDate'] . '" />');
210 $this->extJSCODE .= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 1,0);';
211
212 // Simulate fe_user:
213 $options = '<option value="0">&nbsp;</option>';
214 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
215 'fe_groups.uid, fe_groups.title',
216 'fe_groups,pages',
217 'pages.uid=fe_groups.pid AND pages.deleted=0 ' . t3lib_BEfunc::deleteClause('fe_groups') . ' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1)
218 );
219 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
220 $options .= '<option value="' . $row['uid'] . '"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateUserGroup'] == $row['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars('[' . $row['uid'] . '] ' . $row['title']) . '</option>';
221 }
222 $out .= $this->extGetItem('preview_simulateUserGroup', '<select name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">' . $options . '</select>');
223 }
224
225 return $out;
226 }
227
228 /**
229 * Creates the content for the "cache" section ("module") of the Admin Panel
230 *
231 * @param string Optional start-value; The generated content is added to this variable.
232 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
233 * @see display()
234 */
235 protected function getCacheModule($out = '') {
236 $out.= $this->extGetHead('cache');
237 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_cache']) {
238 $this->extNeedUpdate = true;
239 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_noCache'] ? ' checked="checked"' : '') . ' />');
240 $options = '';
241 $options .= '<option value="0"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_clearCacheLevels'] == 0 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_0') . '</option>';
242 $options .= '<option value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_clearCacheLevels'] == 1 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_1') . '</option>';
243 $options .= '<option value="2"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_clearCacheLevels'] == 2 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_2') . '</option>';
244 $out .= $this->extGetItem('cache_clearLevels', '<select name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">' . $options . '</select>' .
245 '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="' . $GLOBALS['TSFE']->id . '" /><input type="submit" value="' . $this->extGetLL('update') . '" />');
246
247 // Generating tree:
248 $depth = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('cache', 'clearCacheLevels');
249 $outTable = '';
250 $GLOBALS['BE_USER']->extPageInTreeInfo = array();
251 $GLOBALS['BE_USER']->extPageInTreeInfo[] = array($GLOBALS['TSFE']->page['uid'], htmlspecialchars($GLOBALS['TSFE']->page['title']), $depth+1);
252 $GLOBALS['BE_USER']->extGetTreeList($GLOBALS['TSFE']->id, $depth, 0, $GLOBALS['BE_USER']->getPagePermsClause(1));
253 foreach ($GLOBALS['BE_USER']->extPageInTreeInfo as $row) {
254 $outTable .= '
255 <tr>
256 <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>
257 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
258 <td>' . $this->extFw($GLOBALS['BE_USER']->extGetNumberOfCachedPages($row[0])) . '</td>
259 </tr>';
260 }
261
262 $outTable = '<br /><table border="0" cellpadding="0" cellspacing="0" summary="">' . $outTable . '</table>';
263 $outTable .= '<input type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="' . $this->extGetLL('cache_doit') . '" />';
264
265 $out .= $this->extGetItem('cache_cacheEntries', $outTable);
266 }
267
268 return $out;
269 }
270
271 /**
272 * Creates the content for the "publish" section ("module") of the Admin Panel
273 *
274 * @param string Optional start-value; The generated content is added to this variable.
275 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
276 * @see display()
277 */
278 protected function getPublishModule($out = '') {
279 $out .= $this->extGetHead('publish');
280 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_publish']) {
281 $this->extNeedUpdate = true;
282 $options = '';
283 $options .= '<option value="0"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['publish_levels'] == 0 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_0') . '</option>';
284 $options .= '<option value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['publish_levels'] == 1 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_1') . '</option>';
285 $options .= '<option value="2"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['publish_levels'] == 2 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_2') . '</option>';
286 $out .= $this->extGetItem('publish_levels', '<select name="TSFE_ADMIN_PANEL[publish_levels]">' . $options . '</select>' .
287 '<input type="hidden" name="TSFE_ADMIN_PANEL[publish_id]" value="' . $GLOBALS['TSFE']->id . '" />&nbsp;<input type="submit" value="' . $this->extGetLL('update') . '" />');
288
289 // Generating tree:
290 $depth = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('publish', 'levels');
291 $outTable = '';
292 $GLOBALS['BE_USER']->extPageInTreeInfo = array();
293 $GLOBALS['BE_USER']->extPageInTreeInfo[] = array($GLOBALS['TSFE']->page['uid'], htmlspecialchars($GLOBALS['TSFE']->page['title']), $depth+1);
294 $GLOBALS['BE_USER']->extGetTreeList($GLOBALS['TSFE']->id, $depth, 0, $GLOBALS['BE_USER']->getPagePermsClause(1));
295 foreach ($GLOBALS['BE_USER']->extPageInTreeInfo as $row) {
296 $outTable.= '
297 <tr>
298 <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>
299 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
300 <td>' . $this->extFw('...') . '</td>
301 </tr>';
302 }
303 $outTable = '<br /><table border="0" cellpadding="0" cellspacing="0" summary="">' . $outTable . '</table>';
304 $outTable .= '<input type="submit" name="TSFE_ADMIN_PANEL[action][publish]" value="' . $this->extGetLL('publish_doit') . '" />';
305
306 $out .= $this->extGetItem('publish_tree', $outTable);
307 }
308
309 return $out;
310 }
311
312 /**
313 * Creates the content for the "edit" section ("module") of the Admin Panel
314 *
315 * @param string Optional start-value; The generated content is added to this variable.
316 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
317 * @see display()
318 */
319 protected function getEditModule($out = '') {
320 $out .= $this->extGetHead('edit');
321 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_edit']) {
322
323 // If another page module was specified, replace the default Page module with the new one
324 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
325 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
326
327 $this->extNeedUpdate = true;
328 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_displayFieldIcons'] ? ' checked="checked"' : '') . ' />');
329 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_displayIcons'] ? ' checked="checked"' : '') . ' />');
330 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editFormsOnPage'] ? ' checked="checked"':'') . ' />');
331 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup'] ? ' checked="checked"' : '') . ' />');
332 $out .= $this->extGetItem('', $this->ext_makeToolBar());
333
334 if (!t3lib_div::_GP('ADMCMD_view')) {
335 $out .= $this->extGetItem('', '<a href="#" onclick="' .
336 htmlspecialchars('
337 if (parent.opener && parent.opener.top && parent.opener.top.TS) {
338 parent.opener.top.fsMod.recentIds["web"]=' . intval($GLOBALS['TSFE']->page['uid']) . ';
339 if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav) {
340 parent.opener.top.content.nav_frame.refresh_nav();
341 }
342 parent.opener.top.goToModule("' . $pageModule . '");
343 parent.opener.top.focus();
344 } else {
345 vHWin=window.open(\'' . TYPO3_mainDir.t3lib_BEfunc::getBackendScript() . '\',\'' . md5('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '\',\'status=1,menubar=1,scrollbars=1,resizable=1\');
346 vHWin.focus();
347 }
348 return false;
349 ').
350 '">' . $this->extFw($this->extGetLL('edit_openAB')) . '</a>');
351 }
352 }
353
354 return $out;
355 }
356
357 /**
358 * Creates the content for the "tsdebug" section ("module") of the Admin Panel
359 *
360 * @param string Optional start-value; The generated content is added to this variable.
361 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
362 * @see display()
363 */
364 protected function getTSDebugModule($out = '') {
365 $out .= $this->extGetHead('tsdebug');
366 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_tsdebug']) {
367 $this->extNeedUpdate = true;
368
369 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_tree'] ? ' checked="checked"' : '') . ' />');
370 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayTimes'] ? ' checked="checked"' : '') . ' />');
371 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayMessages'] ? ' checked="checked"':'') . ' />');
372 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_LR'] ? ' checked="checked"' : '') . ' />');
373 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayContent'] ? ' checked="checked"' : '') . ' />');
374 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayQueries'] ? ' checked="checked"' : '') . ' />');
375 $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_forceTemplateParsing'] ? ' checked="checked"' : '') . ' />');
376
377 $GLOBALS['TT']->printConf['flag_tree'] = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('tsdebug', 'tree');
378 $GLOBALS['TT']->printConf['allTime'] = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('tsdebug', 'displayTimes');
379 $GLOBALS['TT']->printConf['flag_messages'] = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('tsdebug', 'displayMessages');
380 $GLOBALS['TT']->printConf['flag_content'] = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('tsdebug', 'displayContent');
381 $GLOBALS['TT']->printConf['flag_queries'] = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('tsdebug', 'displayQueries');
382
383 $out.= '
384 <tr>
385 <td><img src="clear.gif" width="50" height="1" alt="" /></td>
386 <td colspan="3">' . $GLOBALS['TT']->printTSlog() . '</td>
387 </tr>';
388 }
389
390 return $out;
391 }
392
393 /**
394 * Creates the content for the "info" section ("module") of the Admin Panel
395 *
396 * @param string Optional start-value; The generated content is added to this variable.
397 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
398 * @see display()
399 */
400 protected function getInfoModule($out = '') {
401 $out .= $this->extGetHead('info');
402 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_info']) {
403 $tableArr = array();
404
405 if ($GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('cache', 'noCache')) {
406 $theBytes = 0;
407 $count = 0;
408
409 if (count($GLOBALS['TSFE']->imagesOnPage)) {
410 $tableArr[] = array('*Images on this page:*', '');
411 foreach ($GLOBALS['TSFE']->imagesOnPage as $file) {
412 $fs = @filesize($file);
413 $tableArr[] = array('&ndash; ' . $file, t3lib_div::formatSize($fs));
414 $theBytes+= $fs;
415 $count++;
416 }
417 }
418 $tableArr[] = array('', ''); // Add an empty line
419
420 $tableArr[] = array('*Total number of images:*', $count);
421 $tableArr[] = array('*Total image file sizes:*', t3lib_div::formatSize($theBytes));
422 $tableArr[] = array('*Document size:*', t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)));
423 $tableArr[] = array('*Total page load:*', t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)+$theBytes));
424 $tableArr[] = array('', '');
425 }
426
427 $tableArr[] = array('id:', $GLOBALS['TSFE']->id);
428 $tableArr[] = array('type:', $GLOBALS['TSFE']->type);
429 $tableArr[] = array('gr_list:', $GLOBALS['TSFE']->gr_list);
430 $tableArr[] = array('no_cache:', $GLOBALS['TSFE']->no_cache ? 1 : 0);
431 $tableArr[] = array('USER_INT objects:', count($GLOBALS['TSFE']->config['INTincScript']));
432 $tableArr[] = array('fe_user, name:', $GLOBALS['TSFE']->fe_user->user['username']);
433 $tableArr[] = array('fe_user, uid:', $GLOBALS['TSFE']->fe_user->user['uid']);
434 $tableArr[] = array('', ''); // Add an empty line
435
436 // parsetime:
437 $tableArr[] = array('*Total parsetime:*', $GLOBALS['TSFE']->scriptParseTime . ' ms');
438
439 $table = '';
440 foreach ($tableArr as $arr) {
441 if (strlen($arr[0])) { // Put text wrapped by "*" between <strong> tags
442 $value1 = preg_replace('/^\*(.*)\*$/', '$1', $arr[0], -1, $count);
443 $value1 = ($count?'<strong>':'') . $this->extFw($value1) . ($count?'</strong>':'');
444 } else {
445 $value1 = $this->extFw('&nbsp;');
446 }
447
448 $value2 = strlen($arr[1]) ? $arr[1] : '&nbsp;';
449 $value2 = $this->extFw($value2);
450
451 $table .= '
452 <tr>
453 <td style="text-align:left">' . $value1 . '</td>
454 <td style="text-align:right">' . $value2 . '</td>
455 </tr>';
456 }
457
458 $table = '<table border="0" cellpadding="0" cellspacing="0" summary="">' . $table . '</table>';
459
460 $out .= '
461 <tr>
462 <td><img src="clear.gif" width="50" height="1" alt="" /></td>
463 <td colspan="3">' . $table . '</td>
464 </tr>';
465 }
466
467 return $out;
468 }
469
470 /*****************************************************
471 *
472 * Admin Panel Layout Helper functions
473 *
474 ****************************************************/
475
476 /**
477 * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
478 * 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
479 * See the functions get*Module
480 *
481 * @param string The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
482 * @return string HTML table row.
483 * @access private
484 * @see extGetItem()
485 */
486 protected function extGetHead($pre) {
487 $out = '<img src="' . TYPO3_mainDir . 'gfx/ol/blank.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
488 $out .= '<img src="' . TYPO3_mainDir . 'gfx/ol/' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_' . $pre] ? 'minus' : 'plus') . 'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
489 $out .= $this->extFw($this->extGetLL($pre));
490
491 $out = $this->extItemLink($pre,$out);
492 return '
493 <tr class="typo3-adminPanel-itemHRow" style="background-color:#abbbb4;">
494 <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="' . $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_' . $pre] . '" /></td>
495 </tr>';
496 }
497
498 /**
499 * Wraps a string in a link which will open/close a certain part of the Admin Panel
500 *
501 * @param string The code for the display_ label/key
502 * @param string Input string
503 * @return string Linked input string
504 * @access private
505 * @see extGetHead()
506 */
507 protected function extItemLink($pre, $str) {
508 return '<a href="#" style="text-decoration:none;" onclick="' .
509 htmlspecialchars('document.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[display_' . $pre . ']\'].value=' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_' . $pre] ? '0' : '1') . '; document.TSFE_ADMIN_PANEL_FORM.submit(); return false;') .
510 '">' . $str . '</a>';
511 }
512
513 /**
514 * Returns a row (with 4 columns) for content in a section of the Admin Panel.
515 * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
516 *
517 * @param string Key to label
518 * @param string The HTML content for the forth table cell.
519 * @return string HTML table row.
520 * @access private
521 * @see extGetHead()
522 */
523 protected function extGetItem($pre, $element) {
524 $out = '
525 <tr class="typo3-adminPanel-itemRow">
526 <td><img src="clear.gif" width="50" height="1" alt="" /></td>
527 <td style="text-align:left; white-space:nowrap;">' . ($pre ? $this->extFw($this->extGetLL($pre)) : '&nbsp;') . '</td>
528 <td><img src="clear.gif" width="30" height="1" alt="" /></td>
529 <td style="text-align:left; white-space:nowrap;">' . $element . '</td>
530 </tr>';
531
532 return $out;
533 }
534
535 /**
536 * Wraps a string in a span-tag with black verdana font
537 *
538 * @param string The string to wrap
539 * @return string
540 */
541 protected function extFw($str) {
542 return '<span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:10px; color:black;">' . $str . '</span>';
543 }
544
545 /**
546 * Creates the tool bar links for the "edit" section of the Admin Panel.
547 *
548 * @return string A string containing images wrapped in <a>-tags linking them to proper functions.
549 */
550 public function ext_makeToolBar() {
551 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
552 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
553 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
554 $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');
555
556 $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
557 $langAllowed = $GLOBALS['BE_USER']->checkLanguageAccess($GLOBALS['TSFE']->sys_language_uid);
558
559 $toolBar = '';
560 $id = $GLOBALS['TSFE']->id;
561 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'show_rechis.php?element=' . rawurlencode('pages:' . $id) . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '#latest">' .
562 '<img src="' . TYPO3_mainDir . 'gfx/history2.gif" width="13" height="12" hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_recordHistory') . '" alt="" /></a>';
563
564 if ($perms&16 && $langAllowed) {
565 $params = '';
566 if ($GLOBALS['TSFE']->sys_language_uid) {
567 $params = '&sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid;
568 }
569 $toolBar .= '<a href="' . htmlspecialchars($newContentWizScriptPath . '?id=' . $id . $params . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
570 '<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>';
571 }
572 if ($perms&2) {
573 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'move_el.php?table=pages&uid=' . $id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
574 '<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>';
575 }
576 if ($perms&8) {
577 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'db_new.php?id=' . $id . '&pagesOnly=1&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
578 '<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>';
579 }
580 if ($perms&2) {
581 $params = '&edit[pages][' . $id . ']=edit';
582 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
583 '<img src="' . TYPO3_mainDir . 'gfx/edit2.gif" width="11" height="12" hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_editPageProperties') . '" alt="" /></a>';
584
585 if ($GLOBALS['TSFE']->sys_language_uid && $langAllowed) {
586 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
587 'uid,pid,t3ver_state', 'pages_language_overlay',
588 'pid=' . intval($id) . ' AND sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid . $GLOBALS['TSFE']->sys_page->enableFields('pages_language_overlay'),
589 '', '', '1');
590 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
591 $GLOBALS['TSFE']->sys_page->versionOL('pages_language_overlay',$row);
592 if (is_array($row)) {
593 $params = '&edit[pages_language_overlay][' . $row['uid'] . ']=edit';
594 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
595 '<img src="' . TYPO3_mainDir . 'gfx/edit3.gif" width="11" height="12" hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_editPageOverlay') . '" alt="" /></a>';
596 }
597 }
598 }
599 if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
600 $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'db_list.php?id=' . $id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
601 '<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>';
602 }
603
604 return $toolBar;
605 }
606
607 /**
608 * Returns the label for key, $key. If a translation for the language set in $GLOBALS['BE_USER']->uc['lang'] is found that is returned, otherwise the default value.
609 * 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
610 *
611 * @param string Key for a label in the $LOCAL_LANG array of "sysext/lang/locallang_tsfe.php"
612 * @return string The value for the $key
613 */
614 protected function extGetLL($key) {
615 global $LOCAL_LANG;
616 if (!is_array($LOCAL_LANG)) {
617 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_tsfe.php');
618 if (!is_array($LOCAL_LANG)) {
619 $LOCAL_LANG = array();
620 }
621 }
622
623 $labelStr = htmlspecialchars($GLOBALS['LANG']->getLL($key)); // Label string in the default backend output charset.
624
625 // Convert to utf-8, then to entities:
626 if ($GLOBALS['LANG']->charSet!='utf-8') {
627 $labelStr = $GLOBALS['LANG']->csConvObj->utf8_encode($labelStr,$GLOBALS['LANG']->charSet);
628 }
629 $labelStr = $GLOBALS['LANG']->csConvObj->utf8_to_entities($labelStr);
630
631 // Return the result:
632 return $labelStr;
633 }
634 }
635
636 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/fe_edit/view/class.tx_feedit_adminpanel.php']) {
637 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/fe_edit/view/class.tx_feedit_adminpanel.php']);
638 }
639
640 ?>