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