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